[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Userdata
- From: Jerome Vuarand <jerome.vuarand@...>
- Date: Tue, 3 Jan 2012 11:28:51 +0100
2012/1/3 Dirk Laurie <firstname.lastname@example.org>:
> 2012/1/3 Patrick Rapin <email@example.com>:
>> You can take the address of the full userdata block, push the address
>> on the stack as a light userdata, and use that light userdata as a key
>> to store the full one into the registry (or any other table).
> That will solve the problem underlying my post. ÂMy userdata structure
> contains pointers to other userdata, and I need functions returning
> those to Lua as full userdata.
What you can do to avoid that centralized index table (for light udata
to full udata conversion) is to store double references in your
userdata, one as pointer in the C structure, and one as a Lua
reference in the userdata environment. Assignment is a bit more
complex, and it may use more memory (a table per userdata for the
environment), but it clearly describes the relationship between the
objects for garbage collection.