Browse Source

[flash] fixed Array#slice when end is null

Andy Li 10 years ago
parent
commit
e1e12a1c03
3 changed files with 16 additions and 2 deletions
  1. 2 0
      genas3.ml
  2. 2 2
      genswf9.ml
  3. 12 0
      std/flash/Boot.hx

+ 2 - 0
genas3.ml

@@ -577,6 +577,8 @@ and gen_field_access ctx t s =
 			spr ctx "[\"mapHX\"]"
 		| [], "Array", "filter" ->
 			spr ctx "[\"filterHX\"]"
+		| [], "Array", "slice" ->
+			spr ctx "[\"sliceHX\"]"
 		| [], "Date", "toString" ->
 			print ctx "[\"toStringHX\"]"
 		| [], "String", "cca" ->

+ 2 - 2
genswf9.ml

@@ -317,8 +317,8 @@ 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
+		| "map" | "filter" | "slice" when Common.defined ctx.com Define.NoFlashOverride -> ident (p ^ "HX"), None, true
+		| "copy" | "insert" | "remove" | "iterator" | "toString" | "map" | "filter" | "slice" -> ident p , None, true
 		| _ -> as3 p, None, false);
 	| TInst ({ cl_path = ["flash"],"Vector" },_) ->
 		(match p with

+ 12 - 0
std/flash/Boot.hx

@@ -283,8 +283,13 @@ class Boot extends flash.display.MovieClip {
 			}
 			return ret;
 		};
+		aproto.sliceHX = function(?s = 0, ?e = 16777215) {
+			if (e == null) e = 16777215;
+			return __this__.slice(s,e);
+		};
 		aproto.setPropertyIsEnumerable("mapHX", false);
 		aproto.setPropertyIsEnumerable("filterHX", false);
+		aproto.setPropertyIsEnumerable("sliceHX", false);
 		String.prototype.charCodeAtHX = function(i) : Null<Int> {
 		#else
 		aproto["filter"] = function(f) {
@@ -308,8 +313,15 @@ class Boot extends flash.display.MovieClip {
 			}
 			return ret;
 		};
+		aproto["slice_o"] = aproto["slice"];
+		aproto["slice"] = function(?s = 0, ?e = 16777215) {
+			if (e == null) e = 16777215;
+			return __this__.slice_o(s,e);
+		};
 		aproto.setPropertyIsEnumerable("map", false);
 		aproto.setPropertyIsEnumerable("filter", false);
+		aproto.setPropertyIsEnumerable("slice", false);
+		aproto.setPropertyIsEnumerable("slice_o", false);
 		String.prototype.charCodeAt = function(i) : Null<Int> {
 		#end
 			var s : String = __this__;