Substitute JS Output

56 views
Skip to first unread message

Gargamel

unread,
Jun 2, 2015, 10:07:01 AM6/2/15
to haxe...@googlegroups.com
Hey guys,
I´m trying to dive into macros...trendy I know. :-) Untit now I can say, that the whole Topic is really hard, but I´ll keep fighting through it. Here´s my problem: I wanna edit the haxe output in JS from some functions. For example the cast-function or something like that.

My idea was to search in my haxecode for every "cast", write a macro to get the "cast"-expr and edit it to my desired output. But I´m stucked, because I can´t find a way to edit the appearance.

Here my idea:

    macro static public function replaceCast( e : Expr ) : Array<Field>{

   
var fields = Context.getBuildFields();
   
var newField = {
    name
: "somename",
    doc
: null,
    meta
: [Context.addGlobalMetaData()],
    access
: [AStatic,APublic],
    kind
: FFun( ret: null, params : null, macro $v{ (cast $e : $type) }, args:[$e, $type]),
    pos
: Context.currentPos()
   
};
    fields
.push(newField);
   
return fields;
   
}


Hopefuly you can help me.

Greetings Garga

Timothy Farrell

unread,
Jun 2, 2015, 11:57:45 AM6/2/15
to haxe...@googlegroups.com
It may be easier to focus on what you want to cast rather than the cast statement itself.

Can you give an example of what you're trying to cast?
Reply all
Reply to author
Forward
0 new messages