[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: light userdata (was Re: Indices in Lua)
- From: "Juris Kalnins" <juris@...>
- Date: Mon, 22 Jun 2009 12:47:12 +0300
What would be the justification for doing so?
For example, storing additional tag information for implementing
lightweight built-in objects. Useful on embedded applications
that do not require C level library compatibility, and
that have sizeof(lua_Number) > sizeof(void *).
Each Value cell has sizeof(lua_Number) storage, which is
8 bytes on most 32 bit Lua configurations, but light userdata
uses only 4 bytes.
lua_touserdata relies on
the fact that full UD and light UD can both be a void*, so if light
UDs are typedeffed to something else, then the function is no longer
valid for light UD.
you can have user redefinable macro:
#define luai_lu2p(x) ((void *) (x))
but yes, additional lua_tolightuserdata would be needed...