Re: Remove Luabind ownership on C++ pointer?

eduard mueller <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
Hold the object in a boost::shared_ptr or some other reference
counting smart_ptr in Lua:
class_<Object, boost::shared_ptr<Object> >("Object")

Then the object will be kept alive as long as another shared_ptr uses
the object in C++. Aka, the instance that is created in Lua will only
release the shared pointer, not destruct the object itself when
garbage collected.

Best regards,
Eduard


On Thu, Sep 30, 2010 at 05:16, neosettlers <[email protected]> wrote:
> Greetings,
>
>
>
> I’m wondering how to remove Luabind ownership on C++ pointers:
>
>
>
> C++
>
> module(lua)
>
> [
>
>                     class_<Object>("Object")
>
>                     .def(constructor<>())
>
> ];
>
>
>
> .lua
>
> local object = Object();
>
>
>
> …
>
>
>
> I would like Luabind NOT to delete the object C++ pointer when lua_gc() is
> called.
>
>
>
> If anyone found an elegant solution for this, I’m definitely interested to
> hear about it.
>
>
>
> Thx,
>
>
>
>
>
> ------------------------------------------------------------------------------
> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.