[geos-devel] c api questions for SWIG
strk at refractions.net
strk at refractions.net
Mon Jul 10 17:25:52 EDT 2006
On Mon, Jul 10, 2006 at 03:13:28PM -0600, Charlie Savage wrote:
> While I'm working through the SWIG bindings, I've come up with a few
> questions/issues about the c api.
>
> 1. GEOSGeomTypeId. This is both a method name in the CAPI and the name
> of an enum. This causes problems in the SWIG bindings because I have
> code that does this:
>
> GEOSGeomTypeIdgeomId = (GEOSGeomTypeId)GEOSGeomTypeId(geom);
>
> switch (geomId)
> {
> case GEOS_POINT:
> case GEOS_LINESTRING:
> etc.
> }
>
> VC++ won't compile this code (haven't checked gcc). However, it seems
> like a bad idea to have the same identifier used for two different
> things. Can we change the name of the enum to something like GeomTypeID?
I already renamed the enum to GEOSGeomTypes.
> 2. Message handlers have this signature:
>
> typedef void (*GEOSMessageHandler)(const char *fmt, ...);
>
> Are the ... parameters ever used (I didn't see any place where they
> were). If they are used, what are they? If not, should they be removed?
'...' is for variable args.
It's the same signature of printf from stdio.h.
I would not change this as it would break existing code.
BTW, you made me notice we're not using it correctly: an unlikely
exception containing any format string might crash the app...
> 3. Init/Finish. In SWIG I can automatically call initGEOS and install
> the message handlers. But I don't know of a way to call finishGEOS
> automatically. What happens if the SWIG bindings don't call it?
In HEAD finishGEOS() is a no-op. In 2.2 deletes a GeometryFactory.
At worst you'll leak.
--strk;
More information about the geos-devel
mailing list