[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] 'const' types not working in define-foreign-record
From: |
felix winkelmann |
Subject: |
Re: [Chicken-users] 'const' types not working in define-foreign-record |
Date: |
Sun, 28 Aug 2005 15:54:27 +0200 |
On 8/27/05, Daniel B. Faken <address@hidden> wrote:
> On Sat, 27 Aug 2005, felix winkelmann wrote:
> > On 8/25/05, Daniel B. Faken <address@hidden> wrote:
> > > Hi,
> > >
> > > When I define a type like c-string, int, and others as 'const' (i.e.
> > > (const c-string), (const int), ..) their accessors give garbage output.
> > >
> >
> > Which accessors? Are you defining them purely as types, or inside
> > a (foreign) record?
>
> Yes, I'm using define-foreign-record and trying to make some fields
> immutable (i.e. avoiding the definition of setters) by declaring their
> types e.g. (const int) instead of int.
>
Here is a version of define-foreign-record that should work better (still not
perfect, though):
182a183,188
> (define (strtype type)
> (or (eq? type tname)
> (and (pair? type)
> (or (and (eq? 'const (car type)) (strtype (cadr type)))
> (memq (car type) '(struct union)) ) ) ) ) ; handle instances?
> (##sys#hash-table-set! ##compiler#foreign-type-table tname `(pointer
> ,fname))
209d214
< (define-foreign-type ,tname (pointer ,fname))
222c227
< (if (eq? type type2) "" "&")
---
> (if (not (strtype type)) "" "&")
249c254
< (if (eq? type type2) "" "&")
---
> (if (not (strtype type)) "" "&")
(chicken-ffi-macros.scm)
cheers,
felix