Created
June 23, 2013 05:41
-
-
Save jasononeil/5843931 to your computer and use it in GitHub Desktop.
Demonstration of blatantly copying fields to a new type not working...
This file contains hidden or 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
-main Main | |
-neko Main.n |
This file contains hidden or 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
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; | |
} | |
} |
This file contains hidden or 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
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