Skip to content

Instantly share code, notes, and snippets.

@jasononeil
Created June 23, 2013 05:41
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 jasononeil/5843931 to your computer and use it in GitHub Desktop.
Save jasononeil/5843931 to your computer and use it in GitHub Desktop.
Demonstration of blatantly copying fields to a new type not working...
-main Main
-neko Main.n
import haxe.macro.Expr;
import haxe.macro.Type;
import haxe.macro.Context;
class MacroTest
{
macro public function build():Array<Field>
{
trace ("Build macro");
var localClass = Context.getLocalClass().get();
var fields = Context.getBuildFields();
Context.defineType({
pos: localClass.pos,
params: [],
pack: ["my","pack"],
name: "MacroBuiltClass",
meta: [],
kind: TDClass(),
isExtern: false,
fields: fields
});
return fields;
}
}
import haxe.ds.*;
@:build(MacroTest.build())
class Main
{
static function main()
{
var s = new StringMap();
trace (s);
var i = new IntMap();
trace (i);
my.pack.MacroBuiltClass.printSomething();
}
public static function printSomething()
{
trace ("Something");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment