possible to Context.parse a whole class ?

26 views
Skip to first unread message

Thomas John

unread,
Apr 2, 2017, 10:04:09 AM4/2/17
to Haxe
I tried but it gave me errors, maybe I'm doing it wrong.
i'm using genericBuild on a class

I just would like to do a Context.parse on a string representing a whole class structure (just like in a .hx file) like this:

var newType = 'class Test
{
public var count:Int = -1;
public function new(count:Int = -1)
{
this.count = count;
}

public function checkCount():Bool
{
if( count < 0 ) return false;
return true;
}
}
';

var typeExp = Context.parse(newType);

Is this even possible ? and if not why ? I can create a whole class with macro reification, why not this way ? would it be possible in the future ?
Wouldn't it be simpler to create whole new types that way ? we can even implement a template system and modify the whole structure without having to go through the whole macro system as this is just a string.

Thanks !
Reply all
Reply to author
Forward
0 new messages