Przeglądaj źródła

fixed Date.toString issue in AS3

Nicolas Cannasse 15 lat temu
rodzic
commit
1852ac2e86
3 zmienionych plików z 15 dodań i 5 usunięć
  1. 4 1
      doc/CHANGES.txt
  2. 10 3
      genas3.ml
  3. 1 1
      std/Date.hx

+ 4 - 1
doc/CHANGES.txt

@@ -32,7 +32,10 @@
 	all : core classes implementation are now in std/(platform)/_std
 	all : added @:final support
 	all : added haxe.rtti.Meta
-
+	flash9 : added flash.desktop.Clipboard* classes (added in flash10)
+	as3 : fixed Date.toString issue in flash.Boot (now use .toStringHX instead)
+		this will only work if .toString called explicitely on Date class
+	
 2010-01-09: 2.05
 	js : added js.Scroll
 	js : package names are now checked at runtime to avoid clashes with existing libs

+ 10 - 3
genas3.ml

@@ -423,10 +423,11 @@ and gen_field_access ctx t s =
 		| [], "Date", "now"
 		| [], "Date", "fromTime"
 		| [], "Date", "fromString"
-		| [], "Date", "toString"
 		| [], "String", "charCodeAt"
 		->
 			print ctx "[\"%s\"]" s
+		| [], "Date", "toString" ->
+			print ctx "[\"toStringHX\"]"
 		| [], "String", "cca" ->
 			print ctx ".charCodeAt"
 		| _ ->
@@ -1016,7 +1017,13 @@ let generate_enum ctx e =
 			print ctx "public static var %s : %s = new %s(\"%s\",%d)" c.ef_name ename ename c.ef_name c.ef_index;
 	) e.e_constrs;
 	newline ctx;
-	print ctx "public static var __constructs__ : Array = [%s];" (String.concat "," (List.map (fun s -> "\"" ^ Ast.s_escape s ^ "\"") e.e_names));
+	(match Codegen.build_metadata ctx.inf.com (TEnumDecl e) with
+	| None -> ()
+	| Some e ->
+		print ctx "public static var __meta__ : * = ";
+		gen_expr ctx e;
+		newline ctx);
+	print ctx "public static var __constructs__ : Array = [%s];" (String.concat "," (List.map (fun s -> "\"" ^ Ast.s_escape s ^ "\"") e.e_names));	
 	cl();
 	newline ctx;
 	print ctx "}";
@@ -1311,7 +1318,7 @@ let gen_fields ctx ch fields others construct =
 				let get = has_getset fields f m in
 				if not get then begin
 					let m = As3code.iget ctx.as3_method_types (As3parse.no_nz m.m3_type) in
-					let t = (match m.mt3_ret with None -> "Dynamic" | Some t -> s_type_path (type_path ctx t)) in
+					let t = (match m.mt3_args with [Some t] -> s_type_path (type_path ctx t) | _ -> "Dynamic") in
 					IO.printf ch "\t%svar %s(null,default) : %s;\n" rights name t
 				end;
 			)

+ 1 - 1
std/Date.hx

@@ -159,7 +159,7 @@ extern class Date
 				throw "Invalid date format : " + s;
 			}
 		};
-		d.prototype["toString"] = function() {
+		d.prototype[#if as3 "toStringHX" #else "toString" #end] = function() {
 			var date : Date = this;
 			var m = date.getMonth() + 1;
 			var d = date.getDate();