From 153379b03a31b08b3d4c9f82f3b3cfe3245cad4e Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Sun, 7 Sep 2025 10:21:19 +0100 Subject: [PATCH 01/11] ParseXS: don't import standard_typemap_locations() ExtUtils::ParseXS imports standard_typemap_locations() but doesn't actually use it: the code which used to need it has since been moved to ExtUtils/ParseXS/Utilities.pm. So remove it from the import list. --- dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm | 1 - 1 file changed, 1 deletion(-) diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm index 6573ed2538c5..935615442187 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm @@ -74,7 +74,6 @@ BEGIN { $VERSION = eval $VERSION if $VERSION =~ /_/; use ExtUtils::ParseXS::Utilities qw( - standard_typemap_locations trim_whitespace C_string valid_proto_string From b1790f49aba24f5206dbd986ab7d0671e2543c28 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Sun, 7 Sep 2025 10:44:03 +0100 Subject: [PATCH 02/11] ParseXS: add tests for standard_typemap_locations Add some more tests to ExtUtils-ParseXS/t/101-standard_typemap_locations. In particular, this time with a faked-up @INC. This is mainly so that the next few commits will only change the things we expect when updating standard_typemap_locations(). Note that this new test directly tests for expected strings such as '../../typemap', rather than using File::Spec->updir() etc. This is to avoid the test code being essentially a duplicate of the sub code. It skips this test on platforms which don't seem to use '..' etc. --- .../t/101-standard_typemap_locations.t | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/dist/ExtUtils-ParseXS/t/101-standard_typemap_locations.t b/dist/ExtUtils-ParseXS/t/101-standard_typemap_locations.t index 285090fed8d7..45d38751d1cc 100644 --- a/dist/ExtUtils-ParseXS/t/101-standard_typemap_locations.t +++ b/dist/ExtUtils-ParseXS/t/101-standard_typemap_locations.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use strict; use warnings; -use Test::More tests => 3; +use Test::More tests => 5; use ExtUtils::ParseXS::Utilities qw( standard_typemap_locations ); @@ -35,3 +35,40 @@ use ExtUtils::ParseXS::Utilities qw( } } +{ + my @fake_INC = qw(a/b/c d/e/f /g/h/i); + my @expected = + ( + qw( + ../../../../lib/ExtUtils/typemap + ../../../../typemap + ../../../lib/ExtUtils/typemap + ../../../typemap + ../../lib/ExtUtils/typemap + ../../typemap + ../lib/ExtUtils/typemap + ../typemap + typemap + ) + ); + + my @stl = standard_typemap_locations( \@fake_INC ); + + is(scalar @stl, scalar @expected, + "with fake INC: corrrect number of entries in typemap locations list" ); + + SKIP: { + # Only do a full string comparison on platforms which handle + # "standard" pathname formats and '..' updirs. We *always* test + # on linux, and otherwise test unless the second from last doesn't + # look standard. Always testing on Linux means there is at least + # one platform that won't falsely skip the test if garbage is + # returned. + skip "platform doesn't use ../..", 1 + if $^O ne 'linux' + and $stl[-2] ne '../typemap'; + + is_deeply(\@stl, \@expected, "with fake INC: list of paths match"); + } +} + From c1010c5654697414b53712a3f289db35667170ec Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Sun, 7 Sep 2025 11:10:56 +0100 Subject: [PATCH 03/11] ParseXS: standard_typemap_locations(): skip -e standard_typemap_locations() returns a set of filenames for where a typemap file map be expected, relative to both the current directory and to @INC. The @INC files are filtered using -e, but the others (../../typemap etc) aren't. This commit removes the -e filtering for @INC, for consistency. This means that standard_typemap_locations() now returns a list of filenames of *all* the standard locations where a typemap file *might* be found, regardless of whether the file exists. Previously it was a weird hybrid. This commit should make no difference in practice, since the one caller of this function, process_typemaps() does it's own -f filtering too. So really the net effect of this commit is to remove a few duplicate stat() OS calls. It also allows one existing test to be simplified, since now there will always be one returned entry per @INC entry, whereas before it might have been less. --- .../lib/ExtUtils/ParseXS/Utilities.pm | 2 +- .../t/101-standard_typemap_locations.t | 12 ++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm index 2e8efcc92368..17f41010d191 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm @@ -147,7 +147,7 @@ SCOPE: { my @tm = @tm_template; foreach my $dir (@{ $include_ref}) { my $file = File::Spec->catfile($dir, ExtUtils => 'typemap'); - unshift @tm, $file if -e $file; + unshift @tm, $file; } return @tm; } diff --git a/dist/ExtUtils-ParseXS/t/101-standard_typemap_locations.t b/dist/ExtUtils-ParseXS/t/101-standard_typemap_locations.t index 45d38751d1cc..32cefffc7398 100644 --- a/dist/ExtUtils-ParseXS/t/101-standard_typemap_locations.t +++ b/dist/ExtUtils-ParseXS/t/101-standard_typemap_locations.t @@ -17,17 +17,8 @@ use ExtUtils::ParseXS::Utilities qw( 1 unless @stl > 9; - # We check only as many location entries from the start of the array - # (where the @INC-related entries are) as there are entries from @INC. - # We manage to do that by stopping when we find the "updir" related - # entries, which we assume is never contained in a default @INC entry. - my $updir = File::Spec->updir; + # Check that at least one typemap file can be found under @INC my $max = $#INC; - $max = $#stl if $#stl < $max; - foreach my $i (0.. $max) { - $max = $i, last if $stl[$i] =~ /\Q$updir\E/; - } - ok( ( 0 < (grep -f $_, @stl[0..$max]) ), "At least one typemap file exists underneath \@INC directories" @@ -39,6 +30,7 @@ use ExtUtils::ParseXS::Utilities qw( my @fake_INC = qw(a/b/c d/e/f /g/h/i); my @expected = ( + map("$_/ExtUtils/typemap", reverse @fake_INC), qw( ../../../../lib/ExtUtils/typemap ../../../../typemap From afb189ba859a5ef1ef30f20aa0506d987ba0d990 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Sun, 7 Sep 2025 11:33:54 +0100 Subject: [PATCH 04/11] ParseXS: update standard_typemap_locations() docs Simplify the text describing what this function does. --- .../lib/ExtUtils/ParseXS/Utilities.pm | 78 ++++++++----------- 1 file changed, 31 insertions(+), 47 deletions(-) diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm index 17f41010d191..ef38941e45b6 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm @@ -64,60 +64,44 @@ They are documented here for the benefit of future maintainers of this module. =item * Purpose -Provide a list of filepaths where F files may be found. The -filepaths -- relative paths to files (not just directory paths) -- appear in this list in lowest-to-highest priority. - -The highest priority is to look in the current directory. - - 'typemap' - -The second and third highest priorities are to look in the parent of the -current directory and a directory called F underneath the parent -directory. - - '../typemap', - '../lib/ExtUtils/typemap', - -The fourth through ninth highest priorities are to look in the corresponding -grandparent, great-grandparent and great-great-grandparent directories. - - '../../typemap', - '../../lib/ExtUtils/typemap', - '../../../typemap', - '../../../lib/ExtUtils/typemap', - '../../../../typemap', - '../../../../lib/ExtUtils/typemap', - -The tenth and subsequent priorities are to look in directories named -F which are subdirectories of directories found in C<@INC> -- -I a file named F actually exists in such a directory. -Example: - - '/usr/local/lib/perl5/5.10.1/ExtUtils/typemap', - -However, these filepaths appear in the list returned by -C in reverse order, I, lowest-to-highest. - - '/usr/local/lib/perl5/5.10.1/ExtUtils/typemap', - '../../../../lib/ExtUtils/typemap', - '../../../../typemap', - '../../../lib/ExtUtils/typemap', - '../../../typemap', - '../../lib/ExtUtils/typemap', - '../../typemap', - '../lib/ExtUtils/typemap', - '../typemap', - 'typemap' +Returns a standard list of filepaths where F files may be found. +This will typically be something like: + + map("$_/ExtUtils/typemap", reverse @INC), + qw( + ../../../../lib/ExtUtils/typemap + ../../../../typemap + ../../../lib/ExtUtils/typemap + ../../../typemap + ../../lib/ExtUtils/typemap + ../../typemap + ../lib/ExtUtils/typemap + ../typemap + typemap + ) + +but the style of the pathnames may vary with OS. Note that the value to +use for C<@INC> is passed as an array reference, and can be something +other than C<@INC> itself. + +Pathnames are returned in the order they are expected to be processed; +this means that later files will update or override entries found in +earlier files. So in particular, F in the current directory has +highest priority. C<@INC> is searched in reverse order so that earlier +entries in C<@INC> are processed later and so have higher priority. + +The values of C<-typemap> switches are not used here; they should be added +by the caller to the list of pathnames returned by this function. =item * Arguments - my @stl = standard_typemap_locations( \@INC ); + my @stl = standard_typemap_locations(\@INC); -Reference to C<@INC>. +A single argument: a reference to an array to use as if it were C<@INC>. =item * Return Value -Array holding list of directories to be searched for F files. +A list of F pathnames. =back From 18547363d05b41d682d99d10fc5d6feecdde533b Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Sun, 7 Sep 2025 12:13:51 +0100 Subject: [PATCH 05/11] ParseXS: standard_typemap_locations(): rm cache standard_typemap_locations() has a static variable, @tm_template, which it populates with all the '../../typemap' etc paths on first call, then reuses on subsequent calls. This doesn't seem very useful, since standard_typemap_locations() is typically only called once per run of xsubpp etc. And anyway, regenerating those paths (which doesn't involve any IO) isn't costly. So simplify the code by removing the cache. --- .../lib/ExtUtils/ParseXS/Utilities.pm | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm index ef38941e45b6..64990af7028f 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm @@ -107,14 +107,10 @@ A list of F pathnames. =cut -SCOPE: { - my @tm_template; - sub standard_typemap_locations { my $include_ref = shift; - if (not @tm_template) { - @tm_template = qw(typemap); + my @tm = qw(typemap); my $updir = File::Spec->updir(); foreach my $dir ( @@ -123,19 +119,16 @@ SCOPE: { File::Spec->catdir(($updir) x 3), File::Spec->catdir(($updir) x 4), ) { - unshift @tm_template, File::Spec->catfile($dir, 'typemap'); - unshift @tm_template, File::Spec->catfile($dir, lib => ExtUtils => 'typemap'); + unshift @tm, File::Spec->catfile($dir, 'typemap'); + unshift @tm, File::Spec->catfile($dir, lib => ExtUtils => 'typemap'); } - } - my @tm = @tm_template; foreach my $dir (@{ $include_ref}) { my $file = File::Spec->catfile($dir, ExtUtils => 'typemap'); unshift @tm, $file; } return @tm; } -} # end SCOPE =head2 C From 518c6492e5a8518a361de484f857c015bf4818d9 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Sun, 7 Sep 2025 12:18:25 +0100 Subject: [PATCH 06/11] ParseXS: standard_typemap_locations(): reindent Reindent after previous removed some scopes. White-space only. --- .../lib/ExtUtils/ParseXS/Utilities.pm | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm index 64990af7028f..43ac48bdf234 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm @@ -107,28 +107,28 @@ A list of F pathnames. =cut - sub standard_typemap_locations { - my $include_ref = shift; - - my @tm = qw(typemap); - - my $updir = File::Spec->updir(); - foreach my $dir ( - File::Spec->catdir(($updir) x 1), - File::Spec->catdir(($updir) x 2), - File::Spec->catdir(($updir) x 3), - File::Spec->catdir(($updir) x 4), - ) { - unshift @tm, File::Spec->catfile($dir, 'typemap'); - unshift @tm, File::Spec->catfile($dir, lib => ExtUtils => 'typemap'); - } +sub standard_typemap_locations { + my $include_ref = shift; + + my @tm = qw(typemap); + + my $updir = File::Spec->updir(); + foreach my $dir ( + File::Spec->catdir(($updir) x 1), + File::Spec->catdir(($updir) x 2), + File::Spec->catdir(($updir) x 3), + File::Spec->catdir(($updir) x 4), + ) { + unshift @tm, File::Spec->catfile($dir, 'typemap'); + unshift @tm, File::Spec->catfile($dir, lib => ExtUtils => 'typemap'); + } - foreach my $dir (@{ $include_ref}) { - my $file = File::Spec->catfile($dir, ExtUtils => 'typemap'); - unshift @tm, $file; - } - return @tm; + foreach my $dir (@{ $include_ref}) { + my $file = File::Spec->catfile($dir, ExtUtils => 'typemap'); + unshift @tm, $file; } + return @tm; +} =head2 C From 069d5ac8402b0c1b2be11398314bdf976fb559d3 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Sun, 7 Sep 2025 12:23:15 +0100 Subject: [PATCH 07/11] ParseXS: standard_typemap_locations(): use push Currently this function builds a list of paths in reverse order, but *unshifts* each result one by one so that they end up in the right order. This commit switches the order of generation and *pushes* the result each time. The net result is the same, but its less cognitive load working out what's going on. --- .../lib/ExtUtils/ParseXS/Utilities.pm | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm index 43ac48bdf234..b2e49c963e74 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm @@ -110,23 +110,27 @@ A list of F pathnames. sub standard_typemap_locations { my $include_ref = shift; - my @tm = qw(typemap); + my @tm; + + # See function description above for why 'reverse' is used here. + foreach my $dir (reverse @{$include_ref}) { + my $file = File::Spec->catfile($dir, ExtUtils => 'typemap'); + push @tm, $file; + } my $updir = File::Spec->updir(); foreach my $dir ( - File::Spec->catdir(($updir) x 1), - File::Spec->catdir(($updir) x 2), - File::Spec->catdir(($updir) x 3), File::Spec->catdir(($updir) x 4), + File::Spec->catdir(($updir) x 3), + File::Spec->catdir(($updir) x 2), + File::Spec->catdir(($updir) x 1), ) { - unshift @tm, File::Spec->catfile($dir, 'typemap'); - unshift @tm, File::Spec->catfile($dir, lib => ExtUtils => 'typemap'); + push @tm, File::Spec->catfile($dir, lib => ExtUtils => 'typemap'); + push @tm, File::Spec->catfile($dir, 'typemap'); } - foreach my $dir (@{ $include_ref}) { - my $file = File::Spec->catfile($dir, ExtUtils => 'typemap'); - unshift @tm, $file; - } + push @tm, 'typemap'; + return @tm; } From adf8f55571305f92e117f695db7fb883826570ea Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Sun, 7 Sep 2025 12:40:42 +0100 Subject: [PATCH 08/11] ParseXS: process_typemaps(): update docs Make them a bit clearer. --- .../lib/ExtUtils/ParseXS/Utilities.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm index b2e49c963e74..b4a8ce842690 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm @@ -226,18 +226,21 @@ sub valid_proto_string { =item * Purpose -Process all typemap files. +Process all typemap files. Reads in any typemap files specified explicitly +with C<-typemap> switches or similar, plus any typemap files found in +standard locations relative to C<@INC> and the current directory. =item * Arguments my $typemaps_object = process_typemaps( $args{typemap}, $pwd ); -List of two elements: C element from C<%args>; current working -directory. +The first argument is the C element from C<%args>; the second is +the current working directory (which is only needed for error messages). =item * Return Value -Upon success, returns an L object. +Upon success, returns an L object which contains the +accumulated results of all processed typemap files. =back From cd0857167edff7f4e415791fc8932a9e0000bbb8 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Sun, 7 Sep 2025 12:51:01 +0100 Subject: [PATCH 09/11] xsubpp: update typemap content in man page What the man page said concerning typemaps, and especially the search path, was out of date. --- dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp | 31 ++++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp b/dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp index d596cdff42aa..887e6c1c66d5 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp @@ -67,18 +67,31 @@ B [B<-v>] [B<-except>] [B<-s pattern>] [B<-prototypes>] [B<-noversionche This compiler is typically run by the makefiles created by L or by L or other Perl module build tools. +I is just a thin wrapper over C. + I will compile XS code into C code by embedding the constructs necessary to let C functions manipulate Perl values and creates the glue necessary to let Perl access those functions. The compiler uses typemaps to -determine how to map C function parameters and variables to Perl values. +determine how to map C function parameters and variables to Perl values +and vice versa. + +The compiler will search for typemap files called I. It will use +the following search path to find typemaps and apply them in that order, +so later typemaps take precedence: -The compiler will search for typemap files called I. It will use -the following search path to find default typemaps, with the rightmost -typemap taking precedence. + any files specifed by -typemap - ../../../typemap:../../typemap:../typemap:typemap + map("$_/ExtUtils/typemap", reverse @INC), -It will also use a default typemap installed as C. + ../../../../lib/ExtUtils/typemap + ../../../../typemap + ../../../lib/ExtUtils/typemap + ../../../typemap + ../../lib/ExtUtils/typemap + ../../typemap + ../lib/ExtUtils/typemap + ../typemap + typemap =head1 OPTIONS @@ -97,9 +110,9 @@ Adds exception handling stubs to the C code. =item B<-typemap typemap> -Indicates that a user-supplied typemap should take precedence over the -default typemaps. This option may be used multiple times, with the last -typemap having the highest precedence. +Indicates that a user-supplied typemap should be applied in additon to any +files found in the standard search path. This option may be used multiple +times, with the last typemap having the highest precedence. =item B<-output filename> From ae6314fd6063272a86113960d7774d15c77c6fca Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Sun, 7 Sep 2025 13:17:06 +0100 Subject: [PATCH 10/11] ParseXS, xsubpp: raise priority of -typemap args Prior to 5.10. / 5.8.9, any -typemap arguments to xsubpp were applied last, and thus had the highest priority. From 5.10.0 this was changed (probably inadvertently) so that the -typemap entries were applied first, and so the system and ./typemap files took priority. This commit reverses that change, so that -typemap files are again applied last. --- .../lib/ExtUtils/ParseXS/Utilities.pm | 8 ++++---- dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp | 7 ++++--- .../ExtUtils-ParseXS/t/106-process_typemaps.t | 19 ++++++++++++++++++- dist/ExtUtils-ParseXS/t/600-t-compat.t | 10 +++++++--- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm index b4a8ce842690..1bdb82cb01e9 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm @@ -249,13 +249,13 @@ accumulated results of all processed typemap files. sub process_typemaps { my ($tmap, $pwd) = @_; - my @tm = ref $tmap ? @{$tmap} : ($tmap); + my @tm = standard_typemap_locations( \@INC ); - foreach my $typemap (@tm) { + my @explicit = ref $tmap ? @{$tmap} : ($tmap); + foreach my $typemap (@explicit) { die "Can't find $typemap in $pwd\n" unless -r $typemap; } - - push @tm, standard_typemap_locations( \@INC ); + push @tm, @explicit; require ExtUtils::Typemaps; my $typemap = ExtUtils::Typemaps->new; diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp b/dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp index 887e6c1c66d5..ff171d839b42 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp @@ -79,8 +79,6 @@ The compiler will search for typemap files called I. It will use the following search path to find typemaps and apply them in that order, so later typemaps take precedence: - any files specifed by -typemap - map("$_/ExtUtils/typemap", reverse @INC), ../../../../lib/ExtUtils/typemap @@ -93,6 +91,8 @@ so later typemaps take precedence: ../typemap typemap + any files specifed by -typemap + =head1 OPTIONS Note that the C MakeMaker option may be used to add these options to @@ -112,7 +112,8 @@ Adds exception handling stubs to the C code. Indicates that a user-supplied typemap should be applied in additon to any files found in the standard search path. This option may be used multiple -times, with the last typemap having the highest precedence. +times, with the last typemap having the highest precedence, and all such +files processed after ones found in the standard path. =item B<-output filename> diff --git a/dist/ExtUtils-ParseXS/t/106-process_typemaps.t b/dist/ExtUtils-ParseXS/t/106-process_typemaps.t index a20389ec1ac0..fab7a54867c1 100644 --- a/dist/ExtUtils-ParseXS/t/106-process_typemaps.t +++ b/dist/ExtUtils-ParseXS/t/106-process_typemaps.t @@ -4,7 +4,8 @@ use warnings; use Carp; use Cwd qw(cwd); use File::Temp qw( tempdir ); -use Test::More tests => 2; +use File::Spec; +use Test::More tests => 6; use ExtUtils::ParseXS::Utilities qw( process_typemaps ); @@ -41,3 +42,19 @@ my $startdir = cwd(); chdir $startdir; } +# Confirm that explicit typemaps via -typemap etc override standard +# entries. + +{ + my $tm_obj = process_typemaps( + [ File::Spec->catfile("t", "data", "conflicting.typemap") ], '.'); + ok($tm_obj, "got typemap object"); + + my $tm_entry = $tm_obj->get_typemap(ctype => 'double'); + ok($tm_entry, "got typemap entry object"); + + my $xs = $tm_entry->xstype; + ok($xs, "got typemap XS type"); + # should be overridden from T_NV + is($xs, "T_DIFFERENT", "got typemap XS type"); +} diff --git a/dist/ExtUtils-ParseXS/t/600-t-compat.t b/dist/ExtUtils-ParseXS/t/600-t-compat.t index 20f2ce07b22e..6a330668d2d1 100644 --- a/dist/ExtUtils-ParseXS/t/600-t-compat.t +++ b/dist/ExtUtils-ParseXS/t/600-t-compat.t @@ -97,16 +97,20 @@ foreach my $test (@tests) { # typemap-parsing/handling code in ExtUtils::ParseXS looked like. For # bug-compatibility, we want to produce the same data structures as that # code as much as possible. +# Except in 2025 the ordering was changed so that local files via -typemap +# are now processed afterwards; the order has been changed here to reflect +# that change. sub _process_typemaps { my ($tmap, $pwd) = @_; - my @tm = ref $tmap ? @{$tmap} : ($tmap); + my @tm = standard_typemap_locations( \@INC ); - foreach my $typemap (@tm) { + my @explicit = ref $tmap ? @{$tmap} : ($tmap); + foreach my $typemap (@explicit) { die "Can't find $typemap in $pwd\n" unless -r $typemap; } + push @tm, @explicit; - push @tm, standard_typemap_locations( \@INC ); my ($type_kind_ref, $proto_letter_ref, $input_expr_ref, $output_expr_ref) = ( {}, {}, {}, {} ); From cd875ae3be9cb133fa5fb81ae266072b60731f57 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Wed, 10 Sep 2025 14:51:08 +0100 Subject: [PATCH 11/11] perldelta XS xsubpp -typemap processing priority --- pod/perldelta.pod | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pod/perldelta.pod b/pod/perldelta.pod index ae8050e8f68f..06fa77438c3e 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -141,6 +141,14 @@ means it now requires a scalar argument, not a list, just like C: # Evaluates @t in scalar context (giving the number of elements) # and sleeps for one second. It used to sleep for 42 seconds. +=item * + +L has been upgraded from version 3.59 to 3.60. This +release changes the ordering of the processing of typemap files which have +been specified via C arguments so that (as was the case +prior to Perl 5.10.0) these files are applied last rather than first, and +thus take priority over any system typemap files. + =back =head2 Removed Modules and Pragmata