[英]Getting the Assembly classes using Mono in C++
I'm creating a Game Engine and I'm implementing ac# scripting system using Mono . 我正在创建一个Game Engine,并正在使用Mono实现ac#脚本系统。
I'm loading the assembly info without problem until I need to create a MonoClass . 我将毫无问题地加载程序集信息,直到需要创建MonoClass为止 。 To create a MonoClass I need the MonoImage, Namespace and Class Name: 要创建MonoClass,我需要MonoImage,命名空间和类名称:
MonoClass* mono_class_from_name (MonoImage *image, const char* name_space, const char *name)
But how can I know the Namespace and Name if I haven't created the dll? 但是,如果我还没有创建dll,我怎么知道命名空间和名称? (Because is a compiled script made by a user using the engine). (因为这是用户使用引擎制作的编译脚本)。
Should I use other function to load the MonoClass? 我应该使用其他功能加载MonoClass吗? Which one? 哪一个?
I found the solution :P 我找到了解决方案:P
std::list<MonoClass*> GetAssemblyClassList(MonoImage * image)
{
std::list<MonoClass*> class_list;
const MonoTableInfo* table_info = mono_image_get_table_info(image, MONO_TABLE_TYPEDEF);
int rows = mono_table_info_get_rows(table_info);
/* For each row, get some of its values */
for (int i = 0; i < rows; i++)
{
MonoClass* _class = nullptr;
uint32_t cols[MONO_TYPEDEF_SIZE];
mono_metadata_decode_row(table_info, i, cols, MONO_TYPEDEF_SIZE);
const char* name = mono_metadata_string_heap(image, cols[MONO_TYPEDEF_NAME]);
const char* name_space = mono_metadata_string_heap(image, cols[MONO_TYPEDEF_NAMESPACE]);
_class = mono_class_from_name(image, name_space, name);
class_list.push_back(_class);
}
return class_list
}
If you want more info: Metada access 如果您需要更多信息: Metada访问
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.