[Gdal-dev] Re: A list of things in the wrappers and geom type in ogr

Charlie Savage cfis at interserv.com
Mon Oct 10 14:03:46 EDT 2005


Hi Ari,


> I tried the unsupported error and it lead me to noticing that the 
> wrappers use throw but do not catch. Don't we need something like
> 
> try{
>    result = (OGRErr)OGRFeatureShadow_SetGeometry(arg1,arg2);
> }
> catch (int e) {
>    SWIG_exception( SWIG_RuntimeError, OGRErrMessages(e) );
> }

The OGR c api returns error codes instead of throwing exceptions.   So 
there isn't a need for catch.  Thus the generated code should look 
something like this:

    CPLErrorReset();
    result = (OGRErr)OGRFeatureShadow_SetGeometry(arg1,arg2);

    CPLErr eclass = CPLGetLastErrorType();
    if ( eclass == CE_Failure || eclass == CE_Fatal ) {
       SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
    }


> Still one more thing, null pointers and wrapper functions. Is the plan 
> to test for inappropriate null pointers in the wrapper functions, or do 
> we write the checks into typemaps? Now the situation is still that it is 
> far too easy to create a segfault with undefined script variables thrown 
> at methods.

What do you mean by a null pointer?  Do you mean passing a null object 
in the target language to OGR?  Do you have an example you could share?

Thanks,

Charlie




More information about the Gdal-dev mailing list