[gdal-dev] Of errors and their treatment in bindings
Ari Jolma
ari.jolma at gmail.com
Fri Sep 17 08:12:34 EDT 2010
Folks,
I added binding to VSIStatL (my idea is to start using ReadDir from GDAL
and I need to know if something is a file or a directory).
That requires, in my mind, a new typemap, which I call
RETURN_NONE_TRUE_IS_ERROR as the VSIStatL in port returns 0 on success
but it does not call CPLError.
Similarly we have from earlier IF_FALSE_RETURN_NONE, which is used now
only in once case (GCPsToGeoTransform) where GDAL non-zero return means
error condition and GDAL does not call CPLError (the docs explain
possible causes of error). And we have IF_ERROR_RETURN_NONE. IMHO these
should be called RETURN_NONE_FALSE_IS_ERROR and RETURN_NONE.
Sometimes the GDAL API uses plain int and sometimes CPLErr. We need to
tell Swig that it should drop the return value. If int is used, it must
be shadowed with typedef int something_else. I renamed the typedef from
FALSE_IS_ERR to RETURN_NONE which is hopefully a bit more descriptive.
I guess if we could trust GDAL to call CPLError always we could simply
use one RETURN_NONE typemap and not three. That would have the added
benefit of having a bit more clear error message as now only issuing an
"unspecified error" can basically be put into the typemaps.
Ari
More information about the gdal-dev
mailing list