Reputation: 15
I want to take a Class<T>
that i've gotten from Type.resolveClass()
and use it to build a variable of type T in a class. I'm not quite sure how to describe it so here's some code that hopefully describes it well enough.
public static function build(name:String) {
var fields = Context.getBuildFields();
// Get Class<T>
var resolved = Type.resolveClass(name);
// Do some magic to get a ComplexType that represents the T in Class<T>
var type = magic(resolved); // I want to find out how to do this
// Create a field of type T
fields.push({
name: "ofTypeName",
pos: Context.currentPos(),
access: [AStatic, APublic],
kind: FVar(type, macro null)
});
return fields;
}
So I want to know how to get a ComplexType
out of Class<T>
which represents T
Upvotes: 1
Views: 145
Reputation: 222
var type = Context.getType(name);
var ctype = TypeTools.toComplexType(type);
Upvotes: 1