Skip to content

Commit

Permalink
make HdrCode and FtrCode run when PMCode supplied - #463
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Feb 24, 2024
1 parent db71519 commit c42b8f7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Basic/Gen/PP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2013,7 +2013,7 @@ EOF
sub {(undef,(make_xs_code(' CODE:','',@_))[1..2])}),
# if PMCode supplied, no var-args stuff
PDL::PP::Rule->new(["NewXSCode","BootSetNewXS","NewXSInPrelude"],
[qw(PMCode NewXSHdr NewXSCHdrs? FixArgsXSOtherOutDeclSV RunFuncCall XSOtherOutSet)],
[qw(PMCode NewXSHdr NewXSCHdrs? FixArgsXSOtherOutDeclSV HdrCode RunFuncCall FtrCode XSOtherOutSet)],
"Non-varargs XS code when PMCode given",
sub {make_xs_code(' CODE:','',@_[1..$#_])}),
PDL::PP::Rule->new(["NewXSCode","BootSetNewXS","NewXSInPrelude"],
Expand Down
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- fix dataflow when vaffine ndarray is between modified and downstream (#461) - thanks @vadim-160102 for continued reporting
- revert the use of ArgOrder for PDL::Ops so op($a,$b,$c,$swap) works again as pre 2.082_01
- error on inflating output ndarrays over dims sized 1 or implicit as undefined
- make HdrCode and FtrCode run when PMCode supplied (#463) - thanks @jo-37 for suggestion

2.085_01 2024-02-10
- test, document PDL::string, make more consistent (#459) - thanks @vadim-160102 for report
Expand Down
21 changes: 21 additions & 0 deletions t/01-pptest.t
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,21 @@ pp_def('ftr',
FtrCode => " sv_setiv(perl_get_sv(\"main::FOOTERVAL\",TRUE), 1);\n",
);
pp_def('ftrPM',
Pars => 'a(); [o]b()',
Code => ';',
HdrCode => " sv_setiv(perl_get_sv(\"main::HEADERVAL\",TRUE), 1);\n",
FtrCode => " sv_setiv(perl_get_sv(\"main::FOOTERVAL\",TRUE), 1);\n",
PMCode => <<'EOPM',
sub PDL::ftrPM {
my ($a, $b) = @_;
$b //= PDL->null;
PDL::_ftrPM_int($a, $b);
$b;
}
EOPM
);
pp_done;
# this tests the bug with a trailing comment and *no* newline
Expand Down Expand Up @@ -533,6 +548,12 @@ undef $main::FOOTERVAL;
ftr(1);
is $main::FOOTERVAL, 1;
undef $main::HEADERVAL;
undef $main::FOOTERVAL;
ftrPM(1);
is $main::HEADERVAL, 1;
is $main::FOOTERVAL, 1;
done_testing;
EOF

Expand Down

0 comments on commit c42b8f7

Please sign in to comment.