[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT FFI cdata introspection
- From: Michal Kottman <k0mpjut0r@...>
- Date: Sat, 19 Feb 2011 00:26:06 +0100
On 18 February 2011 23:49, Mike Pall <mikelu-1102@mike.de> wrote:
> Michal Kottman wrote:
>> I'm trying to add some kind of introspection to LuaJIT FFI, that will
>> allow to determine not only the type of a cdata object, but also list
>> it's fields.
>
> Wouldn't it be easier to copy the data structure declarations from
> lj_ctype.h, export the root of the type tree and then use Lua code
> and the FFI to do the introspection?
Hmm, use the FFI to inspect itself? I am starting to like the FFI so much more:)
>> When looking at ct->info, it is CT_PTR. How can I get to the
>> structure this pointer refers to? I've tried using ct =
>> ctype_child(cts, ct), but it fails later on setstrV() with assertion
>> error.
>
> if (ctype_isptr(ct->info)) ct = ctype_rawchild(cts, ct);
Thanks, that solved it! :)