Skip to content

Commit 55be473

Browse files
committed
ParseXS: refactor: rename some fields to ioparam
In the INPUT_line and OUTPUT_line subclasses, rename the 'param' field to 'ioparam', to better reflect that it holds an IO_Param object rather than a Param object.
1 parent 664dcc0 commit 55be473

File tree

1 file changed

+39
-38
lines changed
  • dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS

1 file changed

+39
-38
lines changed

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

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4225,7 +4225,7 @@ package ExtUtils::ParseXS::Node::INPUT_line;
42254225
# Handle one line from an INPUT keyword block
42264226

42274227
BEGIN { $build_subclass->(parent => 'keyline',
4228-
'param', # The IO_Param object associated with this INPUT line.
4228+
'ioparam', # The IO_Param object associated with this INPUT line.
42294229

42304230
# The parsed components of this INPUT line:
42314231
'type', # Str: char *
@@ -4320,9 +4320,10 @@ sub parse {
43204320

43214321
my $ioparams = $xbody->{ioparams};
43224322

4323-
my ExtUtils::ParseXS::Node::IO_Param $param = $ioparams->{names}{$var_name};
4323+
my ExtUtils::ParseXS::Node::IO_Param $ioparam =
4324+
$ioparams->{names}{$var_name};
43244325

4325-
if (defined $param) {
4326+
if (defined $ioparam) {
43264327
# The var appeared in the signature too.
43274328

43284329
# Check for duplicate definitions of a particular parameter name.
@@ -4331,52 +4332,52 @@ sub parse {
43314332
# and thus shouldn't be defined again. The exception to this are
43324333
# synthetic params like THIS, which are assigned a provisional type
43334334
# which can be overridden.
4334-
if ( $param->{in_input}
4335-
or (!$param->{is_synthetic} and defined $param->{type})
4335+
if ( $ioparam->{in_input}
4336+
or (!$ioparam->{is_synthetic} and defined $ioparam->{type})
43364337
) {
43374338
$pxs->blurt(
43384339
"Error: duplicate definition of parameter '$var_name' ignored");
43394340
return;
43404341
}
43414342

4342-
if ($var_name eq 'RETVAL' and $param->{is_synthetic}) {
4343+
if ($var_name eq 'RETVAL' and $ioparam->{is_synthetic}) {
43434344
# Convert a synthetic RETVAL into a real parameter
4344-
delete $param->{is_synthetic};
4345-
delete $param->{no_init};
4346-
if (! defined $param->{arg_num}) {
4345+
delete $ioparam->{is_synthetic};
4346+
delete $ioparam->{no_init};
4347+
if (! defined $ioparam->{arg_num}) {
43474348
# if has arg_num, RETVAL has appeared in signature but with no
43484349
# type, and has already been moved to the correct position;
43494350
# otherwise, it's an alien var that didn't appear in the
43504351
# signature; move to the correct position.
43514352
@{$ioparams->{kids}} =
4352-
grep $_ != $param, @{$ioparams->{kids}};
4353-
push @{$ioparams->{kids}}, $param;
4354-
$is_alien = 1;
4355-
$param->{is_alien} = 1;
4353+
grep $_ != $ioparam, @{$ioparams->{kids}};
4354+
push @{$ioparams->{kids}}, $ioparam;
4355+
$is_alien = 1;
4356+
$ioparam->{is_alien} = 1;
43564357
}
43574358
}
43584359

4359-
$param->{in_input} = 1;
4360-
$var_num = $param->{arg_num};
4360+
$ioparam->{in_input} = 1;
4361+
$var_num = $ioparam->{arg_num};
43614362
}
43624363
else {
43634364
# The var is in an INPUT line, but not in signature. Treat it as a
43644365
# general var declaration (which really should have been in a
43654366
# PREINIT section). Legal but nasty: flag is as 'alien'
43664367
$is_alien = 1;
4367-
$param = ExtUtils::ParseXS::Node::IO_Param->new({
4368+
$ioparam = ExtUtils::ParseXS::Node::IO_Param->new({
43684369
var => $var_name,
43694370
is_alien => 1,
43704371
});
43714372

4372-
push @{$ioparams->{kids}}, $param;
4373-
$ioparams->{names}{$var_name} = $param;
4373+
push @{$ioparams->{kids}}, $ioparam;
4374+
$ioparams->{names}{$var_name} = $ioparam;
43744375
}
43754376

43764377
# Parse the initialisation part of the INPUT line (if any)
43774378

43784379
my ($init, $defer);
4379-
my $no_init = $param->{no_init}; # may have had OUT in signature
4380+
my $no_init = $ioparam->{no_init}; # may have had OUT in signature
43804381

43814382
if (!$no_init && defined $init_op) {
43824383
# Use the init code based on overridden $var_init, which was
@@ -4420,12 +4421,12 @@ sub parse {
44204421
$self->{name} = $var_name,
44214422
$self->{init_op} = $init_op,
44224423
$self->{init} = $var_init,
4423-
$self->{param} = $param;
4424+
$self->{ioparam} = $ioparam;
44244425

4425-
# and also update the param object using that information
4426+
# and also update the ioparam object using that information
44264427

4427-
%$param = (
4428-
%$param,
4428+
%$ioparam = (
4429+
%$ioparam,
44294430
type => $var_type,
44304431
arg_num => $var_num,
44314432
var => $var_name,
@@ -4449,14 +4450,14 @@ sub as_code {
44494450
# Emit "type var" declaration and possibly various forms of
44504451
# initialiser code.
44514452

4452-
my $ioparam = $self->{param};
4453+
my $ioparam = $self->{ioparam};
44534454

44544455
# Synthetic params like THIS will be emitted later - they
44554456
# are treated like ANSI params, except the type can overridden
44564457
# within an INPUT statement
44574458
return if $ioparam->{is_synthetic};
44584459

4459-
# The param object contains data from both the INPUT line and
4460+
# The ioparam object contains data from both the INPUT line and
44604461
# the XSUB signature.
44614462
$ioparam->as_input_code($pxs, $xsub, $xbody);
44624463
}
@@ -4481,7 +4482,7 @@ package ExtUtils::ParseXS::Node::OUTPUT_line;
44814482
# Handle one line from an OUTPUT keyword block
44824483

44834484
BEGIN { $build_subclass->(parent => 'keyline',
4484-
'param', # the IO_Param object associated with this OUTPUT line.
4485+
'ioparam', # the IO_Param object associated with this OUTPUT line.
44854486
'is_setmagic', # Bool: the line is a SETMAGIC: line
44864487
'do_setmagic', # Bool: the current SETMAGIC state
44874488
'name', # Str: name of the parameter to output
@@ -4524,11 +4525,11 @@ sub parse {
45244525

45254526
$self->{name} = $outarg;
45264527

4527-
my ExtUtils::ParseXS::Node::IO_Param $param =
4528+
my ExtUtils::ParseXS::Node::IO_Param $ioparam =
45284529
$xbody->{ioparams}{names}{$outarg};
4529-
$self->{param} = $param;
4530+
$self->{ioparam} = $ioparam;
45304531

4531-
if ($param && $param->{in_output}) {
4532+
if ($ioparam && $ioparam->{in_output}) {
45324533
$pxs->blurt("Error: duplicate OUTPUT parameter '$outarg' ignored");
45334534
return;
45344535
}
@@ -4541,19 +4542,19 @@ sub parse {
45414542
return;
45424543
}
45434544

4544-
if ( !$param # no such param or, for RETVAL, RETVAL was void
4545-
# not bound to an arg which can be updated
4546-
or $outarg ne "RETVAL" && !$param->{arg_num})
4545+
if ( !$ioparam # no such param or, for RETVAL, RETVAL was void;
4546+
# not bound to an arg which can be updated
4547+
or $outarg ne "RETVAL" && !$ioparam->{arg_num})
45474548
{
45484549
$pxs->blurt("Error: OUTPUT $outarg not a parameter");
45494550
return;
45504551
}
45514552

4552-
$param->{in_output} = 1;
4553-
$param->{do_setmagic} = $outarg eq 'RETVAL'
4553+
$ioparam->{in_output} = 1;
4554+
$ioparam->{do_setmagic} = $outarg eq 'RETVAL'
45544555
? 0 # RETVAL never needs magic setting
45554556
: $xbody->{OUTPUT_SETMAGIC_state};
4556-
$self->{code} = $param->{output_code} = $outcode if length $outcode;
4557+
$self->{code} = $ioparam->{output_code} = $outcode if length $outcode;
45574558

45584559
1;
45594560
}
@@ -4597,10 +4598,10 @@ sub as_code {
45974598

45984599
return if $self->{name} eq 'RETVAL';
45994600

4600-
my $param = $self->{param};
4601-
return unless $param; # might be an ENABLE line with no param to emit
4601+
my $ioparam = $self->{ioparam};
4602+
return unless $ioparam; # might be an ENABLE line with no param to emit
46024603

4603-
$param->as_output_code($pxs);
4604+
$ioparam->as_output_code($pxs);
46044605
}
46054606

46064607

0 commit comments

Comments
 (0)