[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua <-> C++ integration with "unused" stack slots
- From: Oliver Schmidt <oschmidt_do_not_send_email_to_this_address@...>
- Date: Fri, 5 Feb 2010 20:10:40 +0100
On Friday 05 February 2010, Joshua Jensen wrote:
> LuaPlus (http://luaplus.org) lets you hold onto a Lua object within a
> C++ object:
> LuaObject myDataObj = state->GetGlobal("MyData");
> LuaObject valueObj = myDataObj["Value"];
> The Lua data is stored within the LuaObject itself and does not need the
> Lua stack.
How does this work?
As I can see from LuaPlus, the LuaObject class looks like:
LuaObject* m_next; // only valid when in free list
LuaObject* m_prev; // only valid when in used list
So objects of this class are holding directly the lua_TValue from the Lua
How does this interfere with the Lua garbage collector?
I guess the Lua core must have been modified to get this working?
It seems that there are also (LuaPlus-internal?) objects that represent stack
LuaState* m_state; //!< The parent state of this object.
int m_stackIndex; //!< The stack index representing this object.
In you implementation: would have been the existence of something like my
function lua_unuse be useful?
It seems that your implementation does also use a lot of internals of the Lua
core. Do you think that some modifications to the official public Lua C-API
could be useful to make integration with the C++ object system (i.e.
constructor/destructor mechanism) easier?