Branch: refs/heads/davem/xs_refactor10 Home: https://github.com/Perl/perl5 Commit: c3581ccfdd8bb842c662db83c991f48e9bf4a282 https://github.com/Perl/perl5/commit/c3581ccfdd8bb842c662db83c991f48e9bf4a282 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 9fb3e9ffc00d731c05738c3120ebd6de47a20478 https://github.com/Perl/perl5/commit/9fb3e9ffc00d731c05738c3120ebd6de47a20478 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 7c2ab8a0caf8ec1ca5e9e51167ef1c7e4fdaf274 https://github.com/Perl/perl5/commit/7c2ab8a0caf8ec1ca5e9e51167ef1c7e4fdaf274 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 4994f2e5ff92c534be05b698ac0bced819dec150 https://github.com/Perl/perl5/commit/4994f2e5ff92c534be05b698ac0bced819dec150 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: d473ad70a6bab1cd6b45cb9413c42fa1dacc4924 https://github.com/Perl/perl5/commit/d473ad70a6bab1cd6b45cb9413c42fa1dacc4924 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 2470c6666bbf00ff471fb4d500d8946bbc252706 https://github.com/Perl/perl5/commit/2470c6666bbf00ff471fb4d500d8946bbc252706 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 9269eb74a52687566168331fea44139cb72e4f77 https://github.com/Perl/perl5/commit/9269eb74a52687566168331fea44139cb72e4f77 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 21fef4cf8c604e9afa443e8dc3092d464c121bd8 https://github.com/Perl/perl5/commit/21fef4cf8c604e9afa443e8dc3092d464c121bd8 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: f7c5f6614f7a1e0d3a313967eee8cd4a1bde139b https://github.com/Perl/perl5/commit/f7c5f6614f7a1e0d3a313967eee8cd4a1bde139b Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 0ea35bf151cd58cbd9a52c31cfbdd9a94f96364d https://github.com/Perl/perl5/commit/0ea35bf151cd58cbd9a52c31cfbdd9a94f96364d Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 8ccdf7482cf4089b55fbddb605a203394314c3af https://github.com/Perl/perl5/commit/8ccdf7482cf4089b55fbddb605a203394314c3af Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 531b65d3af524cd26866fadacb8f71a228d9c9ad https://github.com/Perl/perl5/commit/531b65d3af524cd26866fadacb8f71a228d9c9ad Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 8208a2797245d70a3906d14822d531858c35ecb7 https://github.com/Perl/perl5/commit/8208a2797245d70a3906d14822d531858c35ecb7 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: f1f0340039ebd711c515b536b2cb0cfb053aceac https://github.com/Perl/perl5/commit/f1f0340039ebd711c515b536b2cb0cfb053aceac Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 7ae52717b22ff53f24e0fc077bae4f2398b7e433 https://github.com/Perl/perl5/commit/7ae52717b22ff53f24e0fc077bae4f2398b7e433 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 6955a17bc22a4e9d10e664d5310e7f01c4b6961d https://github.com/Perl/perl5/commit/6955a17bc22a4e9d10e664d5310e7f01c4b6961d Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: decc152595d8b1b6de68fde6d726ebd5d08aaed4 https://github.com/Perl/perl5/commit/decc152595d8b1b6de68fde6d726ebd5d08aaed4 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 2a5f6c1be2709a8659b698bd85a7948c2a5a4cbe https://github.com/Perl/perl5/commit/2a5f6c1be2709a8659b698bd85a7948c2a5a4cbe Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 3a4df27873145fa4a1ee09f1bce0daecabbc4a30 https://github.com/Perl/perl5/commit/3a4df27873145fa4a1ee09f1bce0daecabbc4a30 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: cfdba7ca4849547ceb29ded8ffec5d2648acfe24 https://github.com/Perl/perl5/commit/cfdba7ca4849547ceb29ded8ffec5d2648acfe24 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 44b694a3b304168489b35cc751ee2a973ae73aeb https://github.com/Perl/perl5/commit/44b694a3b304168489b35cc751ee2a973ae73aeb Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: b16f661b2c8ac714e2943d51989759ddb09b0e60 https://github.com/Perl/perl5/commit/b16f661b2c8ac714e2943d51989759ddb09b0e60 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 5bc73a0c63330fd116891f6788c1a813b59497c7 https://github.com/Perl/perl5/commit/5bc73a0c63330fd116891f6788c1a813b59497c7 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 03189be72f1626cd6e2905d09bf788dd656f6cdb https://github.com/Perl/perl5/commit/03189be72f1626cd6e2905d09bf788dd656f6cdb Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 5ca5592b0bdb7893348e727807aa15261853aa3e https://github.com/Perl/perl5/commit/5ca5592b0bdb7893348e727807aa15261853aa3e Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: ff3ce5a48bce7e37acad47813421d2253645314b https://github.com/Perl/perl5/commit/ff3ce5a48bce7e37acad47813421d2253645314b Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: ac824c7bee7b639cb10625a868828b42d7cc1a48 https://github.com/Perl/perl5/commit/ac824c7bee7b639cb10625a868828b42d7cc1a48 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 206c00229f57612ce837e038ab5728b72ffcba0b https://github.com/Perl/perl5/commit/206c00229f57612ce837e038ab5728b72ffcba0b Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: a48e690d6251e7427f1d6a31062a59f3b660a5c0 https://github.com/Perl/perl5/commit/a48e690d6251e7427f1d6a31062a59f3b660a5c0 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: b801ffe718ff30e7534347850a50fb91787f3f22 https://github.com/Perl/perl5/commit/b801ffe718ff30e7534347850a50fb91787f3f22 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 3a8a69c60bf1ab76f204322f4201e16b6d6f713d https://github.com/Perl/perl5/commit/3a8a69c60bf1ab76f204322f4201e16b6d6f713d Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 0a77954f1015cbd0aab10d51eff0f0ad230627f7 https://github.com/Perl/perl5/commit/0a77954f1015cbd0aab10d51eff0f0ad230627f7 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 41ba5aacd6a7f1ed8b15d37eaa6e4097a77da34c https://github.com/Perl/perl5/commit/41ba5aacd6a7f1ed8b15d37eaa6e4097a77da34c Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 1f296eaf3c3aa3328a50da95cb08e1c6788fca79 https://github.com/Perl/perl5/commit/1f296eaf3c3aa3328a50da95cb08e1c6788fca79 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 6c48ebc7d4b06082cb0500d2b123885162e43b33 https://github.com/Perl/perl5/commit/6c48ebc7d4b06082cb0500d2b123885162e43b33 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 7db9c9144b585375a2da9ce6ee5fda207ffafeee https://github.com/Perl/perl5/commit/7db9c9144b585375a2da9ce6ee5fda207ffafeee Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: b8ae317909de439cc6ace3bb94a89dc9d834a13b https://github.com/Perl/perl5/commit/b8ae317909de439cc6ace3bb94a89dc9d834a13b Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 93cbe56085b592635a032a89e18f02f81757293d https://github.com/Perl/perl5/commit/93cbe56085b592635a032a89e18f02f81757293d Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: aa70fe77f0844acd0e353164e7cebc2ea5d1c73d https://github.com/Perl/perl5/commit/aa70fe77f0844acd0e353164e7cebc2ea5d1c73d Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 47af9511aab6a04a0dae918b2b8b3c43c91601aa https://github.com/Perl/perl5/commit/47af9511aab6a04a0dae918b2b8b3c43c91601aa Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 4e45f124a0c3c20f8a1a15c165cfd266bf510ca3 https://github.com/Perl/perl5/commit/4e45f124a0c3c20f8a1a15c165cfd266bf510ca3 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: c4ba4ccf3f57c641c93b0afbff404eacd6a3256b https://github.com/Perl/perl5/commit/c4ba4ccf3f57c641c93b0afbff404eacd6a3256b Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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 thins 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: bee6b796709f5e86dc97c430ab78f893037c6fc1 https://github.com/Perl/perl5/commit/bee6b796709f5e86dc97c430ab78f893037c6fc1 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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 chuck of code will be moved into a node class in the next commit. Commit: 74d931e314aed8a614faeaf4e31954497ade4ec3 https://github.com/Perl/perl5/commit/74d931e314aed8a614faeaf4e31954497ade4ec3 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 8fc01fee72fa1c007c51c9454df7c45c67adfe76 https://github.com/Perl/perl5/commit/8fc01fee72fa1c007c51c9454df7c45c67adfe76 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: b2ed92ad958ef124ba3a76eda1f717753c8e1674 https://github.com/Perl/perl5/commit/b2ed92ad958ef124ba3a76eda1f717753c8e1674 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 46a993527f9d766886e20d084d1ac67230b402c9 https://github.com/Perl/perl5/commit/46a993527f9d766886e20d084d1ac67230b402c9 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: c65cb5653e15e351d3552280d032fd5355e6cb0e https://github.com/Perl/perl5/commit/c65cb5653e15e351d3552280d032fd5355e6cb0e Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 58ffdb250f33b23f3d5a719275fdaad82a28db37 https://github.com/Perl/perl5/commit/58ffdb250f33b23f3d5a719275fdaad82a28db37 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 32bc99eb360ec1763bee5aecf4a4378269f5454f https://github.com/Perl/perl5/commit/32bc99eb360ec1763bee5aecf4a4378269f5454f Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: bad63680be10cb97d89e1ac6095c10a04858978a https://github.com/Perl/perl5/commit/bad63680be10cb97d89e1ac6095c10a04858978a Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 5edfec5eb29c060601f693825ef225c75b0fb002 https://github.com/Perl/perl5/commit/5edfec5eb29c060601f693825ef225c75b0fb002 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 9b3ee05615e3b852e0e188c3ec5acb185676ba3d https://github.com/Perl/perl5/commit/9b3ee05615e3b852e0e188c3ec5acb185676ba3d Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: a7c5807402758f35530f79a59e7aa254ef42d290 https://github.com/Perl/perl5/commit/a7c5807402758f35530f79a59e7aa254ef42d290 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: db9646ac6b01c566ffbe45a0b9185d35bcb4b792 https://github.com/Perl/perl5/commit/db9646ac6b01c566ffbe45a0b9185d35bcb4b792 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 322341f9514cc1c7f5b283ed34760a58d1041d48 https://github.com/Perl/perl5/commit/322341f9514cc1c7f5b283ed34760a58d1041d48 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: a5542f568e2ec8fef234e83e52abffa1faad2009 https://github.com/Perl/perl5/commit/a5542f568e2ec8fef234e83e52abffa1faad2009 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 7376bcfe16408da3ddba5543c3f5e20fb7d1ff35 https://github.com/Perl/perl5/commit/7376bcfe16408da3ddba5543c3f5e20fb7d1ff35 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: efefc3d07d674a170c43fd80c632a3308376eb6e https://github.com/Perl/perl5/commit/efefc3d07d674a170c43fd80c632a3308376eb6e Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: cd1b5beaa9b3910ca017fc6a2f43feec99b0315d https://github.com/Perl/perl5/commit/cd1b5beaa9b3910ca017fc6a2f43feec99b0315d Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 1a14fa8d7687c269ef4455d05a714a4af7819415 https://github.com/Perl/perl5/commit/1a14fa8d7687c269ef4455d05a714a4af7819415 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: f43812bc499bc81d0be50d2b9bf6458c4b738b74 https://github.com/Perl/perl5/commit/f43812bc499bc81d0be50d2b9bf6458c4b738b74 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 962b410b2d5355fc74a985c9725331fa1a2bb6a2 https://github.com/Perl/perl5/commit/962b410b2d5355fc74a985c9725331fa1a2bb6a2 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 151da801f9f957a2f454741801c2c1d93ebed69f https://github.com/Perl/perl5/commit/151da801f9f957a2f454741801c2c1d93ebed69f Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 2363b14424fb4d233713a22203659c4162019218 https://github.com/Perl/perl5/commit/2363b14424fb4d233713a22203659c4162019218 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: cba3eba5074235d9da06729fa1c30dd6156c44c2 https://github.com/Perl/perl5/commit/cba3eba5074235d9da06729fa1c30dd6156c44c2 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: d724b5a4566c9243cabf28737d997ed61b429622 https://github.com/Perl/perl5/commit/d724b5a4566c9243cabf28737d997ed61b429622 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 5deff008124c673f2831157dfe1ab18941fca948 https://github.com/Perl/perl5/commit/5deff008124c673f2831157dfe1ab18941fca948 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: b407e732ac72135bc5d3c94ca2cbce7f75e4fb86 https://github.com/Perl/perl5/commit/b407e732ac72135bc5d3c94ca2cbce7f75e4fb86 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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 - mover an unshift a couple of lines earlier - make a Warn call be a method call. No functional changes Commit: 76cfd9dc0d5b0b69659b7685647a862cdeb1ee5c https://github.com/Perl/perl5/commit/76cfd9dc0d5b0b69659b7685647a862cdeb1ee5c Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 4cc9af128acd613d5f37cd60204d1d6ad99d193e https://github.com/Perl/perl5/commit/4cc9af128acd613d5f37cd60204d1d6ad99d193e Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 85f2e71cd119051ea8028d7248b139c0c5f920f2 https://github.com/Perl/perl5/commit/85f2e71cd119051ea8028d7248b139c0c5f920f2 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: reindent xsub_decl::parse() whitespace-only Commit: b12cf0596dcd18ced98499b1c16d2ba5be1effb8 https://github.com/Perl/perl5/commit/b12cf0596dcd18ced98499b1c16d2ba5be1effb8 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 1522c502c13558da629f51eeabb539b756bfb99d https://github.com/Perl/perl5/commit/1522c502c13558da629f51eeabb539b756bfb99d Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 9b3514214af475310593f1021d730f2048996b47 https://github.com/Perl/perl5/commit/9b3514214af475310593f1021d730f2048996b47 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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_pdecl 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: 0777151212dc443f917cf9da77563525599defbf https://github.com/Perl/perl5/commit/0777151212dc443f917cf9da77563525599defbf Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: a1ad2a3ddab88db46680fcad87b88c579d422d17 https://github.com/Perl/perl5/commit/a1ad2a3ddab88db46680fcad87b88c579d422d17 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 352745ad4cea44c52efc73ca5eed7aef157f8f77 https://github.com/Perl/perl5/commit/352745ad4cea44c52efc73ca5eed7aef157f8f77 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor; fix a couple of comments Commit: 88d86f6ea85bb620190f915a4bda22d0e0159fba https://github.com/Perl/perl5/commit/88d86f6ea85bb620190f915a4bda22d0e0159fba Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 70ab86158bb206967d2ee35c7a9d5553c92a8380 https://github.com/Perl/perl5/commit/70ab86158bb206967d2ee35c7a9d5553c92a8380 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 84e4db40d57de464966c4cf1eb874cdeee21ef37 https://github.com/Perl/perl5/commit/84e4db40d57de464966c4cf1eb874cdeee21ef37 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 18f384792ecb69532d42c76c1a433df2cd38d70e https://github.com/Perl/perl5/commit/18f384792ecb69532d42c76c1a433df2cd38d70e Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 85c793c7eaf14435cb6e81ca94898b9681077b8f https://github.com/Perl/perl5/commit/85c793c7eaf14435cb6e81ca94898b9681077b8f Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 63537690733307e59a4b65f1c19f9c5b9f997ca5 https://github.com/Perl/perl5/commit/63537690733307e59a4b65f1c19f9c5b9f997ca5 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 19f0af6ae28447eba9a0cefafef2b765ab31d78b https://github.com/Perl/perl5/commit/19f0af6ae28447eba9a0cefafef2b765ab31d78b Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: c9481ee5de72b18e622f7e8886eda56e9c52c3f4 https://github.com/Perl/perl5/commit/c9481ee5de72b18e622f7e8886eda56e9c52c3f4 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 9866e3266b9d9f18d8084369ace6507e501042b0 https://github.com/Perl/perl5/commit/9866e3266b9d9f18d8084369ace6507e501042b0 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 2025) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: add another CASE test Test CASE with unconditional else. Commit: 9d87d60e22266e41a51ded86990c0cbd4d73ae0a https://github.com/Perl/perl5/commit/9d87d60e22266e41a51ded86990c0cbd4d73ae0a Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 8d106304b3069b275d0353403401dfb637039578 https://github.com/Perl/perl5/commit/8d106304b3069b275d0353403401dfb637039578 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 97cfe3acb615e6fdacf6a59a6c3555b914dffba7 https://github.com/Perl/perl5/commit/97cfe3acb615e6fdacf6a59a6c3555b914dffba7 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: fbdaa4b8d4181786f73bb168d6f4b6c85be4a7b8 https://github.com/Perl/perl5/commit/fbdaa4b8d4181786f73bb168d6f4b6c85be4a7b8 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: e7bf5a236829b5c3263d219aaa394f0cc25c7676 https://github.com/Perl/perl5/commit/e7bf5a236829b5c3263d219aaa394f0cc25c7676 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: f7be7e354215aabf3fe22bede08c7da0456cf60f https://github.com/Perl/perl5/commit/f7be7e354215aabf3fe22bede08c7da0456cf60f Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 9b984417aa8b9ad69e9b86279171e1bfa0031eea https://github.com/Perl/perl5/commit/9b984417aa8b9ad69e9b86279171e1bfa0031eea Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 19b43dbf3d593102f758634f6436959dd290c73a https://github.com/Perl/perl5/commit/19b43dbf3d593102f758634f6436959dd290c73a Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 693690d6e94f9f8f816b3e5d7bd98c9567e2346a https://github.com/Perl/perl5/commit/693690d6e94f9f8f816b3e5d7bd98c9567e2346a Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: efbae92910f6c2eb70242e2d2019cb959ead0450 https://github.com/Perl/perl5/commit/efbae92910f6c2eb70242e2d2019cb959ead0450 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 21a697b5ef9d91814365d46887fae5ec019a4e37 https://github.com/Perl/perl5/commit/21a697b5ef9d91814365d46887fae5ec019a4e37 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 58f5bf57acf05e1f1ed676f712a2c2cf233cfd6e https://github.com/Perl/perl5/commit/58f5bf57acf05e1f1ed676f712a2c2cf233cfd6e Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 66410ce6ea90356b02a5c7a0b6991348b0e88abb https://github.com/Perl/perl5/commit/66410ce6ea90356b02a5c7a0b6991348b0e88abb Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 14d25ad857a04162fa0e7c1b745d28d48b300ee4 https://github.com/Perl/perl5/commit/14d25ad857a04162fa0e7c1b745d28d48b300ee4 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 685e46b92632aa9e4dd973880b65cc3dd31845a5 https://github.com/Perl/perl5/commit/685e46b92632aa9e4dd973880b65cc3dd31845a5 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: fbabbf92918abdcdf3e8de8a9dffa9a619d901a0 https://github.com/Perl/perl5/commit/fbabbf92918abdcdf3e8de8a9dffa9a619d901a0 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 54b32d10fcc2d46fcfb0ef7daa6c390a373b3595 https://github.com/Perl/perl5/commit/54b32d10fcc2d46fcfb0ef7daa6c390a373b3595 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 1e5d04259a61091e16ef436aedf7cb71354bd4db https://github.com/Perl/perl5/commit/1e5d04259a61091e16ef436aedf7cb71354bd4db Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 324cbcabc2facdd0bb5504a69e6640e32a6a4ec8 https://github.com/Perl/perl5/commit/324cbcabc2facdd0bb5504a69e6640e32a6a4ec8 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 0d12ffb2283e675699e21e53a7a5b1e73c0be506 https://github.com/Perl/perl5/commit/0d12ffb2283e675699e21e53a7a5b1e73c0be506 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: ceb48740932dad930ad0a01e6e076b27265e609a https://github.com/Perl/perl5/commit/ceb48740932dad930ad0a01e6e076b27265e609a Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 261c2a8101f8cd82ad57a693a153dd28c67bfaac https://github.com/Perl/perl5/commit/261c2a8101f8cd82ad57a693a153dd28c67bfaac Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: b0bb121100f3cf5b473c2a0dd67bf272c00c047b https://github.com/Perl/perl5/commit/b0bb121100f3cf5b473c2a0dd67bf272c00c047b Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 6404deb9352f02066fe12f4c9d158060a2737048 https://github.com/Perl/perl5/commit/6404deb9352f02066fe12f4c9d158060a2737048 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 70cc7a213027525d9171cc5880053a2680f6638a https://github.com/Perl/perl5/commit/70cc7a213027525d9171cc5880053a2680f6638a Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: bd5b89d3a43211fa5560b1ce58bbe7cbb5e8415f https://github.com/Perl/perl5/commit/bd5b89d3a43211fa5560b1ce58bbe7cbb5e8415f Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 308c5192cf46595f0fcfa03c539ac0b6af6b6b3a https://github.com/Perl/perl5/commit/308c5192cf46595f0fcfa03c539ac0b6af6b6b3a Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: bd0f043e95526c48942f06edfe43898914f0990f https://github.com/Perl/perl5/commit/bd0f043e95526c48942f06edfe43898914f0990f Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 89ad7a1bc721f7e5a72e894c150dc682d04b066f https://github.com/Perl/perl5/commit/89ad7a1bc721f7e5a72e894c150dc682d04b066f Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: c933ea6dec23b461464f93fb289fd53caab61d06 https://github.com/Perl/perl5/commit/c933ea6dec23b461464f93fb289fd53caab61d06 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 765b04d7b832da4ad9b4a76c0d55b552b21877f6 https://github.com/Perl/perl5/commit/765b04d7b832da4ad9b4a76c0d55b552b21877f6 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 288da2da06dd45ccb820cb5658cf03ba4e9606b1 https://github.com/Perl/perl5/commit/288da2da06dd45ccb820cb5658cf03ba4e9606b1 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 72fc64a9396552e9a9d23f045627ffcb82aa676f https://github.com/Perl/perl5/commit/72fc64a9396552e9a9d23f045627ffcb82aa676f Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: d308837c7642026ea843e9364f55886b853107b8 https://github.com/Perl/perl5/commit/d308837c7642026ea843e9364f55886b853107b8 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 0e253e5bb57aaf51e77de7d4bcc4a2a2fc3a42e2 https://github.com/Perl/perl5/commit/0e253e5bb57aaf51e77de7d4bcc4a2a2fc3a42e2 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 23afacdff4f4af6a0d927ee8f16a2afda5d770bd https://github.com/Perl/perl5/commit/23afacdff4f4af6a0d927ee8f16a2afda5d770bd Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 1a928b362b98c6992f4907bb3f7fe5c89df41e4a https://github.com/Perl/perl5/commit/1a928b362b98c6992f4907bb3f7fe5c89df41e4a Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 9d3d5b5a1650d7f7ec7d9609a83dae72cfc7cf77 https://github.com/Perl/perl5/commit/9d3d5b5a1650d7f7ec7d9609a83dae72cfc7cf77 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 6700da40e79cb549693336a4d573824da28faaf2 https://github.com/Perl/perl5/commit/6700da40e79cb549693336a4d573824da28faaf2 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 6bcce5e00942921c372d57743b498a763b620c81 https://github.com/Perl/perl5/commit/6bcce5e00942921c372d57743b498a763b620c81 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 06d618e0ccbf9e3ee1d1bd331537e9b884f56075 https://github.com/Perl/perl5/commit/06d618e0ccbf9e3ee1d1bd331537e9b884f56075 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: f88d94abf7c220c07029941e5a2c41a2b72ee7f5 https://github.com/Perl/perl5/commit/f88d94abf7c220c07029941e5a2c41a2b72ee7f5 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 669b19baa6f79a5898c3740f9504fadbf833d558 https://github.com/Perl/perl5/commit/669b19baa6f79a5898c3740f9504fadbf833d558 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: b11bfb7e060a656277b6cb8a98e41cbfea9a8f2b https://github.com/Perl/perl5/commit/b11bfb7e060a656277b6cb8a98e41cbfea9a8f2b Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 76e99d9f1deb7258e1e8273ed460618c0d389bad https://github.com/Perl/perl5/commit/76e99d9f1deb7258e1e8273ed460618c0d389bad Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 9514ad1ef738cad02823822d0649697f2f46bd33 https://github.com/Perl/perl5/commit/9514ad1ef738cad02823822d0649697f2f46bd33 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 6b7167819fe6b975036ec94d69bef43cb8ec2b5d https://github.com/Perl/perl5/commit/6b7167819fe6b975036ec94d69bef43cb8ec2b5d Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: c20945f92d9daa80477cb65421f4c6cde03bb96e https://github.com/Perl/perl5/commit/c20945f92d9daa80477cb65421f4c6cde03bb96e Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: f051302bcb10aae09c063a5fd542b19a4547b750 https://github.com/Perl/perl5/commit/f051302bcb10aae09c063a5fd542b19a4547b750 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: a4ef2a4cb7e57ff12fdcd1ac2c462a07bda0f583 https://github.com/Perl/perl5/commit/a4ef2a4cb7e57ff12fdcd1ac2c462a07bda0f583 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: ec74ddd6aadba9ead8aa0147843852d593fc3729 https://github.com/Perl/perl5/commit/ec74ddd6aadba9ead8aa0147843852d593fc3729 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: 534703019e7050d5258f1d8a02d8dc9dc00acaa5 https://github.com/Perl/perl5/commit/534703019e7050d5258f1d8a02d8dc9dc00acaa5 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: e7eafae96a651229e7057d690dedbfd5370bc120 https://github.com/Perl/perl5/commit/e7eafae96a651229e7057d690dedbfd5370bc120 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-23 (Wed, 23 Apr 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: bcb52afc1fb92c15eaa02b164ffffbbe18441571 https://github.com/Perl/perl5/commit/bcb52afc1fb92c15eaa02b164ffffbbe18441571 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-24 (Thu, 24 Apr 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: d2513afc9ebcce00d2122304c03dfc86493048bf https://github.com/Perl/perl5/commit/d2513afc9ebcce00d2122304c03dfc86493048bf Author: David Mitchell <da...@iabyn.com> Date: 2025-04-24 (Thu, 24 Apr 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: a9bd1a1182dc84d3a891f4f6fa9454f2621e07b5 https://github.com/Perl/perl5/commit/a9bd1a1182dc84d3a891f4f6fa9454f2621e07b5 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-24 (Thu, 24 Apr 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: 4855002a44c34224bf5abf607abb9c38930adc4b https://github.com/Perl/perl5/commit/4855002a44c34224bf5abf607abb9c38930adc4b Author: David Mitchell <da...@iabyn.com> Date: 2025-04-24 (Thu, 24 Apr 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: fixup some code comments Commit: d71ad706e21fea47e131cdf950f3a3ced25d00f1 https://github.com/Perl/perl5/commit/d71ad706e21fea47e131cdf950f3a3ced25d00f1 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-24 (Thu, 24 Apr 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: 894cafd3c29d278e671e0cf590e1ac125e70d70d https://github.com/Perl/perl5/commit/894cafd3c29d278e671e0cf590e1ac125e70d70d Author: David Mitchell <da...@iabyn.com> Date: 2025-04-24 (Thu, 24 Apr 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: 5b6a30f3f13a60c12b40ab9b67d0a7ee02e132d8 https://github.com/Perl/perl5/commit/5b6a30f3f13a60c12b40ab9b67d0a7ee02e132d8 Author: David Mitchell <da...@iabyn.com> Date: 2025-04-24 (Thu, 24 Apr 2025) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: add basic POD for Node.pm Commit: 5d95e1601d73b02c32894a64efdba42eef82755e https://github.com/Perl/perl5/commit/5d95e1601d73b02c32894a64efdba42eef82755e Author: David Mitchell <da...@iabyn.com> Date: 2025-04-24 (Thu, 24 Apr 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. Compare: https://github.com/Perl/perl5/compare/c3581ccfdd8b%5E...5d95e1601d73 To unsubscribe from these emails, change your notification settings at https://github.com/Perl/perl5/settings/notifications