Skip to content

Commit b85d5f8

Browse files
committed
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.
1 parent 9c24c4e commit b85d5f8

File tree

3 files changed

+50
-10
lines changed

3 files changed

+50
-10
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ EOM
956956
my ExtUtils::ParseXS::Node::Param $param
957957
= ExtUtils::ParseXS::Node::Param->new( {
958958
var => $var,
959-
soft_type => $type,
959+
type => $type,
960960
is_synthetic => 1,
961961
arg_num => ++$args_count,
962962
});
@@ -3517,7 +3517,6 @@ sub generate_output {
35173517
my $param = $sig->{names}{$var};
35183518
if ($param) {
35193519
$type = $param->{type};
3520-
$type = $param->{soft_type} unless defined $type;
35213520
}
35223521
}
35233522

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ BEGIN {
8989
our @FIELDS = (
9090
@ExtUtils::ParseXS::Node::FIELDS,
9191
'type', # The C type of the parameter
92-
'soft_type', # The C type be used if not explicitly defined
9392
'arg_num', # The arg number (starting at 1) mapped to this param
9493
'var', # the name of the parameter
9594
'default', # default value (if any)
@@ -124,7 +123,7 @@ sub check {
124123
my ExtUtils::ParseXS::Node::Param $self = shift;
125124
my ExtUtils::ParseXS $pxs = shift;
126125

127-
my $type = defined $self->{type} ? $self->{type} : $self->{soft_type};
126+
my $type = $self->{type};
128127

129128
# Get the overridden prototype character, if any, associated with the
130129
# typemap entry for this var's type.
@@ -142,7 +141,7 @@ sub check {
142141
$pxs->{xsub_sig}{names}{$self->{var}};
143142

144143
if ($sigp) {
145-
for (qw(default soft_type)) {
144+
for (qw(default)) {
146145
$self->{$_} = $sigp->{$_} if exists $sigp->{$_};
147146
}
148147
if ( defined $sigp->{in_out}
@@ -179,12 +178,10 @@ sub as_code {
179178
my ExtUtils::ParseXS::Node::Param $self = shift;
180179
my ExtUtils::ParseXS $pxs = shift;
181180

182-
my ($type, $soft_type, $arg_num, $var, $init, $no_init, $defer, $default)
183-
= @{$self}{qw(type soft_type arg_num var init no_init defer default)};
181+
my ($type, $arg_num, $var, $init, $no_init, $defer, $default)
182+
= @{$self}{qw(type arg_num var init no_init defer default)};
184183

185184
my $arg = $pxs->ST($arg_num, 0);
186-
187-
$type = $soft_type unless defined $type;
188185

189186
if ($self->{is_length}) {
190187
# Process length(foo) parameter.

dist/ExtUtils-ParseXS/t/001-basic.t

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/perl
22

33
use strict;
4-
use Test::More tests => 175;
4+
use Test::More tests => 179;
55
use Config;
66
use DynaLoader;
77
use ExtUtils::CBuilder;
@@ -1253,6 +1253,28 @@ EOF
12531253
"dup err" ],
12541254
],
12551255

1256+
[
1257+
# don't allow THIS in sig, with type
1258+
"C++: f6: sig THIS type",
1259+
[
1260+
'int',
1261+
'X::Y::f6(int THIS)',
1262+
],
1263+
[ 1, 0, qr/\QError: duplicate definition of argument 'THIS'/,
1264+
"dup err" ],
1265+
],
1266+
1267+
[
1268+
# don't allow THIS in sig, without type
1269+
"C++: f7: sig THIS no type",
1270+
[
1271+
'int',
1272+
'X::Y::f7(THIS)',
1273+
],
1274+
[ 1, 0, qr/\QError: duplicate definition of argument 'THIS'/,
1275+
"dup err" ],
1276+
],
1277+
12561278
[
12571279
# allow CLASS's type to be overridden ...
12581280
"C++: new: override CLASS type",
@@ -1280,6 +1302,28 @@ EOF
12801302
"dup err" ],
12811303
],
12821304

1305+
[
1306+
# don't allow CLASS in sig, with type
1307+
"C++: new sig CLASS type",
1308+
[
1309+
'int',
1310+
'X::Y::new(int CLASS)',
1311+
],
1312+
[ 1, 0, qr/\QError: duplicate definition of argument 'CLASS'/,
1313+
"dup err" ],
1314+
],
1315+
1316+
[
1317+
# don't allow CLASS in sig, without type
1318+
"C++: new sig CLASS no type",
1319+
[
1320+
'int',
1321+
'X::Y::new(CLASS)',
1322+
],
1323+
[ 1, 0, qr/\QError: duplicate definition of argument 'CLASS'/,
1324+
"dup err" ],
1325+
],
1326+
12831327
[
12841328
"C++: DESTROY",
12851329
[

0 commit comments

Comments
 (0)