[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] Structs
From: |
Felix Winkelmann |
Subject: |
[Chicken-users] Structs |
Date: |
Mon, 14 Oct 2002 08:57:05 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.0) Gecko/20020530 |
Hi!
>Now, I don't understand how to construct an API for zlib because I
>don't know
>how to make a z_stream structure that can be updated both in the
scheme >side
>and the C side, and have garbage collection not foul anything up.
In this case I would create a number of foreign-lambda*s
that access the slots:
(define-foreign-type z_stream (pointer "z_stream"))
(define make-z_stream
(foreign-lambda* z_stream ()
"return((z_stream *)malloc(sizeof(z_stream)));") )
(define z_stream-next_in
(foreign-lambda* c-pointer ([z_stream p])
"return(p->next_in);") )
(define z_stream-next_in-set!
(foreign-lambda* void ([z_stream p] [pointer x])
"p->next_in = x;") )
...
I can send you a quick-and-dirty macro that does most
of the work. Might need one or two days (I don't have it
here on my machine at work).
cheers,
felix
- [Chicken-users] Structs,
Felix Winkelmann <=