haxe.macro.MacroType issue

34 views
Skip to first unread message

Alexander Kuzmenko

unread,
Nov 1, 2013, 6:16:50 AM11/1/13
to haxe...@googlegroups.com
I've faced a problem using MacroType which i can't solve.
If my class extends with MacroType and has macro methods then compilation fails with message:
BaseExt.hx:7: lines 7-18 : Should extend by using a class
Main.hx:7: lines 7-17 : Defined in this class
Looks like MacroType is not getting invoked during 'macro' phase of building proccess

Here is a basic source code to reproduce: https://gist.github.com/RealyUniqueName/7263182

if i do like
class BaseExt #if !macro haxe.macro.MacroType<[Build.baseType()]> #end {
then this simple example works fine. 
But the real problem is that i want to automatically generate some static macro methods via @:autoBuild of `Base` class, but in this case i can't use `#if !macro` trick and that compilation error appears again.

Juraj Kirchheim

unread,
Nov 1, 2013, 6:35:16 AM11/1/13
to haxe...@googlegroups.com
AFAIK you cannot generate any macro methods in @:build.
> --
> To post to this group haxe...@googlegroups.com
> http://groups.google.com/group/haxelang?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Haxe" group.
> For more options, visit https://groups.google.com/groups/opt_out.

Alexander Kuzmenko

unread,
Nov 1, 2013, 7:04:07 AM11/1/13
to haxe...@googlegroups.com
This is sad :)
I've tryied and compiler complains about macro method is absent despite the fact that code completion shows me generated method :)

пятница, 1 ноября 2013 г., 14:35:16 UTC+4 пользователь back2dos написал:

Juraj Kirchheim

unread,
Nov 1, 2013, 11:10:30 AM11/1/13
to haxe...@googlegroups.com
I think the problem is, that the macro's implementation has to exist
on the macro class in macro context. So you could try to use
reflection to inject an implementation. Marc Weber recently showed a
trick to evaluate expressions with macro-in-macro, so you could
evaluate the expression that returns the implementation.

I vaguely remember talk of some plans to actually support this.
Alternatively you could use using macros or something like that.

Regards,
Juraj
Reply all
Reply to author
Forward
0 new messages