Skip to content

Commit 88f0de5

Browse files
committed
ParseXS: refactor: test for OUT in one place
Currently there is code in both the signature parsing code and in the INPUT parsing code which sets no_init if the IN/OUT/etc parameter modifier matches /^OUT/. This commit makes it check only during signature parsing, which simplifies the code slightly. Should be no functional changes.
1 parent ffc0f1a commit 88f0de5

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,12 +1079,10 @@ EOM
10791079
$param->{is_length} = 1;
10801080
$param->{len_name} = $len_name;
10811081
}
1082-
else {
1083-
$param->{no_init} = 1 if $out_type =~ /^OUT/;
1084-
}
10851082
}
10861083

10871084
$param->{in_out} = $out_type if length $out_type;
1085+
$param->{no_init} = 1 if $out_type =~ /^OUT/;
10881086

10891087
# Process the default expression, including making the text
10901088
# to be used in "usage: ..." error messages.
@@ -2401,9 +2399,10 @@ sub INPUT_handler {
24012399

24022400
# Parse the initialisation part of the INPUT line (if any)
24032401

2404-
my ($init, $no_init, $defer);
2402+
my ($init, $defer);
2403+
my $no_init = $param->{no_init}; # may have had OUT in signature
24052404

2406-
if (defined $init_op) {
2405+
if (!$no_init && defined $init_op) {
24072406
# Emit the init code based on overridden $var_init, which was
24082407
# preceded by /[=;+]/ which has been extracted into $init_op
24092408

@@ -2434,12 +2433,8 @@ sub INPUT_handler {
24342433
}
24352434
else {
24362435
# no initialiser: emit var and init code based on typemap entry,
2437-
# unless:
2438-
# - its alien (so no stack arg to bind to it), or
2439-
# - its an OUT-only var, so not initialised from the arg
2440-
$no_init = 1
2441-
if ( $is_alien
2442-
or defined $param->{in_out} and $param->{in_out} =~ /^OUT/)
2436+
# unless: it's alien (so no stack arg to bind to it)
2437+
$no_init = 1 if $is_alien;
24432438
}
24442439

24452440
%$param = (

0 commit comments

Comments
 (0)