Branch: refs/heads/davem/xs_refactor6 Home: https://github.com/Perl/perl5 Commit: 9a13ff8192343ee39ff106c4978ac47c8c4aaa56 https://github.com/Perl/perl5/commit/9a13ff8192343ee39ff106c4978ac47c8c4aaa56 Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024)
Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Constants.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/CountLines.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Eval.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/Cmd.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/InputMap.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/OutputMap.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/Type.pm M dist/ExtUtils-ParseXS/lib/perlxs.pod Log Message: ----------- ParseXS: bump version 3.55 => 3.56 Commit: d4997b059bc22463dbadfe8a42ca2fe1ef5f69b2 https://github.com/Perl/perl5/commit/d4997b059bc22463dbadfe8a42ca2fe1ef5f69b2 Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: fix code comment typo Commit: dc0d8fb6b09cb8b006fc07e3adefb5d9e842a218 https://github.com/Perl/perl5/commit/dc0d8fb6b09cb8b006fc07e3adefb5d9e842a218 Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: fix generate_output(): s/next/return/ A recent piece of refactoring by me, v5.41.4-92-g9c24c4ed29, moved some error-checking code from OUTPUT_handler() to generate_output(). The former is in a loop, the latter isn't. So in if (bad) { blurt(..); next } the 'next' needs changing to 'return'. It turns out no tests yet exercise this error condition, so it it wasn't spotted at the time. Commit: 8e55c50bd94dcb81a2d3d11da6cbf4d55946b79e https://github.com/Perl/perl5/commit/8e55c50bd94dcb81a2d3d11da6cbf4d55946b79e Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: use a var rather than $1 During earlier refactoring, the captures of a particular match were assigned to variables; but a few lines further down, the code was still using '$1' rather than the variable which $1 had been assigned to. This commit makes it use the var instead. No functional changes. Commit: 2f114a88673d49fb91d3c8cc48410755e02bf9aa https://github.com/Perl/perl5/commit/2f114a88673d49fb91d3c8cc48410755e02bf9aa Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: add tests for RETVAL TARG optimisation There is an optimisation whereby the OP_ENTERSUB's TARG is sometimes used to return the result, rather than creating a new mortal. This optimisation has been present for many years, but was untested. This commit adds tests, including ones for custom typemap entries of the sort that can still be optimised. It also tests for the optimisation in conjunction with OUTLIST args. It also adds tests for when the output code is specified explicitly on the OUTPUT line rather than being retrieved from a typemap. Currently this isn't actually optimised. Commit: c0541adfaa9627f6dbfa435d0b159526da5b93a8 https://github.com/Perl/perl5/commit/c0541adfaa9627f6dbfa435d0b159526da5b93a8 Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: move RETVAL TARG optimise code The perl code which does the emitting of the C code for the RETVAL value return using TARG if possible, is in a different place than the general RETVAL code emitting. This commit moves them into the same function. For now this is a crude cut and paste: any simplifying of the resultant function will be done later. For now, it's good just that more C code generation functionality is concentrated in one place rather than being diffused around all parts of ParseXS.pm. In more detail: before this commit, the code looked like: sub process_file { ... if (RETVAL needs returning) { if (have template code from OUTPUT line) { # just directly emit the template code } elsif (can do TARG optimisation) { # directly emit code to do PUSHi() etc } else { $self->generate_output({ var => 'RETVAL', ...}); } } ... } sub generate_output { ... if ($var eq 'RETVAL') { # emit generic C code to return RETVAL to the caller } ... } After this commit, it looks like: sub process_file { ... if (RETVAL needs returning) { $self->generate_output({ var => 'RETVAL', ...}); } ... } sub generate_output { ... if ($var eq 'RETVAL') { if (have template code from OUTPUT line) { # just directly emit the template code return; if (can do TARG optimisation) { # directly emit code to do PUSHi() etc } else { # emit generic C code to return RETVAL to the caller } } ... } Commit: 0e9d0908cff755bc5c7dd1a3a463fe72a9104741 https://github.com/Perl/perl5/commit/0e9d0908cff755bc5c7dd1a3a463fe72a9104741 Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: add more tests for OUTPUT keyword In particular, test that the 'SETMAGIC: EN/DISABLE' modifiers work, and that duplicate vars are reported. Commit: 742941d53162eeebd51e899c3e285d0874198871 https://github.com/Perl/perl5/commit/742941d53162eeebd51e899c3e285d0874198871 Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: simplify dup OUTPUT RETVAL If RETVAL appears twice in the OUTPUT section, it will be reported as an error (using blurt()), but parsing will continue. During parsing of the second RETVAL, it is treated as an ordinary parameter rather than special-cased as RETVAL. This doesn't seem useful, although ultimately it doesn't matter, as the parse will be reported as failing at the end anyway, so it doesn't matter what code gets generated in the meantime. This commit makes RETVAL still be treated as RETVAL on second appearance in OUTPUT, which get makes the code slightly simpler. Also, change the dup-detecting lines above it from a postfix 'if' to a block 'if', so that the flow-control 'next' appears prominently on its own line. Commit: e0dc4e93d83c3171c1da67c2a19fd1fdd094928d https://github.com/Perl/perl5/commit/e0dc4e93d83c3171c1da67c2a19fd1fdd094928d Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: add tests: 'RETVAL not in OUTPUT' warning If the parser sees RETVAL in a CODE section, but there isn't an OUTPUT section for the RETVAL, then it emits a warning. Test for this warning. Note that it currently warns only if the OUTPUT section is not present; it doesn't warn if the OUTPUT is present but doesn't contain RETVAL. The next commit will fix this. Commit: 894c447f99f3eefa55efcf3e562f4f39182ec96b https://github.com/Perl/perl5/commit/894c447f99f3eefa55efcf3e562f4f39182ec96b Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: make RETVAL in CODE not OUTPUT warn more ParseXS currently emits a warning if RETVAL is seen in a CODE section but there is no OUTPUT section. This commit extends this so it warns even if there *is* an OUTPUT section but that section doesn't contain RETVAL. To stop one of our existing tests giving a false positive warning, this commit now makes it ignore 'PERL_UNUSED_VAR(RETVAL)' in a CODE section in terms of 'have seen RETVAL in CODE', since this isn't a real use of the variable. Note that the original intent of adding this warning was that, without an OUTPUT RETVAL the emitted code would still do XSRETURN(1), but nothing would be stored at ST(0), so whatever was returned on the stack at that slot would be whatever was already at that position on the stack, which might be one of the passed args, or random garbage. This is true regardless of whether OUTPUT is completely absent, or just RETVAL missing from OUTPUT. So it's better to warn in both cases, not just the former. Doing this also means that the 'xsub_seen_OUTPUT' field member is no longer needed, simplifying the code. Commit: 6ff7391379878297d55da3400200fb0cc2641c9d https://github.com/Perl/perl5/commit/6ff7391379878297d55da3400200fb0cc2641c9d Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: fix, test 'OUTPUT foo not a param' err If a var is listed in an OUTPUT section, but is not actually a parameter, then the parser outputs an error message: Error: OUTPUT foo not a parameter This commit: - Fixes a typo in the error message: it was previously "not an parameter". - Extends the warning to include RETVAL where the XSUB is void. Previously, it would plough on, and then give an error that it couldn't find 'void' in the typemap, which is less obvious what the problem is. - Adds tests - this warning previously had no tests for it. Commit: f64c07d524ae6418f28ab53bf0de788b3af16b8a https://github.com/Perl/perl5/commit/f64c07d524ae6418f28ab53bf0de788b3af16b8a Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: make OUTPUT update param fields Currently, an E::PXS::Node::Param object each created for each parameter declared in the XSUB's signature. This object is then updated with any extra data that appears in an INPUT line. This commit extends that so that the Param object is also updated with any extra data from an OUTPUT line. This allows us to remove the $self->{xsub_map_varname_to_seen_in_OUTPUT} field. The next few commits will build upon this to simplify various bits of code, now that the Param object contains OUTPUT state too. Commit: f952e37370eca27953292efe441db0a5ddf0a102 https://github.com/Perl/perl5/commit/f952e37370eca27953292efe441db0a5ddf0a102 Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: refactor: make generate_output take Param The generate_output() method currently takes a hash of args. The fields of this hash are typically generated on the fly by each caller from the fields of an ExtUtils::ParseXS::Node::Param object. This commit makes it so that instead, that Param object is just passed directly to generate_output(). It simplifies the code, and is a step along the path to the eventual goal of making generate_output() be a method of ExtUtils::ParseXS::Node::Param rather than of ExtUtils::ParseXS. This commit causes one slight change in behaviour: set magic; and this is arguably a bug fix. There are two ways of specifying args that get updated on return (the XS equivalent of 'sub foo { $_[0]++ }'): either by declaring the parameter as 'OUT' in the signature: int foo(OUT int a) or by listing it on an OUTPUT line. For the latter, the arg has set magic called on it after the update by default, but this can be overridden with the SETMAGIC keyword: OUTPUT: arg1 // has a SETMAGIC() call SETMAGIC: DISABLE arg2 // doesn't have a SETMAGIC() call SETMAGIC: ENABLE arg3 // has a SETMAGIC() call On the other hand, OUT params have set magic by default *unless* there's an OUTPUT section with at least one SETMAGIC line, in which case the last such SETMAGIC line dictates whether the OUT arg gets set magic. This seems wrong, and this commit changes it so that OUT params *always* get set magic. If this turns out to be wrong, the line to look at is print "\tSvSETMAGIC($arg);\n" if !$param->{in_output} || $do_setmagic; which says to do magic always for OUT params, and to honour the SETMAGIC in force at the line for OUTPUT params. Commit: 45f7c3de30a71f75d0985a948f0dd19fa5dde445 https://github.com/Perl/perl5/commit/45f7c3de30a71f75d0985a948f0dd19fa5dde445 Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: fix recent OUTLIST breakage The last couple of commits broke the unusual (and possibly not very sane) combination of a parameter declared both as IN_OUTLIST and listed in an OUTPUT section. This means that generate_output() is called twice for the same parameter, once to update the value of the arg's SV on the stack, and once to push its value onto the stack. So, distinguish between those two effects by whether the caller of generate_output() passed an extra arg (for OUTLIST) or not, rather than by whether the Param object has an in_out field of /OUTLIST$/. This was manifesting itself as an extra PUSHs and SvSETMAGIC appearing compared with 5.40.0. Fix and add tests. Commit: dfa3e37cdbee2d3907362596c345ac8c7cb349d9 https://github.com/Perl/perl5/commit/dfa3e37cdbee2d3907362596c345ac8c7cb349d9 Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: simplify RETVAL/TARG code A recent commit moved, from outside to inside generate_output(), the perl code which is responsible for generating the C code which handles the "use TARG if possible when returning RETVAL" optimisation. This commit now follows that up by simplifying and tidying that code. Now that it's within generate_output(), the setting of $type, looking up of the typemap etc, have all already been done at the start of the sub, so there's no need to duplicate that effort. Also, set {output_code} as a field value in the faked-up RETVAL param object, so that inside generate_output() it can just check for a generic $param->{output_code} field rather than the special-cased $self->{xsub_RETVAL_typemap_code} value. Commit: 5c8f70542359469e61041a3577bbd4ad1817a185 https://github.com/Perl/perl5/commit/5c8f70542359469e61041a3577bbd4ad1817a185 Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: move OUTPUT code handling. OUTPUT sections can include explicit setting code to override the normal typemap. For example: OUTPUT: arg1 # use standard typemap entry arg2 my_setiv(ST(1), (IV)arg2); # override Formerly, the custom code was emitted directly during parsing by OUTPUT_handler(). This commit moves that emitting code into generate_output(), so that the emitting with/without override are done in the same place. This is a small part of an effort to concentrate all the code-emitting parts into a small number of well-defined places. Commit: 9a19c04542b8d833c6d8204b61d6f6df87ae81db https://github.com/Perl/perl5/commit/9a19c04542b8d833c6d8204b61d6f6df87ae81db Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: s/NO_RETURN/NO_OUTPUT/ In earlier refactoring, I renamed an E::PXS object field to xsub_seen_NO_RETURN, when it should actually have been to xsub_seen_NO_OUTPUT. This commit renames the field again. Should be no functional changes. Commit: f3e24d547f73ac1312244b59d70a65a5ee23091c https://github.com/Perl/perl5/commit/f3e24d547f73ac1312244b59d70a65a5ee23091c Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: add test: OUTPUT RETVAL with code Add a test for the specific: OUTPUT: RETVAL template_override_code Commit: 4d58f44c949d113abb74b64ab89f0d677db7b6a3 https://github.com/Perl/perl5/commit/4d58f44c949d113abb74b64ab89f0d677db7b6a3 Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: add tests for RETVAL as a parameter Normally RETVAL is an implicitly declared local var, but it is legal to also declare it as an explicit parameter. Add tests for the various permutations of this: - void and long XSUB return values; - no param type; int type in signature; int type in INPUT; - with and without an autocall. This isn't well documented as to how it should be interpreted, so these tests are more about checking current behaviour so that inadvertent changes are detected, rather than approving the current behaviour. Some of the current behaviour is less than satisfactory (generally marked with 'XXX' in the test code comments). In particular, a commit shortly is going to change how RETVAL is implemented internally. It also adds a few tests for NO_OUTPUT. Commit: 7acbaa629361fe5bb0b204b03b211061c761684e https://github.com/Perl/perl5/commit/7acbaa629361fe5bb0b204b03b211061c761684e Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: refactor: add RETVAL Node::Param object Currently, RETVAL is handled almost entirely using special-case code all over the place. For non-void XSUBs, this commit adds a Node::Param object with a name of RETVAL to the start of the list of Param objects in the Sig object - but flagged as synthetic and no_init (so it gets declared but not initialised, and doesn't consume an argument from the stack). This makes the emitting of the some_type RETVAL; declaration be part of general parameter processing, rather than being special-cased. Soon, this new object will also be used to make emitting of the code to return RETVAL be more regular; but for now just the initial declaration is handled in the new fashion. Note however, that things get complicated when RETVAL is also declared as a parameter, e.g. int foo(RETVAL) long RETVAL .... or int foo(long RETVAL) .... or even as a parameter but without a type: int foo(RETVAL) # no INPUT lines ... or even as an alien variable: int foo() long RETVAL = 99; Much of the behaviour in such cases is unspecified, and is somewhat emergent - i.e. it behaves that way due to the way the code happened to be structured, rather than due to any particular intent. This commit tries very hard to preserve the current behaviour - hence all the tests added in the previous commit. It has however changed behaviour in a couple of places where the old behaviour emitted broken C code. These changes are indicated by the updates to t/001-basic.t in this commit. To keep the backwards-compatibility behaviour, the basic approach of this commit has been to make the RETVAL object be in one of three main states: fully-synthetic What is initially pushed at the *start* of the param list. RETVAL hasn't yet appeared in a signature or INPUT. Its type is set to the XSUB's return type. semi-real Same as fully-synthetic, but with a defined argument number, and with an updated position within the parameter list. This signifies that a RETVAL has appeared in the signature, but without a type yet specified. It acts as a placeholder, causing one passed argument to be skipped, and to appear in usage() error messages etc. real The is_synthetic and no_init flags are turned off and its type comes from the signature or INPUT line. This is now just a normal parameter. Commit: d1d26fab3b52e4bd510b6eb15ad8177d92015a83 https://github.com/Perl/perl5/commit/d1d26fab3b52e4bd510b6eb15ad8177d92015a83 Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/t/002-more.t M dist/ExtUtils-ParseXS/t/XSMore.xs Log Message: ----------- ParseXS: refactor: use RETVAL param for output The previous commit added a synthetic RETVAL Node::Param object and used it for generating RETVAL declaration code rather than special-casing it. This commit extends this to use the object for output processing too, removing more special-case handling, and removing the need for some special state fields. The next few commits will remove more RETVAL special-handling code and generally simplify and clean up. Note that this commit actually introduces a bug which will be fixed in a few commits' time: the new code doesn't correctly handle multiple CASEs, each with a RETVAL output, such as: int foo(...) CASE: x ... OUTPUT: RETVAL CASE: y ... OUTPUT: RETVAL The code now sees this as a duplicate OUTPUT parameter. For now, a test in t/002-more.t and t/XSMore.xs has been disabled until this is fixed. (Actually, CASE with duplicate INPUT or OUTPUT sections has been broken for a few weeks - but this is the first commit that actually caused a test failure. All will be fixed soon...) Commit: 496574a51ac130393e98f35bf3ccd022a6355473 https://github.com/Perl/perl5/commit/496574a51ac130393e98f35bf3ccd022a6355473 Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: use XSUB return type for RETVAL return Following on from the previous commit, which uses the new RETVAL Node::Param object for generating output code, ensure that the return type used for returning the XSUB's value is the XSUB's type rather than RETVAL's type, where they differ. For example, with int foo(long RETVAL) RETVAL is is declared as long, but an int is returned to the caller. Add tests to confirm. Commit: ffc833cfeb83e93399917b83fb7c19db69a5d963 https://github.com/Perl/perl5/commit/ffc833cfeb83e93399917b83fb7c19db69a5d963 Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: refactor: better handle NO_OUTPUT In an XSUB like NO_OUTPUT int foo(...) An 'int RETVAL;' declaration is emitted, but no code is emitted to return the value of RETVAL to the caller. Before this commit, the way this was handled was that, after all INPUT and CODE/PPCODE/autocall code had been emitted, ParseXS.pm did the following: ($implicit_OUTPUT_RETVAL, $self->{xsub_return_type}) = (0, 'void') if $self->{xsub_seen_NO_OUTPUT}; That is to say, halfway through parsing the XSUB, it suddenly pretends that the XSUB was declared void all along, and that there wasn't an autocall (which would give an implicit OUTPUT: RETVAL declaration). While this works, it is a confusing action-at-a-distance: at any particular point in the code, you don't easily know whether if ($self->{xsub_return_type} eq 'void) { ... } is dealing with a real void or fake void. This commit removes that halfway-along state modification, and instead handles NO_OUTPUT directly where needed: For $implicit_OUTPUT_RETVAL, it now just never sets it if NO_OUTPUT is present, rather than setting it and then later resetting it. For $self->{xsub_return_type}, this now always represents the actual declared return type of the XSUB, and whenever necessary, $self->{xsub_seen_NO_OUTPUT} is checked along side $self->{xsub_return_type} in various places. In addition, the $var_num variable in OUTPUT_handler() handler has been removed, as it was a vestigial value, now only used to determine whether to call $self->blurt("Error: OUTPUT $outarg not a parameter") which can be done directly as boolean expression. Several new NO_OUTPUT tests have been added. Commit: bbb99046c5bcdf162386cb9f80584af79dab3a8a https://github.com/Perl/perl5/commit/bbb99046c5bcdf162386cb9f80584af79dab3a8a Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: reindent block 3 commits ago I added a new scope. This commit re-indents that new block. Whitespace-only (apart from deleting a stray empty comment line too). Commit: a9b73fc1e600b07bf927f0def4ea3555550d0164 https://github.com/Perl/perl5/commit/a9b73fc1e600b07bf927f0def4ea3555550d0164 Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: simplify ST() method. The $self->ST($num) method typically emits "ST(" . ($num-1) . ")" but it has special-case handling for $num being undef, or (in the case of output), being 0. The latter was a special-case for outputting RETVAL return code. Recent refactoring means that the ST() method is no longer called with $num == 0, so the method's code can be simplified (and the $is_output parameter eliminated). Should be no change in functionality. Commit: b826448d5bbbef9e210302bd88571c59184af72f https://github.com/Perl/perl5/commit/b826448d5bbbef9e210302bd88571c59184af72f Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: improve an error message For the specific case of RETVAL appearing in an OUTPUT section when NO_OUTPUT is in force, output this new more specific error message: can't use RETVAL in OUTPUT when NO_OUTPUT declared rather than the more generic (and in this case, slightly confusing) message: OUTPUT RETVAL not a parameter Commit: 88bb21ac00b04a1626b1616c321cd587ff502de1 https://github.com/Perl/perl5/commit/88bb21ac00b04a1626b1616c321cd587ff502de1 Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t M dist/ExtUtils-ParseXS/t/002-more.t M dist/ExtUtils-ParseXS/t/XSMore.xs Log Message: ----------- ParseXS: fix CASE: My recent merge commit v5.41.4-108-g9621dfa822 partially broke the CASE: functionality; although I didn't spot it at first since the ParseXS test suite only has a single CASE: test, and none of the XS code bundled with perl core makes use of it. The issue was that an XSUB with multiple CASEs has a single signature, but potentially multiple sets of INPUT and OUTPUT sections. For example: int foo(abc, def) CASE: X int abc; int def; CODE: RETVAL = abc + def; OUTPUT: RETVAL CASE: Y long abc; long def; CODE: RETVAL = abc - def; OUTPUT: RETVAL Once my merge commit made the data from INPUT and OUTPUT sections be used to update each Node::Param object (which has been derived from the signature entry) then this starts to fall apart. It only started failing the single CASE test in t/002-more.t once *this* branch made RETVAL an object (rather than it being special-cased). The fix in this commit is a bit of hack. Once all of the XSUB's signature has been parsed into a list of Node::Param objects, a copy of this list is taken and kept as the original. Then each time the body is parsed (typically once, but multiple times for bodies with CASE keywords) that original list is copied and becomes the current parameter list. The objects in that list are updated by INPUT and OUTPUT sections as usual. Then for the start of the next CASE, the next copying blows away all those updates. If and when ParseXS takes on more of an AST-like appearance (with, hypothetically, Node::INPUT, Node::OUTPUT etc objects) then this approach should be revisited. Note that this commit restores the CASE test in t/002-more.t which I temporarily disabled a few commits ago. Commit: 8eaf72eca85eb112b7ed4d90dac3655eee8b5d9f https://github.com/Perl/perl5/commit/8eaf72eca85eb112b7ed4d90dac3655eee8b5d9f Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: reindent Node::Sig::parse() My previous merge commit moved (and renamed) this function from ParseXS.pm to ParseXS/Node.pm. The former file has an indent of 2, while the latter has an indent of 4. When I moved the code across, I forgot to reindent it. So this commit does that now. Whitespace-only change, apart from rewrapping some code comment blocks. Commit: a67a29a84f6e8e0fcaffb35d0f47332653440851 https://github.com/Perl/perl5/commit/a67a29a84f6e8e0fcaffb35d0f47332653440851 Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: t/001-basic.t: fixup regex A couple of newly-added regexes had (in part) /....\b*/, which gives the warning: \b* matches null string many times in regex so this commit removes the extraneous '*' Commit: 6644e0029afa5855c52207342e037b9ba08bc93d https://github.com/Perl/perl5/commit/6644e0029afa5855c52207342e037b9ba08bc93d Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: fix under older perls One line had: 'exists $param->{type}' as part of a condition. This worked fine when $param was a normal hash ref (created under 'use fields'), but the combination of: - a recent commit which copies those hashes to $sig->{old_params} then resets some of the fields (to allow for multiple CASEs); - older perls (in particular 5.8.9) which used pseudo-hashes to implement fields, was causing the field to spring into existence, even though it wasn't defined. So change the test from 'exists' to 'defined'. Commit: a1fad1eeb8b565d675b85b5eb3832bbfb97f78be https://github.com/Perl/perl5/commit/a1fad1eeb8b565d675b85b5eb3832bbfb97f78be Author: David Mitchell <da...@iabyn.com> Date: 2024-11-18 (Mon, 18 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: use new() copying to simplify code A recent commit needed, at one point, to make a copy of a Node::Param object, and did so in a clunky way. But this can be simplified by instead using the new() method's built-in ability to take an initialisation hash ref as an arg. So this commit does that. However, it turns out that this new() method *shared* rather than copied that hash ref when running in an environment where 'use fields' isn't available - namely during the building of perl itself. So fix that too. Compare: https://github.com/Perl/perl5/compare/527a03f59d2c...a1fad1eeb8b5 To unsubscribe from these emails, change your notification settings at https://github.com/Perl/perl5/settings/notifications