[gdal-dev] Bindings and typemaps

Even Rouault even.rouault at spatialys.com
Sun Mar 8 14:49:44 PDT 2015


Le dimanche 08 mars 2015 22:20:50, Ari Jolma a écrit :
> Even,
> 
> It took me quite a while again to understand what goes on with Swig when
> we %apply a typemap etc.
> 
> I think we could simplify the things quite a lot if we simply use
> typedefs and then create typemaps for the return values.
> 
> For example CPLErr is never returned to the calling language (I think,
> but it could in any case be defined by the language typemap), thus we
> could simply define typemaps for it in language specific files instead
> of repeating
> 
> %apply (IF_ERROR_RETURN_NONE) { (CPLErr) };
> ...
> %clear (CPLErr);
> 
> in the include/*.i files.
> 
> Also sometimes GDAL has simple int instead of CPLErr, which is used as a
> success/failure return value, then we could (like we already do) write
> 
> typedef int RETURN_NONE;
> 
> (actually we have also
> 
> typedef int OGRErr;
> 
> for SWIGCSHARP, which is invented for the same reason I assume)
> 
> and then define typemaps for the new type and skip again
> 
> %apply (IF_FALSE_RETURN_NONE) { (RETURN_NONE) };
> ...
> %clear (RETURN_NONE);
> 
> which is overkill (and I believe I introduced that).
> 
> BTW, RETURN_NONE is not a good name, maybe use TRUE_OR_FALSE or
> something more descriptive.

Ari,

Your proposal looks reasonable (but I don't pretend mastering SWIG and 
anticipating all side effects) and you can experiment with that if you wish. 
Please make sure to test the 4 supported languages. If there are breakage you 
don't know how to fix, it will require coordination with me and Tamas and that 
should perhaps be done through a ticket with a patch, or a dedicated branch.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list