Prechádzať zdrojové kódy

define UString as normal String on most platforms

ncannasse 8 rokov pred
rodič
commit
266328e063
1 zmenil súbory, kde vykonal 11 pridanie a 20 odobranie
  1. 11 20
      hxd/UString.hx

+ 11 - 20
hxd/UString.hx

@@ -1,43 +1,34 @@
 package hxd;
 
-abstract UString(String) from String to String {
+#if !cpp
+typedef UString = String;
+#else
+typedef UString = UStringImpl;
+
+abstract UStringImpl(String) from String to String {
 
 	public var length(get,never) : Int;
 
 	inline function get_length() : Int {
-		#if (flash || js || hl)
 		return this.length;
-		#else
-		return haxe.Utf8.length( this );
-		#end
 	}
 
-	@:op(a + b) inline static function add( a : UString, b : UString ) : String {
+	@:op(a + b) inline static function add( a : UStringImpl, b : UStringImpl ) : String {
 		return (a:String) + (b:String);
 	}
 
 	public inline function charCodeAt( pos : Int ) : Int {
-		#if (flash || js || hl)
-		return this.charCodeAt( pos );
-		#else
 		return haxe.Utf8.charCodeAt( this, pos );
-		#end
 	}
 
-	public inline function substr( pos : Int, #if (flash || hl || cpp) len = 0x7fffffff #else ?len : Int #end ) : UString {
-		#if (flash || js || hl)
-		return this.substr( pos, len );
-		#else
+	public inline function substr( pos : Int, #if (flash || hl || cpp) len = 0x7fffffff #else ?len : Int #end ) : UStringImpl {
 		return haxe.Utf8.sub( this, pos, len );
-		#end
 	}
 
-	public inline function charAt( pos : Int ) : UString {
-		#if (flash || js || hl)
-		return this.charAt( pos );
-		#else
+	public inline function charAt( pos : Int ) : UStringImpl {
 		return haxe.Utf8.sub( this, pos, 1 );
-		#end
 	}
 
 }
+
+#end