Hi all, Attached are two patches, one to the chicken-5-eggs repo and one to the chicken-core repo to get rid of some declarations that (imho) don't really belong in chicken.h, because they're solely for the benefit of the "bind" (and formerly easyffi) egg.
I don't really know that much about bind, so I'd appreciate if someone who knows more about it (that's probably only Felix?) could review these patches. I've brought up this issue with Felix before, and he agreed that it's probably cleaner to move the declarations from chicken.h, so it's mostly the implementation that I'm worried about, it feels a bit like a hack. Cheers, Peter
From c1a81b5f94050fa8e76f8a9f7023244d9983b927 Mon Sep 17 00:00:00 2001 From: Peter Bex <[email protected]> Date: Wed, 1 Nov 2017 21:29:41 +0100 Subject: [PATCH] Emit ___type declarations in a prelude when needed This allows us to get rid of them in chicken.h, which makes it easier to change them at any point by decoupling bind from CHICKEN core. --- bind/bind.scm | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/bind/bind.scm b/bind/bind.scm index c189b43..380619a 100644 --- a/bind/bind.scm +++ b/bind/bind.scm @@ -18,7 +18,36 @@ (import bind-translator) (import (chicken io)) (import srfi-1) - (import srfi-13)) + (import srfi-13) + + (define emitted-prelude #f) + (define prelude #<<EOF +#define ___fixnum int +#define ___number double +#define ___bool int +#define ___byte char +#define ___scheme_value C_word +#define ___scheme_pointer void * +#define ___blob void * +#define ___pointer_vector void ** +#define ___symbol char * +#define ___safe +#define ___declare(x, y) +#define ___specialize +#define ___abstract +#define ___discard +#define ___in +#define ___out +#define ___inout +#define ___mutable +#define ___length(var) +#define ___pointer +#define ___u32 C_u32 +#define ___s32 C_s32 +#define ___u64 C_u64 +#define ___s64 C_s64 +EOF +)) (define-syntax bind (lambda (x r c) @@ -28,9 +57,11 @@ (define-syntax bind* (lambda (x r c) - (let ((strs (append (cdr x) '("\n")))) + (let* ((strs (append (cdr x) '("\n"))) + (decls (if emitted-prelude strs (cons prelude strs)))) + (set! emitted-prelude #t) `(,(r 'begin) - (,(r 'declare) (foreign-declare ,@strs)) + (,(r 'declare) (foreign-declare ,@decls)) (,(r 'bind) ,@strs)) ) )) (define-for-syntax (bind:read-file f) -- 2.11.0
From 1fc57853aff9540832d83d6e46537d1e714356d8 Mon Sep 17 00:00:00 2001 From: Peter Bex <[email protected]> Date: Wed, 1 Nov 2017 21:31:54 +0100 Subject: [PATCH] Remove declarations for bind/easyffi from chicken.h This decouples the bind egg from CHICKEN core, allowing it to be developed at its own pace and removing its somewhat "special" status among eggs. --- chicken.h | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/chicken.h b/chicken.h index 45571d45..400c80e2 100644 --- a/chicken.h +++ b/chicken.h @@ -316,33 +316,6 @@ void *alloca (); #define C_TIMER_INTERRUPTS -/* For the `bind' (and the obsolete `easyffi'): */ - -#define ___fixnum int -#define ___number double -#define ___bool int -#define ___byte char -#define ___scheme_value C_word -#define ___scheme_pointer void * -#define ___blob void * -#define ___pointer_vector void ** -#define ___symbol char * -#define ___safe -#define ___declare(x, y) -#define ___specialize -#define ___abstract -#define ___discard -#define ___in -#define ___out -#define ___inout -#define ___mutable -#define ___length(var) -#define ___pointer -#define ___u32 C_u32 -#define ___s32 C_s32 -#define ___u64 C_u64 -#define ___s64 C_s64 - /* Constants: */ -- 2.11.0
signature.asc
Description: PGP signature
_______________________________________________ Chicken-hackers mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/chicken-hackers
