chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] Some pointers on easyffi and interfacing with C code


From: Mark Fredrickson
Subject: [Chicken-users] Some pointers on easyffi and interfacing with C code
Date: Thu, 10 Jan 2008 22:17:47 -0600

Hello Chicken expertgenzia,

In attempt to broaden my knowledge of Chicken, I'm attempting to create an egg for the GEOS C library[1]. My first cut has been to use easyffi, and I'm pleased with the results. With minimal hacking at the GEOS API header[2] I've been able to see some results. Now I'm looking to refine.

Here are my questions:

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.

2. Several of the functions return ints to represent success, errors, and take a "return" argument by reference. Is there a best practice for dealing with these kinds of functions? Here's an example if I'm not being clear (the goal is to compute the length of a "geometry" e.g. a line):

extern int GEOSLength(const GEOSGeometry* g1, double *length);

3. How do you get those cool <#TYPENAME> print outs in the the interpreter? E.g.
#;1> (make-hash-table)
#<hash-table>

Since geometries have literal represenstions in the form of Well-Known- Text (e.g. "POINT(100 100)") is there a way to get a call back and print out a literal value? Similarly, can I write a reader macro to turn a literal in source into a geometry? Something like:

(let (p #WKT(POINT 100 100)) .....

This last point is just for my edification right now. I've got plenty to do with the rest of the API first.

Finally, if anyone is feeling like going above and beyond, I could use suggestions how to handle callbacks for the initGEOS() function in that C header. It's a little too complex for easyffi. While I can certainly write a pair of handlers in C, it'd be nice to be able to pass in user lambdas to execute on error and warning conditions.

Thanks in advance,
-Mark

[1] http://geos.refractions.net/
[2] http://geos.refractions.net/ro/doxygen_docs/html/geos__c_8h-source.html





reply via email to

[Prev in Thread] Current Thread [Next in Thread]