More on my ffi-helper project. This time about modules and guild 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. I am looking for concurrence on the following:
The paradigm for using the helper is (1) write ffi-module; (2) compile to Scheme using guild. 1) I can support module-like syntax like the following: mwette$ cat cairo/cairo-svg.ffi ;; cairo-svg.ffi -*- Scheme -*- (define-ffi-module (cairo cairo-svg) #:include "cairo.h" #:include "cairo-svg.h" #:inc-filter (lambda (path) (string=? "cairo" (substring path 0 5))) #:pkg-config "cairo" #:library "libcairo" ;; not needed when pkg-config fully working ;; the following are bent pipe to scm-module #:use-module ((srfi srfi-1) #:select (remove)) #:export (my-cairo-ftn) ) (define my-cairo-hack () (first '(("hello")))) ;; end of file 2) I can run “guild compile-fyi cairo/cairo-svg.ffi” and get the following ;; auto-generated by ffi-help.scm (define-module (cairo cairo-svg) #:use-module ((srfi srfi-1) #:select (remove)) #:export (my-cairo-ftn) #:use-module (ffi-help) #:use-module ((system foreign) #:prefix ffi:) #:use-module ((bytestructures guile) #:prefix bs:) ) (define bs:struct bs:bs:struct) (define bs:union bs:bs:union) (define lib-link (dynamic-link #f)) (define (lib-func name) (dynamic-func name lib-link)) ;; here will be ~1000 lines of autogenerated code (define my-cairo-hack () (first '(("hello")))) ;; --- last line — Matt