且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我如何在不先导入类型的情况下解析类?

更新时间:2023-09-12 17:37:04

首先,应为Type.resolveClass提供类的完全限定名称. IE. pack.subpack.AClass.

Firstly, you should give Type.resolveClass the fully qualified name of the class. I.e. pack.subpack.AClass.

第二,您可以使用--macro include("pack"). include函数是 haxe.macro.Compiler 中的方法. --macro默认情况下会在该类中查找方法.

Secondly, you may use --macro include("pack"). Which the include function is a method from haxe.macro.Compiler. --macro by default looks into that class for methods.

最后,haxe中的import my.package.*语句是惰性的.它告诉编译器解析my.package中的类型,但一开始并没有真正将所有内容导入my.package中.

Lastly, the import my.package.* statement in haxe is lazy. It tell the compiler to resolve types in my.package, but not really import everything in my.package in the beginning.