Prechádzať zdrojové kódy

[js] some random untyped removals

Dan Korostelev 8 rokov pred
rodič
commit
58646af9bf

+ 1 - 1
std/StringTools.hx

@@ -451,7 +451,7 @@ class StringTools {
 		#elseif cs
 		return ( cast(index, UInt) < s.length ) ? cast(s[index], Int) : -1;
 		#elseif js
-		return (untyped s).charCodeAt(index);
+		return (cast s).charCodeAt(index);
 		#elseif python
 		return if (index >= s.length) -1 else python.internal.UBuiltins.ord(python.Syntax.arrayAccess(s, index));
 		#elseif hl

+ 1 - 1
std/js/Boot.hx

@@ -234,7 +234,7 @@ class Boot {
 
 	// resolve native JS class in the global scope:
 	static function __resolveNativeClass(name:String) {
-		return untyped js.Lib.global[name];
+		return js.Lib.global[cast name];
 	}
 
 }

+ 2 - 1
std/js/Syntax.hx

@@ -36,5 +36,6 @@ extern class Syntax {
 	/**
 		Generate `delete o[f]` expression.
 	**/
-	static function delete(o:Dynamic, f:String):Void;
+	@:overload(function(o:Dynamic, f:Int):Bool {})
+	static function delete(o:Dynamic, f:String):Bool;
 }

+ 2 - 2
std/js/_std/EReg.hx

@@ -77,11 +77,11 @@
 	public function split( s : String ) : Array<String> {
 		// we can't use directly s.split because it's ignoring the 'g' flag
 		var d = "#__delim__#";
-		return untyped s.replace(r,d).split(d);
+		return replace(s,d).split(d);
 	}
 
 	public inline function replace( s : String, by : String ) : String {
-		return untyped s.replace(r,by);
+		return (cast s).replace(r,by);
 	}
 
 	public function map( s : String, f : EReg -> String ) : String {

+ 2 - 2
std/js/_std/Type.hx

@@ -48,8 +48,8 @@ enum ValueType {
 		#end
 	}
 
-	public static function getSuperClass( c : Class<Dynamic> ) : Class<Dynamic> untyped {
-		return c.__super__;
+	public static inline function getSuperClass( c : Class<Dynamic> ) : Class<Dynamic> {
+		return (cast c).__super__;
 	}
 
 

+ 2 - 2
std/js/_std/haxe/Http.hx

@@ -52,7 +52,7 @@ class HttpJs extends haxe.http.HttpBase {
 			if(r.readyState != 4)
 				return;
 			var s = try r.status catch(e:Dynamic) null;
-			if (s != null && untyped __js__('"undefined" !== typeof window')) {
+			if (s != null && js.Browser.supported) {
 				// If the request is local and we have data: assume a success (jQuery approach):
 				var protocol = js.Browser.location.protocol.toLowerCase();
 				var rlocalProtocol = ~/^(?:about|app|app-storage|.+-extension|file|res|widget):$/;
@@ -61,7 +61,7 @@ class HttpJs extends haxe.http.HttpBase {
 					s = r.responseText != null ? 200:404;
 				}
 			}
-			if(s == untyped __js__("undefined"))
+			if(s == js.Lib.undefined)
 				s = null;
 			if(s != null)
 				onStatus(s);

+ 6 - 6
std/js/_std/haxe/ds/IntMap.hx

@@ -30,20 +30,20 @@ package haxe.ds;
 	}
 
 	public inline function set( key : Int, value : T ) : Void {
-		untyped h[key] = value;
+		h[key] = value;
 	}
 
 	public inline function get( key : Int ) : Null<T> {
-		return untyped h[key];
+		return h[key];
 	}
 
 	public inline function exists( key : Int ) : Bool {
-		return untyped h.hasOwnProperty(key);
+		return (cast h).hasOwnProperty(key);
 	}
 
 	public function remove( key : Int ) : Bool {
-		if( untyped !h.hasOwnProperty(key) ) return false;
-		untyped  __js__("delete")(h[key]);
+		if( !(cast h).hasOwnProperty(key) ) return false;
+		js.Syntax.delete(h, key);
 		return true;
 	}
 
@@ -61,7 +61,7 @@ package haxe.ds;
 			next : function() { var i = __this__.it.next(); return __this__.ref[i]; }
 		};
 	}
-	
+
 	public function copy() : IntMap<T> {
 		var copied = new IntMap();
 		for(key in keys()) copied.set(key, get(key));

+ 5 - 5
std/js/_std/haxe/ds/StringMap.hx

@@ -83,19 +83,19 @@ private class StringMapIterator<T> {
 
 	function existsReserved( key : String ) : Bool {
 		if( rh == null ) return false;
-		return untyped rh.hasOwnProperty("$"+key);
+		return (cast rh).hasOwnProperty("$"+key);
 	}
 
 	public function remove( key : String ) : Bool {
 		if( isReserved(key) ) {
 			key = "$" + key;
 			if( rh == null || !rh.hasOwnProperty(key) ) return false;
-			untyped __js__("delete")(rh[key]);
+			js.Syntax.delete(rh, key);
 			return true;
 		} else {
 			if( !h.hasOwnProperty(key) )
 				return false;
-			untyped __js__("delete")(h[key]);
+			js.Syntax.delete(h, key);
 			return true;
 		}
 	}
@@ -103,7 +103,7 @@ private class StringMapIterator<T> {
 	public function keys() : Iterator<String> {
 		return arrayKeys().iterator();
 	}
-	
+
 	function arrayKeys() : Array<String> {
 		var out = [];
 		untyped {
@@ -124,7 +124,7 @@ private class StringMapIterator<T> {
 	public inline function iterator() : Iterator<T> {
 		return new StringMapIterator(this, arrayKeys());
 	}
-	
+
 	public function copy() : StringMap<T> {
 		var copied = new StringMap();
 		for(key in keys()) copied.set(key, get(key));