Bladeren bron

added -D no-flash-overrides (necessary for Air/iOS since overrides are not supported in AOT)

Nicolas Cannasse 12 jaren geleden
bovenliggende
commit
e17bd2bf5d
4 gewijzigde bestanden met toevoegingen van 10 en 2 verwijderingen
  1. 2 0
      common.ml
  2. 6 0
      genswf9.ml
  3. 1 1
      std/Date.hx
  4. 1 1
      std/flash/Boot.hx

+ 2 - 0
common.ml

@@ -179,6 +179,7 @@ module Define = struct
 		| NetworkSandbox
 		| NoCompilation
 		| NoCOpt
+		| NoFlashOverride
 		| NoInline
 		| NoOpt
 		| NoPatternMatching
@@ -239,6 +240,7 @@ module Define = struct
 		| NetworkSandbox -> ("network-sandbox","Use local network sandbox instead of local file access one")
 		| NoCompilation -> ("no-compilation","Disable CPP final compilation")
 		| NoCOpt -> ("no_copt","Disable completion optimization (for debug purposes)")
+		| NoFlashOverride -> ("no-flash-override", "Change overrides on some basic classes into HX suffixed methods, flash only")
 		| NoOpt -> ("no_opt","Disable optimizations")
 		| NoPatternMatching -> ("no_pattern_matching","Disable pattern matching")
 		| NoInline -> ("no_inline","Disable inlining")

+ 6 - 0
genswf9.ml

@@ -315,6 +315,7 @@ let property ctx p t =
 	| TInst ({ cl_path = [],"Array" },_) ->
 		(match p with
 		| "length" -> ident p, Some KInt, false (* UInt in the spec *)
+		| "map" | "filter" when Common.defined ctx.com Define.NoFlashOverride -> ident (p ^ "HX"), None, true
 		| "copy" | "insert" | "remove" | "iterator" | "toString" | "map" | "filter" -> ident p , None, true
 		| _ -> as3 p, None, false);
 	| TInst ({ cl_path = ["flash"],"Vector" },_) ->
@@ -326,9 +327,14 @@ let property ctx p t =
 	| TInst ({ cl_path = [],"String" },_) ->
 		(match p with
 		| "length" (* Int in AS3/Haxe *) -> ident p, None, false
+		| "charCodeAt" when Common.defined ctx.com Define.NoFlashOverride -> ident (p ^ "HX"), None, true
 		| "charCodeAt" (* use Haxe version *) -> ident p, None, true
 		| "cca" -> as3 "charCodeAt", None, false
 		| _ -> as3 p, None, false);
+	| TInst ({ cl_path = [],"Date" },_) ->
+		(match p with
+		| "toString" when Common.defined ctx.com Define.NoFlashOverride -> ident (p ^ "HX"), None, true
+		| _ -> ident p, None, false)
 	| TAnon a ->
 		(match !(a.a_status) with
 		| Statics { cl_path = [], "Math" } ->

+ 1 - 1
std/Date.hx

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

+ 1 - 1
std/flash/Boot.hx

@@ -240,7 +240,7 @@ class Boot extends flash.display.MovieClip {
 		aproto.setPropertyIsEnumerable("insert", false);
 		aproto.setPropertyIsEnumerable("remove", false);
 		aproto.setPropertyIsEnumerable("iterator", false);
-		#if as3
+		#if (as3 || no_flash_override)
 		aproto.filterHX = function(f) {
 			var ret = [];
 			var i = 0;