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: #define SOMETHING some_value Date: Thu, 15 Jun 2017 12:21:57 -0700 Message-ID: <81DEFAEA-2D17-41BC-B5ED-5993ACDB7FCE@gmail.com> References: <87shj62twk.fsf@netris.org> 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 1497554552 18042 195.159.176.226 (15 Jun 2017 19:22:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 15 Jun 2017 19:22:32 +0000 (UTC) Cc: guile-user@gnu.org To: Mark H Weaver Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Jun 15 21:22:27 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 1dLaLa-0004Qz-V4 for guile-user@m.gmane.org; Thu, 15 Jun 2017 21:22:27 +0200 Original-Received: from localhost ([::1]:55549 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLaLg-0007CH-0S for guile-user@m.gmane.org; Thu, 15 Jun 2017 15:22:32 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLaLH-0007CB-GD for guile-user@gnu.org; Thu, 15 Jun 2017 15:22:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLaLD-0005Er-G7 for guile-user@gnu.org; Thu, 15 Jun 2017 15:22:07 -0400 Original-Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:32857) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dLaLD-0005DM-AN for guile-user@gnu.org; Thu, 15 Jun 2017 15:22:03 -0400 Original-Received: by mail-pg0-x241.google.com with SMTP id a70so2624118pge.0 for ; Thu, 15 Jun 2017 12:22:01 -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=8ex/S/s2GdnnpTeWz7QX0zE9XTidQYUDhWdVUWgJkBo=; b=YKyTA+RwkaLewfRAyplwCZzT+UD57N+WhoVntGjAEakEOIfNfO8O98vJUkA49+hBd6 l2CDMGr9h98j4/JwdkXDzKYdJwBxDklvHZBCJIWg9wn1iqjRI+b7OcxAj+UKN3LHEhh/ dxHkgaibHAmOx25ZR17yDi/nH53p62wE+hFJx7tvOduWbLHQZCF7g7Liy0+2wdxZuK8l Qq0OCIOyeZtQ/5vsnmam+ZSw7PZCTTKv/Tw1ZXNMKDoERzzR+NZrz0G12OaO2f+z6T02 SEBBDvO5C13f8XOjHPYI+NohEEqnDqL/3mbYwpVJO46QFDGj3NKuk/zjw5PlZ3uSL8jb V0Uw== 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=8ex/S/s2GdnnpTeWz7QX0zE9XTidQYUDhWdVUWgJkBo=; b=qx37INQt5SUu7yqQEbZQPBkLBARYqa/bo8DLmxcljQEuuHhr1tHUM1/xgKVaKcoE7U Ix+cbSffNq1KUzr8Z+6OLQwh3dlRMWuTNunXyVxJU6VYWxOoGWZRng95UClBR2Zn9VqR 8iHLQ4EfNLWTmZf3U3caRrzscAr06WXXZVO011D5qpTv6Pzk7BdOeTAMWhEvrrysLPid dAxvZ7pPqJpuhJ7NVX5Jgd/Xf/7hgF3rKm2W2sWyw/rMT3lEDRWkVn9HZtN1M0UiCFj1 OdS/fxiWWwpPYqWTjAD6gh8Ory4uR1nW4tebn4jpkaL7KIeyMC7TTVZpnHQSRN9Y0GB1 eHFQ== X-Gm-Message-State: AKS2vOy8HtWu+VBxk0xCl73BPWH4v5YilDWZZj5Ax40c2MsTxB/lTnyO CvFN5lptEE1pYeCwq5Y= X-Received: by 10.84.128.107 with SMTP id 98mr3475240pla.285.1497554520828; Thu, 15 Jun 2017 12:22:00 -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 3sm132588pfp.11.2017.06.15.12.21.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Jun 2017 12:21:59 -0700 (PDT) In-Reply-To: <87shj62twk.fsf@netris.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::241 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:13839 Archived-At: > On Jun 11, 2017, at 12:42 PM, Mark H Weaver wrote: >=20 > Amirouche Boubekki writes: >=20 >> What I do is that I hardcode the define in scheme using simple define = form >>=20 >> for instance, the following: >>=20 >> #define SOMETHING some_value >>=20 >> Becomes: >>=20 >> (define SOMETHING some_value) >=20 > Right. Unfortunately, preprocessor macros are replaced with their > right-hand-sides in the first phase of C compilation (preprocessing), > and then forgotten. These macros are not stored in the shared = objects, > so it's simply not possible for us to retrieve them. >=20 > For this reason, I'm sorry to say that the association between = SOMETHING > and some_value must be redundantly represented in your Guile bindings, > as Amirouche describes above. >=20 > It would be nice to have a tool to extract this information from .h > files automatically, but since there's no guarantee that the .h files > are present on the user's machine at run time, nor is there a robust = way > to find those .h files, this would be a tool for your convenience as a > developer, and would still require you to redundantly store the output > of this tool in your Scheme sources. >=20 > I'm sorry that I don't have a better answer for you. >=20 > Mark >=20 I now have my ffi-helper automatically extracting #defines which are = constants. I process on cairo-svg.h + cairo.h and get the following. I don=E2=80=99t= think defining and exporting all these as (define CAIRO_VERSION_MAJOR 1) etc is a good = idea. Comments on this method of providing access? Matt (define xxx-def-val (let ((deftab '((CAIRO_VERSION_MAJOR . 1) (CAIRO_VERSION_MINOR . 14) (CAIRO_VERSION_MICRO . 8) (CAIRO_HAS_FC_FONT . 1) (CAIRO_HAS_FT_FONT . 1) (CAIRO_HAS_GOBJECT_FUNCTIONS . 1) (CAIRO_HAS_IMAGE_SURFACE . 1) (CAIRO_HAS_MIME_SURFACE . 1) (CAIRO_HAS_OBSERVER_SURFACE . 1) (CAIRO_HAS_PDF_SURFACE . 1) (CAIRO_HAS_PNG_FUNCTIONS . 1) (CAIRO_HAS_PS_SURFACE . 1) (CAIRO_HAS_QUARTZ_FONT . 1) (CAIRO_HAS_QUARTZ_IMAGE_SURFACE . 1) (CAIRO_HAS_QUARTZ_SURFACE . 1) (CAIRO_HAS_RECORDING_SURFACE . 1) (CAIRO_HAS_SCRIPT_SURFACE . 1) (CAIRO_HAS_SVG_SURFACE . 1) (CAIRO_HAS_TEE_SURFACE . 1) (CAIRO_HAS_USER_FONT . 1) (CAIRO_HAS_XCB_SURFACE . 1) (CAIRO_HAS_XLIB_SURFACE . 1) (CAIRO_HAS_XLIB_XCB_FUNCTIONS . 1) (CAIRO_HAS_XLIB_XRENDER_SURFACE . 1) (CAIRO_HAS_XML_SURFACE . 1) ))) (lambda (k) (assq-ref deftab k))))