Browse Source

fixed some flash9 typing

Nicolas Cannasse 17 years ago
parent
commit
731918c477

+ 8 - 6
genswf9.ml

@@ -1102,7 +1102,9 @@ and gen_call ctx retval e el =
 		gen_expr ctx true f;
 		gen_expr ctx true f;
 		write ctx (HDeleteProp dynamic_prop);
 		write ctx (HDeleteProp dynamic_prop);
 	| TLocal "__unprotect__" , [e] ->
 	| TLocal "__unprotect__" , [e] ->
-		gen_expr ctx true e
+		write ctx (HGetLex (type_path ctx ([],ctx.boot)));
+		gen_expr ctx true e;
+		write ctx (HCallProperty (ident "__unprotect__",1));
 	| TLocal "__typeof__", [e] ->
 	| TLocal "__typeof__", [e] ->
 		gen_expr ctx true e;
 		gen_expr ctx true e;
 		write ctx HTypeof
 		write ctx HTypeof
@@ -1468,7 +1470,7 @@ let generate_enum_init ctx e hc =
 	write ctx (HReg r.rid);
 	write ctx (HReg r.rid);
 	List.iter (fun n -> write ctx (HString n)) e.e_names;
 	List.iter (fun n -> write ctx (HString n)) e.e_names;
 	write ctx (HArray (List.length e.e_names));
 	write ctx (HArray (List.length e.e_names));
-	write ctx (HSetSlot (!nslot + 1));
+	write ctx (HSetProp (ident "__constructs__"));
 	free_reg ctx r
 	free_reg ctx r
 
 
 let generate_field_kind ctx f c stat =
 let generate_field_kind ctx f c stat =
