Macro mayhem - 1. autobuild misbehaving, 2. reification help

51 views
Skip to first unread message

Rezmason

unread,
Sep 24, 2012, 4:38:13 PM9/24/12
to haxe...@googlegroups.com
Hey guys! Long time no see.

I've just written my first macro, which works as a @build on my Rule subclasses but does not even run as an @autobuild on my Rule class. What are the most likely reasons for an @autobuild to not run on the subclasses of a class?

Also, I'd really like to transition from my old-style expressions to the new style that uses macro reification, but I have no idea how to do this.

My macro finds all fields in the local class that have a certain metatag, and uses that metatag's parameter and the field's name to make expressions that are inserted into new functions, which then get inserted into the class. These generated functions override private functions on the superclass; I'm not sure if that could be the cause of the @autobuild problem.

My macro class is available here. A class that currently uses it successfully as a @build can be viewed here, and the superclass which I want to @autobuild from is over here. Any help would be appreciated!

Rezmason

unread,
Sep 25, 2012, 3:58:21 AM9/25/12
to haxe...@googlegroups.com
Quick update– I've found that macros can trip up on other macros, and that removing the @:build metatags from my Rule subclasses allowed the @:autoBuild on Rule to run. One problem down, one to go.

dlots

unread,
Sep 25, 2012, 4:35:39 AM9/25/12
to haxe...@googlegroups.com
Was just going to log on to bump my thread about the intended functionality of multiple builds on a class and this pops up :) Bumping my thread now :)

David Peek

unread,
Sep 25, 2012, 5:27:43 AM9/25/12
to haxe...@googlegroups.com
We've also run into the problem a couple of times recently, having to add @:build to certain subclasses where the @:autoBuild doesn't run.

I've been unable to discern a pattern so far, will try produce an isolated test case this evening.

Cheers,
David

Nicolas Cannasse

unread,
Sep 25, 2012, 5:32:44 AM9/25/12
to haxe...@googlegroups.com
Le 25/09/2012 11:27, David Peek a �crit :
> We've also run into the problem a couple of times recently, having to
> add @:build to certain subclasses where the @:autoBuild doesn't run.
>
> I've been unable to discern a pattern so far, will try produce an
> isolated test case this evening.

There's been some tricky cases of recursive classes initialization
that's been fixed on SVN recently. That might help a lot with this kind
of things.

Best,
Nicolas

Rezmason

unread,
Sep 25, 2012, 2:01:17 PM9/25/12
to haxe...@googlegroups.com
All right, I've made lots of progress on reifying these expressions. (Lines 66-71) I've still got some expressions that rely on Context.parse, but unless I'm mistaken this code is about as succinct as the Haxe macro system will allow. I'm open to any other suggestions, of course. :-)
Reply all
Reply to author
Forward
0 new messages