|
@@ -43,7 +43,7 @@ package flash;
|
|
|
function toString() : String;
|
|
|
function indexOf( x : T, ?from : Int ) : Int;
|
|
|
function lastIndexOf( x : T, ?from : Int ) : Int;
|
|
|
-
|
|
|
+
|
|
|
#if flash19
|
|
|
function insertAt(index : Int, element : T) : Void;
|
|
|
#else
|
|
@@ -61,4 +61,34 @@ package flash;
|
|
|
return untyped __vector__(v);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ Get a run-time value referencing the `Vector` class with concrete type parameters.
|
|
|
+
|
|
|
+ Normally in Haxe, for most of the types, type parameters are eliminated at run-time,
|
|
|
+ so there is no way to check if a value is of a type with specific type parameters.
|
|
|
+
|
|
|
+ However, on the Flash target, the `flash.Vector<T>` values carry type parameter
|
|
|
+ information at run-time all the type-checks (such as `Std.is` and `Std.downcast`) on them
|
|
|
+ must be done using a `Class<T>` value that also carries the type parameters. However,
|
|
|
+ Haxe syntax does not allow creating such values and this function exists to mitigate
|
|
|
+ this limitation.
|
|
|
+
|
|
|
+ It should be used as such:
|
|
|
+ ```haxe
|
|
|
+ var specificVectorType:Class<Vector<Int>> = Vector.typeReference();
|
|
|
+ trace(Std.is(vec, specificVectorType));
|
|
|
+ ```
|
|
|
+ or using the type-check syntax:
|
|
|
+ ```haxe
|
|
|
+ trace(Std.is(vec, (Vector.typeReference() : Class<Vector<Int>>)));
|
|
|
+ ```
|
|
|
+
|
|
|
+ It's also helpful when working with native Flash libraries, that receive Class instances:
|
|
|
+ ```haxe
|
|
|
+ new Signal((Vector.typeReference() : Class<Vector<Int>>));
|
|
|
+ ```
|
|
|
+ **/
|
|
|
+ public inline static function typeReference<T>() : Class<Vector<T>> {
|
|
|
+ return untyped __vector__();
|
|
|
+ }
|
|
|
}
|