@@ -1643,10 +1645,10 @@ let generate_enum ctx e =
 		hlc_implements = [||];
 		hlc_implements = [||];
 		hlc_construct = construct;
 		hlc_construct = construct;
 		hlc_fields = [|
 		hlc_fields = [|
-			{ hlf_name = tag_id; hlf_slot = 0; hlf_kind = HFVar { hlv_type = None; hlv_value = HVNone; hlv_const = false; }; hlf_metas = None };
-			{ hlf_name = index_id; hlf_slot = 0; hlf_kind = HFVar { hlv_type = None; hlv_value = HVNone; hlv_const = false; }; hlf_metas = None };
-			{ hlf_name = params_id; hlf_slot = 0; hlf_kind = HFVar { hlv_type = None; hlv_value = HVNone; hlv_const = false; }; hlf_metas = None };
-			{ hlf_name = ident "__enum__"; hlf_slot = 0; hlf_kind = HFVar { hlv_type = None; hlv_value = HVBool true; hlv_const = true }; hlf_metas = None };
+			{ hlf_name = tag_id; hlf_slot = 0; hlf_kind = HFVar { hlv_type = Some (HMPath ([],"String")); hlv_value = HVNone; hlv_const = false; }; hlf_metas = None };
+			{ hlf_name = index_id; hlf_slot = 0; hlf_kind = HFVar { hlv_type = Some (HMPath ([],"int")); hlv_value = HVNone; hlv_const = false; }; hlf_metas = None };
+			{ hlf_name = params_id; hlf_slot = 0; hlf_kind = HFVar { hlv_type = Some (HMPath ([],"Array")); hlv_value = HVNone; hlv_const = false; }; hlf_metas = None };
+			{ hlf_name = ident "__enum__"; hlf_slot = 0; hlf_kind = HFVar { hlv_type = Some (HMPath ([],"Boolean")); hlv_value = HVBool true; hlv_const = true }; hlf_metas = None };
 			{
 			{
 				hlf_name = ident "toString";
 				hlf_name = ident "toString";
 				hlf_slot = 0;
 				hlf_slot = 0;

+ 7 - 6
std/Date.hx

@@ -157,12 +157,13 @@ extern class Date
 			}
 			}
 		};
 		};
 		Date.prototype["toString"] = function() {
 		Date.prototype["toString"] = function() {
-			var m = this.getMonth() + 1;
-			var d = this.getDate();
-			var h = this.getHours();
-			var mi = this.getMinutes();
-			var s = this.getSeconds();
-			return this.getFullYear()
+			var date : Date = this;
+			var m = date.getMonth() + 1;
+			var d = date.getDate();
+			var h = date.getHours();
+			var mi = date.getMinutes();
+			var s = date.getSeconds();
+			return date.getFullYear()
 				+"-"+(if( m < 10 ) "0"+m else ""+m)
 				+"-"+(if( m < 10 ) "0"+m else ""+m)
 				+"-"+(if( d < 10 ) "0"+d else ""+d)
 				+"-"+(if( d < 10 ) "0"+d else ""+d)
 				+" "+(if( h < 10 ) "0"+h else ""+h)
 				+" "+(if( h < 10 ) "0"+h else ""+h)

+ 5 - 5
std/Type.hx

@@ -291,17 +291,17 @@ class Type {
 	}
 	}
 
 
 	#if flash9
 	#if flash9
-	static function describe( t : Dynamic, fact : Bool ) {
+	static function describe( t : Dynamic, fact : Bool ) untyped {
 		var fields = new Array();
 		var fields = new Array();
-		var xml : Dynamic = untyped __global__["flash.utils.describeType"](t);
+		var xml : flash.xml.XML = __global__["flash.utils.describeType"](t);
 		if( fact )
 		if( fact )
-			xml = xml.factory;
+			xml = xml.factory[0];
 		var methods = xml.child("method");
 		var methods = xml.child("method");
 		for( i in 0...methods.length() )
 		for( i in 0...methods.length() )
-			fields.push( Std.string(untyped methods[i].attribute("name")) );
+			fields.push( Std.string(methods[i].attribute("name")) );
 		var vars = xml.child("variable");
 		var vars = xml.child("variable");
 		for( i in 0...vars.length() )
 		for( i in 0...vars.length() )
-			fields.push( Std.string(untyped vars[i].attribute("name")) );
+			fields.push( Std.string(vars[i].attribute("name")) );
 		return fields;
 		return fields;
 	}
 	}
 	#end
 	#end

+ 8 - 8
std/flash9/Boot.hx

@@ -26,8 +26,6 @@ package flash;
 
 
 class Boot extends flash.display.MovieClip, implements Dynamic {
 class Boot extends flash.display.MovieClip, implements Dynamic {
 
 
-	#if (!flash9doc)
-
 	static var init : Void -> Void;
 	static var init : Void -> Void;
 	static var tf : flash.text.TextField;
 	static var tf : flash.text.TextField;
 	static var lines : Array<String>;
 	static var lines : Array<String>;
@@ -57,14 +55,14 @@ class Boot extends flash.display.MovieClip, implements Dynamic {
 				return false;
 				return false;
 			}
 			}
 			aproto.iterator = function() {
 			aproto.iterator = function() {
+				var cur = 0;
+				var arr : Array<Dynamic> = this;
 				return {
 				return {
-					cur : 0,
-					arr : this,
 					hasNext : function() {
 					hasNext : function() {
-						return this.cur < this.arr.length;
+						return cur < arr.length;
 					},
 					},
 					next : function() {
 					next : function() {
-						return this.arr[this.cur++];
+						return arr[cur++];
 					}
 					}
 				}
 				}
 			};
 			};
@@ -93,7 +91,7 @@ class Boot extends flash.display.MovieClip, implements Dynamic {
 			init();
 			init();
 	}
 	}
 
 
-	public static function enum_to_string( e ) {
+	public static function enum_to_string( e : { tag : String, params : Array<Dynamic> } ) {
 		if( e.params == null )
 		if( e.params == null )
 			return e.tag;
 			return e.tag;
 		return e.tag+"("+e.params.join(",")+")";
 		return e.tag+"("+e.params.join(",")+")";
@@ -190,6 +188,8 @@ class Boot extends flash.display.MovieClip, implements Dynamic {
 		return new String(v);
 		return new String(v);
 	}
 	}
 
 
-	#end
+	static function __unprotect__( s : String ) {
+		return s;
+	}
 
 
 }
 }

