いくつかのクラスを DLL で Luabind にエクスポートしましたが、これら 2 つのクラス (LuaScriptManager、EventManager) はすべて正常に動作しています。Lua から関数を呼び出すことができ、すべて問題ありませんが、DLL とリンクするクライアント実行可能ファイルに新しいクラスをセットアップしようとしていますが、これまでのところまったくうまくいきません。
呼び出す関数ごとに表示されるエラー メッセージは次のとおりです。「一致するオーバーロードが見つかりません。候補: void loadResource(ResourceManager&, std::string const&)」
クラス バインディングはhttp://www.nuclex.org/articles/5-cxx/1-quick-introduction-to-luabindからのものです。
struct Manager {
Manager() :
m_ResourceCount(0) {}
void loadResource(const std::string &sFilename) {
++m_ResourceCount;
}
size_t getResourceCount() const {
return m_ResourceCount;
}
size_t m_ResourceCount;
};
static Manager MyResourceManager;
void Bind(lua_State* l)
{
// Export our class with LuaBind
luabind::module(l) [
luabind::class_<Manager>("ResourceManager")
.def("loadResource", &Manager::loadResource)
.property("ResourceCount", &Manager::getResourceCount)
];
luabind::globals(l)["MyResourceManager"] = &MyResourceManager;
}
対応する lua テスト コードは次のとおりです。
-- The following call will fail with the above error
MyResourceManager:loadResource("abc.res")
--MyResourceManager:loadResource("xyz.res")
-- If the function is commented out, this will work (accessing the property)
ResourceCount = MyResourceManager.ResourceCount
-- Calling my other classes' functions work fine
LuaScriptManager.GetInstance():WriteLine(ResourceCount)
この奇妙な動作の原因は何ですか?