Automatic FFI binding generation from C headers

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
gilzoide
Prole
Posts: 5
Joined: Fri Jun 19, 2020 2:19 am

Automatic FFI binding generation from C headers

Post by gilzoide »

I recently resurrected a project for automatically generating bindings from C to Lua: inclua (https://github.com/gilzoide/inclua).

It is currently able to generate LuaJIT FFI bindings directly from C header files using clang. Generated Lua code defines metatypes with automatically deduced __gc metamethod and other methods in the __index table, but supports adding extra definitions from a YAML or JSON file for metamethods or other fields to be placed in __index.

In the repository examples folder there are two examples with bindings for clang and raylib, and I also made a binding for CSFML. (These bindings are not useful for using with LÖVE, but the binding generator is, you get the idea)

Some things are missing, like generating entries for #defined constants and support for nested anonymous structs|unions, but I think it is quite usable right now. I plan on also supporting generation of pure C/C++ Lua bindings in the future. Haven't tested on Windows or OSX, but it should work just fine with a working installation of python 3 and clang.

I'm happy to help if anyone would like to try and am open for feedbacks and issue reports =D
RNavega
Party member
Posts: 385
Joined: Sun Aug 16, 2020 1:28 pm

Re: Automatic FFI binding generation from C headers

Post by RNavega »

This looks tasty, thanks for sharing.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 0 guests