LuaBind and Singletons
I have a basic singleton class that i want to bind to lua.
class singleton
{
public
static singleton* GetInstance()
{
if( !m_pInstance )
{
m_pInstance = new singleton;
}
return m_pInstance;
}
void donothing() {}
// Disabled
private:
singleton();
singleton(const singleton&)
singleton& operator =(const singleton&);
// Attributes
private:
static singleton* m_pInstance;
};
singleton* singleton::m_pInsntace = 0;
In luabind i would bind the class like this:
module( lua )
[
class_< singleton >( "singleton" )
.def( "getinstance", &singleton::GetInstance )
.def( "donothing", &singleton::donothing )
];
Here's the error I'm getting:
C2660: 'luabind::detail::overload_rep::overload_rep' : function does not take 2 arguments
The error goes away when I take the line with the "GetInstance" away.
[Edited by - jackiechan on December 5, 2004 2:34:47 PM]
Did you solve the problem? I also had some problems with singletons and luabind.
Ad: Ancamnia
not yet, there was an older post with the same problem. the issue wasn't resolved then either. i'm asking around including the luabind authors. so far nothing yet =\
found it! expose the class and all the non-static members first. then expose the static member function by itself:
module( lua )
[
class_< singleton >( "singleton" )
.def( "donothing", &singleton::donothing )
,def( "getinstance", &singleton::GetInstance ) // like this
];
woo!
module( lua )
[
class_< singleton >( "singleton" )
.def( "donothing", &singleton::donothing )
,def( "getinstance", &singleton::GetInstance ) // like this
];
woo!
Thanks for the tip! I have to test that.. It would make my lua scripts much cleaner.
Ad: Ancamnia
I don't think I'm doing it right.. I get complaints that my destructor is private (which it is). Hmh..
Ad: Ancamnia
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement