2
0
Эх сурвалжийг харах

support Array.map/filter for flash

Nicolas Cannasse 12 жил өмнө
parent
commit
a374bc9f96

+ 1 - 1
genswf9.ml

@@ -310,7 +310,7 @@ let property ctx p t =
 	| TInst ({ cl_path = [],"Array" },_) ->
 		(match p with
 		| "length" -> ident p, Some KInt, false (* UInt in the spec *)
-		| "copy" | "insert" | "remove" | "iterator" | "toString" -> ident p , None, true
+		| "copy" | "insert" | "remove" | "iterator" | "toString" | "map" | "filter" -> ident p , None, true
 		| _ -> as3 p, None, false);
 	| TInst ({ cl_path = ["flash"],"Vector" },_) ->
 		(match p with

+ 8 - 1
tests/unit/unitstd/Array.unit.hx

@@ -211,7 +211,7 @@ var b = a.copy();
 a != b;
 b == [];
 
-#if (!cpp && !flash && !cs && !java)
+#if (!cpp && !cs && !java)
 // map
 [1, 2, 3].map(function(i) return i * 2) == [2, 4, 6];
 var a = [new IntWrap(1), new IntWrap(2)];
@@ -230,4 +230,11 @@ var func = function(s) return s.toUpperCase();
 [1, 2, 3, 4].filter(function(i) return false) == [];
 [].filter(function(i) return true) == [];
 [].filter(function(i) return false) == [];
+
+// check that map and filter work well on Dynamic as well
+var a : Dynamic = [0,1,2];
+var b : Dynamic = a.filter(function(x) return x & 1 == 0).map(function(x) return x * 10);
+b.length == 2;
+b[0] = 0;
+b[1] = 20;
 #end