Is there a way to write a macro that builds classes with a certain @:meta?

47 views
Skip to first unread message

Joshua Granick

unread,
Jan 6, 2017, 2:37:36 AM1/6/17
to haxe...@googlegroups.com
Hi,

I know that there is a way to build out types using @:autoBuild and search
for a specific @:meta tag, but is there a way to do the reverse?

For example:


@:embed("file.dat") class File extends Bytes {}


--macro Embed.allFiles()


...and allow the macro to discover this (incomplete) type, and build it
out?

Thank you

Dan Korostelev

unread,
Jan 6, 2017, 4:32:21 AM1/6/17
to Haxe
I think you can do that with Compiler.addGlobalMetadata, adding a @:build macro to all classes, and then check for `@:embed` meta in that build macro, but I'm not sure if it worth the overhead of running this macro for all types in your compilation.

пятница, 6 января 2017 г., 10:37:36 UTC+3 пользователь Joshua Granick написал:
Reply all
Reply to author
Forward
0 new messages