In order to access the types from a macro, you need to use the haxe.macro.*
API rather than accessing haxe.rtti
. The following example will trace both debug
and author
, which are the metadata applied to MyClass
:
class Boot
{
macro public static function test()
{
switch (haxe.macro.Context.getType("MyClass"))
{
case TInst(cl,_):
trace(cl.get().meta.get());
case _:
}
}
}
In order to get class field metadata, you must go through all fields from cl.get().fields.get()
.
See Context.getType()
, ClassType
and MetaAccess
.