From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Matt Wette Newsgroups: gmane.lisp.guile.devel,gmane.lisp.guile.user Subject: ffi-help: #:use-ffi-module Date: Thu, 7 Sep 2017 20:32:23 -0700 Message-ID: <84325B67-FE0B-4802-861B-0FC50D7CB5D7@gmail.com> References: <25A19914-FADD-46DC-AEFA-F290210C33DF@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1504841584 19845 195.159.176.226 (8 Sep 2017 03:33:04 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 8 Sep 2017 03:33:04 +0000 (UTC) Cc: Guile User , guile-devel To: Matt Wette Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Sep 08 05:32:49 2017 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqA25-00045c-Ln for guile-devel@m.gmane.org; Fri, 08 Sep 2017 05:32:41 +0200 Original-Received: from localhost ([::1]:43137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqA2C-0002Sj-Lu for guile-devel@m.gmane.org; Thu, 07 Sep 2017 23:32:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqA1w-0002Nw-Vx for guile-devel@gnu.org; Thu, 07 Sep 2017 23:32:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqA1s-0002Nj-9K for guile-devel@gnu.org; Thu, 07 Sep 2017 23:32:32 -0400 Original-Received: from mail-pf0-x233.google.com ([2607:f8b0:400e:c00::233]:32863) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dqA1s-0002Mj-2m; Thu, 07 Sep 2017 23:32:28 -0400 Original-Received: by mail-pf0-x233.google.com with SMTP id y29so1837258pff.0; Thu, 07 Sep 2017 20:32:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=LGwxbxxTZ2iYcrr6fL/EL4LhX7yettvtNqAr/oDo1Ss=; b=M+H0lYmm4Hx3ZBCVwm+18NBv8CrkaVbBS0ZtDwodGXxgWibaSbKrnnYywlken3ZZIg 5+hOWF6m+RCQYW+kg+cmo7z2bY5TRUVMmSkxB145oGItSFWfHvygw21zd820Is3iudU4 fLSCZBa79AKL/+LdqSzrYl9r+FygHEsuawD27on30cCMOE0ks8PQvFMkq81Y0zvpMDta Q8efvY/hTW94LeVXKho08/exQULACqYiwiMOCyrSP3xVEFucfqP56Aao7EVkBEMgBQ5e ZKLbe37FS5fcuywtM3v3dTJ4X0DQQOGgivgp0iIXpWR8NUDKDAMfG2o0A2lVZ82b5MKX L6Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=LGwxbxxTZ2iYcrr6fL/EL4LhX7yettvtNqAr/oDo1Ss=; b=YiAmKNsAz1E5sXgGuXqy1tPI/l1aSmtO4awoR6Lt0SPmAsayWePMDavbEPvA+Wfqgt 9FwOY+c3/yCjwL53KdPyvKqqIPAxEfTG2cCeAntz1JMOvM8BWF8+5jUJh7JY6FLHf+PS Rctp2AAANMTeEkTVRYph6U+YnSMPYxDomaoanx6+DdQJcA90CIhQBEhHOrC74LKDYQad Ag+3Y2sBRktoNt4c2UVEccvYujI56bZQp1hMBvoEtOlSOhj5/Kw4Nuoo6y19FkGQ+v7X xyLsZ0/ph32YrnPelN3jn64qBi+ciD2Yj4xy5WKMrXcN0RM6mYnU7Qt8y3AGsxW6Hzb1 5c1Q== X-Gm-Message-State: AHPjjUhg5mUHjNK0KBhEKeuMuJSA5qanHXA3IkHEzS7vdNc7D71OJ4E2 c1yaNsBFw+PZww== X-Google-Smtp-Source: ADKCNb5uuWG0autzMX03IQlvPaEUsWqXp25GqMGHlBwFySSoiQyK1gx6DC1thA0+DBW0PXQ5LMlfug== X-Received: by 10.98.70.90 with SMTP id t87mr1619882pfa.114.1504841545809; Thu, 07 Sep 2017 20:32:25 -0700 (PDT) Original-Received: from nautilus.championbroadband.com (216-165-229-229.championbroadband.com. [216.165.229.229]) by smtp.gmail.com with ESMTPSA id a29sm1043863pgn.75.2017.09.07.20.32.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Sep 2017 20:32:25 -0700 (PDT) In-Reply-To: <25A19914-FADD-46DC-AEFA-F290210C33DF@gmail.com> X-Mailer: Apple Mail (2.3273) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::233 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:19275 gmane.lisp.guile.user:14097 Archived-At: 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=20 which defines a module to provide hooks into the associated C library. = Goal is to release something=20 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=20 use-ffi-module declaration, then the type is expanded. So, the = ffi-module declaration has expressions to=20 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=20 ;; 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