Re: Remove Luabind ownership on C++ pointer?
neosettlers <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
Thx everyone for the inputs,
Well, this is a very rare request. Having to explicitly state that instances
should be destroyed would screw over almost everyone.
I think it is at least practical to have the choice to managed your memory
yourself without reinventing the wheel.
Basically, you have some class whose instances somehow manages their own
lifetime?
Of course, all classes are registered and unregister by an object manager.
You can try holding the Lua-created instances in a special smart pointer
that doesn't delete:
I'm wondering why would you give so much power to scripting... In my case,
scripting is used as an interface to access the C++ functionalities
not to
take over!
I managed to solved my problem in modifying the source directly:
object_rep::~object_rep()
{
if (!m_instance)
return;
/// m_instance->~instance_holder();
deallocate(m_instance);
}
And voila!
-----Original Message-----
From: Daniel Wallin [mailto:[email protected]]
Sent: Thursday, September 30, 2010 3:02 PM
To: [email protected]
Subject: Re: [luabind] Remove Luabind ownership on C++ pointer?
On Thu, Sep 30, 2010 at 5:43 PM, neosettlers <[email protected]>
wrote:
> Hummm...
>
> Luabind, youre a guest in my home (C++ library), on your way out,
> please do not take my garbage with you! (I wish I wouldnt have to
> ask)
>
> No offense but making extra functions or even worst, a manager for this is
embarrassing... this should be solved with something like this:
>
> .def(constructor<>())
> .def(destructor<>()) /// if present, take the garbage out, if not please,
mind your own business!
Well, this is a very rare request. Having to explicitly state that instances
should be destroyed would screw over almost everyone.
Basically, you have some class whose instances somehow manages their own
lifetime? You can try holding the Lua-created instances in a special smart
pointer that doesn't delete:
template <class T>
struct dummy_ptr
{
dummy_ptr(T* p_) : p(p_) {}
T* p;
};
template <class T>
T* get_pointer(dummy_ptr<T> const& p)
{
return p.p;
}
...
class_<Whatever, dummy_ptr<Whatever> >("Whatever")
.def(constructor<>(...))
--
Daniel Wallin
BoostPro Computing
http://www.boostpro.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]
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