我正在尝试将LUA与luabind集成到我的程序中,但我遇到了一个很大的障碍。
我对LUA的电话会议非常陌生,我觉得我错过了一些简单的事情。
以下是我的C++代码:
struct app_t
{
//...
void exit();
void reset();
resource_mgr_t resources;
//...
};
struct resource_mgr_t
{
//...
void prune();
void purge();
//...
};
extern app_t app;还有我的luabind模块:
luabind::module(state)
[
luabind::class_<resource_mgr_t>("resource_mgr")
.def("prune", &resource_mgr_t::prune)
.def("purge", &resource_mgr_t::purge)
];
luabind::module(state)
[
luabind::class_<app_t>("app")
.def("exit", &app_t::exit)
.def("reset", &app_t::reset)
.def_readonly("resources", &app_t::resources)
];
luabind::globals(state)["app"] = &app;我可以很好地执行以下lua命令:
app:exit()
app:reset()但是,以下调用失败:
app.resources:purge()有以下错误:
[string "app.resources:purge()"]:1: attempt to index field 'resources' (a function value)任何帮助都是非常感谢的!
发布于 2014-10-09 08:44:02
当绑定非原始类型的成员时,自动生成的getter函数将返回对它的引用。
而且,正如在app:reset()中一样,资源是一个实例成员字段。
所以,像这样使用它:
app:resources():purge()https://stackoverflow.com/questions/26272193
复制相似问题