Branch: refs/heads/davem/xs_refactor10 Home: https://github.com/Perl/perl5 Commit: f344dc9f72051ff4bc62c6fdc473fc8eaec2a6d8 https://github.com/Perl/perl5/commit/f344dc9f72051ff4bc62c6fdc473fc8eaec2a6d8 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025)
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.57 => 3.58 Commit: 5fb2bf40aa4dbb5be1cd6158f8f4f470d6716242 https://github.com/Perl/perl5/commit/5fb2bf40aa4dbb5be1cd6158f8f4f470d6716242 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add file/line_no fields to Node Add file and line_no fields to the base class of all Node types to record where that node was defined within the XS src file. (There aren't many node types yet, so this commit doesn't really do anything useful at the moment.) Commit: 12bbcb06bb829b7cc4b9e0f9a82a6a14c328ba35 https://github.com/Perl/perl5/commit/12bbcb06bb829b7cc4b9e0f9a82a6a14c328ba35 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add multiline,code,PREINIT node Add these Node subclasses: ExtUtils::ParseXS::Node::multiline ExtUtils::ParseXS::Node::code ExtUtils::ParseXS::Node::PREINIT The first is a very generic base class for the many planned node types which will represent multi-line XS keywords, such as FOO: aaa bbb ccc The lines are just read into an array ref. ExtUtils::ParseXS::Node::code is a generic subclass of Node::multiline which represents keywords that contain sections of C code, such as PREINIT, PPCODE etc. It does extra processing such as skipping leading blank lines and wrapping the output in '#line ...'. ExtUtils::ParseXS::Node::PREINIT is a concrete subclass of Node::code which represents the PREINIT keyword. This is kind of a proof-of-concept; other such code keywords (CODE, PPCODE etc) will be added later. The net effect of this commit is to move processing of the PREINIT: keyword into the parse() and as_code() methods of the Node::PREINIT class (and/or its parents) and away from the print_section() and PREINIT_handler() methods in ExtUtils::ParseXS. This is intended as a small incremental step towards having a real AST. A PREINIT object is currently created, parsed, printed and destroyed all at the same point in time. In some future refactoring, the intention is that the object will be stored in a tree, and the parsing and code-emitting steps will be done at different times. Commit: 741b32a349f85a5fd3c2cbec7d6b3978b0b7514f https://github.com/Perl/perl5/commit/741b32a349f85a5fd3c2cbec7d6b3978b0b7514f Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add C_ARGS,IF,IF_MACRO nodes Add these Node subclasses: ExtUtils::ParseXS::Node::multiline_merged ExtUtils::ParseXS::Node::C_ARGS ExtUtils::ParseXS::Node::INTERFACE ExtUtils::ParseXS::Node::INTERFACE_MACRO multiline_merged is a subclass of multiline which merges all the lines associated with a keyword into a single string. It is then used as a base class for the three concrete classes C_ARGS etc which correspond to keywords which are multi-line but treat all lines as a single string. The effect of this commit is to move more keyword processing out of ExtUtils::ParseXS and into Node.pm, in preparation for building an AST. Commit: 15ba6017344a730d173ae3cbef4bdee153fb6e45 https://github.com/Perl/perl5/commit/15ba6017344a730d173ae3cbef4bdee153fb6e45 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: Node.pm: add class helper fn Add a helper function, build_subclass, to ExtUtils::ParseXS::Node to simplify the boilerplate required to declare the @ISA and @FIELDS of each Node subclass. Commit: f5add6e6ce1706186ffab6024ed74174dabfc745 https://github.com/Perl/perl5/commit/f5add6e6ce1706186ffab6024ed74174dabfc745 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: rename code Node to codeblock Rename the just-added ExtUtils::ParseXS::Node::code class to ExtUtils::ParseXS::Node::codeblock, as that better describes its purpose. (I would have updated the original commit, but reordering squashing commits was too complex due to intervening commits.) Commit: ac9b588a921a5ca0bf2b6dbdf70e8832e9355936 https://github.com/Perl/perl5/commit/ac9b588a921a5ca0bf2b6dbdf70e8832e9355936 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: match EN/DISABLE keyword more strictly Before this commit, three keywords which take ENABLE/DISABLE as their argument were exceedingly lax about what they would accept. This commit makes them slightly less lax: they now have to match an exact word, not a part word; i.e. the regex has changed from: /^(ENABLE|DISABLE)/i; to: /^(ENABLE|DISABLE)\b/i; Note that it still quietly ignores trailing garbage. So before both these lines were legal; now only the second is: PROTOTYPES: ENABLEaaa bsbsbs stbsbsb PROTOTYPES: EnablE bsbsbs stbsbsb This commit makes VERSIONCHECK, PROTOTYPES, EXPORT_XSUB_SYMBOLS match SCOPE, which already had the \b. This is in preparation for an upcoming commit, which will use a common method to parse such keywords. This commit also changes the test infrastructure slightly: the test_many() function no longer bails out if the eval fails; instead the eval error message is added to any STDERR text, accessible to tests which can now test that ParseXS did indeed call death(). Commit: 304a18738802a08491560c8d56a82f8c919721ec https://github.com/Perl/perl5/commit/304a18738802a08491560c8d56a82f8c919721ec Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: don't pass $_ to/from parse() The legacy KEYWORD_handler() methods expect, on entry, for $_ to hold the remainder of the current line (after s/^s*KEYWORD:\s*//), and for @{$self->{line}} to contain any remaining unparsed lines from the current XSUB. On return, they set $_ to the next unparsed line, and @{$self->{line}} to subsequent lines. Recent commits have started added Node (and its subclasses) parse() methods to replace the KEYWORD_handler() methods. Currently they use the same "rely on $_ to pass the current line to and from" scheme. This commit changes them so that they only get lines from @{$pxs->{line}}. This removes one source of weird action-at-a-distance. Commit: fb8c63a89f17ed23ce343323e9c1aec32be9b2f1 https://github.com/Perl/perl5/commit/fb8c63a89f17ed23ce343323e9c1aec32be9b2f1 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/perlxs.pod M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: fix SCOPE keyword and update docs The SCOPE: keyword, which enables wrapping an XSUB's main body with ENTER/LEAVE, has been partially broken since 5.12.0. This commit fixes that, adds tests, and updates the very vague documentation for SCOPE in perlxs.pod. AFAIKT, neither the SCOPE keyword, nor it's associated /* SCOPE */ magic comment in typemap files, are used anywhere in core or on CPAN, nor in any tests. ('SCOPE: DISABLE' appears in a single test file, but disabled is the default anyway.) Background: The SCOPE keyword was added by perl-5.003_03-21-gdb3b941461 (with documentation added soon after by perl-5.003_03-34-g84287afe68). This made the SCOPE: keyword an XSUB-body-scoped keyword, e.g. void foo() SCOPE: ENABLED CODE: blah where the emitted 'blah' code would now be wrapped with ENTER/LEAVE. 13 years later, with v5.11.0-30-g28892255e8, this was extended so that the keyword could appear just before the XSUB too: SCOPE: ENABLED void foo() CODE: blah I don't know what the motivation was behind this; the commit was part of a larger upgrade, which just listed among other bug fixes: - Fix the SCOPE keyword [Goro Fuji] but I can't find any trace of a corresponding problem description on p5p or RT. This change had the unfortunate side-effect of breaking the existing XSUB-scoped variant. This is indirectly due to the fact that XSUB-scoped KEYWORD_handler() methods are supposed to set $_ to the next line before returning, while file scoped ones aren't supposed to. That change made SCOPE_handler() both file- and xsub-scoped, and also made it no longer update $_. So the new file-scoped variant worked, while the old xsub-scope variant broke, because it now retuned with $_ set to 'ENABLE' rather than to the next line. The temporary fix in this commit makes SCOPE_handler() check who its caller is and sets $_ (or not) accordingly. A proper fix will occur shortly when a SCOPE Node subclass is added, since the NODE::parse() methods don't pass values back and forth in $_. This commit also updates the pod for SCOPE, which was very vague about what the SCOPE keyword did and where it should go, syntax-wise. I also changed it so that it suggests the magic comment token in a typemap entry should be /* SCOPE */. The actually regex is {/\*.*scope.*\*/}i, which matches a whole bunch of stuff. If we ever make it stricter, insisting on an upper-case SCOPE with just surrounding white space seems the way to go. Commit: df513979d6779f836498d6850c3edbd0998f40c8 https://github.com/Perl/perl5/commit/df513979d6779f836498d6850c3edbd0998f40c8 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add classes for ENABLE keywords Add the following classes: ExtUtils::ParseXS::Node::oneline ExtUtils::ParseXS::Node::enable ExtUtils::ParseXS::Node::EXPORT_XSUB_SYMBOLS ExtUtils::ParseXS::Node::PROTOTYPES ExtUtils::ParseXS::Node::SCOPE ExtUtils::ParseXS::Node::VERSIONCHECK The first two are base classes for XS keywords which consume only a since line of XS src, and which then expect the keyword to have a value of ENABLE/DISABLE. The rest are concrete Node subclasses representing all the purely ENABLE/DISABLE keywords. Commit: f462fa1c1882d45c7ac9a470a3f055e2f2283b88 https://github.com/Perl/perl5/commit/f462fa1c1882d45c7ac9a470a3f055e2f2283b88 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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 PROTOTYPE node Add this Node subclass: ExtUtils::ParseXS::Node::PROTOTYPE This commit moves the parsing code for the PROTOTYPE keyword from the old PROTOTYPE_handler() method in ExtUtils::ParseXS and into a new Node subclass parse() method. Also add a few more tests for PROTOTYPE - especially parsing edge cases. Commit: 137a8ea5efc405511306046523f7d810243b1ac8 https://github.com/Perl/perl5/commit/137a8ea5efc405511306046523f7d810243b1ac8 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: use __PACKAGE__ to simplify In Node.pm, replace a bunch of declarations of the form package ExtUtils::ParseXS::Node::INTERFACE_MACRO; sub parse { my ExtUtils::ParseXS::Node::INTERFACE_MACRO $self = shift; ... } with package ExtUtils::ParseXS::Node::INTERFACE_MACRO; sub parse { my __PACKAGE__ $self = shift; ... } Commit: 46f57afa104b2c0f47fed20b21855b4f70d69338 https://github.com/Perl/perl5/commit/46f57afa104b2c0f47fed20b21855b4f70d69338 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: fix test infrastructure under 5.8.x A recent commit expanded test_many() in t/001-basic.t to test for errors as well as warnings. This commit tweaks that change to work under 5.8.x: it was emitting "Use of uninitialized value in concatenation" warnings. Commit: 649ef2b78c425b466fa6123c325abfefb7c8932d https://github.com/Perl/perl5/commit/649ef2b78c425b466fa6123c325abfefb7c8932d Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: reindent Param::as_output_code When I moved this sub from ParseXS.pm to Node.pm it retained its 2-char indent. Node.pm uses a 4-char indent, so reindent it. This is whitespace-only change, apart from splitting a few long lines and re-wrapping some comment paragraphs. Commit: 8c8b7702c67643253c3019680f5380fcf16144f9 https://github.com/Perl/perl5/commit/8c8b7702c67643253c3019680f5380fcf16144f9 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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 ALIAS,ALIAS_line nodes Add these Node subclasses: ExtUtils::ParseXS::Node::keylines ExtUtils::ParseXS::Node::keyline ExtUtils::ParseXS::Node::ALIAS ExtUtils::ParseXS::Node::ALIAS_line An ALIAS node represents an ALIAS keyword, which can have multiple ALIAS_line kid nodes, each of which represent one processed line from an ALIAS section. keylines and keyline are base classes for ALIAS and ALIAS_line respectively, which handle the general processing of keywords which are multi-line but where each line needs treating individually. Other examples would be INPUT and OUTPUT keywords (not yet done). It's slightly overkill just for ALIAS (arguably all the data could have just been stored in a single ALIAS node), but doing it properly now will make converting INPUT and OUTPUT keywords into nodes easier in the near future. The base classes also handle shifting lines off the input queue in such a way that warnings and errors come from the right line. Note that this is the first commit which adds an *intermediate* AST tree node class: the previous commits have just been adding terminal nodes. In particular, this commit adds a 'kids' array ref field to the base Node class which allows nodes to have kids; and the parse method for ALIAS repeatedly creates ALIAS_line objects, calls their parse method, then adds to them the ALIAS's kids list. Thus it's an embryonic recursive-decent parser, in the sense that parser subs for 'big' things call parser subs for smaller things. Technically, while there will be nested calls to parser methods, there won't be actual recursion, since the XS syntax isn't recursive. The bulk of this commit consists of moving the get_aliases() sub from Parse.pm into Node.pm and renaming it to ExtUtils::ParseXS::Node::ALIAS_line::parse(). The code is basically unchanged except for tweaks required to make it a Node subclass. Similarly, ALIAS_handler() becomes ExtUtils::ParseXS::Node::ALIAS::parse(). This commit also adds some more tests for the ALIAS keyword: in particular, while there were already some tests for alias warnings, there didn't seem to be any for errors. The old, existing test code for ALIAS is modified slightly so that 'die' text isn't lost if something goes horribly wrong. That test code doesn't use the newer, more general test_many() function from t/001-basic.t which handles that sort of thing better. Commit: 848c6d4c932673753443c9356d332cb1d8ca5989 https://github.com/Perl/perl5/commit/848c6d4c932673753443c9356d332cb1d8ca5989 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: improve error test coverage for Node.pm I audited all the Warn(), death() etc calls in Node.pm and added tests for any which weren't yet covered (apart from hard-to-reproduce ones like internal errors). Commit: 313e0262f3b5552ffb64824b925a5d58f2accfb6 https://github.com/Perl/perl5/commit/313e0262f3b5552ffb64824b925a5d58f2accfb6 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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 ATTRS node Add ExtUtils::ParseXS::Node::ATTRS class, and add a basic test. Commit: 23f7ae52ee066fe9e33f0fd7d995dc1be24523fe https://github.com/Perl/perl5/commit/23f7ae52ee066fe9e33f0fd7d995dc1be24523fe Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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 OVERLOAD node Add ExtUtils::ParseXS::Node::OVERLOAD class, and add a basic test. Note that currently this code doesn't warn about duplicate op names (it just silently skips duplicates), nor warn about unknown op names (it happily accepts them). This commit preserves the current behaviour for now. Commit: 952ae950f84faf8e84d61ccb2237c52af1198d94 https://github.com/Perl/perl5/commit/952ae950f84faf8e84d61ccb2237c52af1198d94 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: INPUT_handler() use $line vs $_ This is #1 of a small series of commits to refactor the INPUT_handler() method and turn it into a Node subclass method. This commit changes the main loop from using $_ to hold the current line, to using the variable $line instead. Commit: 77f47eec886aa1db11dc5c8cd07e2a3ca6a20696 https://github.com/Perl/perl5/commit/77f47eec886aa1db11dc5c8cd07e2a3ca6a20696 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: INPUT_handler() split into two This is #2 of a small series of commits to refactor the INPUT_handler() method and turn it into a Node subclass method. This commit splits the method into two: a smaller outer one which has the 'foreach line' loop, and a new method, INPUT_handler_line() which contains the bulk of the old method and processes a single line from an INPUT section. Commit: 3d710cb1c0244c794b4f255777f21d6e58ba8b1f https://github.com/Perl/perl5/commit/3d710cb1c0244c794b4f255777f21d6e58ba8b1f Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: INPUT_handler() move to Node.pm This is #3 of a small series of commits to refactor the INPUT_handler() method and turn it into a Node subclass method. This commit moves the ExtUtils::ParseXS methods INPUT_handler() INPUT_handler_line() from ParseXS.pm into ParseXS/Node.pm. For now they temporarily remain as ExtUtils::ParseXS methods; this is just a straight cut and paste, except for fully-qualifying the $BLOCK_regexp package variable name and adding a couple of temporary 'package ExtUtils::ParseXS' declarations. Commit: 980d6b18759ad8fa25a6e9a57039077179c7a5d1 https://github.com/Perl/perl5/commit/980d6b18759ad8fa25a6e9a57039077179c7a5d1 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: INPUT_handler() reindent. This is #4 of a small series of commits to refactor the INPUT_handler() method and turn it into a Node subclass method. This commit reindents INPUT_handler() and INPUT_handler_line() from 2-indent to 4-indent to match the policy of the file they were moved to in the previous commit. Whitespace-only change Commit: 76ccc36bcf98b5b0523cbab5a39496d97f073b26 https://github.com/Perl/perl5/commit/76ccc36bcf98b5b0523cbab5a39496d97f073b26 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add INPUT, INPUT_line nodes This is #5 of a small series of commits to refactor INPUT keyword handling. This commit adds these two classes: ExtUtils::ParseXS::Node::INPUT ExtUtils::ParseXS::Node::INPUT_line and converts the two ExtUtils::ParseXS methods INPUT_handler() INPUT_handler_line() into parse() methods of those two classes In a very minor way, this commit also starts separating in time the parsing and the code emitting. Whereas before, each INPUT line was parsed and then C code for it immediately emitted, now *all* lines from an explicit or implicit INPUT section are parsed and stored as an INPUT node with multiple INPUT_line children, and *then* the as_code() method is called for each child. This should make no difference to the generated output code. Commit: 101100f3e98606d0785bc396d7ac2e92f25453d9 https://github.com/Perl/perl5/commit/101100f3e98606d0785bc396d7ac2e92f25453d9 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: INPUT_line::parse(): remove var This is #6 of a small series of commits to refactor INPUT keyword handling. There's no need any more to save the original line in $orig_line, as $self->{line} now holds that value. Also, wrap ... or blurt(...), return; in a do block for clarity: Commit: f76b840112f46f0abf562e776b89ba56e71ca594 https://github.com/Perl/perl5/commit/f76b840112f46f0abf562e776b89ba56e71ca594 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add Node::INPUT_line fields This is #7 of a small series of commits to refactor INPUT keyword handling. The main job of parsing an INPUT line is to extract any information on that line and use it to update the associated Param object (which was likely created earlier when the XSUB's signature was parsed). This commit makes that information also be stored in new fields in the INPUT_line object. These new fields aren't currently used for anything, but they could in principle become useful if options for deparsing or exporting were added to ParseXS. Commit: af2f6a478faaa94e038d853a1925cac75ab5105c https://github.com/Perl/perl5/commit/af2f6a478faaa94e038d853a1925cac75ab5105c Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: move Param field decl Move the declaration of the 'defer' Node::Param field into the "values derived from the XSUB's INPUT line" part of the declaration. No functional change, just fixing an error in the documentation. Commit: c88c1ddb441d3944e0a6517817adbad0af6dfca8 https://github.com/Perl/perl5/commit/c88c1ddb441d3944e0a6517817adbad0af6dfca8 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add Node::Param::set_proto meth Rename the existing check() method to set_proto(). The only thing the method was doing was calculating the overridden prototype char for that parameter based on it's type typemap entry, if any. So give it a better name. Also, rationalise where and when the method is called. It was being called each time a parameter was created, or when its type changed. Instead, just call the method once on all parameters just after all INPUT processing is complete, so the types can't change, but before any inline TYPEMAP entries might change the proto char for that type. In theory this commit should make no functional change. Commit: eae184a2c891b5845f09c6b2711f0d45b0711a90 https://github.com/Perl/perl5/commit/eae184a2c891b5845f09c6b2711f0d45b0711a90 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: add tests for NOT_IMPLEMENTED_YET This keyword, used in place of CODE or PPCODE, emits a stub body that just call croak(). It's undocumented, untested, and appears to be used in only one XS file in all of CPAN. This commit adds some very basic tests. The next commit will change the behaviour slightly: currently, K&R-style params get C declarations, but code emitting stops before ANSI-style declarations and deferred initialisations would normally be emitted. SO a couple of tests are marked as expected to fail. Commit: 578f4f60ce77ecc6fdd57c3c9501a1400523d4f3 https://github.com/Perl/perl5/commit/578f4f60ce77ecc6fdd57c3c9501a1400523d4f3 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: process NOT_IMPLEMENTED_YET later The undocumented and almost-entirely-unused NOT_IMPLEMENTED_YET keyword can be used at the same point in parsing where CODE: or PPCODE: could appear, and emits a croak() call whereas a call to a C library function would otherwise have been auto-generated. This keyword was checked for for partway during emitting of initialisation code; this meant that K&R-style declarations were emitted, but ANSI_style ones weren't. This commit moves the checking for the presence of this keyword to a bit later: after all initialisation code emitting is complete. This makes NOT_IMPLEMENTED_YET logically part of the body-processing section, which now looks roughly like if (/NOT_IMPLEMENTED_YET/) emit croak elsif (/PPCODE:/) ... elsif (/CODE:/) ... else emit autocall and so makes the parsing code cleaner. Conceptually it means that a NOT_IMPLEMENTED_YET can now appear after an INIT keyword; in practice, only *INPUT* section parsing is special-cased to recognise NOT_IMPLEMENTED_YET as another valid keyword which terminates the current section. So INIT, C_ARGS etc sections continue to see "NOT_IMPLEMENTED_YET" as just a bit of text to be consumed from the input stream and added to the init code or the C signature or whatever. Some tests have been added to confirm this. Commit: 082e0889b3b24f14620559c5d63c00d757b8a7c4 https://github.com/Perl/perl5/commit/082e0889b3b24f14620559c5d63c00d757b8a7c4 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: reindent after previous commit The previous commit altered the structure of a big if/else. Reindent to match. Whitespace-only change Commit: 2f0873089399d2e3095e42bbe15782314b04456d https://github.com/Perl/perl5/commit/2f0873089399d2e3095e42bbe15782314b04456d Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: minor tweaks on main loop Make a couple of changes to some code in the main parsing loop, to simplify further refactoring: - move the declaration of $implicit_OUTPUT_RETVAL closer to first use; - eliminate 'my $generic_xsub_keys' and use the fully-qualified package name everywhere for the value it aliases. Commit: f00e0c9f8d6679775116fa2b83eac2e46105f9d3 https://github.com/Perl/perl5/commit/f00e0c9f8d6679775116fa2b83eac2e46105f9d3 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: move input parsing into a sub Move the section of code in the main parsing loop in ParseXS.pm which handles all the input parts of an XSUB (i.e. INPUT, PREINIT, C_ARGS etc) into its own temporary function in Node.pm. The main body of code moved in this commit is a pure cut+paste. Subsequent commits will re-indent, convert it into a Node parse method, etc. Commit: 7980a17229afaecee9bcdb9b9f5aba90fd5cf32a https://github.com/Perl/perl5/commit/7980a17229afaecee9bcdb9b9f5aba90fd5cf32a Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: reindent block of code The previous commit moved a block of code into its own sub in a different file. Now reindent it. Whitespace-only. Commit: 44de4d57a4b15c5323d34f08c806734d9896de21 https://github.com/Perl/perl5/commit/44de4d57a4b15c5323d34f08c806734d9896de21 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add input_part node Add this class: ExtUtils::ParseXS::Node::input_part and give it a parse() method. This is work-in-progress; in particular the parse() method currently also emits code, which will be moved to the as_code() method shortly. In fact this commit mainly just converts the block of code ripped out of the main parsing loop in process_file() in the previous two commits into a Node subclass, mainly by doing s/$self/$pxs/g. It also replaces the call to process_keywords() with an inlined-version which doesn't expect $_ to be set in entry and return. That inlined code will eventually be turned into a proper method. The intent of the input_part node type is to be the parent of all the nodes created when parsing the "input" part of an XSUB - e.g. INPUT, PREINIT, C_ARGS etc. Commit: 1adbf284339880e97dfb66b49cf5ff583c140b90 https://github.com/Perl/perl5/commit/1adbf284339880e97dfb66b49cf5ff583c140b90 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add input_part->as_code() Split the contents of the ExtUtils::ParseXS::Node::input_part::parse() method. Move all the code-emitting stuff into the (previously empty) as_code() method. This commit represents a significant milestone in building an AST and emitting code *after* the AST is complete. Previously as_code() for each node was called immediately after parse(). Now all the nodes associated with the input part of an XSUB are parsed and stored as a (shallow) tree, *then* the as_code() methods for all those nodes are called. Also add an empty as_code() method to the Node base class so there's no need to do "if $self->can('as_code')" in various places. Also also, move the initialisation of the xsub_seen_RETVAL_in_CODE field back into the main loop of parse_file(): it doesn't belong in input_part->parse() Commit: 456dda4ba926ef448d515182fd53413edcb26c87 https://github.com/Perl/perl5/commit/456dda4ba926ef448d515182fd53413edcb26c87 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: mark INPUT node as implicit Give the Node::INPUT class a boolean field called 'implicit', which signifies an INPUT section like: foo(a, b) int a int b as opposed to the explicit: foo(a, b) INPUT: int a int b Also, only add an implicit INPUT node as a kid to the input_part node if it has kids - i.e. if there are actually any implicit input lines present. Neither of these changes is needed for correct functioning, but they might be useful for a hypothetical deparser for example. Commit: 6a9b545cc48a2fa6539dd846e3d9b7a0792bf217 https://github.com/Perl/perl5/commit/6a9b545cc48a2fa6539dd846e3d9b7a0792bf217 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: avoid autovivifying kids Avoid giving some nodes an empty @kids field when looking for child as_code methods to call. Harmless but untidy. And simplify a second such loop. Commit: 6c4879f992e34d36393a1bd5ad4f8d9c5179a3be https://github.com/Perl/perl5/commit/6c4879f992e34d36393a1bd5ad4f8d9c5179a3be Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: make parse() meths return bool Make Node parse() methods normally return '1', so that a plain 'return' indicates failure. This can then be used by the caller to throw away a node which failed to parse. So parsing code which spots an error and does $self->blurt("...."); return; will no longer leave a half-formed node in the tree. Also, make the keylines base class skip blank lines. This means that individual keyline subclasses like INPUT_line etc don't end up generating an empty node for each blank line. Commit: 0c7334d146dd94665be2fc074c8dc8b00fbce396 https://github.com/Perl/perl5/commit/0c7334d146dd94665be2fc074c8dc8b00fbce396 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add parse_keywords() method Add a Node::parse_keywords() method, mainly by moving a block of code in Node::input_part::parse() into its own method. This block of code in turn was derived from the bodies of the legacy ExtUtils::ParseXS check_keyword() and process_keywords() methods. This commit also adds a $max parameter which allows parse_keywords() to act as either check_keyword ($max == 1) or process_keywords ($max is undef). Commit: b3d3d1c687681168231a40ab4a68efb3f55b7ae5 https://github.com/Perl/perl5/commit/b3d3d1c687681168231a40ab4a68efb3f55b7ae5 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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 init_part, INIT nodes add these classes: package ExtUtils::ParseXS::Node::init_part package ExtUtils::ParseXS::Node::INIT which replace the legacy code for parsing and emitting INIT blocks. Also, add some basic tests for the INIT keyword. Commit: 889b1656e0f1fe1ae4f2cd325b39dcea7de2bafe https://github.com/Perl/perl5/commit/889b1656e0f1fe1ae4f2cd325b39dcea7de2bafe Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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 PPCODE node and tests Add this class: ExtUtils::ParseXS::Node::PPCODE and move the direct code in the main loop which handled the PPCODE keyword into that class's parse and as_code methods. Also add some basic tests for PPCODE. Commit: 78cc03bb12850cb137f8616053cc32452563babb https://github.com/Perl/perl5/commit/78cc03bb12850cb137f8616053cc32452563babb Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add CODE node Add this class: ExtUtils::ParseXS::Node::CODE Note that this commit (and the previous one for PPCODE) slightly alter the '#line NNN foo.xs' emitted for empty CODE/PPCODE blocks. While it still emits unchanged a '#line 101 foo.xs' prefix to the code block for e.g. 100: CODE: 101: foo 102: it now emits 101 rather than 100 for: 100: CODE: 101: 102: This makes no practical difference as the '#line NNN foo.xs' is immediately followed by a '#line MMM foo.c' anyway. Commit: d376a94788f94b5d3280f96f46f941eca22a9836 https://github.com/Perl/perl5/commit/d376a94788f94b5d3280f96f46f941eca22a9836 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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 code_part, NIY nodes Add these classes: ExtUtils::ParseXS::Node::code_part; ExtUtils::ParseXS::Node::NOT_IMPLEMENTED_YET; The NIY class is for implementing the NOT_IMPLEMENTED_YET pseudo-keyword, and can be seen as the companion of the CODE and PPCODE nodes - i.e. one of the options for the main body. The code_part class is a companion to input_part and init_part and is the parent of typically a single node such as CODE or PPCODE which is responsible for the "main body" of the XSUB. code_part is not complete yet; the code for emitting an autocall body in the absence of CODE/PPCODE/NOT_IMPLEMENTED_YET is still with the caller of code_part->parse(). That chunk of code will be moved into a node class in the next commit. Commit: 97e2443da478bd61d68015ea44332329b9a4bb33 https://github.com/Perl/perl5/commit/97e2443da478bd61d68015ea44332329b9a4bb33 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add autocall node Add this class: ExtUtils::ParseXS::Node::autocall This is a node which represents the main body of an XSUB in the absence of a real body provided by CODE or PPCODE. It doesn't have to do any parsing, but the job of its as_code() method is to emit an auto-generated call to a C library function of the same name as the XSUB. This commit does two main things: 1), it extends the Node::code_part->parse() method action so that if a CODE or whatever keyword is not found, an autocall node is created and added as a child instead. This means a code_part node will always have exactly one child, one of these classes: NOT_IMPLEMENTED_YET CODE PPCODE autocall 2) all the code in the main loop which generates an autocall body has been cut and pasted and made into the as_code() method of the new autocall class. The only changes in addition to the raw cut and paste are: - reindent - s/$self/$pxs/g - hoist the setting of the $implicit_OUTPUT_RETVAL lex var back to the calling code. The diff looks more complex than it actually is. Commit: 1875283592051dfd9a5df21664c161211d563726 https://github.com/Perl/perl5/commit/1875283592051dfd9a5df21664c161211d563726 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: put code_part next to init_part There is a block of code which creates, parses and calls as_code on input_part and init_part objects. Move the newly added code_part- creating code to be part of the same block. Also move a couple of var declarations / initialisations earlier so that they still come before code_part parsing. Commit: 0e4a0dd60b803cb75b84c90709240d093d6c27e8 https://github.com/Perl/perl5/commit/0e4a0dd60b803cb75b84c90709240d093d6c27e8 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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 POSTCALL node add this class: ExtUtils::ParseXS::Node::POSTCALL and add a few basic tests for the POSTCALL keyword. Note that (similarly to other codeblock-derived Node classes), this commit causes a (harmless) slight change of '#line' output for an empty code block. In particular, this: 5: void 6: foo() 7: POSTCALL: 8: used to generate these two adjacent lines of C code: #line 7 "foo.xs" #line NNN "foo.c" but now outputs: #line 8 "foo.xs" #line NNN "foo.c" Commit: b6687d24404290b2ae130cb944b26494bcb031c9 https://github.com/Perl/perl5/commit/b6687d24404290b2ae130cb944b26494bcb031c9 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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 CLEANUP node add this class: ExtUtils::ParseXS::Node::CLEANUP and add a few basic tests for the CLEANUP keyword. Note that (similarly to other codeblock-derived Node classes), this commit causes a (harmless) slight change of '#line' output for an empty code block. In particular, this: 5: void 6: foo() 7: CLEANUP: 8: used to generate these two adjacent lines of C code: #line 7 "foo.xs" #line NNN "foo.c" but now outputs: #line 8 "foo.xs" #line NNN "foo.c" Commit: 5d73f65eed498c7c48981d2a5cf93ff584c73a37 https://github.com/Perl/perl5/commit/5d73f65eed498c7c48981d2a5cf93ff584c73a37 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: OUTPUT_handler() use $line vs $_ This is #1 of a small series of commits to refactor the OUTPUT_handler() method and turn it into a Node subclass method. This series is very similar to the one earlier in this branch which did the same for INPUT_handler(). This commit changes the main loop from using $_ to hold the current line, to using the variable $line instead. Commit: 50892a55f8ba565e3f37e70f216b3a35729eb902 https://github.com/Perl/perl5/commit/50892a55f8ba565e3f37e70f216b3a35729eb902 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: OUTPUT_handler() split into two This is #2 of a small series of commits to refactor the OUTPUT_handler() method and turn it into a Node subclass method. This commit splits the method into two: a smaller outer one which has the 'foreach line' loop, and a new method, OUTPUT_handler_line() which contains the bulk of the old method and processes a single line from an OUTPUT section. Commit: 414ef7735f5477225ab92e234db31ba582e180a2 https://github.com/Perl/perl5/commit/414ef7735f5477225ab92e234db31ba582e180a2 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: OUTPUT_handler(): mv to Node.pm This is #3 of a small series of commits to refactor the OUTPUT_handler() method and turn it into a Node subclass method. This commit moves the ExtUtils::ParseXS methods OUTPUT_handler() OUTPUT_handler_line() from ParseXS.pm into ParseXS/Node.pm. For now they temporarily remain as ExtUtils::ParseXS methods; this is just a straight cut and paste, except for fully-qualifying the $BLOCK_regexp package variable name and adding a couple of temporary 'package ExtUtils::ParseXS' declarations. Commit: 8b15b314a26631cd6724faaadd70bde3297f2fc0 https://github.com/Perl/perl5/commit/8b15b314a26631cd6724faaadd70bde3297f2fc0 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: OUTPUT_handler() reindent. This is #4 of a small series of commits to refactor the OUTPUT_handler() method and turn it into a Node subclass method. This commit reindents OUTPUT_handler() and OUTPUT_handler_line() from 2-indent to 4-indent to match the policy of the file they were moved to in the previous commit. Whitespace-only change Commit: bf8ea9f31702cf4f977042846fe3a363574846ef https://github.com/Perl/perl5/commit/bf8ea9f31702cf4f977042846fe3a363574846ef Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add OUTPUT, OUTPUT_line nodes This is #5 of a small series of commits to refactor OUTPUT keyword handling. This commit adds these two classes: ExtUtils::ParseXS::Node::OUTPUT ExtUtils::ParseXS::Node::OUTPUT_line and converts the two ExtUtils::ParseXS methods OUTPUT_handler() OUTPUT_handler_line() into parse() methods of those two classes Commit: f281964d1f07cfc5f2e5f5008b1536cc7bba2e53 https://github.com/Perl/perl5/commit/f281964d1f07cfc5f2e5f5008b1536cc7bba2e53 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add Node::OUTPUT_line fields This is #6 of a small series of commits to refactor OUTPUT keyword handling. The main job of parsing an OUTPUT line is to extract any information on that line and use it to update the associated Param object (which was likely created earlier when the XSUB's signature was parsed). This commit makes that information also be stored in new fields in the OUTPUT_line object. These new fields aren't currently used for anything, but they could in principle become useful if options for deparsing or exporting were added to ParseXS. Commit: ebc91c3d8ec81e596d3216301f00a03e2b9e5b0d https://github.com/Perl/perl5/commit/ebc91c3d8ec81e596d3216301f00a03e2b9e5b0d Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: alter Node:OUTPUT_line RETVAL This is #7 of a small series of commits to refactor OUTPUT keyword handling. For OUTPUT_line, move, from the parse() method to the as_code() method, the bit which checks for RETVAL and causes its "push return value on stack" C code to be emitted later. Also, add a long comment explaining why this delay is required. The existing code in parse() worked purely by chance: it was just returning (without a value) if the parameter name was RETVAL. This was a hangover from moving the existing code from OUTPUT_handler() into a Node parse() method. By returning undef, it was signalling to the caller that the parse of the line failed, and so the subsequent call to as_code() was skipped. Instead, indicate that the parse was successful, and have as_code() skip RETVAL. Commit: 3f333b9c88d1245417b3bf9058a1423129b3799b https://github.com/Perl/perl5/commit/3f333b9c88d1245417b3bf9058a1423129b3799b Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: add two xsub_foo fields Add these two fields to the ExtUtils::ParseXS class: xsub_implicit_OUTPUT_RETVAL xsub_XSRETURN_count and use them instead of these two lexical vars $implicit_OUTPUT_RETVAL $XSRETURN_count in the main parsing loop. This is a temporary(ish) measure to simplify some code refactoring that's about to happen. Commit: 68b669e8ac6cc2a4bf564ad436db984bcc414607 https://github.com/Perl/perl5/commit/68b669e8ac6cc2a4bf564ad436db984bcc414607 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: move output parsing into a sub Move the section of code in the main parsing loop in ParseXS.pm which handles the output parts of an XSUB (i.e. OUTPUT plus POSTCALL etc) into its own temporary function in Node.pm. The main body of code moved in this commit is a pure cut+paste. Subsequent commits will re-indent, convert it into a Node parse method, etc. Commit: 89fb03518e1a713f6eb1125ccc7a2cb045c60a4a https://github.com/Perl/perl5/commit/89fb03518e1a713f6eb1125ccc7a2cb045c60a4a Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: reindent block of code The previous commit moved a block of code into its own sub in a different file. Now reindent it. Whitespace-only. Commit: 35dd91261a4a80d372ad49e26581eae9917f9627 https://github.com/Perl/perl5/commit/35dd91261a4a80d372ad49e26581eae9917f9627 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: remove redundant braces Remove a { } pair round a block of code which are no longer needed. No functional change. Commit: 9eb82e63e29f2f807f2dbbffc55c1b596e81bea0 https://github.com/Perl/perl5/commit/9eb82e63e29f2f807f2dbbffc55c1b596e81bea0 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add output_part node Add this class: ExtUtils::ParseXS::Node::output_part and give it parse() and as_code() methods. The block of code cut out of the main parsing loop and moved into Node.pm in the last few commits forms the bulk of the as_code() method, with mainly just doing s/$self/$pxs/g to turn it into a Node subclass. The small bit of parsing at the start of that block of code forms the basis for parse() - basically looking for OUTPUT, POSTCALL or generic keywords. The intent of the output_part node type is to be the parent of all the nodes created when parsing the "output" part of an XSUB. Commit: ec595cc58cb9f41cf253c8e64968f6852d81a98a https://github.com/Perl/perl5/commit/ec595cc58cb9f41cf253c8e64968f6852d81a98a Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add cleanup_part node add this class: package ExtUtils::ParseXS::Node::cleanup_part This node holds any CLEANUP or other generic keywords parsed at the end of an XSUB. Commit: b5d8d03c89ec25f96ce9393d16b0db0b38d07bd5 https://github.com/Perl/perl5/commit/b5d8d03c89ec25f96ce9393d16b0db0b38d07bd5 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: mv xsub_implicit_OUTPUT_RETVAL Move the setting of $self->{xsub_implicit_OUTPUT_RETVAL} into the autocall::parse() code, as it makes more sense there. Should make no functional difference. Commit: 134db99c9dbb324fa2073917c8a3959fcb553c45 https://github.com/Perl/perl5/commit/134db99c9dbb324fa2073917c8a3959fcb553c45 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add xbody node add this class: package ExtUtils::ParseXS::Node::xbody This node holds all the foo_part nodes which make up the body of an XSUB. Note that in the presence of CASE: keywords, an XSUB may have multiple xbodys, one per CASE. This node doesn't contain the signature, and nor is it responsible for emitting the code for the closing part of an XSUB e.g. the XSRETURN(N); there is only one of those per XSUB, so will handled by a higher-level node, once that gets created in further refactoring. Commit: f47946d3dec70cf772a6c23e5a020daab05ea700 https://github.com/Perl/perl5/commit/f47946d3dec70cf772a6c23e5a020daab05ea700 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: move some code emitting Move the opening brace emitted by input_part->as_code() into the newly-created xbody->as_code(). Makes no functional difference (xbody->as_code() immediately calls input_part->as_code()) but logically wrapping the generated XSUB in '{...}' should be done at the higher level. Commit: 2c012de13172839b444a7e61f9cccbd2fc6d8192 https://github.com/Perl/perl5/commit/2c012de13172839b444a7e61f9cccbd2fc6d8192 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: tidy some C-code-emitting code Simplify some code, mainly in the freshly-added xbody->as_code() method. In particular, add $open_brace, $close_brace vars to hide '{}' from text editors in a slightly less obscure manner than Q("[[") and Q("]]"). No change in functionality. Commit: 6983985ca414cf36f6a8cbaeb0e13f972e6c08ad https://github.com/Perl/perl5/commit/6983985ca414cf36f6a8cbaeb0e13f972e6c08ad Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: add CASE tests, tweak err msgs Add tests for for various errors concerning CASE and bad end-of-function handling. Tweak the error messages for the latter: add "Error:" prefix and put the bad line in quotes. Commit: 6b484e4baeb1aba4e7bdb2576040ba547663d3e8 https://github.com/Perl/perl5/commit/6b484e4baeb1aba4e7bdb2576040ba547663d3e8 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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 ReturnType node add this class: ExtUtils::ParseXS::Node::ReturnType mainly by moving the code which extracts the type etc of an XSUB, from the main loop into the parse() method of the new class. It's not a direct cut+paste: the new code in parse() has been tidied up. But it should be the same functionality. Also add some tests. Commit: cac94014187107441fb48301cc0c2c7272276252 https://github.com/Perl/perl5/commit/cac94014187107441fb48301cc0c2c7272276252 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: rename Node::Sig Node::Params Rename this this class: ExtUtils::ParseXS::Node::Sig to this: ExtUtils::ParseXS::Node::Params This class parses and stores the list of params within the parentheses of an XSUB's signature. I will shortly be adding a Signature node class which stores *all* of an XSUB's signature, including name, return type etc. Commit: 25636757ea996540c4b6f0f76cb43b8a548e616c https://github.com/Perl/perl5/commit/25636757ea996540c4b6f0f76cb43b8a548e616c Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: rename Params->{sig_text} field As a followup to the previous commit which renamed the Node::Sig class to Node::Params, rename one of its fields from sig_text to params_text. In addition, pass said text as a parameter to Node::Params->parse() rather than setting it directly in the caller. Commit: b0252ec10fa495c5e5b5bb814523aab9c2b4d1ad https://github.com/Perl/perl5/commit/b0252ec10fa495c5e5b5bb814523aab9c2b4d1ad Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: prepare sig parsing code for mv Make the chunk of code in the main loop, which parses the start of an XSUB, be in a suitable state to be moved to another file. In particular: - make a couple of VMS-state lexicals be package vars - remove the type from a couple of lexicals - move an unshift a couple of lines earlier - make a Warn call be a method call. No functional changes Commit: da9addd7c7b1d45869ebb8bef859d5d12c71f1b5 https://github.com/Perl/perl5/commit/da9addd7c7b1d45869ebb8bef859d5d12c71f1b5 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: move sig-parsing code Move the chunk of code which parses the declaration part of an XSUB into Node.pm. It's temporarily not yet a Node class, so this is just a raw cut and paste. Commit: 8d0625766571bdbc461236cf637eeaf7fcdf875e https://github.com/Perl/perl5/commit/8d0625766571bdbc461236cf637eeaf7fcdf875e Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add xsub_decl Node Add this class: ExtUtils::ParseXS::Node::xsub_decl which processes the declaration part of an XSUB. This commit mainly converts the code which was cut and paste out the main loop by the previous commit, into a parse method - chiefly by doing s/$self/$pxs/g. Commit: 07d87cbfd8adf31e7c3bd1b087f6b1305ed54a42 https://github.com/Perl/perl5/commit/07d87cbfd8adf31e7c3bd1b087f6b1305ed54a42 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: reindent xsub_decl::parse() whitespace-only Commit: 6e64d869c9d43e8e8dd91f8f1d17bbf798f6d400 https://github.com/Perl/perl5/commit/6e64d869c9d43e8e8dd91f8f1d17bbf798f6d400 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: remove redundant block Remove the braces of a block which is no longer needed. When the block was part of a 1000-line sub, it made sense to keep some lexical vars within a smaller scope. It's now in a 100-line sub. Commit: 6c95f45165d67b2d7420ff5df149d67c721acdff https://github.com/Perl/perl5/commit/6c95f45165d67b2d7420ff5df149d67c721acdff Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add fields to xsub_decl Node Add some fields to the newly-created ExtUtils::ParseXS::Node::xsub_decl class. Currently the parse() method sets a bunch of $pxs->{xsub_foo} values in the ExtUtils::ParseXS object. This commit adds local fields to the Node::xsub_dec class and sets $self->{foo} to those same values too. For now, most code will continue to use the xsub_foo fields, but most of those will be removed at some point in the future. This commit also cleans up the code in parse() a bit, mainly by storing values initially in lexical vars before saving them to the two sets of object fields. Commit: 2f9b70f915e749adbe6b7023f52236d52b0c94c7 https://github.com/Perl/perl5/commit/2f9b70f915e749adbe6b7023f52236d52b0c94c7 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: move some xsub_decl init stuff During the last few commits which moved the XSUB declaration-parsing code into a new Node::xsub_decl->parse() method, some per-xsub initialisation code got moved with it. Move that code back up into the main loop. Shouldn't make any functional difference. Commit: 9c3c8f1ed278944411f290f110f2124a5c601abb https://github.com/Perl/perl5/commit/9c3c8f1ed278944411f290f110f2124a5c601abb Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- parseXS: add tests for XSUB declaration errs make sure that all the warnings/errors that can be emitted by Node::xsub_decl->parse() have tests. Commit: c858b0afaabf72f7525c3c7a000579d094f38ee1 https://github.com/Perl/perl5/commit/c858b0afaabf72f7525c3c7a000579d094f38ee1 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- parseXS: refactor: delete whitespace lines Node.pm During recent refactoring and reindenting, a bunch of blank lines ended up with whitespace. Do s/^ +$//g. Commit: c5556a8fdb8b694775370cffdaa7ef1096dc0b69 https://github.com/Perl/perl5/commit/c5556a8fdb8b694775370cffdaa7ef1096dc0b69 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor; fix a couple of comments Commit: 5747bf6f7d74b4968bd3519aebe76dc1582baa79 https://github.com/Perl/perl5/commit/5747bf6f7d74b4968bd3519aebe76dc1582baa79 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: prepare for xsub parsing move Do some minor tweaks to the code which parses an XSUB at the top level, in preparation for the next commit which will move that code to Node.pm. Commit: 089405c01d2e36d5cf118a95e315a3f0f76770c5 https://github.com/Perl/perl5/commit/089405c01d2e36d5cf118a95e315a3f0f76770c5 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: move xsub parse code to Node.pm Move the big chunk of code in the main loop in ParseXS.pm which does the top-level parsing of an XSUB into Node.pm For now this is just a crude cut+paste with no changes other than s/next PARAGRAPH/return/. The next few commits will turn it into a proper Node class. Commit: 9c17c14b94e1e1075d18fa7d909cca4eed87241e https://github.com/Perl/perl5/commit/9c17c14b94e1e1075d18fa7d909cca4eed87241e Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- parseXS: refactor: add xsub Node class Add this class: ExtUtils::ParseXS::Node::xsub Thus isn't complete. Basically the code cut+parse from the main loop in the previous commit has been turned into a parse() method, mainly via lots of s/$self/$pxs/g. The parse() method is still doing both parsing and code generation. The latter will be moved into as_code() shortly. Commit: d0ad1adc3c0619a255072669f19bece55ca2103d https://github.com/Perl/perl5/commit/d0ad1adc3c0619a255072669f19bece55ca2103d Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: reindent sub Reindent Node::xsub->parse() after moving code from 2-indent ParseXS.pm to 4-indent Node.pm Whitespace-only Commit: 33707baa715c1624773427fa21bc81d5697013e2 https://github.com/Perl/perl5/commit/33707baa715c1624773427fa21bc81d5697013e2 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add boot_code() in Node::xsub Move the code which generates the "newXS(...)" boot code from the parse() method into a new boot_code() method. This is a straight cut+paste. Commit: 351a949d37645fc1c74e74e8701e0a9f24139a13 https://github.com/Perl/perl5/commit/351a949d37645fc1c74e74e8701e0a9f24139a13 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: boot_code(): remove block Remove the { ...} surrounding most of the body of boot_code(), and remove one level of indent. Commit: 50e97e5ec25eb3b5aeaf204a53f8f2560c926cc0 https://github.com/Perl/perl5/commit/50e97e5ec25eb3b5aeaf204a53f8f2560c926cc0 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: make :boot_code() return val Make the newly added/refactored Node::xsub::boot_code() method return a list of C code strings, and leave it to the caller to push them onto @{ $pxs->{bootcode_early}, rather than doing the pushing in the sub itself. Commit: c91674faa4bdb0550b02d263c40f3d6f56899b62 https://github.com/Perl/perl5/commit/c91674faa4bdb0550b02d263c40f3d6f56899b62 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add decl field to Node::xsub Don't immediately throw away the object holding the parsed xsub declaration. Keep it in the tree. Also clarify a code comment. Commit: 47193517ba981d4b870422c5dcaebca9d298cf8a https://github.com/Perl/perl5/commit/47193517ba981d4b870422c5dcaebca9d298cf8a Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: add another CASE test Test CASE with unconditional else. Commit: e08a1d1537dd17273fbb7916322dc4553eb25490 https://github.com/Perl/perl5/commit/e08a1d1537dd17273fbb7916322dc4553eb25490 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add CASE node type Add this class: ExtUtils::ParseXS::Node::CASE; This is the last Node subclass required to represent an entire XSUB as an AST. It just requires some further refactoring of Node::xsub to be a valid AST. (This commit actually comes in the middle of a series of Node::xsub commits, as it was necessary for an xsub object to exist first for CASE to work properly as a node.) This commit also: - makes the parse_keywords() method return a list of the nodes it has just created, rather than just a count. This makes accessing the just-created CASE node slightly easier. Can still be used as a boolean, which is all the return value has been used for up until now. - removes the no-longer-need ParseXS object fields: xsub_CASE_condition xsub_CASE_condition_count - removes the process_keywords() ParseXS method, as all keywords which it used to process are now processed by the parse_keywords() Node method. Commit: d4765e4a5013dc65b0941a65cac751087a853e8a https://github.com/Perl/perl5/commit/d4765e4a5013dc65b0941a65cac751087a853e8a Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: some tweaks to Node::xsub Fix a couple of issues in the newly-added Node::xsub class. These don't cause problems at the moment, but will, once parsing and code-emitting for this class are separated out. It was pushing the xbody as a kid of xsub node twice, and wasn't passing the $pxs object to the (currently NOOP) as_code() method. Also fix a thinko in a comment. Commit: 2864b6e5c5ae77426edfbf129e7269e82ee9dfb6 https://github.com/Perl/perl5/commit/2864b6e5c5ae77426edfbf129e7269e82ee9dfb6 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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 per-xbody Params objects Before this commit, there was a *single* Params object, $pxs->{xsub_params}, which contained two lists of Param objects. The {orig_params} field contained a list of Param objects generated by parsing the XSUB's signature. The {params} field contained a second list of Param objects, which started out as copy of the {orig_params}, but was then augmented by parsing INPUT and OUTPUT sections. When there was more than one CASE, the {params} Param objects would be emptied out and their contents re-copied from {orig_params} at the start of each new CASE. Note that the physical Param hashes remained the same, they were merely emptied, i.e. %$param = (), rather then being freed. Each Params object also held a {names} hash which mapped param names to Param objects - this was why they weren't deleted but merely emptied: to maintain the mapping across CASESs. This commit reorganises this. Now there is: - a Params object in the {xsub}{decl} object, which holds a list of Param objects containing just the data derived from parsing the signature, plus a {names} hash which maps names to *those* Param objects. - a Params object per {xbody}, which holds a list of Param objects containing both the data derived from parsing the signature plus any extra INPUT/OUTPUT data parsed from just the xbody associated with the current CASE, plus a {names} hash which maps names to *those* Param objects. $pxs->{xsub_params} points to this Params object, and is updated to point to a new object at the start of every xbody (i.e. per CASE). This commit causes a couple of prototype-related tests in t/001-basic.t to fail; they will be fixed by the next commit. In fact the following few commits are updates to this commit, fixing up various bits of fallout - mostly relating to accessing $pxs->{xsub_params} within as_code() methods, whereas it's value is really only meaningful now within parse() methods. It's also intended that in a few commits' time, the Param class will be split into two: Param and a IOParam subclass, with only the latter having the extra fields related to INPUT and OUTPUT. In anticipation of this, some vars etc in this commit have been called '$ioparam' rather than '$param' etc. Commit: 5ee420758714b3f9dabecdcba6621ad40355a7bf https://github.com/Perl/perl5/commit/5ee420758714b3f9dabecdcba6621ad40355a7bf Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: add warning about varying prototype chars It's possible for a particular typemap entry to override the default ('$') prototype. It's also possible, in the presence of multiple CASEs, for a parameter to have multiple types, and thus potentially differing prototype chars. But there can be only one proto char per param per XSUB (as passed in the newXS_foo(...) call). This commit checks whether the prototype char is consistent across all branches, and if not, warns. This commit also fixes overridden prototype handling generally, after it it got broken by the previous param-refactoring commit. Since the previous commit, there is now a per-XSUB list of Params (derived from the XSUB's declaration) plus a per-xsub-body list of Params (derived from the declaration plus any INPUT/OUTPUT updates for this body). For each xbody (i.e. per CASE), calculate the proto char of each param, and store it in the per-xbody Param, but also copy that value back to the per-XSUB Param (and warn if there's already a different value there). Commit: 2ece592b03b9910a49da2b3a199b1112e17fbead https://github.com/Perl/perl5/commit/2ece592b03b9910a49da2b3a199b1112e17fbead Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: refactor: ensure C_ARGS per CASE Ensure that the value of C_ARGS is stored per-CASE, at parse() time. This is so that when shortly the parsing and code-emitting of an XSUB is split into separate phases, the args to the generated autocall function are correct per-CASE, rather than all cases having the final value. Commit: 7d1d68ac2f0feb7efb0f8381b9974cf3896583f5 https://github.com/Perl/perl5/commit/7d1d68ac2f0feb7efb0f8381b9974cf3896583f5 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: pass xbody to foo_part::as_code Pass the current Node::xbody object as an extra parameter to the various foo_part::as_code() methods. The next few commits will make use of it. Also, in one particular loop, use the full name of the foo_part classes for easier searching in the src code (searching for "input_part" wasn't finding where an object of that class was being created). Commit: 675fedcce2a9071ce852cb6e7a80ce6eef15cd7a https://github.com/Perl/perl5/commit/675fedcce2a9071ce852cb6e7a80ce6eef15cd7a Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: refactor: avoid xsub_params in _part code In the input_part->as_code() and output_part->as_code() methods, avoid using the $pxs->{xsub_params} value. Once parsing and code-emitting are fully split, that value will no longer be valid during code emitting. Add a few tests too. Commit: 6674def461cd19ec9827111b5b643e624aedd18f https://github.com/Perl/perl5/commit/6674def461cd19ec9827111b5b643e624aedd18f Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: give error on unmatched length(foo) In this form of XSUB: foo(char *s, int length(s)) if the length pseudo-parameter's name didn't match another parameter, e.g. foo(int length(s)) then it would quietly generate bad C code. This commit makes it produce an error instead: Error: length() on non-parameter 's' It does this by adding a new field, 'has_length' on Param objects, which is set by a quick scan of all params just after the XSUB's signature has been parsed. This also removes one more "runtime" usage of the $pxs->{xsub_params} value in an as_code() method. Commit: f8f4c0404f1e6e0c77167327539c8ec3b3c780c2 https://github.com/Perl/perl5/commit/f8f4c0404f1e6e0c77167327539c8ec3b3c780c2 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add cur_xbody, rm xsub_params Add a new field, cur_xbody, to the ParseXS class. This tracks the current Node::xbody object during parsing (an XSUB can have multiple bodies, one per CASE). Then remove the field xsub_params from the ParseXS class. This can now be derived as $pxs->{cur_xbody}{ioparams}. Commit: 37657cb6833b1d8b338e61f7989af6c3fe6fcffb https://github.com/Perl/perl5/commit/37657cb6833b1d8b338e61f7989af6c3fe6fcffb Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: refactor: split xsub parse() method Move the code-emitting actions of the recently-created Node::xsub:parse() method into a separate as_code() method. This means that *all* the parsing actions for an XSUB take place before any code-emitting. This is a major milestone in this branch, which has been moving towards creating an AST, and *then* walking it to emit code. This commit actually introduces a lot of subtle bugs when there is more than one CASE in an XSUB. These will be fixed in the following commits. In particular, one test now fails; this has been temporarily disabled. The issue is that much parsing state is stored as 'global' state in the xsub_foo fields within a ParseXS object. These fields tend to get initialised at the start of each CASE, then get set to values and are used to to emit code, during the parsing of that CASE. The field's value thus might be different for each CASE. Now, the parsing for *all* CASEs is done before code emitting, so those field values which are used to determine how to emit code, now all have values relevant to the *last* CASE, but are then used to emit the code for *all* CASES. The follow-up commits to this commit will remove all those 'global' fields and replace them with similar fields within the relevant Node classes. This ensures that there will be such values in separate nodes for *each* CASE, so each branch gets its own state. Commit: 8b87dcf58e44d3fe5a37032f41a7fb92ac7a3906 https://github.com/Perl/perl5/commit/8b87dcf58e44d3fe5a37032f41a7fb92ac7a3906 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: pass xsub obj to as_code meths Currently, calls to as_code() methods in middle-level nodes of the AST pass the current Node::xbody node as an extra argument. This commit makes the current Node::xsub object also be passed. This helps lower-level nodes access state held in a higher part of the tree. Note that there is one xsub node per XSUB, plus at least one xbody child - or multiple xbody children in the presence of CASE keywords. Commit: 77a40320c0d9455aebce1280710a4096d4bfb8ed https://github.com/Perl/perl5/commit/77a40320c0d9455aebce1280710a4096d4bfb8ed Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: rm xsub_targ_declared_early Remove the field 'xsub_targ_declared_early' from the ParseXS class, and instead add a 'use_early_targ' field to the ReturnType Node class. This is the first in a series of commits which will remove many of the 'global' parse state fields from the ParseXS object and instead add them as fields of the relevant Node objects. Commit: 739709c68240632271eea95c85b4a74b5b5f5b13 https://github.com/Perl/perl5/commit/739709c68240632271eea95c85b4a74b5b5f5b13 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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: remove xsub_targ_used Remove the field 'xsub_targ_used' from the ParseXS class, and instead add a 'targ_used' field to the xbody Node class. This allows a TARG to be declared and used within *every* CASE (i.e. xbody) of an XSUB. This fixes a bug which was introduced a couple of commits ago when the xsub node's parsing and code-emitting actions were split into separate subs and no longer interleaved. Accordingly, a test which was temporarily disabled then is now re-enabled. Commit: 913a46b98e3a7462e0f5d3f7af74495c82f1ee63 https://github.com/Perl/perl5/commit/913a46b98e3a7462e0f5d3f7af74495c82f1ee63 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: tidy up some code comments Update some code comments following recent refactoring. Commit: 8e8ebc9b8dbc6962a5544ad13892edd6f3b270f5 https://github.com/Perl/perl5/commit/8e8ebc9b8dbc6962a5544ad13892edd6f3b270f5 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: refactor: re-add SCOPE dup err message Refactoring earlier in this branch accidentally deleted the check for duplicate SCOPE: entries in the same XSUB. This commit restores the check (with a slightly better error message), makes it a blurt() rather than death(), and adds a test for the error message. Commit: 48f91830d0730beee46c15661fe3499c3b52aea2 https://github.com/Perl/perl5/commit/48f91830d0730beee46c15661fe3499c3b52aea2 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Eval.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: refactor: remove xsub_seen_ALIAS Remove the xsub_seen_ALIAS field of the ExtUtils::ParseXS class and instead add a seen_ALIAS field to the ExtUtils::ParseXS::Node::xsub class. Set this field from within ALIAS::parse(), rather than peeking ahead by grepping through the unprocessed lines of the current XSUB looking for /ALIAS:/. This is part of a process of moving per-XSUB state into the relevant nodes of the AST. This particular change was made slightly more complex due to the fact that typemap evals set an $ALIAS variable if the XSUB contains aliases - this is typically used by typemap entries to decide how to identify the name of the function when croaking. So this commit makes sure the value is still passed to eval, and adds a test. Commit: 535ea77483deef333995c65314709e76fc60be43 https://github.com/Perl/perl5/commit/535ea77483deef333995c65314709e76fc60be43 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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: remove various xsub_seen_FOO Remove the following fields from the ExtUtils::ParseXS class: xsub_seen_PPCODE xsub_seen_INTERFACE xsub_seen_PROTOTYPE xsub_seen_SCOPE xsub_seen_INTERFACE_or_MACRO and replace them with these new fields in the ExtUtils::ParseXS::Node::xsub class: seen_INTERFACE seen_INTERFACE_MACRO seen_PPCODE seen_PROTOTYPE seen_SCOPE Note that the combined flag xsub_seen_INTERFACE_or_MACRO has been replaced with a flag which indicates the presence of just a INTERFACE_MACRO keyword, rather than that *or* INTERFACE. Where the old flag was tested, we now test for two flags (seen_I *or* seen_I_M). This commit also adds a few tests for some of the unloved keywords being flagged. Commit: ae9cc49a7a7a7de8e295bd8bf41519e3f8ba2b7f https://github.com/Perl/perl5/commit/ae9cc49a7a7a7de8e295bd8bf41519e3f8ba2b7f Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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: remove xsub_seen_RETVAL_in_CODE Remove the following field from the ExtUtils::ParseXS class: xsub_seen_RETVAL_in_CODE and replace it with this new field in the ExtUtils::ParseXS::Node::xbody class: seen_RETVAL_in_CODE Note that the previous commit did similar things, but for fields added to the Node::xsub class. This flag is per-CASE, so goes in Node::xbody instead. Also add a test for multiple CASEs. Commit: 352a7a67548e93a37155cb8534e26260cf3fa16c https://github.com/Perl/perl5/commit/352a7a67548e93a37155cb8534e26260cf3fa16c Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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: rm xsub_FOO's for return and fix CASE Remove these fields from the ExtUtils::ParseXS class which relate to returning SVs from the XSUB call: xsub_seen_CODE xsub_XSRETURN_count and replace them with these new fields in the ExtUtils::ParseXS::Node::xsub class: CODE_sets_ST0 XSRETURN_count_basic XSRETURN_count_extra As well as being part of a series of commits which are moving state into the AST, this commit in particular also changes how the N is calculated for EXTEND(SP,N) and XSRETURN(N). As well as the code being cleaner now, it fixes a number of bugs related to multiple CASEs and OUTLIST variables. For each branch, the number of OUTLIST variables used to get added to the running total, so the later EXTEND()s and final XSRETURN() would have a count too large, and the ST(N) numbers could be wrong. Tests have been added for these cases. This commit also has a slight change of behaviour in a hacky edge case. XSUB's declared void but which have something like 'ST(0) = ...' in their body cause XSRETURN(1) to be emitted whereas normally the 'void' would imply 'XSRETURN_EMPTY'. This was a hack put into place around 1996 to accommodate code which had been following a poor coding style recommendation in the then-docs. Prior to this commit, early on in the parsing of an XSUB, it would peek ahead and see if there is a 'CODE:' keyword, and if so would peek ahead again and look for 'ST(0) = ...' and similar in *any* of the as-yet unparsed lines of the current XSUB. After this commit, it now looks for such assigns *only* in the text of a CODE: body. Either approach can be argued to be right or wrong: for example, perhaps a POSTCALL block is doing the naughty assign. But if so, and there's no CODE: block too, then previously it wouldn't have been spotted either. At least the new approach is consistent. Commit: 4cbb765594d83351fc4ef739a0ff97c494e0fd8b https://github.com/Perl/perl5/commit/4cbb765594d83351fc4ef739a0ff97c494e0fd8b Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: cosmetic: change SCOPE indent For an XSUB which has 'SCOPE: ENABLE', an extra ENTER: { and LEAVE: } are added to the generated C code. These used to have a 3-indent; this commit changes them to a 6-indent. They are added where there's currently a transition between a 4- and 8-indent, so 6 makes more sense. Commit: ca280159bee0afaa55b35f608e37620566dd1560 https://github.com/Perl/perl5/commit/ca280159bee0afaa55b35f608e37620566dd1560 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: use $open/close_brace more the Q() quoting method converts [[ into { and ]] into }, but it's not obvious, so I added $open_brace and $close_brace lexicals to make it more obvious. This commit uses them in the couple of places in Node.pm which I missed earlier. Commit: f3b9e90e5428cee2f1b041f8d3968bd981d6a5bc https://github.com/Perl/perl5/commit/f3b9e90e5428cee2f1b041f8d3968bd981d6a5bc Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: rm return-type xsub_foo fields Remove these fields from the ExtUtils::ParseXS class: xsub_return_type xsub_seen_extern_C xsub_seen_NO_OUTPUT xsub_seen_static and instead use the analogous fields of the Node::ReturnType class. Commit: 9850ee78ae28e47096aad23fdccfd8205975fa2f https://github.com/Perl/perl5/commit/9850ee78ae28e47096aad23fdccfd8205975fa2f Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: add seen_an_XSUB EU::PXS field Add a new field to the ExtUtils::ParseXS class: seen_an_XSUB (this bucks the trend of recent commits which have been *removing* fields from that class). The code currently uses the field 'xsub_func_full_C_name' being defined to indicate that at least one XSUB has been parsed. That field is going away shortly, so so add a different field just for that one explicit purpose. Commit: 1b878516eeef97cdd570875c98f34bc96ba788c4 https://github.com/Perl/perl5/commit/1b878516eeef97cdd570875c98f34bc96ba788c4 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Eval.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: rm fn name/class xsub_FOO's Remove these fields from the ExtUtils::ParseXS class which relate to storing the XSUB's class and name in various formats: xsub_class xsub_func_name xsub_func_full_perl_name xsub_func_full_C_name and instead use the analogous fields of the Node::decl class Commit: 7e19021f973bd72f505a8bae165ce693ef716920 https://github.com/Perl/perl5/commit/7e19021f973bd72f505a8bae165ce693ef716920 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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: rm xsub_implicit_OUTPUT_RETVAL Remove the following field from the ExtUtils::ParseXS class: xsub_implicit_OUTPUT_RETVAL and replace it with this new field in the ExtUtils::ParseXS::Node::xbody class: seen_autocall Basically there is some logic which says that a bodiless (i.e. autocall) XSUB has an implicit 'OUTPUT: RETVAL' - i.e. return RETVAL even though it hasn't explicitly been requested. This commit moves the logic to the point where is RETVAL is emitted, and earlier just notes that an autocall is present. This commit also fixes a bug introduced by the earlier refactoring in this branch which split out parsing and code emitting. When an XSUB has two or more CASEs, the xbody's weren't treated independently - so the behaviour of all CASE branches was determined by the state of the last branch. With seen_autocall being set per xbody, the corrrect behaviour is now restored. This commit adds a couple of tests to confirm this. Commit: 3d0ac0c89185afa494d4a57936bc2ae0fc75024f https://github.com/Perl/perl5/commit/3d0ac0c89185afa494d4a57936bc2ae0fc75024f Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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: fix alias/attr cv, add need_boot_cv field Add a new field to the ExtUtils::ParseXS class: need_boot_cv and remove the seen_INTERFACE_or_MACRO field. The boot XSUB emitted by the XS parser will sometimes declare a 'cv' variable within a narrow scope when it knows that part of the boot code will need it, e.g. for: cv = newXS_deffile("Foo::foo", XS_Foo_foo); apply_attrs_string("Foo", cv, "x y", 0); Previously it would guess whether to to emit '{ CV *cv; ... }' based on flags indicating the presence of various keywords which were known to generate such code. This commit changes it so that instead, it sets a new flag, 'need_boot_cv', any time code is generated which uses 'cv'. This seems more logical to me. It also allows us to remove the flag indicating that INTERFACE: or INTERFACE_MACRO: was seen, since the only remaining use of that flag was for cv-emitting. This commit also fixes a bug whereby the cv declaration wasn't being emitted for the ALIAS and ATTR keywords (even though it uses it to call e.g. apply_attrs_string() as shown above). This was in fact *fairly* harmless, since the boot XSUB has a cv parameter anyway (the CV of the BOOT sub), and as long as nothing in the boot XSUB needs the original value held in cv, no harm was done. In the case of ALIAS, it checked for the existence of $pxs->{xsub_map_alias_name_to_value} as an indication of the presence of ALIAS, that field is undeffed after each each XSUB has been parsed. In the case of ATTR, I don't think it ever added cv.. Commit: 0ff0026fe99752ddaff9a2c4be6cf24cfc21b36b https://github.com/Perl/perl5/commit/0ff0026fe99752ddaff9a2c4be6cf24cfc21b36b Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: rm various xsub_*alias* fields Remove the following fields from the ExtUtils::ParseXS class: xsub_map_alias_name_to_value xsub_map_alias_value_to_name_seen_hash xsub_alias_clash_hinted and replace them with these new fields in the ExtUtils::ParseXS::Node::xsub class: map_alias_name_to_value map_alias_value_to_name_seen_hash alias_clash_hinted Commit: d0382a7f16322d92c8c71b82c42dc0503a225ca6 https://github.com/Perl/perl5/commit/d0382a7f16322d92c8c71b82c42dc0503a225ca6 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: rm xsub_map_interface_foo field Remove the following field from the ExtUtils::ParseXS class: xsub_map_interface_name_short_to_original and replace it with this new field in the ExtUtils::ParseXS::Node::xsub class: map_interface_name_short_to_original In addition, remove the 'map_short_orig' field from the Node::INTERFACE class - that was added by me earlier in this branch (initially unused) with the intent to become what 'map_interface_name_short_to_original' is now, but it turned out not to be suitable for this purpose, as the latter can accumulate data over multiple INTERFACE keywords. Commit: c7f8e671f717e51bc25071567eaac36230cf426a https://github.com/Perl/perl5/commit/c7f8e671f717e51bc25071567eaac36230cf426a Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: rm xsub_attributes field Remove the following field from the ExtUtils::ParseXS class: xsub_attributes and replace it with this new field in the ExtUtils::ParseXS::Node::xsub class: attributes Commit: 636339ed3dd38770cc7c2ca3c253726b641c36fe https://github.com/Perl/perl5/commit/636339ed3dd38770cc7c2ca3c253726b641c36fe Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: tweak some code comments and indents Make small tweaks to some of my recent work. Commit: f6ae738dfbb2f27bf3bb35c74b74389f4b1e158f https://github.com/Perl/perl5/commit/f6ae738dfbb2f27bf3bb35c74b74389f4b1e158f Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) 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: make OUTPUT: SETMAGIC per-CASE In code like: int foo(int a, int b) CASE: X OUTPUT: a SETMAGIC: DISABLE b CASE: Y OUTPUT: a SETMAGIC: DISABLE b when the caller's two args are updated with the final values of a and b, the first CASE calls SvSETMAGIC() after updating ST(0), but not after updating ST(1). This is as expected. However in the second CASE, the current setting of SETMAGIC (i.e disabled) from the first CASE is passed on and "inherited' by the second CASE: so in the second branch, magic isn't called on ST(0). This commit fixes that (i.e. calls SvSETMAGIC on ST(0) in the second CASE) by making the current SETMAGIC state per-xbody rather than per-xsub. This commit achieves that by: Remove the following field from the ExtUtils::ParseXS class: xsub_SETMAGIC_state and replace it with this new field in the ExtUtils::ParseXS::Node::xbody class: OUTPUT_SETMAGIC_state and adds 4 tests (the latter two of which failed before this commit). Commit: 01f156c7097327f35ebefe498ba8d6205838f067 https://github.com/Perl/perl5/commit/01f156c7097327f35ebefe498ba8d6205838f067 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: rm xsub_deferred_code_lines Remove the following field from the ExtUtils::ParseXS class: xsub_deferred_code_lines and replace it with this new field in the ExtUtils::ParseXS::Node::input_part class: deferred_code_lines This field contains initialisation lines which have been deferred to after any declarations emitted by INPUT and/or PREINIT lines. As such, it can be local to just the code generation phase (i.e. calling as_code()) during processing the input part of the xbody of an xsub - so store the field in the input_part node. Also, add input_part, init_part etc fields to the Node::xbody object. These are aliases to make access to its children easier - i.e. these were all already accessible as $xbody->{kids}{N}, but are now accessible as, e.g. $xbody->{input_part} too. Commit: 4f12368dbfea3f4e0dacdeb9e0e88383cb3d0aa0 https://github.com/Perl/perl5/commit/4f12368dbfea3f4e0dacdeb9e0e88383cb3d0aa0 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: reduce scope of targ_used field Move this field from Node::xbody to Node::output_part, as it's only used while generating the code for the output part of the xsub. No functional change. Commit: e41555ae9ff3867a3dba65d8fe9b3b92df5ff19f https://github.com/Perl/perl5/commit/e41555ae9ff3867a3dba65d8fe9b3b92df5ff19f Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: rm xsub_stack_was_reset field Remove the following field from the ExtUtils::ParseXS class: xsub_stack_was_reset and replace it with this new field in the ExtUtils::ParseXS::Node::output_part class: stack_was_reset Commit: c3dd275628639883af38d340d048bd171a40a79c https://github.com/Perl/perl5/commit/c3dd275628639883af38d340d048bd171a40a79c Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: rm xsub_interface_macro fields Remove the following fields from the ExtUtils::ParseXS class: xsub_interface_macro xsub_interface_macro_set and replace them with these new fields in the ExtUtils::ParseXS::Node::xsub class: interface_macro interface_macro_set There is also a slight change in the way these two fields are used. Formerly they were initialised to the default values "XSINTERFACE_FUNC" and "XSINTERFACE_FUNC_SET", then potentially changed by the INTERFACE_MACRO keyword, then the current values were used to emit the interface function pointer getting and setting code. Now, the values are initially undef, and the emitting code checks for defined-ness and if so uses the default value. This means that the logic for using default or overridden value is local to where that value is used rather than being hidden away elsewhere.No change in functionality though. Commit: 7fe85caf2ca851814d85985007683a50be6b1c34 https://github.com/Perl/perl5/commit/7fe85caf2ca851814d85985007683a50be6b1c34 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: remove misc xsub_foo fields Remove the following fields from the ExtUtils::ParseXS class: xsub_map_overload_name_to_seen xsub_prototype and replace them with these new fields in the ExtUtils::ParseXS::Node::xsub class: overload_name_seen prototype Commit: ff047b2a2ed8cc6c82d463dd08f233cad9fca42a https://github.com/Perl/perl5/commit/ff047b2a2ed8cc6c82d463dd08f233cad9fca42a Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: sort out SCOPE object fields This commit renames the ExtUtils::ParseXS class field xsub_SCOPE_enabled to file_SCOPE_enabled and adds a new field in the ExtUtils::ParseXS::Node::xsub class: SCOPE_enabled This is because SCOPE can be used either in file scope: SCOPE: ENABLE int foo(...) or in XSUB scope, int foo(...) SCOPE: ENABLE The file_SCOPE_enabled field records whether a SCOPE keyword has been encountered just before the XSUB, while the Node::xsub SCOPE_enabled field is initialised to the current value of file_SCOPE_enabled when XSUB parsing starts, and is updated if the SCOPE keyword is encountered within the XSUB. Commit: 47d33f74ecc44b3e69be06fc890f131b1ac8971f https://github.com/Perl/perl5/commit/47d33f74ecc44b3e69be06fc890f131b1ac8971f Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: refactor: avoid cur_xsub/xbody in as_code During the course of the refactoring in this branch, perl code has gradually been split between doing parsing in Node::FOO::parse() methods and code emitting in Node::FOO::as_code() methods (before, both were completely interleaved). How the current xsub and xbody nodes are tracked varies between those two types of methods: the as_code() methods pass them as explicit parameters, while the parse() methods rely on two 'global' fields within the ExtUtils::ParseXS object, cur_xsub and cur_xbody. However, some some as_code() methods were still relying on cur_xsub/xbody rather than the passed $xsub and $xbody params. This commit fixes that. At the moment it is mostly harmless, as each XSUB's top_level as_code() is called immediately after it's top-level parse(), so cur_xsub still points to the right XSUB. But that will change in future, so get it right now. The next commit will in fact explicitly undef cur_xsub/xbody immediately after parsing is finished. This commit includes a test for one edge case where the cur_xbody being wrong did make a difference. Commit: 581af29e298ef649b59acd0ba3e06b982c2c434e https://github.com/Perl/perl5/commit/581af29e298ef649b59acd0ba3e06b982c2c434e Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: undef cur_xsub/xbody after use Currently, the fields cur_xsub and cur_xbody of ExtUtils::ParseXS track the current xsub and body nodes during parsing. This commit undefs them immediately after use so that they can't be inadvertently used elsewhere. The fixups in the previous commit were all discovered by this undeffing. Commit: defbefc29b63ebfbf3e1b06fb32a0a2b3ffcf7fd https://github.com/Perl/perl5/commit/defbefc29b63ebfbf3e1b06fb32a0a2b3ffcf7fd Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: remove cur_xsub/xbody fields Currently all the Node::FOO::as_code() methods get passed two args, $xsub and xbody, to indicate the current Node::xsub and Node::xbody objects. Conversely, all the Node::FOO::parse() methods access the current two objects via two 'global' fields in the ExtUtils:;ParseXS object: cur_xsub cur_xbody This commit deletes these two fields and instead passes the objects as extra parameters to all the parse() methods. Less action-at-a-distance. Commit: a3f5e14e609dddda9be517859b649e7f7084cf46 https://github.com/Perl/perl5/commit/a3f5e14e609dddda9be517859b649e7f7084cf46 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: tweak some code comments Add comments about keywords which can be both inside or outside an XSUB. Commit: faffeb365adf53068b38e13dc452ba6c7cb77ac2 https://github.com/Perl/perl5/commit/faffeb365adf53068b38e13dc452ba6c7cb77ac2 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: delete param field from Params The Node::Params class has a 'params' field which holds a list of Node::Param objects. This class was one of the first Node classes to be created during my recent refactoring work, and at the time, Node subclasses didn't have a generic 'kids' field. They do now, so just store the list of Param objects of 'kids' of the Params object. Commit: d60dad82658d504674df1ec6c3e8bc0a2caf0b01 https://github.com/Perl/perl5/commit/d60dad82658d504674df1ec6c3e8bc0a2caf0b01 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add Node:IO_Param class Add a ExtUtils::ParseXS::Node::IO_Param class as a subclass of the existing ExtUtils::ParseXS::Node::Param class. Then Param objects will be used solely to hold the details of a parameter which have been extracted from an XSUB's signature, while IO_Param objects contain a copy of that info, but augmented with any further info gleaned from INPUT or OUTPUT lines. For example with void foo(a) int a OUTPUT: a Then the Param object for 'a' will look something like: { arg_num => 1 var => 'a', } while the corresponding IO_Param object will look something like: { arg_num => 1, var => 'a', type => 'int', in_input => 1, in_output => 1, .... } All the code-emitting methods have been moved from Param to IO_Param, and the as_code() method has been renamed to as_input_code(), to better match the naming convention of the existing as_output_code() method: an IO_Param can generate code both to declare/initialise a var, and to update/return a var. Commit: 6a62e67befe6071290f7a94a106106eae11adbbb https://github.com/Perl/perl5/commit/6a62e67befe6071290f7a94a106106eae11adbbb Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: refactor: set default alias at parse time If the list of aliases for an XSUB doesn't include the XSUB's main name, an extra alias entry is added, mapping the main name to ix 0. Move this setting from the code generation phase to the end of the parsing phase, because the AST should really be complete by the end of parsing. Also add a test for this behaviour. Shouldn't affect hat code is generated. Commit: 36bda2a93c8626c6795a2cd34705045c73be3a7f https://github.com/Perl/perl5/commit/36bda2a93c8626c6795a2cd34705045c73be3a7f Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: remove print_section() This method is no longer used anywhere Commit: 79c833f3163c5119494438b1effdc6e2ae8f71b9 https://github.com/Perl/perl5/commit/79c833f3163c5119494438b1effdc6e2ae8f71b9 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: turn param parsing into a sub Currently the parsing of an XSUB's signature, and the parsing of the individual comma-separated items within that signature, are done in the same function, Params->parse(). This commit is the first of three which will extract out the latter into a separate Param->parse() method. For now, the per-param code is kept in-place (to make the diff easier to understand), but is wrapped within an immediately-called anon sub, in preparation to be moved. So before, the code was (very simplified): for (split /,/, $params_text) { ... parse type, name, init etc ... next if can't parse; my $param = Param->new(var = $var, type => $type, ...); push @{$params->{kids}}, $param; } After this commit, it looks more like: for (split /,/, $params_text) { my $param = Param->new(); sub { my $param = shift; ... ... parse type, name, init etc ... return if can't parse; $param->{var} = $var; ... return 1; }->{$param, ...) or next; push @{$params->{kids}}, $param; } Note that the inner sub leaves pushing the new param, updating the names hash and setting the arg_num to the caller. In theory there are no functional changes, except that when a synthetic RETVAL is being kept (but its position within kids moved), we now keep the Param hash and update its contents, rather than replace it with a new hash. This shouldn't make any difference. Commit: 83daa9953d67c1d0ece843ecc55fe281603670bd https://github.com/Perl/perl5/commit/83daa9953d67c1d0ece843ecc55fe281603670bd Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add Param->parse() method. This commit just moves a block of code of the form sub {...}->() into its own named sub. There are no changes to the moved lines of code apart from indentation. This is the second of three commits to create the parse() method. The next commit will do any final tidying up. Commit: af37e313a05de95b8217503c9e838852ed9e57b7 https://github.com/Perl/perl5/commit/af37e313a05de95b8217503c9e838852ed9e57b7 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: clean-up Param->parse() method This is the third of three commits to create the parse() method. Mainly do s/$param/$self/g, and add a call to set file/line number foer the object. Commit: 233dbabea93adffa24ca8d8cc779b82aaf2d669d https://github.com/Perl/perl5/commit/233dbabea93adffa24ca8d8cc779b82aaf2d669d Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: refactor: IO_Param::lookup_input_typemap Move all the code out of ExtUtils::ParseXS::Node::IO_Param::as_input_code() which is responsible for looking up the template initialisation code in the typemap (or elsewhere) and put it in it's own method, lookup_input_typemap(). As well as splitting a 300-line method into two approx 150-line methods, this will also allow us shortly to move the template lookup to earlier, at parse time rather than code-emitting time. Also add some more tests for the length(foo) pseudo-parameter, which I broke while working on this commit, and then noticed it was under-tested. Commit: 34bc5e96d66dc144269f70458ef2493f71bd676f https://github.com/Perl/perl5/commit/34bc5e96d66dc144269f70458ef2493f71bd676f Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: IO_Param::lookup_output_typemap Move all the code out of ExtUtils::ParseXS::Node::IO_Param::as_output_code() which is responsible for looking up the template output code in the typemap (or elsewhere) and put it in it's own method, lookup_output_typemap(). As well as splitting a 490-line method into two 200 and 340-line methods, this will also allow us shortly to move the template lookup to earlier, at parse time rather than code-emitting time. It may also be possible at some point to merge the two methods added by these last two commits, lookup_intput_typemap and lookup_output_typemap, into a single method, since they share a lot of common code. Commit: a249d0335c3638eb8e184ad78a46c121f1374410 https://github.com/Perl/perl5/commit/a249d0335c3638eb8e184ad78a46c121f1374410 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: refactor: set XSRETURN_count_* earlier Previously these two values were set at the end of parsing an XSUB: XSRETURN_count_basic XSRETURN_count_extra They represent whether a RETVAL SV will be returned by the XSUB, and how many extra SVs are returned due to parameters declared as OUTLIST. This commit sets them earlier, as in particular, the next commit will need to access XSRETURN_count_basic earlier. XSRETURN_count_extra is now set right after parsing the XSUB's declaration, as its value can't change after then. XSRETURN_count_basic is now set after parsing the output part of the each body of the XSUB (an XSUB can have a body per CASE). Its value *aught* to be consistent across all bodies, but it's possible for the CODE_sets_ST0 hack (which looks for code like like 'ST(0) = ...' in any CODE: block) to vary across bodies; so this commit also adds a new warning and test for that. Commit: 8ea5caf559a5e5625f228f11c6e9aea603e50eb2 https://github.com/Perl/perl5/commit/8ea5caf559a5e5625f228f11c6e9aea603e50eb2 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: lookup typemaps at parse time The last few commits have moved the looking-up and processing of typemap entries (but not the evalling) for parameters from Param::as_input_code() and Param::as_output_code() into their own subs, lookup_input_typemap() and lookup_output_typemap(). This commit takes that one step further, and makes those new subs be called at parse time, rather than at code-generation time. This is needed because in principle, XSUB ASTs should be completely self-contained, and the code they emit shouldn't vary depending on when their top-level as_code() methods are called. But via the TYPEMAP: <<EOF mechanism, its possible for the typemap to change between XSUBs. This commit does this in a very crude way. Formerly, at code-emitting time, as_input_code() etc would do: my ($foo, $bar, ...) = lookup_input_typemap(...); Now, the parsing code does $self->{input_typemap_vals} = [ lookup_input_typemap(...) ]; and as_input_code() etc does: my ($foo, $bar, ...) = @{$self->{input_typemap_vals}}; Note that there are both output_typemap_vals and output_typemap_vals_outlist fields, as it's possible for the same parameter to be used both for updating the original arg (OUTPUT) and for returning the current value as a new SV (OUTLIST). So potentially we save the results of *two* calls to lookup_output_typemap() for each parameter. Commit: e19347876c43fe6a8a7f6ecb010192d345c28bd6 https://github.com/Perl/perl5/commit/e19347876c43fe6a8a7f6ecb010192d345c28bd6 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: clean up error messages and tests Rationalise warning and error messages which appear in Node.pm: - always prefix with Warning: / Error: / Internal error: - lower-case the first letter following Error: etc - fix grammar - ensure full test coverage (except 'Internal error', which shouldn't be reproducible). Commit: 6d97eef0d48d8cc9e03efe3df6d8fd5c04d5b35a https://github.com/Perl/perl5/commit/6d97eef0d48d8cc9e03efe3df6d8fd5c04d5b35a Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: always store kid nodes in kids Some node types have fields to point to particular children. Make these kids also be in the generic @{$self->{kids}} array. That way, hypothetical generic tree-walking code will be able to access the whole tree just by following @{$self->{kids}}, without needing to know for example that the xsub_decl Node type has a child pointed to by $self->{return_type}. Commit: 6b66e8a44c3e0048689843f478db5bf758cee18e https://github.com/Perl/perl5/commit/6b66e8a44c3e0048689843f478db5bf758cee18e Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: tidy up Node.pm Do a general tidy-up of this src file: white space, plus wrap long lines and strings. Commit: 06d92a86ff3bc8f20e942a361df9fa1900a3221e https://github.com/Perl/perl5/commit/06d92a86ff3bc8f20e942a361df9fa1900a3221e Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: give $build_subclass parent arg For aesthetic reasons, give the $build_subclass sub an extra first arg which must be the string 'parent'. Then change invocations from: BEGIN { $build_subclass->('Foo', # parent 'field1', # ... ... } to BEGIN { $build_subclass->(parent => 'Foo', 'field1', # ... ... } Commit: 1e1c19551eb703bb7d778a266aecf3bd240f6971 https://github.com/Perl/perl5/commit/1e1c19551eb703bb7d778a266aecf3bd240f6971 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: fixup some code comments Commit: 9f5a17fffe39530915af599dd9977aa86bafb3ab https://github.com/Perl/perl5/commit/9f5a17fffe39530915af599dd9977aa86bafb3ab Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: update field code comments Update the code comments in calls to $build_subclass->() to indicate more consistently the 'type' of each field being declared. Commit: 93b7d08d5b7de331275b5191791c0213f94b78ef https://github.com/Perl/perl5/commit/93b7d08d5b7de331275b5191791c0213f94b78ef Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: rename some fields to ioparam In the INPUT_line and OUTPUT_line subclasses, rename the 'param' field to 'ioparam', to better reflect that it holds an IO_Param object rather than a Param object. Commit: e40d5786f84297b3123f1d33e3f0956cd32dbfd2 https://github.com/Perl/perl5/commit/e40d5786f84297b3123f1d33e3f0956cd32dbfd2 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add basic POD for Node.pm Commit: 91bc1138c0dc826364fe881f09e921183d15a7c8 https://github.com/Perl/perl5/commit/91bc1138c0dc826364fe881f09e921183d15a7c8 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: fix for 5.8.9 builds The work in this branch broke the parser under 5.8.9. Fix it, by not trying to autovivify an undef object pointer (which under 5.8.9 is a pseudo-hash thingy and generally behaves weirdly). The attempt to autovivify an undef $xsub was always wrong, but harmless: the value wasn't needed and was soon discarded. But under 5.8.9, it became a runtime error. Commit: 60b797cb0745b5544b348f53d1eee61dbdbe8100 https://github.com/Perl/perl5/commit/60b797cb0745b5544b348f53d1eee61dbdbe8100 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: fix trivial indentation issue whitespace-only Commit: e32c641bfc0f0951483df4697000ee26cedd66fb https://github.com/Perl/perl5/commit/e32c641bfc0f0951483df4697000ee26cedd66fb Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: make build_subclass() simpler The $build_subclass->() method called in BEGIN by subclasses to create a subclass, has as the first two parameters: a key which must be 'parent', and the suffix of the parent class name. If the latter is '', 'ExtUtils::ParseXS::Node' is assumed. This commit makes these two args optional; if not present, it acts like ('parent' => '') used to. In addition, the 'parent' arg has been renamed to '-parent' to distinguish it from a possible field name. Based on a suggestion from Tony C. Commit: 826c0ff7dad990da6bd5069a799a0a9c62a49dab https://github.com/Perl/perl5/commit/826c0ff7dad990da6bd5069a799a0a9c62a49dab Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: disallow const on non-C++ methods It's possible for an XSUB's name to include a class, in which case the XS parser will treat it as a C++ method and declare a THIS variable. It's also possible for an XSUB to have a postfix 'const' modifier to mimic similar in C++ method declarations. For example this XS declaration: void X::Y::foo(...) const causes this C++ variable to be declared: const X__Y * THIS = ...; The 'const' is supposed to be an optional modifier to a C++ XSUB but the parser currently allows it it on plain XSUBs, e.g. void foo(...) const which leads to 'uninit var' warnings during parsing, and to badly-formed C code or weird errors about missing typemap entries. This commit makes it an error to have 'const' on a non-C++ XSUB. Commit: 076b428a75d56f19bbf74e3626facadc6d89f0e8 https://github.com/Perl/perl5/commit/076b428a75d56f19bbf74e3626facadc6d89f0e8 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: split out C++ class and const An XSUB can be a C++ method if its name includes a class; it can also have an optional 'const' postfix modifier; e.g.: int X::Y::foo(...) const Before this commit, the class of the XSUB and the const modifier were combined into a single string that was used to declare the type of the THIS variable, e.g. const X__Y THIS = ...; Unfortunately this string (stored as $xsub->{xsub_decl}{class}) is also used to generate an autocall line, which could lead to nonsense such as: RETVAL = new const X::Y(); This commit splits the state into two fields during parsing, then these two fields are used later during code generation to Do the Right Thing. So before, the XSUB declaration above would, at parse time, have created an xsub_decl node which looked like: $xsub->{xsub_decl}{class} = 'const X::Y'; and which now looks like: $xsub->{xsub_decl}{class} = 'X::Y'; $xsub->{xsub_decl}{is_const} = TRUE; The three tests added by this commit all failed before this fix. Commit: e2cc3dbef60f33ddeb1c2959c3645c904b153e1b https://github.com/Perl/perl5/commit/e2cc3dbef60f33ddeb1c2959c3645c904b153e1b Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M ext/PerlIO-via/via.pm M ext/PerlIO-via/via.xs Log Message: ----------- PerlIO-via: fix PROTOTYPES typo This line: PROTOTYPES: ENABLE; is actually an error: such declarations shouldn't end with a semicolon. However, the XS parser has historically treated anything it doesn't recognise following the PROTOTYPES: keyword as if was 'DISABLE'. So this commit changes it to 'DISABLE'. This should make no functional difference, but it will avoid this module starting to warn when ParseXS is updated shortly to be stricter. Commit: 228706080af8a89403b6e1df8737837650ede6ed https://github.com/Perl/perl5/commit/228706080af8a89403b6e1df8737837650ede6ed Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: make most ENABLE keywords stricter These four keywords are supposed to have only ENABLE or DISABLE as their value: EXPORT_XSUB_SYMBOLS: SCOPE: VERSIONCHECK: PROTOTYPES: It turns out that the XS parser is very lax and allows all sorts of rubbish as the keyword's value. For example all these are valid, and the first of them was originally interpreted as *DISABLE*, due to case-insensitive validation, but case-sensitive value interpretation: KEYWORD: Enable KEYWORD: ENABLE; KEYWORD: ENABLE # comment KEYWORD: ENABLE the quick brown fox An earlier commit in this branch, in the course of refactoring, silently made the value matching to be case insensitive for *all* keywords (originally it was only CI for SCOPE). So originally, PROTOTYPES: Enable actually disabled prototypes; now it enables them. This commit and the next will restore the original behaviour and/or make things stricter. This commit makes all such keywords stricter, apart from PROTOTYPES, which is much more widely used (often incorrectly) and will require more careful backwards-compatibility handling. It's behaviour is left untouched by this commit; the next commit will update it. For the first three keywords, this commit makes the only acceptable values to match be /^(ENABLE|DISABLE)\s*$/. Commit: cfee0243fc75164d70d6ba193801517b96896355 https://github.com/Perl/perl5/commit/cfee0243fc75164d70d6ba193801517b96896355 Author: David Mitchell <da...@iabyn.com> Date: 2025-05-26 (Mon, 26 May 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: handle PROTOTYPES keyword. See the previous commit for a general discussion on the problems with ENABLE/DISABLE-valued keywords. This commit specifically updated how the PROTOTYPES: keyword is handled. Compared with the previous production release, PROTOTYPES now: is stricter in validation: it still accepts ENABLE or DISABLE in a case-insensitive matter, but now treats any trailing text as an error, apart from possibly a 'D' or ':'. So Anything apart these forms are compile-time errors now: ENABLE enable Enabled DISABLE; DisablED; etc For backwards compatibility it still treats anything apart from /^ENABLE/ as false; so all except the first example above are treated as DISABLE. But now, it warns if the keyword has been accepted but isn't one of ENABLE/DISABLE. Compare: https://github.com/Perl/perl5/compare/5d95e1601d73...cfee0243fc75 To unsubscribe from these emails, change your notification settings at https://github.com/Perl/perl5/settings/notifications