diff options
author | Steffen Mueller <smueller@cpan.org> | 2013-05-22 21:57:59 +0200 |
---|---|---|
committer | Steffen Mueller <smueller@cpan.org> | 2013-06-25 08:00:25 +0200 |
commit | 42dec8cfd2525f918d33c27c30c864005682b786 (patch) | |
tree | a243819080c78da3c68f06080d210bff5951c1b5 /dist/ExtUtils-ParseXS/lib | |
parent | 33de40a5a571ddfe03de5490b56560c86bcdf7c4 (diff) | |
download | perl-42dec8cfd2525f918d33c27c30c864005682b786.tar.gz |
EU::ParseXS: Fix targetable size detection
Adds new / vastly improved tests for 'targetable'.
Also improves targetable documentation.
Diffstat (limited to 'dist/ExtUtils-ParseXS/lib')
-rw-r--r-- | dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/OutputMap.pm | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/OutputMap.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/OutputMap.pm index 6ae4e0e58b..918785c1ab 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/OutputMap.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/OutputMap.pm @@ -95,16 +95,23 @@ sub cleaned_code { =head2 targetable -This is an obscure optimization that used to live in C<ExtUtils::ParseXS> -directly. +This is an obscure but effective optimization that used to +live in C<ExtUtils::ParseXS> directly. Not implementing it +should never result in incorrect use of typemaps, just less +efficient code. In a nutshell, this will check whether the output code -involves calling C<set_iv>, C<set_uv>, C<set_nv>, C<set_pv> or C<set_pvn> -to set the special C<$arg> placeholder to a new value +involves calling C<sv_setiv>, C<sv_setuv>, C<sv_setnv>, C<sv_setpv> or +C<sv_setpvn> to set the special C<$arg> placeholder to a new value B<AT THE END OF THE OUTPUT CODE>. If that is the case, the code is eligible for using the C<TARG>-related macros to optimize this. Thus the name of the method: C<targetable>. +If this optimization is applicable, C<ExtUtils::ParseXS> will +emit a C<dXSTARG;> definition at the start of the generate XSUB code, +and type (see below) dependent code to set C<TARG> and push it on +the stack at the end of the generated XSUB code. + If the optimization can not be applied, this returns undef. If it can be applied, this method returns a hash reference containing the following information: @@ -113,7 +120,7 @@ the following information: with_size: Bool indicating whether this is the sv_setpvn variant what: The code that actually evaluates to the output scalar what_size: If "with_size", this has the string length (as code, - not constant) + not constant, including leading comma) =cut @@ -128,7 +135,14 @@ sub targetable { | \( (??{ $bal }) \) )* - ]xo; + ]x; + my $bal_no_comma = qr[ + (?: + (?>[^(),]+) + | + \( (??{ $bal }) \) + )+ + ]x; # matches variations on (SV*) my $sv_cast = qr[ @@ -155,9 +169,9 @@ sub targetable { \s* \( \s* $sv_cast \$arg \s* , \s* - ( (??{ $bal }) ) # Set from - ( (??{ $size }) )? # Possible sizeof set-from - \) \s* ; \s* $ + ( $bal_no_comma ) # Set from + ( $size )? # Possible sizeof set-from + \s* \) \s* ; \s* $ ]xo ); |