I would like to know how to read metadata from a class (and its methods) in a macro.
I tried to modify this example.
I added :
to see if metadata without them is only available in generated code, but nothing.. I have an empty result in all three cases.. Any ideas?
@:author("Nicolas")
@debug
class MyClass {
@:range(1, 8)
var value:Int;
@broken
@:noCompletion
static function method() { }
}
class Boot {
static public function main() {
test();
}
macro public static function test() {
trace(haxe.rtti.Meta.getType(MyClass)); // { author : ["Nicolas"], debug : null }
trace(haxe.rtti.Meta.getFields(MyClass).value.range); // [1,8]
trace(haxe.rtti.Meta.getStatics(MyClass).method); // { broken: null }
return haxe.macro.Context.makeExpr({}, haxe.macro.Context.currentPos());
}
}
cl
and_
comes from? (ex: incase TInst(cl,_):
andcase _:
) – Fillip