import haxe.macro.Expr;
class MyClass { @:mydata(123) var myvar:String; }
class MacroMeta { @:macro public static function getMeta() : Expr { var m = haxe.rtti.Meta.getFields(MyClass); trace(m); return { expr : EConst(CString("")), pos : haxe.macro.Context.currentPos() }; }
public static function main():Void{ getMeta(); } }
MacroMeta.hx:11: {}
Use Context.resolve("full.path.ClassName") to get the Type
Then get the ClassType from that
@:macro public static function getMeta() : Expr {
var t = haxe.macro.Context.getType("MyClass"); // trace(t); // TInst(MyClass,[]) var cl = Type.getClass(t); trace(cl); // null
return { expr : EConst(CString("")), pos : haxe.macro.Context.currentPos() }; }
@:build(
MacroClass.theMethod("cms/application/cms.php")
)
class GeneratedExtern implements Dynamic { }
class Main
{
@libdirLive("/path/to/lib") var ld1:String;
}
//in a separate file:
class MacroClass{
macro static public function theMethod
(filePath:String){
switch Context.getType("Main") {
case TInst(ref, params):
var cl:ClassType = ref.get();
trace(Meta.getFields(cl));
default:
}
}
}
MacroClass
.hx:85: {}MacroClass
.hx:85: {}MacroClass
.hx:85: {}MacroClass
.hx:85: {}MacroClass
.hx:85: {}MacroClass
.hx:85: {}MacroClass
.hx:85: {}--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.