As a general rule of thumb: when you're trying to move information
around through macros in a way that seems impossible because of
evaluation order, chances are, you're implementing something like
COMEFROM (
http://en.wikipedia.org/wiki/COMEFROM).
And even if it's not half that crazy, you should consider that if you
want these kind of super-global transformation rules, you really risk
of running into incompatibility with others. Of course, if you're 100%
happy with being a lone wolf programmer, that's not an issue.
The rationale is, that all macros are triggered by some explicit
mention. Either as a command line argument, or as a
@:build/@:autoBuild argument. Or as a "direct" macro. With that
restriction, two heavily macro based libraries can quite peacefully
coexist in a single project.
As for semi-automagical, the @:autoBuild-approach is usually the most
popular one. You declare an empty "marker" interface, that has the
@:autoBuild, and then triggering the magic becomes as easy as
implementing that interface.
----
As for parsing files: You can use Context.getType or Context.getModule
to get the parsed and typed information (assuming you know where to
look). But I think you will have to grab a nightly to recover
metadata, because Haxe has only lately started to preserve it in the
typed AST. Of course if you only need member/class metadata, then this
already works.
Regards,
Juraj