Ver código fonte

fixed default basic types values in interfaces

Nicolas Cannasse 16 anos atrás
pai
commit
b021b56e83
2 arquivos alterados com 8 adições e 2 exclusões
  1. 1 0
      doc/CHANGES.txt
  2. 7 2
      genas3.ml

+ 1 - 0
doc/CHANGES.txt

@@ -27,6 +27,7 @@ TODO :
 	added haxe.rtti.HtmlEditor
 	added neko.db.Manager.setLockMode
 	genAS3 : fixed Error classes issues
+	genAS3 : fixed default basic type value in interfaces
 	flash9 : fixed UInt default parameter verify error
 	compiler : allowed \r line separators for HXML files
 

+ 7 - 2
genas3.ml

@@ -812,8 +812,13 @@ let generate_field ctx static f =
 			| TFun (args,r) ->
 				print ctx "function %s(" f.cf_name;
 				concat ctx "," (fun (arg,o,t) ->
-					print ctx "%s : %s" arg (type_str ctx t p);
-					if o then spr ctx " = null";
+					let tstr = type_str ctx t p in
+					print ctx "%s : %s" arg tstr;
+					if o then print ctx " = %s" (match tstr with
+						| "int" | "uint" -> "0"
+						| "Number" -> "NaN"
+						| "Boolean" -> "false"
+						| _ -> "null");					
 				) args;
 				print ctx ") : %s " (type_str ctx r p);
 			| _ -> ()