lua-users home
lua-l archive

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


On Sun, 16 Aug 2009, Chris Camacho wrote:
>
> Is there any way to make a new userdata that is a reference to an
> already allocated userdata from just a C pointer?

Create a weak table mapping lightuserdata to the full userdata. You can
convert a C pointer directly to a lightuserdata which you can use to index
the table. The table must have weak values so that your objects are still
collected. Lightuserdata doesn't affect collection of the objects it
points to.

Tony.
-- 
f.anthony.n.finch  <dot@dotat.at>  http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.