Created
June 3, 2014 12:04
-
-
Save AxGord/440d5b97477f1b6de2b5 to your computer and use it in GitHub Desktop.
Macro inside macro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if macro | |
import haxe.macro.Expr; | |
import haxe.macro.Context; | |
import haxe.macro.Type; | |
#end | |
#if !macro | |
@:autoBuild(BuilderBuilder.build()) | |
#end | |
interface Builder { } | |
class BuilderBuilder { | |
macro static public function build():Array<Field> { | |
var fields = Context.getBuildFields(); | |
fields.push( { name: 'm', pos: Context.currentPos(), access: [AStatic, AMacro], kind: FFun( { args:[ { name:'e', type: macro:Array<haxe.macro.Expr> } ], ret:macro:haxe.macro.Expr, expr: macro { trace(e); return macro null; }} ) } ); | |
return fields; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
src/Main.hx:13: characters 2-8 : Class<Main> has no field m | |
src/Main.hx:13: characters 2-13 : Method m not found on class Main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Main implements Builder { | |
static function main() { | |
Main.m(123); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment