Hello all,
I’m trying to instantiate object using Type.resolveClass but that class path is typedef alias for some other class.
So what I’m doing is:
-
Have a config file where the class path is specified. Something like this:
{
“id”:“0”,
“name”:“test_model”,
“type”:“model”,
“classPath”: “my.typedef.Alias”
} -
Have a typedef like this ( which actually point to some other class ):
package my.typedef;
#if ( ubi_target_html && ubi_backend_vanilla && ubi_renderer_3D )
typedef Alias = udriver.assets.PCAsset;
#elseif ( ubi_target_html && ubi_backend_vanilla && ubi_renderer_2D )
typedef Alias = udriver.assets.PCAsset2D;
#end
- Then after loading and parsing json config from 1) I’m just passing the classpath ( my.typedef.Aliast ) to ‘Type.resolveClass’ but if returns null but if I pass the ‘original’ class path it works fine ( udriver.assets.PCAsset )
var a = parsed json config from 1)
assetObj = Type.createInstance( Type.resolveClass( a.classPath ), [ a, app ] );
Are there any limitations in Haxe which are preventing instantiation in this manner? If so, are there any workarounds?
I really need typedefs for this so I can have unique class name for different classes based on #if-s
Many thanks in advance,
Dinko