From: Matt Wette <matt.wette@gmail.com>
To: Matt Wette <matt.wette@gmail.com>
Cc: Guile User <guile-user@gnu.org>, guile-devel <guile-devel@gnu.org>
Subject: ffi-help: #:use-ffi-module
Date: Thu, 7 Sep 2017 20:32:23 -0700 [thread overview]
Message-ID: <84325B67-FE0B-4802-861B-0FC50D7CB5D7@gmail.com> (raw)
In-Reply-To: <25A19914-FADD-46DC-AEFA-F290210C33DF@gmail.com>
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
next prev parent reply other threads:[~2017-09-08 3:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-03 17:25 ffi-help: documentation Matt Wette
2017-08-19 15:30 ` ffi-help: status to 19 Aug 2017 Matt Wette
2017-09-08 3:32 ` Matt Wette [this message]
2017-09-08 3:40 ` ffi-help: #:use-ffi-module Matt Wette
2017-10-22 18:31 ` ffi-help: status to date Matt Wette
2017-10-25 0:18 ` Matt Wette
2017-11-09 19:10 ` ffi-help: status to 19 Aug 2017 Roel Janssen
2017-11-10 1:00 ` Matt Wette
2017-11-10 2:34 ` Matt Wette
2017-11-10 2:39 ` Matt Wette
2017-11-10 23:04 ` Stefan Israelsson Tampe
2017-11-11 4:38 ` Matt Wette
2017-11-14 18:06 ` Ricardo Wurmus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=84325B67-FE0B-4802-861B-0FC50D7CB5D7@gmail.com \
--to=matt.wette@gmail.com \
--cc=guile-devel@gnu.org \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).