parseback
In LuaJIT's FFI, ctype objects carry C data structures and functions. Unfortunately, while there are several functions to handle and compose ctype objects, there's very little introspection capabilities. This library inspects the information provided by ffi.typeinfo() to recreate useful descriptions of ctype objects, as Lua tables, C declarations and GraphViz diagrams.
Installation
It's a single Lua file, just put it anywhere in your $LUA_PATH .
License
MIT licensed, like the Lua and LuaJIT languages/implementations
Usage
Returns a table tree describing the given type. Some of the fields appear only on appropriate types. Most interesting fields include:
type a label ( 'num' , 'union' , 'struct' , 'ptr' , 'complex' , 'array' , 'void' , 'enum' , 'function' , 'typedef' , 'field' , 'bitfield' , 'const' , 'keyword' ), hopefully useful to traverse the tree.
a label ( , , , , , , , , , , , , , ), hopefully useful to traverse the tree. name if available.
if available. c a reconstructed C definition.
a reconstructed C definition. size data size in bytes.
data size in bytes. fields (in union, struct, enum and functions) array of descriptions of elements or arguments.
(in union, struct, enum and functions) array of descriptions of elements or arguments. subtype a "content" type description. For arrays, pointers and typedefs it's the description of the inner type; for functions it's the description of the return type.