[Gdal-dev] Re: DISOWN in ogr.i
Charlie Savage
cfis at interserv.com
Tue Apr 11 04:39:22 EDT 2006
Well from the SWIG changes file:
10/25/2005: mmatus
- Perl, complete the DISOWN typemap.
If you look in perlrun.swg (SWIG 1.3.29):
SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr,
swig_type_info *_t, int flags) {
...
/*
* DISOWN implementation: we need a perl guru to check this one.
*/
if (tsv && (flags & SWIG_POINTER_DISOWN)) {
/*
* almost copy paste code from below SWIG_POINTER_OWN setting
*/
SV *obj = sv;
HV *stash = SvSTASH(SvRV(obj));
GV *gv = *(GV**) hv_fetch(stash, "OWNER", 5, TRUE);
if (isGV(gv)) {
HV *hv = GvHVn(gv);
/*
* To set ownership (see below), a newSViv(1) entry is added.
* Hence, to remove ownership, we delete the entry.
*/
if (hv_exists_ent(hv, obj, 0)) {
hv_delete_ent(hv, obj, 0, 0);
}
}
}
return SWIG_OK;
}
I don't know any Perl - but this looks at least somewhat like the
equivalent Ruby code. There is also %delobject, see:
http://www.swig.org/Doc1.3/Customization.html#ownership
If this is the same DISOWN as Ruby/Python, I suppose that would be
another argument for using SWIG 1.3.29 since it would avoid special
cases for Perl.
Thanks,
Charlie
Ari Jolma wrote:
> Charlie Savage kirjoitti:
>> Hi Ari,
>>
>>> There has been three warnings on *DISOWN when generating the Perl
>>> bindings. These have come from swig/include/ogr.i. As I understand
>>> swig/Perl does not use *DISOWN, so I commented them out for Perl.
>>
>> According to the SWIG documentation Perl does support DISOWN - see
>> http://www.swig.org/Doc1.3/Perl5.html#Perl5_nn42. I think this might
>> be a newer feature.
>
> The DISOWN method, which swig generates for Perl, is for the Perl
> programmer to use, and does not automate the handing of the object from
> Perl to C. This is an unnecessary extra task for him/her so I'd like the
> bindings to do it, as it assumably does for the other languages. Now a
> (not "the") solution (with swig 1.2.25 at least) is to write %perlcode
> into the bindings to explicitly call DISOWN in these few cases
> (SetGeometryDirectly etc).
>
> Regarding the files in the CVS and swig version, I'd think that would be
> a task for the PSC to decide ;-)
>
> Just a few thoughts: Are people developing GDAL in Windows? Couldn't
> there be a nightly make dist for those who need a bleeding edge version?
> The Fedora 5 still has swig 1.3.24, installing 1.3.29 is an extra step,
> which is not needed for Perl bindings I believe.
>
> Thanks for the replies.
>
> Ari
>
More information about the Gdal-dev
mailing list