RFC on plans to implement a c2ffi->cffi generator

Attila Lendvai attila at lendvai.name
Wed Dec 9 21:10:59 UTC 2015


dear list,

c2ffi is a tool written in C that uses the llvm/clang libs to generate
a json file from C headers. it's like gcc-xml, only much better. the
json file has explicit offsets and sizes, etc... see an example here:

https://github.com/rpav/ZMQ4L/blob/master/src/autospec/zmq.x86_64-pc-linux-gnu.spec

once this json has been generated for your platform, it can be checked
into the repo and no external tool is needed afterwards.

cl-autowrap uses such json files to generate an alternative FFI API,
but i'd like to use vanilla CFFI, so i'm planning to write some code
towards this direction, but i'd like to hear some input on this before
i start working on anything...

i imagine it to be similar to how groveling works in iolib, namely:
generate the intermediate files from the json files using some ASDF
integration, and then compile the lisp files as any other lisp files.

my first question is why isn't this ASDF integration, or something
like this, ported into cffi for the gorveler? is there any other
reason besides nobody has done it yet?

https://github.com/sionescu/iolib/blob/master/src/grovel/asdf.lisp

does anyone see some showstoppers? e.g. can i lay out defcstruct
fields with explicit offsets? NOTICE-FOREIGN-STRUCT-DEFINITION
suggests so.

should this code go into a cffi-c2ffi.asd or into a standalone
project? any ideas for a name?

-- 
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
Blaming the prince of the fools should not blind anyone to the vast
confederacy of fools that made him their prince.



More information about the cffi-devel mailing list