2011-06-27 33 views
4

私はluaにバインドしたいクラスがあります。減少したコードは次のようになります。私がコンパイルしようとすると、コンパイラはスローし、エラー過負荷関数とluabindに関する問題

class CSprite2D{ 
    void setPosition(glm::ivec2 val) { m_position = val; } 
    void setPosition(int posX, int posY) { m_position.x = posX; m_position.y = posY; } 
    static void exposeAPI(lua_State* L,const unsigned char* data) 
    { 
     assert(L); 
     luabind::module(L)[ 
     luabind::class_<CSprite2D>("CSprite2D") 
     .def("setPosition",(void(*)(int,int))&CSprite2D::setPosition) 
    ]; 
    } 

Error 1 error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'void (__cdecl *)(int,int)' c:\directo\gameprojects2008\zeleste2d\src\graphics\gpx\sprite2d.cpp 74 
Error 2 error C2780: 'luabind::class_<T> &luabind::class_<T>::def(luabind::detail::operator_<Derived>)' : expects 1 arguments - 2 provided c:\directo\gameprojects2008\zeleste2d\src\graphics\gpx\sprite2d.cpp 74 
Error 3 error C2784: 'luabind::class_<T> &luabind::class_<T>::def(luabind::detail::operator_<Derived>,const Policies &)' : could not deduce template argument for 'luabind::detail::operator_<Derived>' from 'const char [12]' c:\directo\gameprojects2008\zeleste2d\src\graphics\gpx\sprite2d.cpp 74 
Error 4 error C2784: 'luabind::class_<T> &luabind::class_<T>::def(luabind::constructor<A0,A1,A2,A3,A4,A5,A6,A7,A8,A9>,const Policies &)' : could not deduce template argument for 'luabind::constructor<A0,A1,A2,A3,A4,A5,A6,A7,A8,A9>' from 'const char [12]' c:\directo\gameprojects2008\zeleste2d\src\graphics\gpx\sprite2d.cpp 74 
Error 5 error C2780: 'luabind::class_<T> &luabind::class_<T>::def(luabind::constructor<A0,A1,A2,A3,A4,A5,A6,A7,A8,A9>)' : expects 1 arguments - 2 provided c:\directo\gameprojects2008\zeleste2d\src\graphics\gpx\sprite2d.cpp 74 
Error 6 error C2780: 'luabind::class_<T> &luabind::class_<T>::def(const char *,F,Default,const Policies &)' : expects 4 arguments - 2 provided c:\directo\gameprojects2008\zeleste2d\src\graphics\gpx\sprite2d.cpp 74 
Error 7 error C2780: 'luabind::class_<T> &luabind::class_<T>::def(const char *,F,DefaultOrPolicies)' : expects 3 arguments - 2 provided c:\directo\gameprojects2008\zeleste2d\src\graphics\gpx\sprite2d.cpp 74 

私は、問題の原因がluabindが最高過負荷機能を推定できないことを知っています、しかしreading the luabind documentation私はluabindで関数を正しく定義しています。

アイデア?あなたが間違った型に関数をキャストしている事前

答えて

5

おかげで、あなたはポインタ・ツー・メンバー関数にキャストする必要があります。

試してみてください。

.def("setPosition", (void (CSprite2D::*)(int, int))&CSprite2D::setPosition) 
+0

はい!それが問題でした。どうもありがとう!!! – Killrazor

関連する問題