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.user Subject: Re: ffi helper Date: Mon, 17 Apr 2017 19:26:57 -0700 Message-ID: <093A1AB8-D7BD-4DAF-B5EC-DC0228D6A29C@gmail.com> References: <96434CF4-E3F9-4410-82B6-9EB8DEE130B9@gmail.com> <95B6EEEF-5278-44C8-B640-647A16AEFD1F@gmail.com> <201FF019-FA10-4B35-A96D-BC0AD078F5DB@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1492482454 19643 195.159.176.226 (18 Apr 2017 02:27:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 18 Apr 2017 02:27:34 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Apr 18 04:27:30 2017 Return-path: Envelope-to: guile-user@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 1d0IrZ-00051J-OC for guile-user@m.gmane.org; Tue, 18 Apr 2017 04:27:29 +0200 Original-Received: from localhost ([::1]:39694 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0Irf-0004v4-Jz for guile-user@m.gmane.org; Mon, 17 Apr 2017 22:27:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44347) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0IrB-0004tI-QK for guile-user@gnu.org; Mon, 17 Apr 2017 22:27:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0Ir8-0007bI-KX for guile-user@gnu.org; Mon, 17 Apr 2017 22:27:05 -0400 Original-Received: from mail-pg0-x234.google.com ([2607:f8b0:400e:c05::234]:36599) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d0Ir8-0007aj-CH for guile-user@gnu.org; Mon, 17 Apr 2017 22:27:02 -0400 Original-Received: by mail-pg0-x234.google.com with SMTP id g2so80057942pge.3 for ; Mon, 17 Apr 2017 19:27:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:mime-version:subject:date:references:to:in-reply-to:message-id; bh=0U7fWokOBi3OWAzMax3NHR4aXgx0UbSFambvLTrtrRg=; b=gPEE2khVQBFWthe/j6SxmwyXcUN14UN8NXTAK6/Ee5TM80wcWM0pcHM7rPKXgG9Fy/ 31pwmSm3vR2CL1u8zSPjbbgKYuUvS4qWBKeQwU+tR5auIXfMLGQf7ylG70qOErIQPZ/u UcpY8GBVbG1SyHetERRnTES5C9CPmXyunHLM8QyykXDbUr5oeHFPNutu+J+E3WGRieIW gRt1StPR94aV+vpgnyrv8fm6EfoQGIlHf6Avuq+vRHpg/zONikDOgHVKtliojBfZbFlj cpkni/A6JHpZfzczF0GTYxCKW7noffNZYU8QprZM8glb6I0aXmyvIAb1qhbDzUV3I4b7 3SRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:subject:date:references:to :in-reply-to:message-id; bh=0U7fWokOBi3OWAzMax3NHR4aXgx0UbSFambvLTrtrRg=; b=YkBiYCvC57z0JPBi5KPz90AuiO6gn6nkIY7ndYJSJ8pyGQHLOg3atwyU6vaGo0ZVBj O+zQGH7AWe+ypOY0IOKve9e7itkSr1rUNE4fbtC+niEO4oHd/9fAALiU/Su0wSi5/t1a cbsy/rTcw6rORxSqYai5ZwhLnvxslVTyFx0P/xTg/UJEH/rqdgmx2WSBTieN5+qSODJX L83x4+5U8PyCKg2DADMBTq+VSoE4kqeq71+bhqjX5aGC6koqdDJSmDI1x0dQutCD1XZG YsjoDSEOzWk18o+YkAGs5t7Y0/iTWOZ/QmLHOQ8mJDAZ0IZf1ysr02wZv2Rah7ezd4UR sqwQ== X-Gm-Message-State: AN3rC/5JZpl8rPAsLQxU5hj4YmFSsEEQ/LEoAUrjkIZf3VXtiXBzRewC 5Hw/rTjCmP4AQfNjmQU= X-Received: by 10.98.73.214 with SMTP id r83mr15291622pfi.253.1492482420139; Mon, 17 Apr 2017 19:27:00 -0700 (PDT) Original-Received: from [192.168.2.114] (216-165-236-44.championbroadband.com. [216.165.236.44]) by smtp.gmail.com with ESMTPSA id u63sm20328508pfb.55.2017.04.17.19.26.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Apr 2017 19:26:58 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3273) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c05::234 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:13609 Archived-At: > On Mar 21, 2017, at 3:40 PM, Matt Wette wrote: >> On Mar 19, 2017, at 10:23 AM, Matt Wette = wrote: >>> On Mar 13, 2017, at 5:53 PM, Matt Wette = wrote: >>>> On Mar 8, 2017, at 6:06 PM, Matt Wette = wrote: >>>> I=E2=80=99m now working on a FFI helper based on the nyacc C99 = parser. =20 Still working on it. I ran into some issues with the C preprocessor = again so had to fix that. =20 I have a lot to do still, but now I have a source file that looks like = this: (use-modules (ffi-help)) (define-ffi-helper (cairo cairo) #:pkg-config "cairo" #:include "cairo-svg.h" #:library "libcairo" #:filter (lambda (path) (string=3D? "cairo" (substring path 0 5))) ) and generates a 4800 line files that includes stuff like this: (define-module (path-list) <=3D should read (cairo cairo) #:(use-module (ffi-help) #:(use-module (system foreign) #:(use-module ((bytestructures guile) #:renamer bs-renamer) ) (define lib-link (dynamic-link "libcairo")) (define (lib-func name) (dynamic-func name lib-link)) ;; "cairo_version" (define cairo_version (let ((f (pointer->procedure int (lib-func "cairo_version") (list)))) (lambda () (let () (wrap-int (f)))))) (export cairo_version) ;; "cairo_version_string" (define cairo_version_string (let ((f (pointer->procedure '* (lib-func "cairo_version_string") (list)))) (lambda () (let () (wrap-char* (f)))))) (export cairo_version_string) ;; "cairo_t" (define-std-pointer-wrapper cairo_t*) (export cairo_t*) ;; "cairo_surface_t" (define-std-pointer-wrapper cairo_surface_t*) (export cairo_surface_t*) ;; "cairo_device_t" (define-std-pointer-wrapper cairo_device_t*) (export cairo_device_t*) ;; "cairo_matrix_t" (define cairo_matrix_t (bs:struct `((xx ,double) (yx ,double) (xy ,double) (yy ,double) (x0 ,double) (y0 ,double)))) (export cairo_matrix_t) ;; "cairo_get_user_data" (define cairo_get_user_data (let ((f (pointer->procedure '* (lib-func "cairo_get_user_data") (list '* '*)))) (lambda (cr key) (let ((~cr (unwrap-cairo_t* cr)) (~key (unwrap-cairo_user_data_key_t* key))) (wrap-void* (f ~cr ~key)))))) (export cairo_get_user_data) ;; "cairo_push_group_with_content" (define cairo_push_group_with_content (let ((f (pointer->procedure void (lib-func "cairo_push_group_with_content") (list '* tbd:cairo_content_t)))) (lambda (cr content) (let ((~cr (unwrap-cairo_t* cr)) (~content content)) (f ~cr ~content))))) (export cairo_push_group_with_content) ;; "cairo_set_source_rgba" (define cairo_set_source_rgba (let ((f (pointer->procedure void (lib-func "cairo_set_source_rgba") (list '* double double double double)))) (lambda (cr red green blue alpha) (let ((~cr (unwrap-cairo_t* cr)) (~red red) (~green green) (~blue blue) (~alpha alpha)) (f ~cr ~red ~green ~blue ~alpha))))) (export cairo_set_source_rgba)