Re: Binding static methods with luabind?
Nicolas Goles <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
Just saw your explanation about invoking with dot instead of : , read
the docs and I get it now.
Thanks again!
--
Nicolas Goles Domic
Founder & Lead Programmer
Gando Games <www.gandogames.com>
Iliya Trendafilov wrote:
> Hi,
>
> That should do it, note the scope around the definition of getInstance
>
> luabind::module(L)
> [
> luabind::class_<LuaRegisterManager>("LuaRegisterManager") //Register the class
> .def("execScript", (void(LuaRegisterManager::*)())&LuaRegisterManager::execScript) //method to execute a lua script
> .scope
> [
> def("getInstance",&LuaRegisterManager::getInstance) //returns static singleton instance
> ]
>
> ];
>
>
> Invoke with LuaRegisterManager.getInstance() (i.e. dot instead of
> colon). A bit of explanation can be found here:
> http://www.rasterbar.com/products/luabind/docs.html#nested-scopes-and-static-functions
>
> Hope that helps
>
> On Wed, Sep 15, 2010 at 7:32 PM, Nicolas Goles <[email protected]
> <mailto:[email protected]>> wrote:
>
> Hello,
>
> I have a Singleton Class in my application, it has a member method
> defined like:
>
> static LuaRegisterManager* getInstance();
>
> I'm trying to register this class with Luabind, and expose some
> methods to Lua:
>
> //Register with luabind.
>
> luabind::module(L)
>
> [
>
> luabind::class_<LuaRegisterManager>("LuaRegisterManager") //Register the class
>
> .def("execScript", (void(LuaRegisterManager::*)())&LuaRegisterManager::execScript) //method to execute a lua script
>
> .def("getInstance",&LuaRegisterManager::getInstance) //returns static singleton instance
>
> ];
>
> The problem is that if I execute the following Lua script:
>
>
> LuaRegisterManager:getInstance()
>
> I get :
>
> Error: no static 'getInstance' in class 'LuaRegisterManager'
>
>
>
> So I guess I'm making an error and my static getInstance() method
> is not being registered with luabind correctly.
>
> Help is welcome :)
>
> --
> Nicolas Goles Domic
> Founder & Lead Programmer
> Gando Games <http://www.gandogames.com>
>
>
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> luabind-user mailing list
> [email protected]
> <mailto:[email protected]>
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev
> ------------------------------------------------------------------------
>
> _______________________________________________
> luabind-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user