develooper Front page | perl.perl5.porters | Postings from July 2016

Re: substr as parameter to a XS sub

Thread Previous | Thread Next
From:
Father Chrysostomos
Date:
July 4, 2016 15:25
Subject:
Re: substr as parameter to a XS sub
Message ID:
20160704152505.30750.qmail@lists-nntp.develooper.com
Tony Cook wrote:
> Something like:
> 
> T_PV
>         $var = (SvGETMAGIC($arg), SvOK ($arg)) ? ($type) SvPV_nomg_nolen($arg) : NULL
> 
> should work.
> 
> Use SvPV_nomg($arg, &PL_na) if you need to support perls older than 5.14.

Without the ampersand.  Also, SvGETMAGIC is not an expression, but a statement, in 5.14 and earlier.  If you want to support perl older than 5.16, you need to make it a separate statement:

T_PV
        SvGETMAGIC($arg);
        $var = SvOK ($arg) ? ($type) SvPV_nomg($arg, PL_na) : NULL;

(A typemap can be multiple statements, right?)


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About