Skip to content

Commit 3ee6057

Browse files
committed
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.
1 parent 05c2d6d commit 3ee6057

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,15 +1051,14 @@ EOM
10511051
# Process 'length(foo)' pseudo-parameter
10521052

10531053
my $is_length;
1054-
my $name = $name_or_lenname;
1054+
my $len_name;
10551055

10561056
if ($name_or_lenname =~ /^length\( \s* (\w+) \s* \)\z/x) {
10571057
if ($self->{config_allow_argtypes}) {
1058-
$name = $1;
1059-
$name_or_lenname = "XSauto_length_of_$name";
1058+
$len_name = $1;
10601059
$is_length = 1;
10611060
if (defined $default) {
1062-
$self->blurt("Default value not allowed on length() parameter '$name'");
1061+
$self->blurt("Default value not allowed on length() parameter '$len_name'");
10631062
undef $default;
10641063
}
10651064
}
@@ -1072,13 +1071,12 @@ EOM
10721071
# and which thus don't need a matching INPUT line.
10731072

10741073
if (defined $type or $is_length) { # 'int foo' or 'length(foo)'
1075-
@$param{qw(type var is_ansi)} = ($type, $name, 1);
1074+
@$param{qw(type is_ansi)} = ($type, 1);
10761075

10771076
if ($is_length) {
10781077
$param->{no_init} = 1;
10791078
$param->{is_length} = 1;
1080-
$param->{len_name} = $name;
1081-
$param->{var} = $name_or_lenname;
1079+
$param->{len_name} = $len_name;
10821080
}
10831081
else {
10841082
$param->{no_init} = 1 if $out_type =~ /^OUT/;

0 commit comments

Comments
 (0)