Sign in to follow this  

LuaBind and Singletons

Recommended Posts

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]

Share this post

Link to post
Share on other sites
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


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this