PP.pod (PDL-2.081) | : | PP.pod (PDL-2.082) | ||
---|---|---|---|---|
skipping to change at line 105 | skipping to change at line 105 | |||
called with, rather than a single string, split like the C pre-processor | called with, rather than a single string, split like the C pre-processor | |||
on commas except if in C<""> or C<()>, with leading and trailing | on commas except if in C<""> or C<()>, with leading and trailing | |||
whitespace removed. | whitespace removed. | |||
=for example | =for example | |||
pp_add_macros(SUCC => sub { "($_[0] + 1)" }); | pp_add_macros(SUCC => sub { "($_[0] + 1)" }); | |||
# ... | # ... | |||
Code => '$a() = $SUCC($b());', | Code => '$a() = $SUCC($b());', | |||
=head2 pp_add_typemaps | ||||
=for ref | ||||
Available from 2.082. Add an XS typemap for use as C<OtherPars>. Takes | ||||
one named argument, either C<typemap> (an L<ExtUtils::Typemaps> object), | ||||
C<string>, or C<file>. | ||||
=for example | ||||
pp_add_typemaps(string=><<'EOT'); | ||||
TYPEMAP: <<END_OF_TYPEMAP | ||||
TYPEMAP | ||||
NV_ADD1 T_NV_ADD1 | ||||
INPUT | ||||
T_NV_ADD1 | ||||
$var = SvNV($arg) + 1; | ||||
OUTPUT | ||||
T_NV_ADD1 | ||||
sv_setnv($arg, $var - 1); | ||||
END_OF_TYPEMAP | ||||
EOT | ||||
# ... | ||||
OtherPars => '[o] NV_ADD1 v1', | ||||
=head2 pp_beginwrap | =head2 pp_beginwrap | |||
=for ref | =for ref | |||
Add BEGIN-block wrapping to code for the generated .pm file | Add BEGIN-block wrapping to code for the generated .pm file | |||
=head2 pp_bless | =head2 pp_bless | |||
=for ref | =for ref | |||
skipping to change at line 1280 | skipping to change at line 1307 | |||
pp_def('setdim', | pp_def('setdim', | |||
Pars => '[o] a(n)', | Pars => '[o] a(n)', | |||
OtherPars => 'int ns => n', | OtherPars => 'int ns => n', | |||
Code => 'loop(n) %{ $a() = n; %}', | Code => 'loop(n) %{ $a() = n; %}', | |||
); | ); | |||
This says that the named dimension C<n> will be initialised from the | This says that the named dimension C<n> will be initialised from the | |||
value of the I<other parameter> C<ns> which is of integer type (I guess | value of the I<other parameter> C<ns> which is of integer type (I guess | |||
you have realised that we use the C<CType From =E<gt> named_dim> syntax). | you have realised that we use the C<CType From =E<gt> named_dim> syntax). | |||
As of 2.082, this can be used to set the size of a dimension not used | ||||
in any C<Pars>. | ||||
Now you can call this function in the usual way: | Now you can call this function in the usual way: | |||
setdim(($x=null),5); | setdim(($x=null),5); | |||
print $x; | print $x; | |||
[ 0 1 2 3 4 ] | [ 0 1 2 3 4 ] | |||
Admittedly this function is not very useful but it demonstrates how it | Admittedly this function is not very useful but it demonstrates how it | |||
works. If you call the function with an existing pdl and you don't need | works. If you call the function with an existing pdl and you don't need | |||
to explicitly specify the size of C<n> since PDL::PP can figure it out | to explicitly specify the size of C<n> since PDL::PP can figure it out | |||
from the dimensions of the non-null pdl. In that case you just give the | from the dimensions of the non-null pdl. In that case you just give the | |||
End of changes. 2 change blocks. | ||||
0 lines changed or deleted | 29 lines changed or added |