Jump to content
  • Advertisement
Sign in to follow this  
jackiechan

LuaBind and Singletons

This topic is 4965 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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 =\

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
];

woo!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!