guile-ffi

Gordon Matzigkeit (gord@trick.fig.org)
14 Aug 1998 10:52:48 -0600

Hi!

I firmly believe that guile-ffi is the Right Thing as far as writing
Guile wrappers for existing libraries. It's a PITA to have to muck
with SCM and recompile every time I want a new function.

I want to write C preprocessor module that can import macros constants
and declarations from a .h file into the current module, something
like:

(define-module (gnu errno)
:use-module (dlopen libc))

(cpp:include "<errno.h>")
(define ENOSYS (cpp:get-macro "ENOSYS"))
(and ENOSYS (export ENOSYS))
[...]

Then, when taken in conjunction with libffi, we can write wrappers
like:

(define strerror-sym (dynamic-func dlopen-libc-handle "strerror"))
(define-public strerror
(if strerror-sym
(ffi-create strerror-sym 'string 'int)
(lambda (num)
;; Some other definition of strerror...
(string-append "Unknown error code " (number->string num)))))

Anyway, let me know what you think, and if you're interested in
helping,

-- 
 Gordon Matzigkeit <gord@fig.org> //\ I'm a FIG (http://www.fig.org/)
    Lovers of freedom, unite!     \// I use GNU (http://www.gnu.org/)

Copyright (C) 1998 FIG.org; the creator offers you this gift and wants it to remain free. See http://www.fig.org/freedom.html for details. This work may be copied, modified and distributed under the GNU General Public License (GPL). See http://www.gnu.org/copyleft/gpl.html.