Browse Source

still use/define cca for real charCodeAt (when -D mt), which allows to include both old .js output and new one together

Nicolas Cannasse 13 years ago
parent
commit
25b88d9cbd
2 changed files with 11 additions and 0 deletions
  1. 4 0
      std/StringTools.hx
  2. 7 0
      std/js/_std/HxOverrides.hx

+ 4 - 0
std/StringTools.hx

@@ -300,7 +300,11 @@ class StringTools {
 		else
 			return cast(untyped s[index], Int);
 		#elseif js
+			#if mt
+		return (untyped s).cca(index);
+			#else
 		return (untyped s).charCodeAt(index);
+			#endif
 		#else
 		return s.cca(index);
 		#end

+ 7 - 0
std/js/_std/HxOverrides.hx

@@ -67,7 +67,11 @@ class HxOverrides {
 	}
 
 	static function cca( s : String, index : Int ) : Null<Int> {
+		#if mt
+		var x = (cast s).cca(index);
+		#else
 		var x = (cast s).charCodeAt(index);
+		#end
 		if( x != x ) // fast isNaN
 			return untyped undefined; // isNaN will still return true
 		return x;
@@ -121,6 +125,9 @@ class HxOverrides {
 				return true;
 			}
 		);
+		#if mt
+		if( String.prototype.cca == null ) String.prototype.cca = String.prototype.charCodeAt;
+		#end
 	}
 
 }