How to return a field with macro

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to return a field with macro

Julien CASTETS
Hi,

Could someone help me with the EReturn macro ? I need to return a field of a class.
I made it working using Context.parse("manager") but I'm not sure this is THE solution

var returnExpr = { expr:EReturn(Context.parse("manager", p)), pos:p};
var f = { args:[], params:[], ret:null, expr : returnExpr };
fields.push( { name:"getManager", meta: [], kind: FFun(f), doc:null, access: [AOverride,APrivate], pos : p});

I thought I could use something like EReturn(EField()) or EReturn(EVars()) but I can't figure out.

Thank you
Best
Julien




--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: How to return a field with macro

Matthew Spencer-2
Try EConst(CIdent("manager"))

You can always build the class how you want it to end up, and then trace it from a macro to see what Expr's it generates.


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: How to return a field with macro

Julien CASTETS
This works, thank you.
Do you know the meaning of CIdent ? (Maybe Constant Identify  ? =)

And thank you too for the trace tip !

Best
Julien

2011/8/29 Matthew Spencer <[hidden email]>
Try EConst(CIdent("manager"))

You can always build the class how you want it to end up, and then trace it from a macro to see what Expr's it generates.


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: How to return a field with macro

Matthew Spencer-2
This works, thank you.
Do you know the meaning of CIdent ? (Maybe Constant Identify  ? =)
Sounds like a good guess to me.
 

And thank you too for the trace tip !
No problem, glad to help.

--Matthew Spencer

--
haXe - an open source web programming language
http://haxe.org