[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Some pointers on easyffi and interfacing with C code
From: |
Zbigniew |
Subject: |
Re: [Chicken-users] Some pointers on easyffi and interfacing with C code |
Date: |
Thu, 10 Jan 2008 23:55:12 -0600 |
On Jan 10, 2008 10:17 PM, Mark Fredrickson <address@hidden> wrote:
> 1. Many of the GEOS functions return 'char', even though the actual
> data should be a bool. Is there a way to tell easyffi to treat these
> characters as #t/#f? I'm thinking there might be a __declare() for it,
> but I didn't see anything that made immediate sense to me.
Try using the ___bool return type instead of char.
> 2. Several of the functions return ints to represent success, errors,
> and take a "return" argument by reference.
> extern int GEOSLength(const GEOSGeometry* g1, double *length);
You can use the ___out modifier on the length argument; search for it
in the easyffi doc. This will allocate temporary storage and return
2 values you access with let-values.
(let-values (((rv len) (GEOSLength g1)))
(and rv (print "length: " len)))
Alternatively, without changing the prototype you can use let-location
to allocate the storage yourself (see
http://chicken.wiki.br/Locations)
(let-location ((len double))
(and (GEOSLength g1 (location len))
(print "length: " len)))
> 3. How do you get those cool <#TYPENAME> print outs in the the
> interpreter?
Use define-record-printer for output, and (probably easiest) SRFI-10's
define-reader-ctor for input. If you use the latter, you should
output in corresponding format, i.e. #,(...) so it can be read back
in.
The best way to learn about this stuff is to grep through the egg
repository code.
Also study that code in general.