+ 1 - 1
std/flash9/xml/XML.hx

@@ -1,6 +1,6 @@
 package flash.xml;
 package flash.xml;
 
 
-extern class XML {
+extern class XML implements Dynamic<XMLList> {
 	function new(?value : Dynamic) : Void;
 	function new(?value : Dynamic) : Void;
 	function addNamespace(ns : Dynamic) : XML;
 	function addNamespace(ns : Dynamic) : XML;
 	function appendChild(child : Dynamic) : XML;
 	function appendChild(child : Dynamic) : XML;

+ 1 - 1
std/flash9/xml/XMLList.hx

@@ -1,6 +1,6 @@
 package flash.xml;
 package flash.xml;
 
 
-extern class XMLList {
+extern class XMLList implements ArrayAccess<XML> {
 	function new(?value : Dynamic) : Void;
 	function new(?value : Dynamic) : Void;
 	function addNamespace(ns : Dynamic) : XML;
 	function addNamespace(ns : Dynamic) : XML;
 	function appendChild(child : Dynamic) : XML;
 	function appendChild(child : Dynamic) : XML;

+ 3 - 3
std/haxe/Serializer.hx

@@ -133,10 +133,10 @@ class Serializer {
 	// only the instance variables
 	// only the instance variables
 
 
 	function serializeClassFields(v,c) {
 	function serializeClassFields(v,c) {
-		var xml : Dynamic = untyped __global__["flash.utils.describeType"](c).factory;
-		var vars = xml.child("variable");
+		var xml : flash.xml.XML = untyped __global__["flash.utils.describeType"](c);
+		var vars = xml.factory[0].child("variable");
 		for( i in 0...vars.length() ) {
 		for( i in 0...vars.length() ) {
-			var f = untyped vars[i].attribute("name").toString();
+			var f = vars[i].attribute("name").toString();
 			if( !v.hasOwnProperty(f) )
 			if( !v.hasOwnProperty(f) )
 				continue;
 				continue;
 			serializeString(f);
 			serializeString(f);

+ 1 - 0
std/haxe/remoting/SocketWrapper.hx

@@ -74,6 +74,7 @@ class SocketWrapper {
 	}
 	}
 
 
 	static function init() {
 	static function init() {
+		if( !flash.external.ExternalInterface.available ) return;
 		var ctx = new Context();
 		var ctx = new Context();
 		var o = {};
 		var o = {};
 		Reflect.setField(o,"create",create);
 		Reflect.setField(o,"create",create);

+ 2 - 2
tests/unit/TestReflect.hx

@@ -11,7 +11,7 @@ class TestReflect extends Test {
 	];
 	];
 
 
 	static inline function u( s : String ) : String {
 	static inline function u( s : String ) : String {
-		#if (flash && !flash9)
+		#if flash
 		return untyped __unprotect__(s);
 		return untyped __unprotect__(s);
 		#else
 		#else
 		return s;
 		return s;
@@ -26,7 +26,7 @@ class TestReflect extends Test {
 		"null","Int","String","Bool","Float",
 		"null","Int","String","Bool","Float",
 		"Array",u("Hash"),u("List"),"Date","Xml","Math",
 		"Array",u("Hash"),u("List"),"Date","Xml","Math",
 		u2("unit","MyEnum"),u2("unit","MyClass"),u2("unit","MySubClass"),
 		u2("unit","MyEnum"),u2("unit","MyClass"),u2("unit","MySubClass"),
-		u("Class"),u("Enum"),u("Void"),u("Dynamic"),
+		#if !flash9 u #end("Class"),u("Enum"),u("Void"),u("Dynamic"),
 	];
 	];
 
 
 	public function testTypes() {
 	public function testTypes() {