Branch: refs/heads/blead Home: https://github.com/Perl/perl5 Commit: 75a0e547bf13d0943f017dcdcf5ed922883e339c https://github.com/Perl/perl5/commit/75a0e547bf13d0943f017dcdcf5ed922883e339c Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 539712ed7656d3aab8c228046d7c3ab6c01adff3 https://github.com/Perl/perl5/commit/539712ed7656d3aab8c228046d7c3ab6c01adff3 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 2e0a01d05bae7e19fde47bd405bc376ac8eb7195 https://github.com/Perl/perl5/commit/2e0a01d05bae7e19fde47bd405bc376ac8eb7195 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 7b75783397dc8adea7cd3be5af3de86099ed9eb9 https://github.com/Perl/perl5/commit/7b75783397dc8adea7cd3be5af3de86099ed9eb9 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 620bd2ff833b89fccb24d912a3a63f94f814b313 https://github.com/Perl/perl5/commit/620bd2ff833b89fccb24d912a3a63f94f814b313 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: be4686394552aacd1807ddacf3c466fee19c3134 https://github.com/Perl/perl5/commit/be4686394552aacd1807ddacf3c466fee19c3134 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: aa0d7310442678bcfe46eb389b309118a549245e https://github.com/Perl/perl5/commit/aa0d7310442678bcfe46eb389b309118a549245e Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 6d428734a44e37155f63fb5f9a2d06641afdb3ef https://github.com/Perl/perl5/commit/6d428734a44e37155f63fb5f9a2d06641afdb3ef Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: ad1a0513173710b35aab29f81337ae173caeaaf5 https://github.com/Perl/perl5/commit/ad1a0513173710b35aab29f81337ae173caeaaf5 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: a14f63eba0c2adf6f4b3575a3a582038f8ec915b https://github.com/Perl/perl5/commit/a14f63eba0c2adf6f4b3575a3a582038f8ec915b Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: dec364da1e13c1ee56cfcc9842e6b59bb1e43976 https://github.com/Perl/perl5/commit/dec364da1e13c1ee56cfcc9842e6b59bb1e43976 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 86f56624336d780b9dd8635d63efe97674b54fe5 https://github.com/Perl/perl5/commit/86f56624336d780b9dd8635d63efe97674b54fe5 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 401034892b7c45158bb964152de50e55e853346c https://github.com/Perl/perl5/commit/401034892b7c45158bb964152de50e55e853346c Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: bcc9ef88885ff2dc36c95c76032e958758c9253c https://github.com/Perl/perl5/commit/bcc9ef88885ff2dc36c95c76032e958758c9253c Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 218f29d3c51ef82159767f202677c2d17af03fe1 https://github.com/Perl/perl5/commit/218f29d3c51ef82159767f202677c2d17af03fe1 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: e28e5ae8c35e86aaf67667a148facfe9c924cfae https://github.com/Perl/perl5/commit/e28e5ae8c35e86aaf67667a148facfe9c924cfae Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 85516d97af179021db4d302b7c0352590bf0dccd https://github.com/Perl/perl5/commit/85516d97af179021db4d302b7c0352590bf0dccd Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 30b0145d62ef6eab285d57cdb48f5da23bfddbcd https://github.com/Perl/perl5/commit/30b0145d62ef6eab285d57cdb48f5da23bfddbcd Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: fc2dda06f226b2233891d303bc6d497dbef284e0 https://github.com/Perl/perl5/commit/fc2dda06f226b2233891d303bc6d497dbef284e0 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 8784182370375cdbd07d8bd2c7af65e6da594ed0 https://github.com/Perl/perl5/commit/8784182370375cdbd07d8bd2c7af65e6da594ed0 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: a9646798a15eb23f4da20a2c5bb432222f2f1ef6 https://github.com/Perl/perl5/commit/a9646798a15eb23f4da20a2c5bb432222f2f1ef6 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: aeff664984d7138bf6fdb69a55d9e9cbcc83f45b https://github.com/Perl/perl5/commit/aeff664984d7138bf6fdb69a55d9e9cbcc83f45b Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: e58b4a564bbcd7671f877c748c778c96b3e5da79 https://github.com/Perl/perl5/commit/e58b4a564bbcd7671f877c748c778c96b3e5da79 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 5047469c915f41bf9f692d0127a6e429f844b2a3 https://github.com/Perl/perl5/commit/5047469c915f41bf9f692d0127a6e429f844b2a3 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: b0fa5e33b8fdeede207ea2c89094710ac9b143a7 https://github.com/Perl/perl5/commit/b0fa5e33b8fdeede207ea2c89094710ac9b143a7 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 26909c161df0b68b4579a74fb0792c78880c401d https://github.com/Perl/perl5/commit/26909c161df0b68b4579a74fb0792c78880c401d Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: bf53b82527ec46a48b9d2b0f5a86721a2fb63fc8 https://github.com/Perl/perl5/commit/bf53b82527ec46a48b9d2b0f5a86721a2fb63fc8 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 461717604bdc9163e211f7ddad0943c7de161db7 https://github.com/Perl/perl5/commit/461717604bdc9163e211f7ddad0943c7de161db7 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: b22968a1a54dd8302a7b19faf8ae29306e7a8a9e https://github.com/Perl/perl5/commit/b22968a1a54dd8302a7b19faf8ae29306e7a8a9e Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: f68429004380832a6539a90a836b3a5f23799f40 https://github.com/Perl/perl5/commit/f68429004380832a6539a90a836b3a5f23799f40 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 45e88382939f314d961dfa61d954edbac7263973 https://github.com/Perl/perl5/commit/45e88382939f314d961dfa61d954edbac7263973 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 5b2f3e52fb11f7d5edc8680c351081b34a5199ec https://github.com/Perl/perl5/commit/5b2f3e52fb11f7d5edc8680c351081b34a5199ec Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 2aed8f13a6916730c3b2b3deb528f963c920b189 https://github.com/Perl/perl5/commit/2aed8f13a6916730c3b2b3deb528f963c920b189 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: aeffad6ba7d6a4dfebc68c7cc9ff108bf0bacd19 https://github.com/Perl/perl5/commit/aeffad6ba7d6a4dfebc68c7cc9ff108bf0bacd19 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: ddb8667b9fc77558cc4793f05be1db3b7e1f1f21 https://github.com/Perl/perl5/commit/ddb8667b9fc77558cc4793f05be1db3b7e1f1f21 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 5a8b3ca2bdcb85963f4c1d1219dce093362492e3 https://github.com/Perl/perl5/commit/5a8b3ca2bdcb85963f4c1d1219dce093362492e3 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: bc303ac972806a821e744335b0d3350493391afa https://github.com/Perl/perl5/commit/bc303ac972806a821e744335b0d3350493391afa Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 8c45a6bf049555a607d5b81ef456ed2829f7242f https://github.com/Perl/perl5/commit/8c45a6bf049555a607d5b81ef456ed2829f7242f Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 3607187dd0fa6ae605d7938b8d5b7350a640da9d https://github.com/Perl/perl5/commit/3607187dd0fa6ae605d7938b8d5b7350a640da9d Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: b68b9300c2339c7a1f1cdb60fde8da2ae518628e https://github.com/Perl/perl5/commit/b68b9300c2339c7a1f1cdb60fde8da2ae518628e Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 7e3d649e4a41376de29fb9ced56221e3ace1c22b https://github.com/Perl/perl5/commit/7e3d649e4a41376de29fb9ced56221e3ace1c22b Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 41c5d829c3f41f0921904932d573dbe0f7a9f704 https://github.com/Perl/perl5/commit/41c5d829c3f41f0921904932d573dbe0f7a9f704 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: d050d3f958c811475ff49f82e175b415cc1b929b https://github.com/Perl/perl5/commit/d050d3f958c811475ff49f82e175b415cc1b929b Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 1c5e12248515063689cde5762813360aa74bd800 https://github.com/Perl/perl5/commit/1c5e12248515063689cde5762813360aa74bd800 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 3ca4844742954b8313d261acdcb04d46f3016595 https://github.com/Perl/perl5/commit/3ca4844742954b8313d261acdcb04d46f3016595 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 4841c28312ef753d6fe1fc4c22961b856a26f106 https://github.com/Perl/perl5/commit/4841c28312ef753d6fe1fc4c22961b856a26f106 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 3658205a6f13b3741d8d9aee6a5e99e372677930 https://github.com/Perl/perl5/commit/3658205a6f13b3741d8d9aee6a5e99e372677930 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: acb827aaf74fa4268436fdb475b437724c26143d https://github.com/Perl/perl5/commit/acb827aaf74fa4268436fdb475b437724c26143d Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 6f72655b7c3dbd4c66a3cdefde8a0859a09956aa https://github.com/Perl/perl5/commit/6f72655b7c3dbd4c66a3cdefde8a0859a09956aa Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 97fd7672b6b0929508775d86b126b58337c25e0c https://github.com/Perl/perl5/commit/97fd7672b6b0929508775d86b126b58337c25e0c Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 927f43a58740ceffd2af265032a59dff9e768ae9 https://github.com/Perl/perl5/commit/927f43a58740ceffd2af265032a59dff9e768ae9 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 934abfb8de75540d23ce06313ef63427bd260094 https://github.com/Perl/perl5/commit/934abfb8de75540d23ce06313ef63427bd260094 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: ff1886d0d861b1735e05f53f53577a7e6fb601dd https://github.com/Perl/perl5/commit/ff1886d0d861b1735e05f53f53577a7e6fb601dd Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 457f886c9bb81b8325dcb7144611032905187a09 https://github.com/Perl/perl5/commit/457f886c9bb81b8325dcb7144611032905187a09 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: cce143e54340e8448304cdb92bbf7e6c18a2ff01 https://github.com/Perl/perl5/commit/cce143e54340e8448304cdb92bbf7e6c18a2ff01 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 3cd957554fcf030ed4aec131bfdfb9ab1f47eb72 https://github.com/Perl/perl5/commit/3cd957554fcf030ed4aec131bfdfb9ab1f47eb72 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: b4cc232ee515456e10e2c9fdec5ce73ec614161d https://github.com/Perl/perl5/commit/b4cc232ee515456e10e2c9fdec5ce73ec614161d Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 044ef7880f183c70b4778f75ad837373d6643ba3 https://github.com/Perl/perl5/commit/044ef7880f183c70b4778f75ad837373d6643ba3 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 00db4177226343d1d63402408735275e30a44991 https://github.com/Perl/perl5/commit/00db4177226343d1d63402408735275e30a44991 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 6e9bd6a9e2c113e528d4c28298f709bbd29d00e8 https://github.com/Perl/perl5/commit/6e9bd6a9e2c113e528d4c28298f709bbd29d00e8 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: eb65eb773fa748499f86f7e4f3d37efdf1390a9f https://github.com/Perl/perl5/commit/eb65eb773fa748499f86f7e4f3d37efdf1390a9f Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 8fd2c457c8bf7c9d437b5f959fc6c0a4bfe249a9 https://github.com/Perl/perl5/commit/8fd2c457c8bf7c9d437b5f959fc6c0a4bfe249a9 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 40751169315ed1295b30ccfb1c982761e8b3c9e1 https://github.com/Perl/perl5/commit/40751169315ed1295b30ccfb1c982761e8b3c9e1 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 51097b84a6c743dc5315993468f2d10bef57b79b https://github.com/Perl/perl5/commit/51097b84a6c743dc5315993468f2d10bef57b79b Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: d3e1d56412992086b76e9028969d022c8502b5a5 https://github.com/Perl/perl5/commit/d3e1d56412992086b76e9028969d022c8502b5a5 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: a813c2a64183c3dd625abaf7780b9ad9c0070e86 https://github.com/Perl/perl5/commit/a813c2a64183c3dd625abaf7780b9ad9c0070e86 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: e256ad9fcfad28031a7497c0afd9bec528d595d2 https://github.com/Perl/perl5/commit/e256ad9fcfad28031a7497c0afd9bec528d595d2 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: b942a7460aadd6ccc34d6398bf472c34651914e1 https://github.com/Perl/perl5/commit/b942a7460aadd6ccc34d6398bf472c34651914e1 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: fe4f332e4a5e4becb7a11b7fcc7c113e80734e14 https://github.com/Perl/perl5/commit/fe4f332e4a5e4becb7a11b7fcc7c113e80734e14 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: c21eba3988a93be09094550f6d5bf2e7f7b46ffa https://github.com/Perl/perl5/commit/c21eba3988a93be09094550f6d5bf2e7f7b46ffa Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: bd13b83198fc9b12df5ea8ff8128bc4222cfa73c https://github.com/Perl/perl5/commit/bd13b83198fc9b12df5ea8ff8128bc4222cfa73c Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 27c9b9159b76174f150f17a41faffb02202be155 https://github.com/Perl/perl5/commit/27c9b9159b76174f150f17a41faffb02202be155 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: reindent xsub_decl::parse() whitespace-only Commit: e3f0f1330e5453d49b78847668953ba499e117a6 https://github.com/Perl/perl5/commit/e3f0f1330e5453d49b78847668953ba499e117a6 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: f0ae3835295eeef8f651501fef38676d13ea46d9 https://github.com/Perl/perl5/commit/f0ae3835295eeef8f651501fef38676d13ea46d9 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: e64f8ab03a5d33393bae63ba774529a48c2736c2 https://github.com/Perl/perl5/commit/e64f8ab03a5d33393bae63ba774529a48c2736c2 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 681a31c3912873f005a363f6dafac51204f3eb6b https://github.com/Perl/perl5/commit/681a31c3912873f005a363f6dafac51204f3eb6b Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 07d2d98e4616ac6cbf598609e684741fda455d82 https://github.com/Perl/perl5/commit/07d2d98e4616ac6cbf598609e684741fda455d82 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 65a9a0bbbccf08895c87c768a489e124ed18c50c https://github.com/Perl/perl5/commit/65a9a0bbbccf08895c87c768a489e124ed18c50c Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor; fix a couple of comments Commit: bbe4307a039b9478266f44c5d8be3905760a597b https://github.com/Perl/perl5/commit/bbe4307a039b9478266f44c5d8be3905760a597b Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 25655357ed74fe29c9d6a5483f1fd41bf4b88c46 https://github.com/Perl/perl5/commit/25655357ed74fe29c9d6a5483f1fd41bf4b88c46 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 6161527aed8097f3ccaa1b7269478852bcdaa9d0 https://github.com/Perl/perl5/commit/6161527aed8097f3ccaa1b7269478852bcdaa9d0 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 91384995530c35299462a432de43a4c773e2bd6e https://github.com/Perl/perl5/commit/91384995530c35299462a432de43a4c773e2bd6e Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 8d958f050339d0cdee95fb8f96cdbe22bce15581 https://github.com/Perl/perl5/commit/8d958f050339d0cdee95fb8f96cdbe22bce15581 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 92e62c32ad0365acd26947f2fcfb1d7429c06a4f https://github.com/Perl/perl5/commit/92e62c32ad0365acd26947f2fcfb1d7429c06a4f Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 64bb5c50b8697b2fe60d6d1ce54bbea3661330d5 https://github.com/Perl/perl5/commit/64bb5c50b8697b2fe60d6d1ce54bbea3661330d5 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: d9b6bb2f67d2bbbd4aced4eff755912db7a5bbb6 https://github.com/Perl/perl5/commit/d9b6bb2f67d2bbbd4aced4eff755912db7a5bbb6 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 99104f3a3ed3d7dc0cc4da0bc34947bb52aba6dc https://github.com/Perl/perl5/commit/99104f3a3ed3d7dc0cc4da0bc34947bb52aba6dc Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 2025) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: add another CASE test Test CASE with unconditional else. Commit: ab0eab9f1a09ab8f7a2d7e1c8bfa0e3387cc35f8 https://github.com/Perl/perl5/commit/ab0eab9f1a09ab8f7a2d7e1c8bfa0e3387cc35f8 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: bc069d8566e7eb17c4e3fab9711a2bd5bb48c1fe https://github.com/Perl/perl5/commit/bc069d8566e7eb17c4e3fab9711a2bd5bb48c1fe Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 55313588c37d521efca0ff8baca8cc684fc5e172 https://github.com/Perl/perl5/commit/55313588c37d521efca0ff8baca8cc684fc5e172 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 1c9bc7744b9707baf43d2fe521c2c0122237d1c3 https://github.com/Perl/perl5/commit/1c9bc7744b9707baf43d2fe521c2c0122237d1c3 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 910b2f2ec605c3ae579588d1e21405814020e523 https://github.com/Perl/perl5/commit/910b2f2ec605c3ae579588d1e21405814020e523 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 88b3d99259d1ade362c36dd23e9563983a309d0a https://github.com/Perl/perl5/commit/88b3d99259d1ade362c36dd23e9563983a309d0a Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 288e01cbd58e358205ec53c895728b1b54325e91 https://github.com/Perl/perl5/commit/288e01cbd58e358205ec53c895728b1b54325e91 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 9208d941bc0f246f108455f13a8496fac37ca0f9 https://github.com/Perl/perl5/commit/9208d941bc0f246f108455f13a8496fac37ca0f9 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: cca682c3870f04d4e4a991077be6c648d6da85cf https://github.com/Perl/perl5/commit/cca682c3870f04d4e4a991077be6c648d6da85cf Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: a94e302dc803819b75557a24bdc3ec2ca8f2102b https://github.com/Perl/perl5/commit/a94e302dc803819b75557a24bdc3ec2ca8f2102b Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 6a03ec92885f2d075c38e16c74a5a33e6a2c6986 https://github.com/Perl/perl5/commit/6a03ec92885f2d075c38e16c74a5a33e6a2c6986 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 93f966c96c236fa9968b21997d3c222df94c1eaa https://github.com/Perl/perl5/commit/93f966c96c236fa9968b21997d3c222df94c1eaa Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: a5414f680dd8812875ca64cbca43845e2a0a0fc4 https://github.com/Perl/perl5/commit/a5414f680dd8812875ca64cbca43845e2a0a0fc4 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 1f57c59bea3e2683745a2c902d411c38ff83ca50 https://github.com/Perl/perl5/commit/1f57c59bea3e2683745a2c902d411c38ff83ca50 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 92d5280127cca31e6c3a8e2fa015c007378f9b67 https://github.com/Perl/perl5/commit/92d5280127cca31e6c3a8e2fa015c007378f9b67 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: d199aec830ef05d16a6ff7191bb0e93cf5e20535 https://github.com/Perl/perl5/commit/d199aec830ef05d16a6ff7191bb0e93cf5e20535 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 4aa948d810ffa39bdbffd966c130ee766e5272fc https://github.com/Perl/perl5/commit/4aa948d810ffa39bdbffd966c130ee766e5272fc Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: f6d84f254fe86e0b7dc5afc33d82b76fe3188b69 https://github.com/Perl/perl5/commit/f6d84f254fe86e0b7dc5afc33d82b76fe3188b69 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: dbe10d20eaace7a1397f40f607699a410e68b9b9 https://github.com/Perl/perl5/commit/dbe10d20eaace7a1397f40f607699a410e68b9b9 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 7a8b60e71ecf72b32e2d6b913a4fa1c41205da03 https://github.com/Perl/perl5/commit/7a8b60e71ecf72b32e2d6b913a4fa1c41205da03 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 817c7a5ad2e241757679ca151cde5fe903eb5f5d https://github.com/Perl/perl5/commit/817c7a5ad2e241757679ca151cde5fe903eb5f5d Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 8da1856cbbea0e58599dbd2dd016cea2d7643f92 https://github.com/Perl/perl5/commit/8da1856cbbea0e58599dbd2dd016cea2d7643f92 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 8b6eea697ff318549ae3ecc579ecc267e76bf268 https://github.com/Perl/perl5/commit/8b6eea697ff318549ae3ecc579ecc267e76bf268 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 8627c43c7b896b20567f11d04190e0d3fb7360fc https://github.com/Perl/perl5/commit/8627c43c7b896b20567f11d04190e0d3fb7360fc Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: d663961b75fe542c80deceacd0ad50709a9efe98 https://github.com/Perl/perl5/commit/d663961b75fe542c80deceacd0ad50709a9efe98 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: f775bec555eaa8a1dc4a6d92bef3665dc4e4d85d https://github.com/Perl/perl5/commit/f775bec555eaa8a1dc4a6d92bef3665dc4e4d85d Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 7559ea2195608d8c83b3d95fbee92b0f7efbe0d2 https://github.com/Perl/perl5/commit/7559ea2195608d8c83b3d95fbee92b0f7efbe0d2 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 8dec29efc1ccd6f21412a6e711c034b247d9cbcd https://github.com/Perl/perl5/commit/8dec29efc1ccd6f21412a6e711c034b247d9cbcd Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: b25f1d324b7114c791836b96975d6002499c5ecf https://github.com/Perl/perl5/commit/b25f1d324b7114c791836b96975d6002499c5ecf Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: bb670b14bda356ddd7655c437f2cb576eb08966e https://github.com/Perl/perl5/commit/bb670b14bda356ddd7655c437f2cb576eb08966e Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: c07b5e59a7de643d0a983f01cedfdd33ba1e7cfe https://github.com/Perl/perl5/commit/c07b5e59a7de643d0a983f01cedfdd33ba1e7cfe Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 1be2f76919a1f49267bed5d79ffffdf6697f7794 https://github.com/Perl/perl5/commit/1be2f76919a1f49267bed5d79ffffdf6697f7794 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 0f55cf9ab551abb447adb9791c1a69f058734f24 https://github.com/Perl/perl5/commit/0f55cf9ab551abb447adb9791c1a69f058734f24 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 194bb9876155230b69e41bd0dcc4bd6489a4dd5d https://github.com/Perl/perl5/commit/194bb9876155230b69e41bd0dcc4bd6489a4dd5d Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 7ca700f799c0a223746528101e174dde0ef35969 https://github.com/Perl/perl5/commit/7ca700f799c0a223746528101e174dde0ef35969 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: ddf9e907ba8c131613ced6717403dfb18742a0af https://github.com/Perl/perl5/commit/ddf9e907ba8c131613ced6717403dfb18742a0af Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 5a137aa612ff3c89b92f9ce36e8bf8cd720fa4fc https://github.com/Perl/perl5/commit/5a137aa612ff3c89b92f9ce36e8bf8cd720fa4fc Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 8a6fadefc85982acb5aa43389b07a460d4760149 https://github.com/Perl/perl5/commit/8a6fadefc85982acb5aa43389b07a460d4760149 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 80141c2463a3aa071c91f5829e8b64f643dc3e8c https://github.com/Perl/perl5/commit/80141c2463a3aa071c91f5829e8b64f643dc3e8c Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 6e5771d0bc061e694d5c8c2babfd104b8a9135ec https://github.com/Perl/perl5/commit/6e5771d0bc061e694d5c8c2babfd104b8a9135ec Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 34ec18206b69992c41dc39ae38c20607baad32bb https://github.com/Perl/perl5/commit/34ec18206b69992c41dc39ae38c20607baad32bb Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 2db64d252d9fc89c53abe545271e15e43b985718 https://github.com/Perl/perl5/commit/2db64d252d9fc89c53abe545271e15e43b985718 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: ee5c48e6e7e007c911a8e9f68e560c00a2045046 https://github.com/Perl/perl5/commit/ee5c48e6e7e007c911a8e9f68e560c00a2045046 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 4ccada0472f3b48f0178e1921e8afa940620a7a5 https://github.com/Perl/perl5/commit/4ccada0472f3b48f0178e1921e8afa940620a7a5 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: df71d29c827993d4abd9cec570a18917dce267c2 https://github.com/Perl/perl5/commit/df71d29c827993d4abd9cec570a18917dce267c2 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: cfedea9b775f4fba91b36694537bf274ac5ac0f2 https://github.com/Perl/perl5/commit/cfedea9b775f4fba91b36694537bf274ac5ac0f2 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: dcc507c404e3c01bfac24835a81a79b88c92060c https://github.com/Perl/perl5/commit/dcc507c404e3c01bfac24835a81a79b88c92060c Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 156f4ea858b8b72e245c1eef21601ee1fe38cfea https://github.com/Perl/perl5/commit/156f4ea858b8b72e245c1eef21601ee1fe38cfea Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 05151396135fb1c4508d9dbcdc582d5eaf06f174 https://github.com/Perl/perl5/commit/05151396135fb1c4508d9dbcdc582d5eaf06f174 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: c4d786d5c99b94b44e3eccac8ab1ba7e4a96c1e4 https://github.com/Perl/perl5/commit/c4d786d5c99b94b44e3eccac8ab1ba7e4a96c1e4 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: b713240e73b2d58b014b142ce3bca6b339ec8e18 https://github.com/Perl/perl5/commit/b713240e73b2d58b014b142ce3bca6b339ec8e18 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 19caf65c1d043c2d5339b4f266507d1c8fb9e9be https://github.com/Perl/perl5/commit/19caf65c1d043c2d5339b4f266507d1c8fb9e9be Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 5d4af979380235aabf61d4cf9318401eca64dd70 https://github.com/Perl/perl5/commit/5d4af979380235aabf61d4cf9318401eca64dd70 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 7da1bc704ba83ea10fa6a662cfc23692c7487e7a https://github.com/Perl/perl5/commit/7da1bc704ba83ea10fa6a662cfc23692c7487e7a Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 003f2ca65b2a7c1ffabafd2760d4602e87115361 https://github.com/Perl/perl5/commit/003f2ca65b2a7c1ffabafd2760d4602e87115361 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 0f6eaf1304f851df66b354f76303d88a50727df3 https://github.com/Perl/perl5/commit/0f6eaf1304f851df66b354f76303d88a50727df3 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 10adb09aea54ac21f80c94ce2e0f81858c447018 https://github.com/Perl/perl5/commit/10adb09aea54ac21f80c94ce2e0f81858c447018 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: fixup some code comments Commit: 664dcc0d9e9b806cf3bab4062e01efa584fd26d4 https://github.com/Perl/perl5/commit/664dcc0d9e9b806cf3bab4062e01efa584fd26d4 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 55be473c808fe2f3ddde31311d3b5ac60515201a https://github.com/Perl/perl5/commit/55be473c808fe2f3ddde31311d3b5ac60515201a Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: e7db42544137cb458c4a1ec3d3135cbc7140f450 https://github.com/Perl/perl5/commit/e7db42544137cb458c4a1ec3d3135cbc7140f450 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add basic POD for Node.pm Commit: d0021b251efb2708b78f839ecec0c28c3c9e7dda https://github.com/Perl/perl5/commit/d0021b251efb2708b78f839ecec0c28c3c9e7dda Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 373806a46623bf91f427d5ab09af6f46ae3c4620 https://github.com/Perl/perl5/commit/373806a46623bf91f427d5ab09af6f46ae3c4620 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: fix trivial indentation issue whitespace-only Commit: cf92befd499f53e8699597110ea32aa73fc96fd5 https://github.com/Perl/perl5/commit/cf92befd499f53e8699597110ea32aa73fc96fd5 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 43263bcabe909962d76a791208d057c9e9eb3a22 https://github.com/Perl/perl5/commit/43263bcabe909962d76a791208d057c9e9eb3a22 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: e561b6e409d376fc7035611cb3dc3e9104eaf1a8 https://github.com/Perl/perl5/commit/e561b6e409d376fc7035611cb3dc3e9104eaf1a8 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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, both the class of the XSUB and the const modifier were combined into a single string that was used in various places, suvh as to declare the type of the THIS variable, e.g. const X__Y THIS = ...; This commit splits the state into two separate 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: 6d6660a115503c96a84edb7c177857be511af3b2 https://github.com/Perl/perl5/commit/6d6660a115503c96a84edb7c177857be511af3b2 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 3e449b61c77b2b451f2a728018d71645dcb80829 https://github.com/Perl/perl5/commit/3e449b61c77b2b451f2a728018d71645dcb80829 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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: 9a808ada1511978774906737dca581a79dea1d9e https://github.com/Perl/perl5/commit/9a808ada1511978774906737dca581a79dea1d9e Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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 more strictly See the previous commit for a general discussion on the problems with ENABLE/DISABLE-valued keywords. This commit specifically updates how the PROTOTYPES: keyword is handled. Compared with the previous production release, PROTOTYPES is now 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. Commit: fec16c72d7eb401cc209c699f72ff1af9a502bf6 https://github.com/Perl/perl5/commit/fec16c72d7eb401cc209c699f72ff1af9a502bf6 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: tweak some code comments Commit: 195fee3008c1811c23ac17195d7325efdd077bc2 https://github.com/Perl/perl5/commit/195fee3008c1811c23ac17195d7325efdd077bc2 Author: David Mitchell <da...@iabyn.com> Date: 2025-07-06 (Sun, 06 Jul 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 M dist/ExtUtils-ParseXS/t/001-basic.t M ext/PerlIO-via/via.pm M ext/PerlIO-via/via.xs Log Message: ----------- [MERGE] ParseXS: build an AST for each XSUB This series 156 commits changes ExtUtils::ParseXS so that, instead of intermixing parsing and code-emitting for each XSUB, it now parses each XSUB into an Abstract Syntax Tree, and then walks the tree to emit all the C code for that XSUB. This makes the code generally more understandable and maintainable. For now it still just discards each tree after the XSUB is parsed; in future work, the AST will be extended so that it holds the whole file (including all the XSUBs) rather than just the current XSUB. This branch contains six types of commit. 1) For terminal AST nodes for keywords such as FOO, the old ExtUtils::ParseXS::handle_FOO() method is removed and a new ExtUtils::ParseXS::Node::FOO class is added with parse() and as_code() methods which copy over the parsing and code-emitting parts of the handle_FOO() method. For a few keywords like INPUT which have values per line, both a Node::FOO and Node::FOO_line class are created, with several FOO_line nodes being children of the FOO node. Note that doing the modifications for a single keyword often consists in fact of several commits in sequence. 2) For higher-level nodes, a Node::foo class is created with parse() and as_code() methods as before, but the contents of these methods are typically populated by moving the relevant bits of code over from the big ExtUtils::ParseXS::process_file() method. 3) Most of the state fields of the ExtUtils::ParseXS class (especially all the xsub_foo ones) are removed, and similar fields added to the various Node subclasses instead. 4) Fixups to ensure that all parse-time code is only in parse() methods or associated helper functions, and similarly for as_code(). 5) Various bug fixes related to state that should be per-CASE rather than per-XSUB. Some of these bugs were pre-existing, some were introduced during this branch. 6) General tidying-up, fixing code comments, adding POD etc. Compare: https://github.com/Perl/perl5/compare/5fa00eaee8c3...195fee3008c1 To unsubscribe from these emails, change your notification settings at https://github.com/Perl/perl5/settings/notifications