Next: cffi-grovel concepts, Previous: release note, Up: Top
CFFI-Grovel is a tool which makes it easier to write CFFI declarations for libraries that are implemented in C. That is, it grovels through the system headers, getting information about types and structures, so you don't have to. This is especially important for libraries which are implemented in different ways by different vendors, such as the Unix/Posix functions. The CFFI declarations are usually quite different from platform to platform, but the information you give to CFFI-Grovel is the same. Hence, much less work!
If you use ASDF, CFFI-Grovel is integrated, so that it will run automatically when your system is building. This feature was inspired by SB-Grovel, a similar project for SBCL. CFFI-Grovel can also be used without ASDF.
Circa January 2006, CFFI-Grovel has been tested with recent versions of Openmcl and SBCL on Mac OS 10.4, and with SBCL on Debian/x86. There is a fair chance of it working with other Lisps and platforms; if you get it to work, please let us know! In particular, we intend to support Solaris, which is probably partially working right now. CFFI-Grovel uses the CFFI-Luis branch of CFFI.
CFFI-Grovel provides correct definitions for the current platform of :int8, :uint8, :int16, and so on up to 64 bits. It is also capable of providing definitions for standard types such as size_t, constants such as AF_INET, and structs such as sockaddr_in.
As an example we have a package CFFI-Unix, which provides the basics needed to interact with a Unix system, with particular focus on networking. This is intended to be a thin layer on top of the standard Posix calls, providing to Lisp the same semantics as a C program would get.
Our design calls for a thicker layer, not yet written, which will sit atop CFFI-Unix and provide more Lisp-like, idiomatic behavior. Because CFFI-Unix will eventually be a stable interface, it will be possible for other authors to develop their own abstraction layers to use instead of ours.
CFFI-Unix does map C errno values onto Lisp conditions, which means that any abstraction layer using it will gain the benefit thereof.