Branch: refs/heads/davem/xs_refactor5 Home: https://github.com/Perl/perl5 Commit: a52ebeb954254dbf700ec26f2b02f14d02b559ba https://github.com/Perl/perl5/commit/a52ebeb954254dbf700ec26f2b02f14d02b559ba Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024)
Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Constants.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/CountLines.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Eval.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/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.54 => 3.55 Commit: a925fd3ec3b55e458a35f77249e4abe3edfb19d3 https://github.com/Perl/perl5/commit/a925fd3ec3b55e458a35f77249e4abe3edfb19d3 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: param_check(): refactor: rename lex var Rename $argsref to $param for consistency with param_check() etc. No functional changes. Commit: e8fd2ac2b4491af8904693139692aff77c9c72d9 https://github.com/Perl/perl5/commit/e8fd2ac2b4491af8904693139692aff77c9c72d9 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: INPUT_handler(): update code comments One code comment referred to something that has since been changed: update it. Also add a comment about how INPUT lines are split by a regex. Commit: 39b06b5a0fd4b5b93dbad2167f3f0c65385144fd https://github.com/Perl/perl5/commit/39b06b5a0fd4b5b93dbad2167f3f0c65385144fd Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: INPUT_handler(): refactor: add $init_op This sub looks for an initialiser string, which starts with a /[=+;]/. This commit extracts out that first character into a separate variable, $init_op, which will make further refactoring easier. Should be no functional changes. Commit: 1b61f22bb9faa2928d7c77a87468dcb06da22c36 https://github.com/Perl/perl5/commit/1b61f22bb9faa2928d7c77a87468dcb06da22c36 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: INPUT_handler(): refactor: add $is_alien Flag more explicitly that a var is declared in an INPUT line but not in the XSUB's signature (rather than just relying on $var_num not being defined). Should be no functional changes. Commit: 0c3c7c67b37b6802fc520466a2b56685befbfce2 https://github.com/Perl/perl5/commit/0c3c7c67b37b6802fc520466a2b56685befbfce2 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M MANIFEST M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm A dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: add Node.pm, Node::Param class Add the file lib/ExtUtils/ParseXS/Node.pm, and in it, define a base class and one derived class: ExtUtils::ParseXS::Node ExtUtils::ParseXS::Node::Param; Then use the Node::Param class within ParseXS.pm to store details about a particular XSUB's params. Currently this just involves upgrading a few hash refs into proper Node::Param objects. There are no methods yet to operate on such objects: the current methods in class ExtUtils::ParseXS expect a hash as an arg, and that's what they get passed - they don't care that the hash is now blessed. Soon, those methods will instead be made methods of the Node::Param class. This commit is the very first baby step into making the XS parser generate an Abstract Syntax Tree (AST). Currently the parser generates C code on the fly, maintaining just the minimum state necessary for that task. I intend over time to (hopefully) gradually store more state in Node::Foo objects, and rather than throwing the objects away after their immediate use, to combine them into bigger and bigger subtrees, until eventually there is a tree which represents an entire XS file. Commit: e8d417edf037a837abe9d4daba2b2a5d95c3bd3c https://github.com/Perl/perl5/commit/e8d417edf037a837abe9d4daba2b2a5d95c3bd3c Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor param_check() & generate_init() Rename these methods to check() and as_code(), and make them be methods of the new ExtUtils::ParseXS::Node::Param class, instead of ExtUtils::ParseXS. Should be no functional changes, unless someone has been calling these private methods directly. The diff looks complex, but it's mostly just swapping round which arg is the Param object and which is the ParseXS object; and then doing a general s/\$self/\$xps/g and s/\$param/\$self/g within the methods. The next commit will move the two methods into Node.pm. Commit: b9c84d9326ecf4e8a4385abcea96f923f665b694 https://github.com/Perl/perl5/commit/b9c84d9326ecf4e8a4385abcea96f923f665b694 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: move check() and as_code() into Node.pm The previous commit made those two functions be methods of ExtUtils::ParseXS::Node::Param; now move those two functions into Node.pm where they belong. No functional changes; just a literal cut+paste, except for no longer needing the full package name in the sub declaration, so sub ExtUtils::ParseXS::Node::Param::check { becomes sub check { etc. Commit: 7cb436fff77e971c441fbe845b8b31454f3a8ff7 https://github.com/Perl/perl5/commit/7cb436fff77e971c441fbe845b8b31454f3a8ff7 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: re-indent two subs in Node.pm The previous commit moved those subs from ParseXS.pm (where indentation is 2 columns) to the new Node.pm file (where the indentation is 4 columns, because I created that file and so I get to choose). This commit re-indents those subs to match the 4-indent. Whitespace and line re-wrapping changes only. Commit: 17e002b6678cbdbeb4c0b7bf074bce0dff99588c https://github.com/Perl/perl5/commit/17e002b6678cbdbeb4c0b7bf074bce0dff99588c Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: rename two Node::Param fields Rename a couple of fields in ExtUtils::ParseXS::Node::Param for clarity and/or consistency: num => arg_num ansi => is_ansi Should be no functional changes. Commit: 3aa0ea74df719b909f89897aa5c3f1dce769c6ee https://github.com/Perl/perl5/commit/3aa0ea74df719b909f89897aa5c3f1dce769c6ee Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: XSUB signature-splitting This is the first of a few commits which will refactor the code which splits and processes the parameters in an XSUB's signature, such as '(IN char* s, int n = 0)' The code currently has three separate initial splitting/processing loops. This commit combines two of those into a common loop. The next commit will combine the third one. The biggest loop uses a complex regex to split the signature on commas into separate parameters, but where something like (char c = ',', int n = 0) correctly ignores the quoted comma. The other two loops are essentially fallbacks: one where the regex doesn't work, and the other in the presence of the -noargtypes switch. The code was structured along the lines of: my @args; if (config_allow_argtypes) { # ANSI-style Sig if (can split using regex) { @args = /regex/g; for (@args) { # big loop to do lots of processing of all the extra syntactical features allowed with a full ANSI-style signature, i.e. IN/OUT, type, and length(foo), leaving the elements of @_ with all the extra stuff stripped. } } else { @args = split /,/, ...; Warn "Warning: cannot parse argument list"; } } else { # K&R-style Sig @args = split /,/, ...; if (config_allow_inout) { # process IN/OUT etc } for (@args) { # do common K&R syntax processing of each parameter } This commit merges the first two branches, so the code in outline now looks like: my @args; if (config_allow_argtypes) { if (can split using regex) { @args = /regex/g; else { @args = split /,/, ...; Warn "Warning: cannot parse argument list"; } for (@args) { # do lots of processing of all the extra syntactical # features allowed with a full ANSI-style signature, # i.e. IN/OUT, type, length(foo) } } .... In theory this is a change in behaviour, since the "can't split with regex" branch now does full ANSI-style processing of the parameters, albeit ones which possibly haven't been split correctly. But since this branch is supposed never to be taken, and would only ever be taken if there was a design flaw in the regex which meant it couldn't smartly split on commas, I don't think this really matters. Commit: 2bc54edb5b5ca8298ad9c68f74272dc7e238f153 https://github.com/Perl/perl5/commit/2bc54edb5b5ca8298ad9c68f74272dc7e238f153 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: refactor: XSUB signature-processing The previous commit reduced the three separate XSUB signature-splitting and initial processing branches into two. This commit reduces it to a single common block of code. It also heavily refactors the initial parameter processing code, and adds several new checks. In outline: before this commit, the sig splitting and processing code looked like: my @args; if (config_allow_argtypes) { # ANSI-style Sig if (can split using regex) { @args = /regex/g; for (@args) { # big loop to do lots of processing of all the extra syntactical features allowed with a full ANSI-style signature, i.e. IN/OUT, type, and length(foo), leaving the elements of @_ with all the extra stuff stripped. } } else { @args = split /,/, ...; Warn "Warning: cannot parse argument list"; } } else { # K&R-style Sig @args = split /,/, ...; if (config_allow_inout) { # process IN/OUT etc } for (@args) { # do common K&R syntax processing of each parameter } Following this commit, it now looks like: my @args; if (can split using regex) { @args = /regex/g; } else { @args = split /,/, ...; Warn "Warning: cannot parse argument list"; } for (@args) { # big loop to do lots of processing of all the extra syntactical features allowed with a full ANSI-style signature, i.e. IN/OUT, type, and length(foo), leaving the elements of @_ with all the extra stuff stripped. $self->blurt("type not allowed") if defined $type && !$self{config_allow_argtypes}; # ... and similar error checks ... } for (@args) { # do common K&R syntax processing of each parameter } So under -noargtypes, instead of parsing a parameter by using a separate block of code which doesn't know about the new syntactical features like types etc, always parse using code which understands all the extra stuff, but which then errors out with a specific error message if it finds something disallowed under -noargtypes. This is better than previously, where the forbidden thing was simply not understood by the parsing code, and might trigger a confusing generic error, or be silently accepted and cause malformed C code to be emitted. The new errors are: "parameter type not allowed under -noargtypes") "length() pseudo-parameter not allowed under -noargtypes") "parameter IN/OUT modifier not allowed under -noinout") "Unparseable XSUB parameter: '$_'"); "Default value not allowed on length() parameter '$name'" That last one was already an error, but the text has been changed from: "Default value on length() argument: '$_'" and it now does a $self->blurt() rather than a plain 'die', so the correct line number is reported, and parsing can continue, looking for further errors. The next few commits will be moving all the code within that "do common K&R syntax processing" block into the first 'for (@args)' loop, eventually removing the second loop altogether. Commit: 20b66d0744878dc44495087e886e0420013559cd https://github.com/Perl/perl5/commit/20b66d0744878dc44495087e886e0420013559cd Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: make $report_args an array Rather than iteratively appending to a comma-separated string of params on the fly, push them into an array; then join and quote-escape them only when used. Makes the code simpler. Also rename the variable to @report_params since it holds parameter names, not arguments. Should be no functional changes Commit: 2ebe306e99bd1cc3415432c153df2cc64bebc8f3 https://github.com/Perl/perl5/commit/2ebe306e99bd1cc3415432c153df2cc64bebc8f3 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: rationalise '...' in XSUB signature XSUBs are allowed to have a trailing ellipsis in the signature to disable arg count checking: int foo(a, b, ...) The current code which parses this is very dumb and broken. It doesn't complain about ellipses occurring in positions other than the last, and more bizarrely it actually deletes any embedded ellipis. So for example the default expression in foo(int a, char *b = "stuff ...", int c = 0) gets modified from "stuff ..." into "stuff ". It also emits broken code for the arguments of a wrapped function; i.e. int foo(a, b, ...) embeds a call to the C function 'foo' which looks like: foo(a, b,) Although auto-call with ellipsis doesn't necessarily make much sense, this commit changes it to be 'foo(a, b)' which at least compiles. This commit adds some tests too. Commit: 70b9f5d16665b018e610d2f12bb1ea3bf7bad381 https://github.com/Perl/perl5/commit/70b9f5d16665b018e610d2f12bb1ea3bf7bad381 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: centralise default arg parsing There are two 'for (@args)' parsing loops, and the processing of the '= default_expr' part of a parameter is currently split between the two loops. This commit moves everything into the first loop: this is one of a series of commits aimed at the complete elimination of the second loop. It also stores the default value expression in its original form, and now defers any quote-escaping to the code output stage. In theory, no functional changes. Commit: 9d49fd6d70f9665b8b7f92ac73a0bac694a24df9 https://github.com/Perl/perl5/commit/9d49fd6d70f9665b8b7f92ac73a0bac694a24df9 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: refactor/fix: move CLASS/THIS sig parsing There are currently two 'for (@args)' parsing loops to parse an XSUB's signature. Move the special-case code for handling a C++ XSUB's initial THIS/CLASS parameter from before the second loop to before the first loop. This is one of a series of commits aimed at the complete elimination of the second loop. This commit also fixes a bug introduced a couple of commits ago that caused the initial "THIS" or "CLASS" arg in this emitted code's error message to be be skipped: if (items < N) croak("usage: foo(...)") This commit also adds some tests for THIS/CLASS in usage message and autocall parameters. Commit: 95df1b8cd06e83ad1fc667c38c1bc532ae30d08b https://github.com/Perl/perl5/commit/95df1b8cd06e83ad1fc667c38c1bc532ae30d08b Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: move arg index calc earlier There are currently two 'for (@args)' parsing loops to parse an XSUB's signature. Move the code from the second to the first loop which determines the arg number (if any) associated with each parameter. This is one of a series of commits aimed at the complete elimination of the second loop. Commit: 067073e0ed592d6ea9cf88af80d7d79f0f6d0851 https://github.com/Perl/perl5/commit/067073e0ed592d6ea9cf88af80d7d79f0f6d0851 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm M dist/ExtUtils-ParseXS/t/110-assign_func_args.t Log Message: ----------- ParseXS: refactor: add Node::Sig class Add a ExtUtils::ParseXS::Node::Sig class. This is is a subclass of Node which is intended to hold all the info parsed and extracted from an XSUB's signature plus any INPUT lines. It mainly consists of an array of Node::Param objects, which hold info about each parsed parameter, plus a hash which maps param names to those param objects. This commit does the basic work; subsequent commits will handle some individual cases which are more complex. The basic arrangement used to be like this: The XSUB's signature (such as "a, OUT b, int c, d = 999") was split and parsed, and the info about each parameter was stored in a collection of hashes; for example: $self->{xsub_map_argname_to_in_out}{b} = 'OUT'; $self->{xsub_map_argname_to_default}{d} = '999'; etc. In addition, a Node::Param object was created for each parameter which has the *type* specified (such as as 'c' above), and pushed onto the @ANSI_params array. Then, each INPUT line was parsed, stored as a temporary Node::Param object, then the as_code() method was called on that object, which emitted the C declaration and initialisation code for that parameter. as_code() would use the various {xsub_map_argname_to_foo} hashes to lookup information needed for the code generation (such as the default expression to emit). Finally, as_code() was called on each param in @ANSI_params, to emit declarations for params listed in the signature but not in an INPUT line. What this commit does is to replace all the various $self->{xsub_map_argname_to_foo} fields with a single $self->{xsub_sig} Node::Sig object; then it creates a Node::Param object for each parameter in the signature and stores them in the Sig object. This means that the info about each param is now stored in a single Node::Param object, rather than being stored across several hashes. A couple of more tricksy xsub_map_argname_to_foo fields have been left as-is for now, to be handled by individual commits to follow shortly. The INPUT processing is left largely unchanged for now: it still, for each INPUT line, creates a Node::Param object, calls as_code() on it, and then immediately frees it. The difference being that as_code() now looks up the info it needs from under $self->{xsub_sig} rather than from lots of hashes. The intention is that eventually those temporary INPUT objects won't be discarded, but will instead be merged into the list of Node::Params in the Node::Sig object. Code will then be emitted by iterating over the params in the Sig object once all sig/INPUT parsing is complete. This will be a significant step towards changing from an "emit code as we go along" model into a "parse everything into an AST then walk the tree, emitting code" model. Commit: 0af1c9b0163a5ee133a088e61d13ceb01fd9a117 https://github.com/Perl/perl5/commit/0af1c9b0163a5ee133a088e61d13ceb01fd9a117 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) 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 seen INPUT flags Move the setting of $self->{xsub_seen_THIS_in_INPUT} $self->{xsub_seen_RETVAL_in_INPUT} back to INPUT_handler from the check() method. I moved them earlier when splitting out INPUT_handler() into separate parsing and checking functions, but really they should have stayed in INPUT_handler(). It's unlikely to make any functional difference, but logically they are flagging having literally seen a 'THIS' or 'RETVAL' in an INPUT line, and so belong there. Commit: b8aaaa80fd258e5f630bad8e552d132420e0df5d https://github.com/Perl/perl5/commit/b8aaaa80fd258e5f630bad8e552d132420e0df5d Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: make THIS/CLASS a param object Make the handling of an implied THIS or CLASS first parameter slightly more regular, by pushing a Node::Param object at the start of the list of param objects in the Node::Sig object. The code for this synthetic parameter is still emitted as a special-case: really it could be emitted at the same time as the ANSI-like parameters, but this commit keeps the emitted C declarations in the same order for now. It shouldn't make any difference, but you never know.... This commit breaks a few edge-case behaviours with C++ methods. The next five commits add tests and fixes. Commit: 1e31f428b1d2a39a644c5e4b1fdc46443e7f958b https://github.com/Perl/perl5/commit/1e31f428b1d2a39a644c5e4b1fdc46443e7f958b Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: fix code comment The xsub_class object field is a string, not a boolean. Commit: 730cc77d448958fa98b6ecc73a090f8d701abba7 https://github.com/Perl/perl5/commit/730cc77d448958fa98b6ecc73a090f8d701abba7 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: expand tests for C++ methods There are already some basic tests for C++ XSUBs (i.e. XSUBs which include a class in the function name). Expand the tests to cover what should be all the permutations of special cases, e.g. new/DESTROY, static method, etc. Commit: c99731dbf40bea4366d352f1471c7162795584be https://github.com/Perl/perl5/commit/c99731dbf40bea4366d352f1471c7162795584be Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: ignore 'static' modifier on non-C++ XSUBs An XSUB can have a class as part of its function name, to indicate that it is a C++ method, It can also have a 'static' prefix on the return type to indicate that it is a class method. For example: static int X::Y::foo(...) However, 'static' without 'X::Y::' makes no sense, and generates invalid C code for an autocall. It's been this way since 5.000 AFAIKT. It's also recently started emitting an 'uninit var' warning. This commit detects the "static but no class" condition, emits a new warning, and turns off the flag which indicated that 'static' was present. The new warning is: "Ignoring 'static' type modifier:" . " only valid with an XSUB name which includes a class" Commit: d246c7486c5d8b8a1805a153032368deb7b60c5a https://github.com/Perl/perl5/commit/d246c7486c5d8b8a1805a153032368deb7b60c5a Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: formally disallow dup THIS,CLASS If an XSUB's name includes a class, it is treated as a C++ method and an implicit initial 'THIS' or 'CLASS' parameter is added. If the XSUB also includes an explicit THIS/CLASS variable, Bad Things happen. There is in fact code in ParseXS.pm which detects 'THIS' in an INPUT line and suppresses the emitting of a duplicate C var declaration; but the generated C code is still wrong. For example, in X::Y::f(int THIS) the C code will expect 2 passed args, for both the implicit and explicit THIS, and the usage() message will be: croak_xs_usage(cv, "THIS, THIS") As it happens, the changes from 3 commits ago to THIS/CLASS handling turned such duplicate declarations into a compile-time error, .e.g. Error: duplicate definition of argument 'THIS' ignored in foo.xs, line N This commit adds tests for those changes, and also removes the now-redundant code from ParseXS which skips emitting a duplicate var definition, as the dup will already have been reported as an error by then. Commit: 1deba5b3135dd2a5726239841dad61bbdc073d22 https://github.com/Perl/perl5/commit/1deba5b3135dd2a5726239841dad61bbdc073d22 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: fix OUTPUT THIS C++ XSUB methods which indicate that the 'THIS' arg should be updated, such as My::Class::foo(int i) OUTPUT: THIS stopped emitting the update code as of 5 commits ago. Thus commit restores the behaviour, and adds tests. Commit: 23977a8c6fb711a0525ca921e886ce81d5202fb5 https://github.com/Perl/perl5/commit/23977a8c6fb711a0525ca921e886ce81d5202fb5 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: THIS tests: add tests for no STDERR noise For each set of tests in the THIS/CLASS block of tests, if there isn't any explicit test for expected STDERR values, add a test that STDERR was undef; i.e. explicitly test that there were no warnings or errors. To have a suitable description for the new tests, extract out the common prefix from the descriptions of each set of tests. Also, add an extra boolean field to each test indicating that the regex *shouldn't* match (this will be used in the next commit). Commit: 102a2baceae88d8381b17d310c4734c252bcc521 https://github.com/Perl/perl5/commit/102a2baceae88d8381b17d310c4734c252bcc521 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: allow THIS/CLASS to be overridden For a long time, ParseXS allowed the type of the implicit THIS variable to be overridden. For example, while this: void X::Y::foo() would cause this line of C to be emitted: X__Y * THIS = ....; this : void X::Y::foo() int THIS would cause this line of C to be emitted: int THIS = ....; This wasn't documented, but might be useful and code out there might be relying on it. This was broken by me a few commits ago, and this commit restores the behaviour and adds tests. There is a similar issue for new() methods, which create an implicit CLASS parameter rather than THIS. In this case, ParseXS has *never* handled it correctly. This: void X::Y::new() int CLASS would cause *two* lines of C to be emitted: int CLASS = ....; char * CLASS = ....; This commit also fixes that, so now the type of both THIS *and* CLASS are overrideable. The fix works by adding a new field to the Node::Param object, 'soft_type', which is a type to be used unless explicitly overridden in an INPUT line. The code for this fix is a bit messy because the Node::Param objects in the Node::Sig object, and the temporary Node::Param object created for each line of an INPUT block, aren't yet unified. Commit: 7b2973d2a40df49cabd1af4e324855bc70ffdc5e https://github.com/Perl/perl5/commit/7b2973d2a40df49cabd1af4e324855bc70ffdc5e Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: tweak THIS/CLASS test code Make the test code take an array ref of XSUB code lines rather than just two fixed lines. This doesn't change the current test functionality, but helps generalise it so it can shortly be extracted out as a general test sub. Commit: 6cdddaa9aeff6c8ff3a3d7570fefdd39f3e5ab70 https://github.com/Perl/perl5/commit/6cdddaa9aeff6c8ff3a3d7570fefdd39f3e5ab70 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: t/001-basic.t: add test_many() sub Factor out the recently-added test loop for testing THIS/CLASS into a more generalised "test multiple XSUBs against lists of regexes" test sub. Commit: 8bfe3d819ddde9ec02a0ed0b5a7b454489c74e66 https://github.com/Perl/perl5/commit/8bfe3d819ddde9ec02a0ed0b5a7b454489c74e66 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: add Node::Sig::usage_string() method. Previously, to generate the string to output as C code like croak_xs_usage(cv, "a, b,c = 0") the code used a lexical var, @report_params, to build up a list of parameter names, such as ('a', 'c = 0') etc, as the parameters were processed. This commit gets rid of @report_params, and instead adds a new method, ExtUtils::ParseXS::Node::Sig::usage_string() which examines the list of parameters stored in the Sig object and deduces the usage string from that. This is part of gradually moving towards a "build an AST *then* output stuff based on that tree" model. Commit: 54a8ae1133c6e326e3225e6bc00e120bdc1894a3 https://github.com/Perl/perl5/commit/54a8ae1133c6e326e3225e6bc00e120bdc1894a3 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M MANIFEST M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm M dist/ExtUtils-ParseXS/t/001-basic.t R dist/ExtUtils-ParseXS/t/110-assign_func_args.t Log Message: ----------- ParseXS: reimplement autocall arg calculation. This commit changes how the argument string is generated which is output as part of an autocall to a C function. In particular: - it deletes the ExtUtils::ParseXS::Utilities::C_func_signature() method; - it deletes the test file t/110-assign_func_args.t which exercised that method; - it adds a method called ExtUtils::ParseXS::Node::Sig::C_func_signature() which serves a similar purpose as the removed method, but in a different and more robust way; - it adds several tests to t/001-basic.t which provide similar coverage to the deleted tests. The former way of generating the arg string worked by: during XSUB signature processing, a list of candidate arg names was accumulated, then joined and stored as $self->{xsub_C_auto_function_signature} by C_func_signature(), which handled OUT params and skipped any fake THIS/CLASS arg. Then, If a C_ARGS keyword was then encountered, that would overwrite the xsub_C_auto_function_signature string. Then when INPUT lines were processed, any var declared as '&foo' would cause something like this to be done: $self->{xsub_C_auto_function_signature} =~ s/\bfoo\b/&foo/. This was not robust and could modify the C_ARGS overridden string. The new method instead scans the parameter list in the Node::Sig object and builds the argument list from that *at the time it is needed*. Any C_ARGS value is saved and used as an override. In principle there are no functional changes, apart from bug fixes and the deleting of a "not for public use" method. Commit: 561ac8d914121da08ed59ad725fd9fd31c73c5f3 https://github.com/Perl/perl5/commit/561ac8d914121da08ed59ad725fd9fd31c73c5f3 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: add more tests for OUTLIST etc Add tests that all the IN/OUT/IN_OUTLIST etc permutations generate plausible code Commit: 6388a84332e4bc4697b8322e3e8473eab211b1a4 https://github.com/Perl/perl5/commit/6388a84332e4bc4697b8322e3e8473eab211b1a4 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: remove @ANSI_params var Now that *all* XSUB parameters are stored as a list of Node::Param objects - not just ANSI ones - there's no longer a need to keep a list of the ANSI ones; instead, just 'grep $_->{is_ansi} all the params' to get the needed ones. Should be no functional changes. Commit: 82c3dc8d1cec6e0cd294b8ddbc191e5649af77bc https://github.com/Perl/perl5/commit/82c3dc8d1cec6e0cd294b8ddbc191e5649af77bc Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: remove @OUTLIST_vars Rather than pushing param names into an array if the XSUB signature declares them as 'OUTLIST' or 'IN_OUTLIST', just grep for such params within the list of Node::Param objects as needed. Should be no functional changes. Commit: 8103afce22f744291fec05579caf2c58b26ba21e https://github.com/Perl/perl5/commit/8103afce22f744291fec05579caf2c58b26ba21e Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: t/001-basic.t: tweak test_many() On the convenience test function test_many(), make the arg which trims away all generated output except the matching function(s) a bit more flexible, so that in the next commit, it can be used to extract a boot function instead of regular function. Commit: 15ffd9cddad99f2e6e79fcaee92c9085fede24a7 https://github.com/Perl/perl5/commit/15ffd9cddad99f2e6e79fcaee92c9085fede24a7 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: refactor prototype generation This commit: - eliminates the $self->{xsub_map_arg_idx_to_proto} fields, and in keeping with similar recent comments, instead generates the XSUB's proto string when needed by scanning the list of params in the Node::Sig object. - adds a Node::Sig method, proto_string(), to do that. - Adds lots of tests of XSUB prototype strings. - Adds a 'proto' field to Node::Param objects to store the prototype char(s) for that parameter if it's been overridden by the typemap (the override is actually broken, and always has been; see the next commit for the fix). - Finishes off removing the second signature args processing loop, which the last several commits have been aiming for. - Moves arg count and min arg count state into the Node::Sig object. - Eliminates the no-longer-needed %only_C_inlist var. This commit may well change the generation of XSUB prototype strings in edge cases - if so, then hopefully for the better. Commit: 948c3ff64fbd8d2fe324a7a45b0fb14e1fa0a430 https://github.com/Perl/perl5/commit/948c3ff64fbd8d2fe324a7a45b0fb14e1fa0a430 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/Type.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: fix overridden prototype char(s) There is supported syntax in typemaps to specify a sub prototype value for a parameter, to override the default of '$'. This is done using an optional third field in the TYPEMAP section of a typemap file. For example: Foo* T_FOO \[@%] However, due to a thinko in the typemap parser code (using 'proto' rather than 'prototype' as one of the args to a ExtUtils::Typemaps::Type->new() method call), this overridden value has always been silently ignored. And there were no tests for it. This commit fixes that and adds tests. In the usual case where there is no override, the original intent of the Typemap parser code was to add '$' as the proto value. Due to the bug, this was never added, and ExtUtils::Typemaps::Type objects generally had no proto field. This commit diverges from the original intent and keeps the proto field undefined rather than setting it to '$', because there are several tests which check that a regenerated typemap looks like it expects, and they were all suddenly failing due to a sudden '$' appearing on the regenerated typemap line. In addition, in the XS parser, the overridden value as returned by the typemap parser, was being emitted as-is into the generated C code within a double-quoted string. For example, a three-parameter XSUB with an overridden first parameter type, as in the example above, would generate C code along the lines of: newXSproto_portable(..., "\[@%]$$") and the backslash would get removed by the C compiler. So this commit also causes backslashes be escaped before emitting the C code: newXSproto_portable(..., "\\[@%]$$") Commit: a615c3953c4a24d289517d1eff3893b76c78eaa5 https://github.com/Perl/perl5/commit/a615c3953c4a24d289517d1eff3893b76c78eaa5 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: reindent arg-processing code Slightly widen the scope of a {...} block which encloses most of the arg-splitting/processing code so that the block now encompasses *all* the code, then re-indent the 'for (@args)' block within it, which was was one indent too much due to earlier code refactoring. Apart from the slight scope tweak, whitespace-only. Commit: 042fe91a147c1d19c8b8af58bea58bd934129d7b https://github.com/Perl/perl5/commit/042fe91a147c1d19c8b8af58bea58bd934129d7b Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: tidy up sig-processing code comments after heavy refactoring, make the code comments concerning parsing the XSUB signature and its parameters reflect the new reality Commit: 19fbcd82fa1f7c7b2add743b63c59d7dd3307b37 https://github.com/Perl/perl5/commit/19fbcd82fa1f7c7b2add743b63c59d7dd3307b37 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) 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_argname_to_type} Eliminate the xsub_map_argname_to_type field of ExtUtils::ParseXS objects. Instead, now that they exist, get the type value from the relevant Node::Param object within the Node::Sig object. Commit: 7abf613779cabac5a193767a5042aba278e62361 https://github.com/Perl/perl5/commit/7abf613779cabac5a193767a5042aba278e62361 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: refactor: rm soft_type Node:Param field The 'soft_type' field was added by me about 13 commits ago to get round issues where a TYPE/CLASS param's type is being defined both implicitly (by having the XSUB function name include a class) and explicitly in an INPUT line. Further refactoring since then has made the field unnecessary, and so this commit removed it and just uses the 'type' field of Node::Param always. Also add some more tests for dup THIS/CLASS. There were already tests for a dup in an INPUT line, but not in the signature. Commit: c445e2acd8e855ccf81bdd161e1993c2c17ef6d0 https://github.com/Perl/perl5/commit/c445e2acd8e855ccf81bdd161e1993c2c17ef6d0 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: rm xsub_map_varname_to_seen_in_INPUT More refactoring: remove the xsub_map_varname_to_seen_in_INPUT field from the ExtUtils::ParseXS class and instead add an in_input field to the ExtUtils::ParseXS::Node::Param class. Commit: 11cea86f1cdc93910dc948507273969146da3eaf https://github.com/Perl/perl5/commit/11cea86f1cdc93910dc948507273969146da3eaf Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: refactor: unify sig and INPUT params The series of approx 45 refactoring commits in this branch have added E::P::Node::Param and E::P::Node:Sig objects, to allow an XSUB's signature to be stored as a list of Param objects in a Sig object. So in a straightforward XSUB like: int foo(a, b = 999) int a int b a pair of Param objects is created and stored in a Sig object to represent the two items in the signature, e.g. { var => 'a', arg_num => 1 }, { var => 'b', arg_num => 2, default => 999 }, But up until now, when the lines in the implicit INPUT section were subsequently parsed, a *second* pair of temporary Param objects were created using both data obtained from the Sig objects and from the INPUT line. The as_code() method was then called on each temp Param object, and the temp object was then thrown away. This commit changes it so that instead, any extra info obtained from an INPUT line is added to the original Param object in the Sig object, (e.g. the 'type' value) and the as_code() method is called on the *original* object. No temporary Param objects are created. This commit is effectively what the previous chain of commits have been preparing for. Before that, all info obtained from the signature was stored in a series of hash refs stored in the ExtUtils::ParseXS object, such as $self->{sub_map_argname_to_default}{b} = 999; The new way is cleaner, conceptually simpler, gathers related code and data into one location, and has fewer special cases that need handling. The main thing it doesn't do yet is defer code generation. It still emits a C var declaration directly after each INPUT line is read and parsed. Eventually I would like for the whole signature/INPUT sequence to be read in and parsed and *then* emit all the code one go (and in the long term, to read in the *whole* XS file before emitting any code). One intended side effect of this commit is that it now detects duplicate 'alien' parameters again - this was broken during the earlier refactoring. An alien param is one declared in INPUT but not in the signature: int foo(a) int a # normal parameter int b # alien parameter int b # duplicate alien parameter A test has been added for this. A test has also been added for looking up the prototype char associated with a type when the type can change, as with a synthetic parameter like THIS. Commit: 47f88ff4f0acd0092e46bd6e241ba5b64cb8ac33 https://github.com/Perl/perl5/commit/47f88ff4f0acd0092e46bd6e241ba5b64cb8ac33 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- parseXS: refactor: INPUT_handler() init parsing Simplify a complex series of nested if/elses and update code comments. Should be no functional changes. Commit: 997bf73a1a38a848fe04742f14f1e7f6f0c5599e https://github.com/Perl/perl5/commit/997bf73a1a38a848fe04742f14f1e7f6f0c5599e Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: simplify length(foo) handling Currently, the pseudo-parameter 'length(foo)' is handled by creating a Node::Param object with a 'var' field value of 'XSauto_length_of_foo', while that object is then added to the $sig->{names} object using a key of 'foo'. This commit removes that inconsistency and makes both use 'length(foo)'. This shouldn't (in theory) change the what C code is emitted for the 'STRLEN XSauto_length_of_foo = ...' declaration etc, but might (in principle) change for (better or worse) the detection of errors for things like duplicate var declarations if someone includes 'XSauto_length_of_foo' in an INPUT line. I'm not worrying about it too much as the way such C code is generated will be changed soon. Commit: b35cee75ffc6fd42f9df83272663229eedc12a97 https://github.com/Perl/perl5/commit/b35cee75ffc6fd42f9df83272663229eedc12a97 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: rename $name_or_lenname Rename this long lex var to just '$name' now that the code is simpler and there is less need to distinguish between various name variants. Commit: dc4559ee1be54004bd225e83bc510d38b7aacf86 https://github.com/Perl/perl5/commit/dc4559ee1be54004bd225e83bc510d38b7aacf86 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: test for OUT in one place Currently there is code in both the signature parsing code and in the INPUT parsing code which sets no_init if the IN/OUT/etc parameter modifier matches /^OUT/. This commit makes it check only during signature parsing, which simplifies the code slightly. Should be no functional changes. Commit: 324dc6f33d89964e5249373270ad00d464ad3b13 https://github.com/Perl/perl5/commit/324dc6f33d89964e5249373270ad00d464ad3b13 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: sort Node::Param fields Sort the field declaration lines for E::P::Node::Param into a more logical order. Commit: 6d19ed44ebb32d29f35c196aa79ec3104d25e09b https://github.com/Perl/perl5/commit/6d19ed44ebb32d29f35c196aa79ec3104d25e09b Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: move sig parsing code into fn Move the 200 or so lines of code which splits and parses an XSUB's signature out from process_file() and into its own method. This commit changes as little as possible: apart from adding a method declaration and call, the main body of the code has just been cut and pasted as-is, apart from reducing the indentation. The next few commits will change and move the code so that it becomes a method of ExtUtils::ParseXS::Node::Sig rather than of ExtUtils::ParseXS. Commit: 2daa05e0760146972a31dd1de1097f238692c6ba https://github.com/Perl/perl5/commit/2daa05e0760146972a31dd1de1097f238692c6ba Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm Log Message: ----------- ParseXS: refactor: make parse_sig a Node::Sig meth The previous commit moved the signature parsing code into its own method. This commit makes the method be in the Extutils::ParseXS::Node::Sig class. This involves changing the name to just 'parse', and swapping around all the mentions of $self and $sig. The next commit will move the method into Node.pm. (By doing this in 3 commits, code changes don't get hidden in the noise). Commit: e4e78069770ecad6b0c4c0919d28e564012a0674 https://github.com/Perl/perl5/commit/e4e78069770ecad6b0c4c0919d28e564012a0674 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) 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::parse() into Node.pm The previous two commits have moved the signature parsing code into its own sub and made it a method of Extutils::ParseXS::Node::Sig. This commit moves the body of the method into Node.pm. There are no changes to the method's code apart from no longer needing to fully qualify the method name in the declaration. This commit also moves the our ($C_group_rex, $C_arg) var definitions from ParseXS.pm to Node.pm, as they're only used to hold regexes used to split the parameters in the signature. They've also been changed from 'our' to 'my'. Commit: 12774ce09fd5dd116a72f196e1b18bb0b35e2e52 https://github.com/Perl/perl5/commit/12774ce09fd5dd116a72f196e1b18bb0b35e2e52 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm Log Message: ----------- ParseXS: refactor: Sig::parse(): rename arg vars This method splits the XSUB signature string into individual parameter strings and then parses them. Rename the var from '@args' to '@param_texts' since it contains parameters rather than args. The _text suffix is to distinguish them from $param objects. This is one of the last steps in my quiet mission to rename variables etc from *arg* to *param* where they hold info about params rather than args. This is particularly significant as some parameters (like 'length(foo)') don't get bound to args, so there isn't a 1:1 correspondence. Also, shorten the names of a couple of lex vars now that they're only in a small method with limited scope: $args_count => $nargs $optional_args_count => $opt_args Should be no functional changes. Commit: 543cb985f9698d83334ae3479569e11fffe72ad6 https://github.com/Perl/perl5/commit/543cb985f9698d83334ae3479569e11fffe72ad6 Author: David Mitchell <da...@iabyn.com> Date: 2024-10-08 (Tue, 08 Oct 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: change error msgs argument => parameter Several error messages complain about things like "duplicate argument" when they mean "duplicate parameter". So update these messages to be more accurate. Compare: https://github.com/Perl/perl5/compare/a52ebeb95425%5E...543cb985f969 To unsubscribe from these emails, change your notification settings at https://github.com/Perl/perl5/settings/notifications