diff --git a/Basic/Gen/PP.pm b/Basic/Gen/PP.pm index 7eefeca9f..5ea279922 100644 --- a/Basic/Gen/PP.pm +++ b/Basic/Gen/PP.pm @@ -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"], diff --git a/Changes b/Changes index c93b3c8c4..643d5895d 100644 --- a/Changes +++ b/Changes @@ -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 diff --git a/t/01-pptest.t b/t/01-pptest.t index 14d027d15..f9d0b6988 100644 --- a/t/01-pptest.t +++ b/t/01-pptest.t @@ -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 @@ -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