lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Friday 05 February 2010, Joshua Jensen wrote:
> LuaPlus ( 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
        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;
        LP_lua_TValue m_object;
        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 

    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,