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: ffi-help: handling types Date: Tue, 27 Jun 2017 19:26:16 -0700 Message-ID: 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 1498616798 31460 195.159.176.226 (28 Jun 2017 02:26:38 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 28 Jun 2017 02:26:38 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Jun 28 04:26:33 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 1dQ2ga-0007qu-Ky for guile-devel@m.gmane.org; Wed, 28 Jun 2017 04:26:32 +0200 Original-Received: from localhost ([::1]:58960 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQ2gf-0006XT-Jt for guile-devel@m.gmane.org; Tue, 27 Jun 2017 22:26:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41587) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQ2gU-0006XN-Bv for guile-devel@gnu.org; Tue, 27 Jun 2017 22:26:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQ2gR-0002VT-8O for guile-devel@gnu.org; Tue, 27 Jun 2017 22:26:26 -0400 Original-Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]:35410) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dQ2gR-0002Ut-2e for guile-devel@gnu.org; Tue, 27 Jun 2017 22:26:23 -0400 Original-Received: by mail-pf0-x229.google.com with SMTP id c73so25586460pfk.2 for ; Tue, 27 Jun 2017 19:26:20 -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:message-id:date :to; bh=U5fLu2nth4MjhEyIr/xLfmU1Gf2C1usUFEFX+fxBLj4=; b=N3/UmhYVrKwWv4y893lplKMfKj+y+5NXD1fZsoZzw4kuIHCymsokcq3mKDQiOrWuMK eeecU6umaeRFaasSESbkhe2PLhfvBdf4zmyxHmECWFPto6b8bzYPRSjqakez1pEsVFut NBdiKQPnXSO5DiM2WRLGEmGHgeGanb3UE5uPe8AB9idMbuYLGBgqAs6huFVvMZesTATE 9P2umrMJP7Gx3gRFVFbJHPe5bDNOHQZPy2XuBYhwzkSfoQ74F7Ec1oRrGr5LxXf5C1+L 5FK2H62G8jdQZMeg/8RE+POxqUOs+caSjFvtZSRkGjSt1iQVaL5Mtz68trX3sPw0DX59 JczA== 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:message-id:date:to; bh=U5fLu2nth4MjhEyIr/xLfmU1Gf2C1usUFEFX+fxBLj4=; b=ViaLhW5IcEIIOrdPUzbKn2H23OTRNOGmMluinhQrFKbaWJqNI3kFteMx188RwrVknn 7Q4NnrSANbhfQy9teRQvS2Sv0Jm6y4AcXQSegg/PisLgswSPOmOl1d92hL1IYSp78WXX SlfpBUp8QYVO6UpgyREeclh297pXJ12ZzZpVWkgbvuH9zyeqehxe5UuCM3OLokBow7G9 //hmNSnwW5QqPTjbUro/OV+XjosZ5X/J5RyGnB6ZM4HRxlmQMIUmnX0ikyYpEjCnZuNz FltbeHwu0py32fPM9Vlgb9Nhwixs3MlaDe+cyr5zVV/5EuajSdHCzYUfLjn7U+QrfA7A bDCw== X-Gm-Message-State: AKS2vOwxs8yy3Ht21YaVUA4tuMLcXvX9TbQlwFUqsGaPlNs4aBFMHzZt FkMBFNfj8vg5xy/gaJQ= X-Received: by 10.84.218.71 with SMTP id f7mr8912480plm.282.1498616778745; Tue, 27 Jun 2017 19:26:18 -0700 (PDT) Original-Received: from nautilus.championbroadband.com (216-165-236-44.championbroadband.com. [216.165.236.44]) by smtp.gmail.com with ESMTPSA id g7sm1015015pfj.29.2017.06.27.19.26.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Jun 2017 19:26:17 -0700 (PDT) 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::229 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:19234 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 which defines a module to provide = hooks into the associated C library. A little status on type handling: For nominal C types I am trying to stick to the (system foreign) type = system. For aggregate types I am using scheme-bytestructures = (https://github.com/TaylanUB/scheme-bytestructures). However, I am = currently putting a guile struct wrapper on top of bytestructure = descriptors in order to provide a more user-friendly interface (IMO). =20= In the demo I have created a (cairo cairo-svg) ffi-module which gets = converted to a guile module via $ guild compile-ffi cairo/cairo-svg.ffi Then I start guile and do this: scheme@(guile-user)> (use-modules (cairo cairo-svg)) scheme@(guile-user)> (use-modules (ffi-help)) scheme@(guile-user)> (use-modules (system foreign)) scheme@(guile-user)> (define srf (cairo_svg_surface_create = (string->pointer "abc.svg") 200.0 200.0)) scheme@(guile-user)> srf $2 =3D @(guile-user)> (define cr (cairo_create srf)) scheme@(guile-user)> cr $1 =3D scheme@(guile-user)> (define mx (make-cairo_matrix_t)) scheme@(guile-user)> mx $3 =3D # scheme@(guile-user)> (pointer-to mx) =20 $4 =3D scheme@(guile-user)> (cairo_get_font_matrix cr (pointer-to mx)) scheme@(guile-user)>=20 Matt