develooper Front page | perl.perl5.porters | Postings from March 2001

Re: XS has broken my brain

Ilya Zakharevich
March 10, 2001 12:07
Re: XS has broken my brain
Message ID:
On Sat, Mar 10, 2001 at 11:41:02AM -0600, David wrote:
> > > module_struct *		MODULE_SUBPACKAGE_OBJ
> > > 
> > > INPUT
> > >     $var = ($type) SvIV((SV *)SvRV($arg));
> > > 
> > > OUTPUT
> > > 	sv_setref_pv($arg, "Module::SubPackage", (void *) $var);
> > 
> > So basically it is a sped-up T_PTROBJ, without type checks on input, right?
> Right... found the problem.  Apparently, something "special" happens when
> you define a type whose name ends in OBJ or REF in xsupbb, that actually
> looks for the method name DESTROY and does... something... with it.  So I
> renamed my type and it worked great.  Problem is, OBJ seems like an
> intuitive choice for a type name to me...

You probably mean these lines

    $tk = $type_kind{$type};
    $tk =~ s/OBJ$/REF/ if $func_name =~ /DESTROY$/;
    $type =~ tr/:/_/;

This is a horrible hack.  The only "standard" entry ending on OBJ is
T_PTROBJ.  The only difference between T_PTROBJ and T_PTRREF is that
T_PTRREF does not check for "derived-from".  The above change makes no

There are additional types defined but not used in the standard
typemap: T_REFOBJ and T_REFREF.  Here the difference is that T_REFOBJ
checks for *exact* type, not for *derived-from*.  But there is no way
to create T_REFOBJ by a typemap...

So this substitution looks like a complete NOP.

> I'm not on p5p (at least, not until I get my procmail filters set up again
> :) so if you could forward this, I'm sure *someone* would appreciate
> it. :-)

You do not need to be on p5p to send messages there.  I'm not on p5p
for around 5 years...  But I Cc them this message...

Ilya Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About