3 ms·
Parseback: A pure-Lua introspection library for LuaJIT's FFI ctype objects
- sillysaurusx 3y agoI’ve often felt great LuaJIT’s "just paste C declarations for FFI" was its greatest achievement. I tried to dig into the source code and port the C parser to Python, but it was beyond me at the time. Still seems like a good idea that I hope someone will do.
- mcepl 3y agohttps://eli.thegreenplace.net/2013/03/09/python-ffi-with-ctypes-and-cffi https://eli.thegreenplace.net/2013/03/09/python-ffi-with-cty...
- sillysaurusx 3y agoThanks!
- andrewmcwatters 3y agoIt's by far the best FFI implementation in the industry across all languages. You can even setup a GCC workflow to automate the bindings by stripping information from headers. I'm disappointed by the FFI experience everywhere else, it makes you feel like you're doing software development in the stone ages.
- lifthrasiir 3y agoI think that's because FFI is only a small (and rather easily automatable in other means) portion of making a usable binding for the target language.
- lowq 3y agoIt's fantastic when embedding Lua in a self contained executable too! I have a routine that goes through and 'cdef's certain headers that were also #included at compile time. Super powerful extending a C program this way.
- imtringued 3y agoHow do you resolve the declarations for your particular system? Do you run the preprocessor?
- lowq 3y agoIt doesn't run the preprocessor, so you have to expose constants as externs, for example. Things like `int32_t` still work, so it must just have built in support for standard types.
- sneusse 3y agoSee also: https://github.com/corsix/ffi-reflect/ https://github.com/corsix/ffi-reflect/
- vitiral 3y agoDoes anyone know if there's a Lua (not LuaJIT) library for the ffi functionality? I wonder if this library could work for both
- chadcmulligan 3y agoThere's this https://github.com/q66/cffi-lua https://github.com/q66/cffi-lua, I haven't used it but seems to be used a bit Edit and Alien - https://luarocks.org/modules/mascarenhas/alien https://luarocks.org/modules/mascarenhas/alien, they both use libffi - http://sourceware.org/libffi http://sourceware.org/libffi