Luabind:“未找到匹配的重载,候选者:”
请注意,我已阅读并将答案应用于: 从 Luabind 调用 C++ 成员函数会导致“未找到匹配的重载”,但这并没有解决我的问题。
我有一个简单的类,通过 luabind 暴露给 LUA
这是绑定代码:
void LogManager::luaBindImpl() const
{
using namespace luabind;
lua_State* state(Supervisor::getSingleton().getManager<LuaManager>()->state());
// LogManager
module(state)
[
class_<LogManager>("LogManager")
.enum_("LogType")
[
value("Info", 1)
,value("Warning", 2)
,value("Critical", 3)
,value("Debug", 4)
]
.def("log", &LogManager::log)
.def("registerSource", &LogManager::registerSource)
];
// Add to globals
globals(state)["LogManager"] = this;
}; // eo luaBindImpl
这是我的 LUA:
LogManager.registerSource("lol");
但我收到标题中提到的错误(这直接取自我的日志文件):
00:00:00:0520- lua:Exception - No matching overload found, candidates:
void registerSource(LogManager&,std::string const&)
我一直在撕扯我的头发对此,我看不出我做错了什么。任何人都可以阐明吗? :)
Note, I have read and applied the answer to: Calling C++ member function from Luabind causes "No matching overload found", but this did not solve my issue.
I have a simple class that I expose to LUA via luabind
Here is the binding code:
void LogManager::luaBindImpl() const
{
using namespace luabind;
lua_State* state(Supervisor::getSingleton().getManager<LuaManager>()->state());
// LogManager
module(state)
[
class_<LogManager>("LogManager")
.enum_("LogType")
[
value("Info", 1)
,value("Warning", 2)
,value("Critical", 3)
,value("Debug", 4)
]
.def("log", &LogManager::log)
.def("registerSource", &LogManager::registerSource)
];
// Add to globals
globals(state)["LogManager"] = this;
}; // eo luaBindImpl
And here is my LUA:
LogManager.registerSource("lol");
But I get the error mentioned in the title (this taken straight from my log file):
00:00:00:0520- lua:Exception - No matching overload found, candidates:
void registerSource(LogManager&,std::string const&)
I've been tearing my hair out over this and can't see what I am doing wrong. Can anyone shed any light?! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在Lua部分,您需要使用冒号(
:
)而不是点:并且您确实意识到全局变量
LogManager
与类具有相同的名称日志管理器
;这样您将无法使用枚举常量,例如 LogManager.Info 将返回 nil。In the Lua part, you need to use colon (
:
) instead of a dot:And you do realize the global variable
LogManager
has the same name with the classLogManager
; that way you won't be able to use the enum constants, e.g.LogManager.Info
will return nil.