Skip to content

Commit 58ffdb2

Browse files
committed
ParseXS: refactor: OUTPUT_handler() split into two
This is #2 of a small series of commits to refactor the OUTPUT_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, OUTPUT_handler_line() which contains the bulk of the old method and processes a single line from an OUTPUT section.
1 parent c65cb56 commit 58ffdb2

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

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

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,11 +1754,24 @@ sub OUTPUT_handler {
17541754
# paragraph
17551755

17561756
for (; $line !~ /^$BLOCK_regexp/o; $line = shift(@{ $self->{line} })) {
1757-
next unless $line =~ /\S/; # skip blank lines
1757+
$self->OUTPUT_handler_line($line);
1758+
} # foreach line in OUTPUT block
1759+
1760+
$_ = $line;
1761+
}
1762+
1763+
1764+
# process a single line from an OUTPUT section
1765+
1766+
sub OUTPUT_handler_line {
1767+
my ExtUtils::ParseXS $self = shift;
1768+
my $line = shift;
1769+
1770+
return unless $line =~ /\S/; # skip blank lines
17581771

17591772
if ($line =~ /^\s*SETMAGIC\s*:\s*(ENABLE|DISABLE)\s*/) {
17601773
$self->{xsub_SETMAGIC_state} = ($1 eq "ENABLE" ? 1 : 0);
1761-
next;
1774+
return;
17621775
}
17631776

17641777
# Expect lines of the two forms
@@ -1772,20 +1785,20 @@ sub OUTPUT_handler {
17721785

17731786
if ($param && $param->{in_output}) {
17741787
$self->blurt("Error: duplicate OUTPUT parameter '$outarg' ignored");
1775-
next;
1788+
return;
17761789
}
17771790

17781791
if ($outarg eq "RETVAL" and $self->{xsub_seen_NO_OUTPUT}) {
17791792
$self->blurt("Error: can't use RETVAL in OUTPUT when NO_OUTPUT declared");
1780-
next;
1793+
return;
17811794
}
17821795

17831796
if ( !$param # no such param or, for RETVAL, RETVAL was void
17841797
# not bound to an arg which can be updated
17851798
or $outarg ne "RETVAL" && !$param->{arg_num})
17861799
{
17871800
$self->blurt("Error: OUTPUT $outarg not a parameter");
1788-
next;
1801+
return;
17891802
}
17901803

17911804

@@ -1798,13 +1811,10 @@ sub OUTPUT_handler {
17981811
if ($outarg eq 'RETVAL') {
17991812
# Postpone processing the RETVAL line to last (it's left to the
18001813
# caller to finish).
1801-
next;
1814+
return;
18021815
}
18031816

18041817
$param->as_output_code($self);
1805-
} # foreach line in OUTPUT block
1806-
1807-
$_ = $line;
18081818
}
18091819

18101820

0 commit comments

Comments
 (0)