Skip to content

Commit 156f4ea

Browse files
committed
ParseXS: refactor: clean-up Param->parse() method
This is the third of three commits to create the parse() method. Mainly do s/$param/$self/g, and add a call to set file/line number foer the object.
1 parent dcc507c commit 156f4ea

File tree

1 file changed

+14
-13
lines changed
  • dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS

1 file changed

+14
-13
lines changed

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -908,11 +908,12 @@ BEGIN { $build_subclass->('', # parent
908908
# $pxs->{config_allow_argtypes}
909909

910910
sub parse {
911-
my ExtUtils::ParseXS::Node::Param $param = shift;
911+
my __PACKAGE__ $self = shift;
912912
my ExtUtils::ParseXS $pxs = shift;
913913
my $params = shift; # parent Params
914914
my $param_text = shift;
915915

916+
$self->SUPER::parse($pxs); # set file/line_no
916917
$_ = $param_text;
917918

918919
# Decompose parameter into its components.
@@ -941,15 +942,15 @@ sub parse {
941942
if (/^ SV \s* \* $/x) {
942943
# special-case SV* as a placeholder for backwards
943944
# compatibility.
944-
$param->{var} = 'SV *';
945+
$self->{var} = 'SV *';
945946
return 1;
946947
}
947948
$pxs->blurt("Unparseable XSUB parameter: '$_'");
948949
return;
949950
}
950951

951952
undef $type unless length($type) && $type =~ /\S/;
952-
$param->{var} = $name;
953+
$self->{var} = $name;
953954

954955
# Check for duplicates
955956

@@ -965,15 +966,15 @@ sub parse {
965966
# RETVAL is currently fully synthetic. Now that it has
966967
# been declared as a parameter too, override any implicit
967968
# RETVAL declaration. Delete the original param from the
968-
# param list and later re-add it as a parameter in it's
969+
# param list and later re-add it as a parameter in its
969970
# correct position.
970971
@{$params->{kids}} = grep $_ != $old_param, @{$params->{kids}};
971972
# If the param declaration includes a type, it becomes a
972973
# real parameter. Otherwise the param is kept as
973974
# 'semi-real' (synthetic, but with an arg_num) until such
974975
# time as it gets a type set in INPUT, which would remove
975976
# the synthetic/no_init.
976-
%$param = %$old_param unless defined $type;
977+
%$self = %$old_param unless defined $type;
977978
}
978979
else {
979980
$pxs->blurt(
@@ -1026,17 +1027,17 @@ sub parse {
10261027
# and which thus don't need a matching INPUT line.
10271028

10281029
if (defined $type or $is_length) { # 'int foo' or 'length(foo)'
1029-
@$param{qw(type is_ansi)} = ($type, 1);
1030+
@$self{qw(type is_ansi)} = ($type, 1);
10301031

10311032
if ($is_length) {
1032-
$param->{no_init} = 1;
1033-
$param->{is_length} = 1;
1034-
$param->{len_name} = $len_name;
1033+
$self->{no_init} = 1;
1034+
$self->{is_length} = 1;
1035+
$self->{len_name} = $len_name;
10351036
}
10361037
}
10371038

1038-
$param->{in_out} = $out_type if length $out_type;
1039-
$param->{no_init} = 1 if $out_type =~ /^OUT/;
1039+
$self->{in_out} = $out_type if length $out_type;
1040+
$self->{no_init} = 1 if $out_type =~ /^OUT/;
10401041

10411042
# Process the default expression, including making the text
10421043
# to be used in "usage: ..." error messages.
@@ -1046,8 +1047,8 @@ sub parse {
10461047
# sometimes preserve the spaces either side of the '='
10471048
$report_def = ((defined $type or $is_length) ? '' : $sp1)
10481049
. "=$sp2$default";
1049-
$param->{default_usage} = $report_def;
1050-
$param->{default} = $default;
1050+
$self->{default_usage} = $report_def;
1051+
$self->{default} = $default;
10511052
}
10521053

10531054
1;

0 commit comments

Comments
 (0)