[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: LuaJIT: userdata and FFI cdata (was: Re: LuaJIT 2 ffi (casting /	force hotpath))
 
- From: Florian Weimer <fw@...>
 
- Date: Sun, 23 Jan 2011 21:26:21 +0100
 
* Mike Pall:
> The FFI treats userdata like a 'void *' pointing to the payload.
> So you can assign or cast it to a pointer to a struct and then
> access its fields:
>
>   ffi.cdef[[
>   typedef struct { int x; } foo_t;
>   ]]
>   local tostruct = ffi.typeof("foo_t *")
>   local function inc_x(ud)
>     local s = tostruct(ud)
>     s.x = s.x + 1
>   end
However, it seems that there is no way to create a userdata object
which is not zero-sized.  Am I missing something?