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: Re: ffi-help: status to 19 Aug 2017 Date: Thu, 9 Nov 2017 17:00:23 -0800 Message-ID: <0B1CB7F6-A400-487D-BBCA-BE08E75033CA@gmail.com> References: <25A19914-FADD-46DC-AEFA-F290210C33DF@gmail.com> <878tfffet8.fsf@gnu.org> 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 1510275653 11323 195.159.176.226 (10 Nov 2017 01:00:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 10 Nov 2017 01:00:53 +0000 (UTC) Cc: Guile User , guile-devel To: Roel Janssen Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Nov 10 02:00:43 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 1eCxgY-0002RK-E9 for guile-devel@m.gmane.org; Fri, 10 Nov 2017 02:00:42 +0100 Original-Received: from localhost ([::1]:39665 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCxgd-0007Cm-5H for guile-devel@m.gmane.org; Thu, 09 Nov 2017 20:00:47 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCxgQ-0007BH-Nu for guile-devel@gnu.org; Thu, 09 Nov 2017 20:00:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCxgP-00023P-Ob for guile-devel@gnu.org; Thu, 09 Nov 2017 20:00:34 -0500 Original-Received: from mail-pg0-x232.google.com ([2607:f8b0:400e:c05::232]:52587) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eCxgJ-0001yg-Hg; Thu, 09 Nov 2017 20:00:27 -0500 Original-Received: by mail-pg0-x232.google.com with SMTP id j16so617834pgn.9; Thu, 09 Nov 2017 17:00:27 -0800 (PST) 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=bDVatHIiHZ+b62TR6dwBKX+dquc+FedS5Fr5QU+BbtA=; b=imGndgyrB+d42W/LrWQJQJPXTE9f7GBZcDvHKFQ6jOgtlvxJ2QrbATcSIqemjHJ7NB GgudWm+nA7AzYJqPE+Bc0DTbL9QtnC74R1i5MPiUUUh7hHg4p3FR+p4drJKdM1gS6YYa 7/cLvqlk6FMVkqtTFBcZWqpxsm1z4We//FVUGG7by0+IiLSmWJpBSO7WfuWlfh2YuHfv mbXxapJEngWQDzrZcE4qbcJ6oPznb9/azAAsVw+i8Ok9keIaXfWE5Fuvqf1hKwnXuLev qMrLQS5ObGbgVPTKo4qS4OM9BDc539oYcmLoBvewcZAhDT908ubGIxYhkJb4p4ezBSu2 QyLg== 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=bDVatHIiHZ+b62TR6dwBKX+dquc+FedS5Fr5QU+BbtA=; b=D68BhArLT+EfhBbhPmw32hwBHfDavqyi31ipwksbt/R6qLvMO1We+I5MiikgwfKRfD /jeCEUzN5pJ0nZBVV7Eg83i/h0Mv9ZnqwXD8B3eCroFH7xhBqtUW+cBVcf+TIAgJ6S6R BpKQ3aX8nWiw6A7cpKWW1AnuHTw6rS9MZFHSBH4iUlLOqJRvbs2aJCHpNYdH/r0scJk7 8ICjIMkZ1lDgFIho9fBCjzrf/TSX/4EiHlNgLrx7L3SvgzreGwsAndunZghI4BfU01Ig mI2X4eOBG2x5ODktB4qIhj8OHa8F5h52qTMPtwBcfd/N5SujHzWGwFqmazi1FHVg7qGS NGKg== X-Gm-Message-State: AJaThX5iU8M0+MU/igK0qOZIh7GQ2JTZ2Ovl/H3IwNKDgM9tprS9sjJN mh0ltDcmXL+eh3svxMAEEZZNHkEf X-Google-Smtp-Source: ABhQp+SxUv41LrQTvsyjg0O5vFb4wNx6UAC82vloM/eewJ9L2lFdKa8TabgboXjLgfbHSRhu33rqkg== X-Received: by 10.101.81.131 with SMTP id h3mr2278144pgq.190.1510275625653; Thu, 09 Nov 2017 17:00:25 -0800 (PST) Original-Received: from nautilus.championbroadband.com (216-165-229-229.championbroadband.com. [216.165.229.229]) by smtp.gmail.com with ESMTPSA id m25sm15820405pfg.49.2017.11.09.17.00.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Nov 2017 17:00:25 -0800 (PST) In-Reply-To: <878tfffet8.fsf@gnu.org> 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:c05::232 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:19377 gmane.lisp.guile.user:14235 Archived-At: > On Nov 9, 2017, at 11:10 AM, Roel Janssen wrote: >=20 >=20 > Matt Wette writes: >=20 >> Hi All, >>=20 >> 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 in >> Oct 2017 but that date is likely to slip. >>=20 >> Current shortcomings: >> 1) Guile does not currently handle some types (e..g, long long, = uintptr_t). >> 2) Guile does not have support for varargs (e.g., printf(char *, ...) = ). >> I may take a look at this. One idea I have is to use '... in the = call interface spec >> and use (type . value) pairs in the calls. >> 3) The bytestructures module does not support function declarations. >> 4) ... (probably more) >>=20 >> Someone asked to have libgit2 converted and this, and some others, = turned out to give visibility >> to several limitations and bugs in my C parser. For one, how = #include is interpreted=20 >> is not specified by the language: it is implementation defined, and I = had to track down how libgit2=20 >> was including files. I also had to add some GNUC extensions (e.g., = asm, statement-block expressions, >> include_next) to the parser and preprocessor. As one can see from = the file listing below, libgit2=20 >> has a large number of files, and declarations. >>=20 >> ... >=20 > Thanks for creating this! It seems to be very useful and powerful. >=20 > I wanted to try ffi-helper on htslib, but I am confused on how to get > started. Where does the "compile-ffi" subcommand for "guild" come = from? >=20 > Kind regards, > Roel Janssen See the following, but I'm seeing a parse error so may be a bug in my = C99 parser. And not sure "hts.h" is the only include you need. mwette$ git clone -b c99dev git://git.savannah.nongnu.org/nyacc.git = nyacc Cloning into 'nyacc'... remote: Counting objects: 5927, done. mwette$ cd nyacc mwette$ cd examples mwette$ source env.sh mwette$ cd ffi mwette$ cp TMPL.ffi htslib.ffi mwette$ vi htslib.ffi mwette$ cat htslib.ffi ;; htslib.ffi -*- Scheme -*- (define-ffi-module (ffi htslib) #:pkg-config "htslib" #:include '("htslib/hts.h") #:inc-filter (lambda (file-spec path-spec) (string-contains path-spec "htslib/" 0)) ) ;; --- last line --- mwette$ guild compile ffi/htslib.fif ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=3D0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /var/tmp/yy/nyacc/examples/scripts/compile-ffi.scm ... ;;; compiled .../c99/ffi-help.scm.go TODO: fix gen-lookup-proc: it's including imported symbols ;;; scripts/compile-ffi.scm:119:8: warning: possibly unbound variable = `compile' ;;; compiled = /Users/mwette/.cache/guile/ccache/2.2-LE-8-3.A/private/var/tmp/yy/nyacc/ex= amples/scripts/compile-ffi.scm.go ffi-help: WARNING: the FFI helper is experimental /opt/local/include/htslib/hts.h:774: parse failed at state 313, on input = "U" (unknown):1: C99 parse error *** compile-ffi: parse failed The offending line is the following, which seems to indicate my lexer is = not reading "LLU" constants. I will check. v =3D ((v & 0x00000000FFFFFFFFLLU) << 32) | (v >> 32); Had the above worked, then you should be able to `(use-modules (ffi = htslib))': mwette$ guile GNU Guile 2.2.2 Copyright (C) 1995-2017 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guile-user)> (use-modules (ffi htslib)) ERROR: no code for module (ffi htslib)