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

Re: substr as parameter to a XS sub

Thread Previous | Thread Next
From:
=?UTF-8?Q?Alberto_Sim=c3=b5es?=
Date:
July 4, 2016 15:47
Subject:
Re: substr as parameter to a XS sub
Message ID:
594006f8-7309-2924-fd8d-2616abafd559@alfarrabio.di.uminho.pt


On 04/07/16 16:25, Father Chrysostomos wrote:
> 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?)


/me hugs Tony Cook and Father Chrysostomos.

Thanks, solved!

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