lua-users home
lua-l archive

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


Hi..

At 12:35 AM 1/28/2004, you wrote:
[...]
        append(void* item);

var = myOtherClass:new()  -- myOtherClass is a toLua'd class also

l = list:new()            -- make the list object

l:append( var )           -- append var

When I check the ToLua-generated code for list:append the item address (for
the myOtherClass object) is close, but NOT the same. When I get this value
out of the list (in LUA) I get an error (obviously since the ptr is
different).
[...]

I think the problem is that tolua5 stores the objects as void**, wich means that the value you carry on the script is a pointer to a 4 byte userdata with the address of the object. 'void*' is still treated as a 'light user data', wich is just the value of the pointer. tolua4 used to treat both as light userdatas, the documentation probably still reflects that, but I think there's a note about this on the compatibility section of the tolua++ documentation..

You could dereference the parameter you get on the append() method.. Or, if you're reusing the list outside lua, you could just use tolua++ to bind the stl list class, wich is probably safer than using void*.. :)

bye..

Ariel.


Ariel.
http://Anime.com.ar
snm