Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cfdba7c

Browse files
committedApr 23, 2025
ParseXS: refactor: INPUT_handler() split into two
This is #2 of a small series of commits to refactor the INPUT_handler() method and turn it into a Node subclass method. This commit splits the method into two: a smaller outer one which has the 'foreach line' loop, and a new method, INPUT_handler_line() which contains the bulk of the old method and processes a single line from an INPUT section.
1 parent 3a4df27 commit cfdba7c

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed
 

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

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,7 +1970,20 @@ sub INPUT_handler {
19701970
# treat NOT_IMPLEMENTED_YET as another block separator, in addition to
19711971
# $BLOCK_regexp.
19721972
last if $line =~ /^\s*NOT_IMPLEMENTED_YET/;
1973-
next unless $line =~ /\S/; # skip blank lines
1973+
1974+
$self->INPUT_handler_line($line);
1975+
} # foreach line in INPUT block
1976+
$_ = $line;
1977+
}
1978+
1979+
1980+
# process a single line from an INPUT section
1981+
1982+
sub INPUT_handler_line {
1983+
my ExtUtils::ParseXS $self = shift;
1984+
my $line = shift;
1985+
1986+
return unless $line =~ /\S/; # skip blank lines
19741987

19751988
trim_whitespace($line);
19761989
my $orig_line = $line; # keep original line for error messages
@@ -2012,12 +2025,12 @@ sub INPUT_handler {
20122025
(\w+ | length\(\w+\)) # name or length(name)
20132026
$
20142027
/xs
2015-
or $self->blurt("Error: invalid parameter declaration '$orig_line'"), next;
2028+
or $self->blurt("Error: invalid parameter declaration '$orig_line'"), return;
20162029

20172030
# length(s) is only allowed in the XSUB's signature.
20182031
if ($var_name =~ /^length\((\w+)\)$/) {
20192032
$self->blurt("Error: length() not permitted in INPUT section");
2020-
next;
2033+
return;
20212034
}
20222035

20232036
my ($var_num, $is_alien);
@@ -2040,7 +2053,7 @@ sub INPUT_handler {
20402053
) {
20412054
$self->blurt(
20422055
"Error: duplicate definition of parameter '$var_name' ignored");
2043-
next;
2056+
return;
20442057
}
20452058

20462059
if ($var_name eq 'RETVAL' and $param->{is_synthetic}) {
@@ -2130,21 +2143,17 @@ sub INPUT_handler {
21302143
);
21312144

21322145
$param->check($self)
2133-
or next;
2146+
or return;
21342147

21352148
# Emit "type var" declaration and possibly various forms of
21362149
# initialiser code.
21372150

21382151
# Synthetic params like THIS will be emitted later - they
21392152
# are treated like ANSI params, except the type can overridden
21402153
# within an INPUT statement
2141-
next if $param->{is_synthetic};
2154+
return if $param->{is_synthetic};
21422155

21432156
$param->as_code($self);
2144-
2145-
} # foreach line in INPUT block
2146-
2147-
$_ = $line;
21482157
}
21492158

21502159

0 commit comments

Comments
 (0)
Please sign in to comment.