[gdal-dev] Suggested new typemap for the bindings

Ari Jolma ari.jolma at gmail.com
Thu May 21 09:13:18 PDT 2015


21.05.2015, 19:07, Even Rouault kirjoitti:
> Ari,
>
> I regenerated the Python bindings and I'm now spammed with messages like the
> following that cause the tests to fail:
>
> $ python vsifile.py
>    TEST: vsifile_1 ... swig/python detected a memory leak of type 'VSI_RETVAL
> *', no destructor found.
> swig/python detected a memory leak of type 'VSI_RETVAL *', no destructor
> found.
> swig/python detected a memory leak of type 'VSI_RETVAL *', no destructor
> found.
> fail
>      line 96: failure
> [...]
>
> It looks like
>
>   %{
>   /* use this to not return the int returned by GDAL */
>   typedef int RETURN_NONE;
> +/* return value that is used for VSI methods that return -1 on error (and set
> errno) */
> +typedef int VSI_RETVAL;
>   
>   %}
>
> is not sufficient and we would need to instanciate typemaps for this in the
> Python bindings ? I hate SWIG... I'm afraid other languages might have similar
> issue

I tried to avoid a lot of ifdef PERLs...

There should be a way to tell swig that VSI_RETVAL should use int 
typemaps unless they are defined specially. Hm.

Ari


>
> Even
>
>> I defined a new type VSI_RETVAL to be used instead of int with VSI
>> functions that return -1 in error and set errno.
>>
>> For the Perl bindings I defined two typemaps for this type. One which
>> strips the return value and one which throws an error if the return
>> value is -1. The error is strerror(errno).
>>
>> I think this improves the usability of those VSI functions from the
>> binded languages.
>>
>> Ari
>>
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev



More information about the gdal-dev mailing list