[Gdal-dev] Bool vs int in bindings?

Tamas Szekeres szekerest at gmail.com
Tue Apr 3 11:16:17 EDT 2007


2007/4/3, Simon Perkins <sy at perkins.net>:
> Hi,
>
> A lot of the SWIG generated binding functions use ints as arguments and
> return types when a boolean type would be more appropriate, e.g. the OGR
> Open() method takes an int as the second argument to indicate whether
> the file should be opened with update access, and the
> SpatialReference.IsGeographic() method returns an int. It would be nice
> to use a more natural bool in these cases for languages that support it.
>
> Would I be right in thinking that there's pretty much no way of changing
> this now without breaking a lot of code? What about just changing it for
> some of the newer bindings, e.g. C#, that have recently had breaking API
> changes applied anyway. I like the new enums, etc for the C# bindings in
> place of int constants, can we fix the bool vs int problem there as
> well? I'd be happy to do this if people want to fix it, and Tamas
> doesn't have time.
>

Simon,

I would object to fix this issue only for the C# interface. The only
solution I can accept is to define a specific type for the booleans
(like GDAL_BOOL etc.) in the GDAL core and the various bindings can
create proper typemaps to map this type to the corresponting language
specific type. Without adding these typemaps the created interface
could fall back to the current integer based implementation.

> And while we're changing this, should wkbGeometryType be WkbGeometryType?
>

The benefit of this change is not obvious for me, but would bring in
unacceptable divergence between the various bindings and we would not
want to create separate reference documentation specifically for a
particular language.

Best regards,

Tamas



More information about the Gdal-dev mailing list