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 Subject: Re: ffi-help: status to date Date: Tue, 24 Oct 2017 17:18:29 -0700 Message-ID: <91AF422B-BC34-4F99-BEE1-87B946A9FBD4@gmail.com> References: <25A19914-FADD-46DC-AEFA-F290210C33DF@gmail.com> <84325B67-FE0B-4802-861B-0FC50D7CB5D7@gmail.com> <47398F30-BD71-43ED-B9A0-DA86CCCA4D40@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 1508890733 22495 195.159.176.226 (25 Oct 2017 00:18:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 25 Oct 2017 00:18:53 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Oct 25 02:18:46 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 1e79P6-00049f-7R for guile-devel@m.gmane.org; Wed, 25 Oct 2017 02:18:40 +0200 Original-Received: from localhost ([::1]:46007 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e79PB-00058U-VB for guile-devel@m.gmane.org; Tue, 24 Oct 2017 20:18:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e79P1-00058O-LG for guile-devel@gnu.org; Tue, 24 Oct 2017 20:18:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e79Oy-0001E4-H5 for guile-devel@gnu.org; Tue, 24 Oct 2017 20:18:35 -0400 Original-Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]:54336) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e79Oy-0001DX-Bh for guile-devel@gnu.org; Tue, 24 Oct 2017 20:18:32 -0400 Original-Received: by mail-pf0-x22c.google.com with SMTP id n89so20881081pfk.11 for ; Tue, 24 Oct 2017 17:18:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=5RO1Ptax39z+rrLv+wnEt4Vx0LAxXUCxiL80JEGYCdg=; b=G8Cjm60P+V+GEEF5zzI+2Ud0R3+qCAGrSDZfLVHLhN5r8AGvmda3QP11AiMExCWgeJ E1Zwokq5evU4flAc0Lx0+LwC0jB82wM9QIS0eWZsL4u2TthDjltVxEUC5CxqaBz0jqTX VNLZlywp97qKZ0sxivMoZO973HNsTU9MZxpDEFKg6NQMMfLm5EltFV5t27kmKutTmT84 YvRJN6Ncmauy1CAviLoyFDu1PaljEhC9VgU7NCZV1kA1pP2ub/l7bPjlCfwLc/kHTY0/ Ju4QbcXDlZFalEsRARKL/xMBOetI4RB4//KFXPtdfR4FppAmsX0OAwr+BhMGD09PxuxD T98g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:references:to:in-reply-to:message-id; bh=5RO1Ptax39z+rrLv+wnEt4Vx0LAxXUCxiL80JEGYCdg=; b=p2UQIhhHT6dsimtgjhfJrWorugkRkk1sUmheYiqnWimlibPNA15FUYswL+u3uXhgY7 j32G8eoWaJgqQc83/YAuwyXmEf1BeFMK/nTw5lehR1l37GsAyTlOpC3AyF1x2WMn1zTm e48n15gYUFQ7nTD+Pi2jH41t+WO/cxZZq/ufc3y04KRR6qbqD7Tcxs1x6Fz9J631ZvSI F2q7gHL7WjYeESoR5oWrHUD5eFOvPY6tV+fgBvmacxc7wNyTaStFgYZf1hKdHFEuY+4q HEp0/6NC8Aeep+Bdm1TBaoYdwFJdNTIZLHOj07N1aZ4NlPyRwTTVWltxOCU/eK/mC4Kt CfOg== X-Gm-Message-State: AMCzsaUUl2/LBxTqGzkhF4cIzCIVqTfgvvRwjfthkL2jt810mCAVYctW rB5TF3gChKnWViIG0Op3vJswvqfm X-Google-Smtp-Source: ABhQp+QkI6c7XSlhur9LcUQsHaJGuKvMFNbSE+sWNhBBZI8PEh4fIAgxFNK9ZBoWSwnNQ6U0I8q3mA== X-Received: by 10.99.95.14 with SMTP id t14mr368367pgb.70.1508890710773; Tue, 24 Oct 2017 17:18:30 -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 k10sm1682661pgq.92.2017.10.24.17.18.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Oct 2017 17:18:30 -0700 (PDT) In-Reply-To: <47398F30-BD71-43ED-B9A0-DA86CCCA4D40@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::22c 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:19347 Archived-At: > On Oct 22, 2017, at 11:31 AM, Matt Wette wrote: >=20 > Hi All, >=20 > I am working on a ffi-helper (FH): 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. = =20 >=20 > I was able to generate scm code for glib, gobject, gio, pango, and = gtk2+. The following demo code actually works. > I get a GUI and click the button and it closes, though with an error = message: > gtkdemo.scm:16:0: Wrong number of arguments to # >=20 > (define (hello widget data) > (display "Hello World!\n")) > (g_signal_connect button "clicked" hello NULL) The reason I got error messages was that g_signal_connect uses signature = `void (*f)(void)' for the=20 callback but the semantics of GTK say use `void (*f)(void*, void*)', = basically. GTK handles this=20 by providing casts for arguments. I got the code working by hand = generating casts: (define ~hello (ffi:procedure->pointer ffi:void hello (list '* '*))) (g_signal_connect button "clicked" ~hello NULL) Doing this by hand is a bit of a mess, but ... there it is. I am not = confident that there is a way to automate or make this easier. I had to generate a couple other = hand-casts but the result is that the demo is now working w/o error messages. =20 In case you are interested here are line counts for the text files and = sizes for the object files. (oops, didn't include pango; that is bigish) mwette$ wc gobject.* glib.* gtk2+.* gdk2.* 26 77 885 gobject.ffi 12543 28465 426476 gobject.scm 31 82 1006 glib.ffi 31326 75035 1013504 glib.scm 17 47 470 gtk2+.ffi 92827 210107 3259549 gtk2+.scm 18 52 534 gdk2.ffi 18986 45046 639630 gdk2.scm mwette$ ls -l gobject.* glib.* gtk2+.* gdk2.* -rw-r--r-- 1 mwette staff 3619461 Oct 22 10:57 gdk2.scm.go -rw-r--r-- 1 mwette staff 5546829 Oct 22 10:48 glib.scm.go -rw-r--r-- 1 mwette staff 2554501 Oct 24 16:36 gobject.scm.go -rw-r--r-- 1 mwette staff 18521997 Oct 22 11:06 gtk2+.scm.go