Branch: refs/heads/davem/xs_refactor7 Home: https://github.com/Perl/perl5 Commit: 8ac54f3b085ddccdcd8c1c39a4ac5814dabf967f https://github.com/Perl/perl5/commit/8ac54f3b085ddccdcd8c1c39a4ac5814dabf967f Author: David Mitchell <da...@iabyn.com> Date: 2024-11-19 (Tue, 19 Nov 2024)
Changed paths: M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: add tests for typeless param placeholders In XS, you can declare a parameter without a type being specified (neither in the signature, nor in an INPUT line) and it informally becomes a placeholder: no C variable of that name is declared, but it causes the next arg to be skipped. For example, int foo(int A, B, int C) ... emits C code which: checks for 3 args, declares A and C as vars, and assigns them the values of ST(0) and ST(2). This commit adds some tests which confirm this behaviour. The semantics of such XSUBs with no body (i.e. autocall) are a bit odd. The parameter is passed as an arg to the wrapped C function even though the C var hasn't been declared or initialised. I decided to keep that as-is, because it's possible that the var has instead been declared in a PREINIT section. (I have no idea why you would want to do that, which makes it almost certain that some XS module on CPAN is in fact doing it.) Note that placeholders with default values are supported: both the var and the default value are ignored, and the arg is skipped. This is a bit ugly, but it allows an XSUB to accept a variable number of parameters, even if one of those parameters is no longer used. (And like most such things, I first discovered that it was a "thing" by seeing DB_File.xs break when I tried to disallow it. If there is a weird or impossible thing to do in XS, you can be certain that DB_File is doing it.) Commit: 1b371875923fcdc4d96765398ef73934e46952fe https://github.com/Perl/perl5/commit/1b371875923fcdc4d96765398ef73934e46952fe Author: David Mitchell <da...@iabyn.com> Date: 2024-11-19 (Tue, 19 Nov 2024) Changed paths: M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm M dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm M dist/ExtUtils-ParseXS/t/001-basic.t Log Message: ----------- ParseXS: allow SV* as placeholder ExtUtils::ParseXS, up until and including perl 5.40.0, accepted unparseable XSUB parameter declarations: if the parameter couldn't be parsed, it was just silently skipped. This had the side effect that any old line noise could be used as a placeholder: no parameter would be declared, but during arg processing, the arg would be skipped. During my recent refactoring work, I instead made it an error if the parameter couldn't be parsed, but this broke some modules which were using 'SV*' as a placeholder, e.g. int foo(int a, SV*, int b) ... To partially restore backwards compatibility, this commit recognises the special case of 'SV*' being used as a placeholder. All other unparseable parameter declarations will continue to be an error. It will however now still emit an error if 'SV*' is used on a bodiless sub. It used to cause the call to the C function to be emitted as (from the example above), RETVAL = foo(a, SV*, b); which isn't legal C code. So making it an error isn't breaking backwards compatibility. The coder can still use C_ARGS, e.g. int foo(int a, SV*, int b) C_ARGS: a, b Compare: https://github.com/Perl/perl5/compare/1491ccde81dd...1b371875923f To unsubscribe from these emails, change your notification settings at https://github.com/Perl/perl5/settings/notifications