On Wed, Dec 9, 2015 at 9:10 PM, Attila Lendvai attila@lendvai.name wrote:
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-g...
once this json has been generated for your platform, it can be checked into the repo and no external tool is needed afterwards.
That is very nice. The need for a C compiler during compilation of things that use cffi-grovel, particularly on Windows where, ironically, binary compatibility is easier.
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...
Cool!
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.
I was thinking it'd be pretty neat to COMPILE-FILE the spec file directly using a custom readtable, but whatever's easier. :-)
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
Not sure what you mean. This ASDF integration is in cffi-grovel.
BTW, the scope of the groveller is quite narrow. Things like c2ffi are for grabbing everything a header file has got to offer. The groveller way is just "hey, I know this constant exists, grab me its value please". But, if something like c2ffi turns out to work very well, then we can reimplement the groveller's API on top of it, sure.
Have you seen https://github.com/rpav/c2ffi-cffi?
does anyone see some showstoppers? e.g. can i lay out defcstruct fields with explicit offsets? NOTICE-FOREIGN-STRUCT-DEFINITION suggests so.
I don't see any showstoppers. cl-autowrap is built on top of CFFI, as is the groveller.
should this code go into a cffi-c2ffi.asd or into a standalone project? any ideas for a name?
cffi-c2ffi sounds good and I'd be happy to merge into CFFI.
Looking forward to your next steps!
Cheers,