lua-users home
lua-l archive

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


Hi (not sure if this should be posted here (since it might be more to do
with tolua rather than lua itself).

First off: thansk for the answers to my previous post (few days ago). I was
moving ahead like 'gangbusters' until this new problem presented itself :-(

Anyway:

I have a simple linked list class (in C++)...

class list
{
	list();
	~list();

	append(void* item);

      ...
};

in a Lua script I do:

-------------------

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

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

l:append( var )           -- append var

-------------------

If I check the address of the class being created in myOtherClass:new() (on
the C++ side in the debugger) I get a valid address.

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).

The generated code for the append method treats the second param (the item)
as *userdata* (which I suppose it will since its a void*) the append first
param is a usertype (the list - or self - ptr) this is fine and has the
correct address when viewed in the ToLua generated code within the
debugger).

I have no idea why the append method is not passing the correct parameter
value - obviously its something to do with the  void* parameter? Eveything
else I have done through ToLua works great!! this is causing me a headache -
so any help is really appreciated.

Thanks in advance

Andy