Manipulate Several Classes With Only One @:autoubuild directive?

69 views
Skip to first unread message

AlienCoder

unread,
May 20, 2016, 5:26:58 AM5/20/16
to Haxe
Hello community,

I dare to collect my first experiences with this 'dark matter' macro programming in HAXE.

I would like to access manipulate all classes that are processed throughout their reference within the main() method.


For example:

Main
{
main()
{
[ complementary 'macrofized' code ]
var x = AnyClass.anyFunction( y );

}
}

AnyClass
{
anyFunction( variable : Type )
{
[ another complementary 'macrofized' code ]

[ the original function code ]
}
}



I only can use the @:autobuild directive only for child classes right?

How can I manipulate classes that occure because they are referenced in any way without to place the @:build or @:autobuild directive on each of them?

Is it possible anyway?
If it is, how can I exclude library classes / regular HAXE classes to be manipulated?

Kind regards
Michael



Alexander Kuzmenko

unread,
May 20, 2016, 6:37:33 AM5/20/16
to Haxe
Add this to your build configuration:
--macro addGlobalMetadata('', '@:build(my.macro.GlobalBuilder.build())', true, true, false)

http://api.haxe.org/haxe/macro/Compiler.html#addGlobalMetadata

пятница, 20 мая 2016 г., 12:26:58 UTC+3 пользователь AlienCoder написал:

AlienCoder

unread,
May 20, 2016, 7:33:38 AM5/20/16
to Haxe
Hello Alexander,

thank you for your reply.

Quick and simple. But very helpful.

Have a nice weekend.

Kind regards
Michael

AlienCoder

unread,
May 23, 2016, 3:43:34 AM5/23/16
to Haxe


Hello again, Alexander,

I have experimented a lot with the addGlobalMetadata compiler method. I always come to the conclusion that the compiler compiles the regular haxe classes as well, when he is in the recursive mode.

You can see it here (cmd output):



So he parses the expressions of the std/ package of the haxe libraries and probably any other he finds there.
How can I prevent this? I am thankful for any idea...

Kind regards
Michael


Auto Generated Inline Image 1

Alexander Kuzmenko

unread,
May 23, 2016, 3:50:33 AM5/23/16
to Haxe
You need to set `pathFilter` argument to desired package. Like --macro addGlobalMetadata('my.pack', '@:build(my.macro.GlobalBuilder.build())', true, true, false)
Or filter out unwanted types in in your build macro:
macro static public fucntion build () {
     if (/* check if current type is in you ignore list */) return null;
     //useful stuff
}

понедельник, 23 мая 2016 г., 10:43:34 UTC+3 пользователь AlienCoder написал:

AlienCoder

unread,
May 23, 2016, 1:27:20 PM5/23/16
to Haxe

Thanks again for your reply.

It turned out to be a little more complicated than expected. But I think, I found good solution.

Kind regards
Michael
Reply all
Reply to author
Forward
0 new messages