[Gdal-dev] Re: A list of things in the wrappers and geom type in ogr
Charlie Savage
cfis at interserv.com
Mon Oct 10 15:22:13 EDT 2005
That's very interesting. Hadn't noticed that before.
I think the new code in cpl_exceptions.i will take care of these
situations, so the throw would be redundant. I think all we have to do
is this:
void SetFeature(OGRFeatureShadow *feature) {
OGR_L_SetFeature(self, feature);
}
Then in the wrapper function we check for the error and take the
appropriate action.
Kevin, what do you think?
> For example SetProjection in Dataset.i, it takes (char *prj) parameter.
> If I give it uninitialized (undef) $prj in Perl, I get a segfault. There
> are two possibilities: 1) I write
>
> %typemap(perl5,in) (char const *prj)
> {
> /* %typemap(freearg) (char const *prj) */
> if ( !$1 ) {
> croak("null argument is not allowed");
> SWIG_fail;
> }
> }
>
> or we write in Dataset.i
>
> CPLErr SetProjection( char const *prj ) {
> if (!prj) return SOME_ERROR_CODE;
> return GDALSetProjection( self, prj );
> }
I'll check in Ruby. If this occurs in all languages, I'd vote choice #2
(update Dataset.i).
> Ah, one more thing to this list: in osr.i there is
>
> ~OSRSpatialReferenceShadow() {
> if (OSRDereference( self ) == 0 ) {
> OSRDestroySpatialReference( self );
> }
> }
>
> It seems to me that OSRDereference is currently stopping the
> OSRSpatialReferenceShadow being properly disposed of (I saw this in
> debugging, there are also some (Kevin's?) comments near this in osr.i).
> At least datasource.createlayer makes a copy of the osr, I'm not sure of
> other methods.
Not sure, I'm not as familiar with OSR. However, I've started to test
the OSR wrappers in Ruby, so I'll add it to the todo list to check.
Charlie
More information about the Gdal-dev
mailing list