Hi All, I am working on a ffi-helper: a program that will read in a C dot-h file and generate a Guile dot-scm file which defines a module to provide hooks into the associated C library. Goal is to release something around Apr 2018.
With the helper interfaces are with ffi-modules. A module is a set of C includes and C libraries. The Scheme interface code encapsulated in a Guile module. If a C type is defined in the set of C includes, you will see it in the associated Guile module. If a C type is defined outside the set of includes, and is not included in a use-ffi-module declaration, then the type is expanded. So, the ffi-module declaration has expressions to indicate which files should be include in the set defining the module. Here is a ffi-module declaration for the gobject: mwette$ cat gobject.ffi ;; gobject.ffi -*- Scheme -*- (define-ffi-module (gobject) #:use-ffi-module (glib) #:pkg-config "gobject-2.0" #:include '("glib-object.h") #:inc-filter (lambda (file-spec path-spec) (string-contains path-spec "gobject/" 0)) ) ;; --- last line --- To convert a dot-ffi module to dot-scm you use guild: mwette$ guild compile-ffi gobject.ffi Currently not handled: varargs, long double, some function types, ... I have some ideas for handling varargs. But otherwise I'm getting things to compile: mwette$ wc {cairo,gdbm,gio,glib,gobject,libgit2,sqlite3}.ffi 25 65 657 cairo.ffi 14 45 371 gdbm.ffi 10 27 218 gio.ffi 19 47 509 glib.ffi 11 27 265 gobject.ffi 14 35 403 libgit2.ffi 12 34 339 sqlite3.ffi mwette$ wc {cairo,gdbm,gio,glib,gobject,libgit2,sqlite3}.scm 6629 16556 221347 cairo.scm 747 2067 23093 gdbm.scm 42884 109771 1554684 gio.scm 28275 74979 887380 glib.scm 10417 26654 349534 gobject.scm 15702 45142 524011 libgit2.scm 4980 14389 168532 sqlite3.scm mwette$ ls -l {cairo,gdbm,gio,glib,gobject,libgit2,sqlite3}.scm.go -rw-r--r-- 1 mwette staff 657197 Sep 7 20:15 cairo.scm.go -rw-r--r-- 1 mwette staff 105509 Sep 7 20:15 gdbm.scm.go -rw-r--r-- 1 mwette staff 7313669 Sep 7 20:07 gio.scm.go -rw-r--r-- 1 mwette staff 3168869 Sep 7 19:03 glib.scm.go -rw-r--r-- 1 mwette staff 1672685 Sep 7 18:43 gobject.scm.go -rw-r--r-- 1 mwette staff 2018653 Sep 7 20:17 libgit2.scm.go -rw-r--r-- 1 mwette staff 766205 Sep 7 20:17 sqlite3.scm.go Matt