Re: Lua <-> C++ integration with "unused" stack slots
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- 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:
 class LuaObject
 {
 public:
 ....
 private:
 LuaObject* m_next; // only valid when in free list
 LuaObject* m_prev; // only valid when in used list
 #if defined(BUILDING_LUAPLUS)
 lua_TValue m_object;
 #else
 LP_lua_TValue m_object;
 #endif
 LuaState* m_state;
 };
So objects of this class are holding directly the lua_TValue from the Lua 
virtual machine?
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 
slots: 
 class LuaStackObject
 {
 ...
 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?
Best regards,
Oliver