@:build macro help

48 views
Skip to first unread message

Warren Eng

unread,
Mar 28, 2014, 5:05:48 AM3/28/14
to haxe...@googlegroups.com
I'm getting "Class not found: B" when trying to use the @:build() macro in this simple example. I'm not sure what I'm doing wrong here:

package;

import foo.A;

class Main 
{
static function main()
{
var a:A = new A();
}
}

package foo;

@:build(B.build()) class A
{
public function new() 
{
//
}
}

package foo;

import haxe.macro.Context;
import haxe.macro.Expr;

class B 
{
public static macro function build():Array<haxe.macro.Field>
{
var fields:Array<haxe.macro.Field> = Context.getBuildFields();
return fields;
}
}

Anyone know what's going on? Thanks!

Heinz Hölzer

unread,
Mar 28, 2014, 5:14:29 AM3/28/14
to haxe...@googlegroups.com
i think it must be full qualified like

@:build(foo.B.build()) class A

does that work?

Andreas Mokros

unread,
Mar 28, 2014, 5:16:45 AM3/28/14
to haxe...@googlegroups.com
Hi.

On Fri, 28 Mar 2014 02:05:48 -0700 (PDT)
Warren Eng <eng...@gmail.com> wrote:
> I'm getting "Class not found: B" when trying to use the @:build()
> macro in this simple example. I'm not sure what I'm doing wrong here:

I think you need the full classpath in @:build, i.e.:
@:build(foo.B.build()) class A

--
Mockey

Warren Eng

unread,
Mar 28, 2014, 3:13:45 PM3/28/14
to haxe...@googlegroups.com
Yup, that fixed it. Thank you!
Reply all
Reply to author
Forward
0 new messages