Skip to content

Instantly share code, notes, and snippets.

@AxGord
Created June 3, 2014 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AxGord/440d5b97477f1b6de2b5 to your computer and use it in GitHub Desktop.
Save AxGord/440d5b97477f1b6de2b5 to your computer and use it in GitHub Desktop.
Macro inside macro
#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;
}
}
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
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