Skip to content

Commit 52745e9

Browse files
committed
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.
1 parent 4adf59b commit 52745e9

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,13 @@ accumulated results of all processed typemap files.
249249
sub process_typemaps {
250250
my ($tmap, $pwd) = @_;
251251

252-
my @tm = ref $tmap ? @{$tmap} : ($tmap);
252+
my @tm = standard_typemap_locations( \@INC );
253253

254-
foreach my $typemap (@tm) {
254+
my @explicit = ref $tmap ? @{$tmap} : ($tmap);
255+
foreach my $typemap (@explicit) {
255256
die "Can't find $typemap in $pwd\n" unless -r $typemap;
256257
}
257-
258-
push @tm, standard_typemap_locations( \@INC );
258+
push @tm, @explicit;
259259

260260
require ExtUtils::Typemaps;
261261
my $typemap = ExtUtils::Typemaps->new;

dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ The compiler will search for typemap files called I<typemap>. It will use
7979
the following search path to find typemaps and apply them in that order,
8080
so later typemaps take precedence:
8181

82-
any files specifed by -typemap
83-
8482
map("$_/ExtUtils/typemap", reverse @INC),
8583

8684
../../../../lib/ExtUtils/typemap
@@ -93,6 +91,8 @@ so later typemaps take precedence:
9391
../typemap
9492
typemap
9593

94+
any files specifed by -typemap
95+
9696
=head1 OPTIONS
9797

9898
Note that the C<XSOPT> MakeMaker option may be used to add these options to
@@ -112,7 +112,8 @@ Adds exception handling stubs to the C code.
112112

113113
Indicates that a user-supplied typemap should be applied in additon to any
114114
files found in the standard search path. This option may be used multiple
115-
times, with the last typemap having the highest precedence.
115+
times, with the last typemap having the highest precedence, and all such
116+
files processed after ones found in the standard path.
116117

117118
=item B<-output filename>
118119

dist/ExtUtils-ParseXS/t/106-process_typemaps.t

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ use warnings;
44
use Carp;
55
use Cwd qw(cwd);
66
use File::Temp qw( tempdir );
7-
use Test::More tests => 2;
7+
use File::Spec;
8+
use Test::More tests => 6;
89
use ExtUtils::ParseXS::Utilities qw(
910
process_typemaps
1011
);
@@ -41,3 +42,19 @@ my $startdir = cwd();
4142
chdir $startdir;
4243
}
4344

45+
# Confirm that explicit typemaps via -typemap etc override standard
46+
# entries.
47+
48+
{
49+
my $tm_obj = process_typemaps(
50+
[ File::Spec->catfile("t", "data", "conflicting.typemap") ], '.');
51+
ok($tm_obj, "got typemap object");
52+
53+
my $tm_entry = $tm_obj->get_typemap(ctype => 'double');
54+
ok($tm_entry, "got typemap entry object");
55+
56+
my $xs = $tm_entry->xstype;
57+
ok($xs, "got typemap XS type");
58+
# should be overridden from T_NV
59+
is($xs, "T_DIFFERENT", "got typemap XS type");
60+
}

dist/ExtUtils-ParseXS/t/600-t-compat.t

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,20 @@ foreach my $test (@tests) {
9797
# typemap-parsing/handling code in ExtUtils::ParseXS looked like. For
9898
# bug-compatibility, we want to produce the same data structures as that
9999
# code as much as possible.
100+
# Except in 2025 the ordering was changed so that local files via -typemap
101+
# are now processed afterwards; the order has been changed here to reflect
102+
# that change.
100103
sub _process_typemaps {
101104
my ($tmap, $pwd) = @_;
102105

103-
my @tm = ref $tmap ? @{$tmap} : ($tmap);
106+
my @tm = standard_typemap_locations( \@INC );
104107

105-
foreach my $typemap (@tm) {
108+
my @explicit = ref $tmap ? @{$tmap} : ($tmap);
109+
foreach my $typemap (@explicit) {
106110
die "Can't find $typemap in $pwd\n" unless -r $typemap;
107111
}
112+
push @tm, @explicit;
108113

109-
push @tm, standard_typemap_locations( \@INC );
110114

111115
my ($type_kind_ref, $proto_letter_ref, $input_expr_ref, $output_expr_ref)
112116
= ( {}, {}, {}, {} );

0 commit comments

Comments
 (0)