|
@@ -257,6 +257,24 @@ class Type {
|
|
|
return e;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ Creates an instance of the given class with the list of constructor arguments.
|
|
|
+ **/
|
|
|
+ public static function createInstance<T>( cl : Class<T>, args : Array<Dynamic> ) : T untyped {
|
|
|
+ #if flash9
|
|
|
+ return cl.__construct__.call(null,args);
|
|
|
+ #else flash
|
|
|
+ var o = { __constructor__ : cl, __proto__ : cl.prototype };
|
|
|
+ cl["apply"](o,args);
|
|
|
+ return o;
|
|
|
+ #else neko
|
|
|
+ return untyped __dollar__call(__dollar__objget(cl,__dollar__hash("new".__s)),cl,args.__a);
|
|
|
+ #else js
|
|
|
+ if( args.length >= 6 ) throw "Too many arguments";
|
|
|
+ return untyped __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5]);
|
|
|
+ #else error
|
|
|
+ #end
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
Similar to [Reflect.createInstance] excepts that the constructor is not called.
|