Macros 使用haxe.macro.TypeTools失败
我正在尝试调试一个使用Macros 使用haxe.macro.TypeTools失败,macros,haxe,Macros,Haxe,我正在尝试调试一个使用haxe.macro.TypeTools::findField的库。我为此创建了一个简单的代码: package; using haxe.macro.TypeTools; class Main { public function new() { var test = findField(Child, "hello"); trace(test); } } class Base { private
haxe.macro.TypeTools::findField
的库。我为此创建了一个简单的代码:
package;
using haxe.macro.TypeTools;
class Main
{
public function new()
{
var test = findField(Child, "hello");
trace(test);
}
}
class Base
{
private function hello()
{
}
}
class Child extends Base
{
public function new() {}
}
但是,我得到了错误未知标识符:findField
。这是因为它只能在生成宏上下文中使用吗
是我试图模拟的。首先,函数
findField()
不是来自haxe.macro.TypeTools
。
是的
要在没有类路径的情况下使用它,请使用通配符导入它的类import edge.core.macro.Macros.*
其次,
findField()
应该只在构建宏上下文中使用,因为它需要Array
,这是通过haxe.macro.context.getBuildFields()
获得的,谢谢!还有一个问题:如何使用它?好的,我通读了静态扩展文档页面,所以它的名称应该是:SomeClassType.findField(“field”,true)代码>是,但仅在宏上下文中