[gdal-dev] GIntBig in the bindings

Ari Jolma ari.jolma at gmail.com
Sat May 23 00:00:40 PDT 2015


22.05.2015, 12:44, Even Rouault kirjoitti:
>> 22.05.2015, 11:38, Ari Jolma kirjoitti:
>> I must also say that we're loosing (have lost?) the benefit of having 
>> a single set of "language independent" interface files because of all 
>> the #ifdefs in them. It might be easier to have only separate sets 
>> and then manually copy paste and edit when new things are added. 
> I don't know. We have the possibility to clear incrementally the .i file as
> soon as we identify that some features can be supported by all languages.

Here's an example from cpl.i. The bindings for BinaryToHex.

There are four cases separated by #ifdefs. In three of them the function 
declaration is the same, in one the return value is char* instead of 
retStringAndCPLFree*, which is a type defined for the bindings and a 
typemap is required for it (if there is no typemap, the code works but 
looses memory).

In the three others the difference is what typemap is applied. In one 
there is no apply and in the two others the typemap is almost the same 
except one uses unsigned char * and the other uses char *. I guess this 
is just because of convenience.

Overall in the interface files the apply's are causing many of the #ifdef's.

My suggestion is that we use recognized patterns in the function 
declarations and require that the language specific typemaps define 
typemaps for those that it needs.

In this case the pattern would be "int nBytes, const GByte *pabyData", 
which is used twice in the bindings as such and could be used in a 
couple more. For example in CreateGeometryFromWkb where OGR does not use 
it but I don't see why it couldn't be used.

I'll work on this approach in my github fork.

Best,

Ari



More information about the gdal-dev mailing list