Skip to content

Commit 8f459ca

Browse files
committed
ExtUtils::ParseXS: delete newXS/file/proto fields
Remove these three fields: $self->{newXS} $self->{file} $self->{proto} from the ParseXS object. They don't really store any proper parsing state; they're just three temporary values better served by three restricted-scope lexical vars. The next commit will re-indent the new scope this commit adds.
1 parent 5aac1f7 commit 8f459ca

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

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

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,6 @@ BEGIN {
372372
# be emitted *after* all INPUT and PREINIT
373373
# keywords have been processed.
374374

375-
'proto', # These three are used when generating the
376-
'newXS', # newXS code. They should really be just
377-
'file', # lexical vars.
378-
379375
);
380376

381377
# do 'use fields', except: fields needs Hash::Util which is XS, which
@@ -1702,29 +1698,31 @@ EOF
17021698
EOF
17031699

17041700
# ----------------------------------------------------------------
1705-
# Generate (but don't yet emit) the boot code for the XSUB, including
1706-
# newXS() call(s) plus any additional boot stuff like handling
1707-
# attributes or storing an alias index in the XSUB's CV.
1701+
# Generate (but don't yet emit - push to $self->{InitFileCode}) the
1702+
# boot code for the XSUB, including newXS() call(s) plus any
1703+
# additional boot stuff like handling attributes or storing an alias
1704+
# index in the XSUB's CV.
17081705
# ----------------------------------------------------------------
17091706

1707+
{
17101708
# Depending on whether the XSUB has a prototype, work out how to
17111709
# invoke one of the newXS() function variants. Set these:
17121710
#
1713-
# $self->{newXS} - the newXS() variant to be called in the boot section
1714-
# $self->{file} - extra ', file' arg to be passed to newXS call
1715-
# $self->{proto} - extra e.g. ', "$@"' arg to be passed to newXS call
1711+
my $newXS; # the newXS() variant to be called in the boot section
1712+
my $file_arg; # an extra ', file' arg to be passed to newXS call
1713+
my $proto_arg; # an extra e.g. ', "$@"' arg to be passed to newXS call
17161714

1717-
$self->{proto} = "";
1715+
$proto_arg = "";
17181716

17191717
unless($self->{ProtoThisXSUB}) {
17201718
# no prototype
1721-
$self->{newXS} = "newXS_deffile";
1722-
$self->{file} = "";
1719+
$newXS = "newXS_deffile";
1720+
$file_arg = "";
17231721
}
17241722
else {
17251723
# needs prototype
1726-
$self->{newXS} = "newXSproto_portable";
1727-
$self->{file} = ", file";
1724+
$newXS = "newXSproto_portable";
1725+
$file_arg = ", file";
17281726

17291727
if ($self->{ProtoThisXSUB} eq 2) {
17301728
# User has specified an empty prototype
@@ -1742,14 +1740,14 @@ EOF
17421740
push @{ $self->{proto_arg} }, "$s\@"
17431741
if $seen_ellipsis; # '...' was seen in XSUB signature
17441742

1745-
$self->{proto} = join ("", grep defined, @{ $self->{proto_arg} } );
1743+
$proto_arg = join ("", grep defined, @{ $self->{proto_arg} } );
17461744
}
17471745
else {
17481746
# User has manually specified a prototype
1749-
$self->{proto} = $self->{ProtoThisXSUB};
1747+
$proto_arg = $self->{ProtoThisXSUB};
17501748
}
17511749

1752-
$self->{proto} = qq{, "$self->{proto}"};
1750+
$proto_arg = qq{, "$proto_arg"};
17531751
}
17541752

17551753
# Now use those values to append suitable newXS() and other code
@@ -1767,7 +1765,7 @@ EOF
17671765
foreach my $xname (sort keys %{ $self->{XsubAliases} }) {
17681766
my $value = $self->{XsubAliases}{$xname};
17691767
push(@{ $self->{InitFileCode} }, Q(<<"EOF"));
1770-
# cv = $self->{newXS}(\"$xname\", XS_$self->{Full_func_name}$self->{file}$self->{proto});
1768+
# cv = $newXS(\"$xname\", XS_$self->{Full_func_name}$file_arg$proto_arg);
17711769
# XSANY.any_i32 = $value;
17721770
EOF
17731771
}
@@ -1776,7 +1774,7 @@ EOF
17761774
# Generate a standard newXS() call, plus a single call to
17771775
# apply_attrs_string() call with the string of attributes.
17781776
push(@{ $self->{InitFileCode} }, Q(<<"EOF"));
1779-
# cv = $self->{newXS}(\"$self->{pname}\", XS_$self->{Full_func_name}$self->{file}$self->{proto});
1777+
# cv = $newXS(\"$self->{pname}\", XS_$self->{Full_func_name}$file_arg$proto_arg);
17801778
# apply_attrs_string("$self->{Package}", cv, "@{ $self->{Attributes} }", 0);
17811779
EOF
17821780
}
@@ -1787,30 +1785,30 @@ EOF
17871785
my $value = $self->{Interfaces}{$yname};
17881786
$yname = "$self->{Package}\::$yname" unless $yname =~ /::/;
17891787
push(@{ $self->{InitFileCode} }, Q(<<"EOF"));
1790-
# cv = $self->{newXS}(\"$yname\", XS_$self->{Full_func_name}$self->{file}$self->{proto});
1788+
# cv = $newXS(\"$yname\", XS_$self->{Full_func_name}$file_arg$proto_arg);
17911789
# $self->{interface_macro_set}(cv,$value);
17921790
EOF
17931791
}
17941792
}
1795-
elsif ($self->{newXS} eq 'newXS_deffile'){
1793+
elsif ($newXS eq 'newXS_deffile'){
17961794
# Modified default: generate a standard newXS() call; but
17971795
# work around the CPAN 'P5NCI' distribution doing:
17981796
# #undef newXS
17991797
# #define newXS ;
18001798
# by omitting the initial (void).
18011799
# XXX DAPM 2024:
1802-
# this branch was originally: "elsif ($self->{newXS} eq 'newXS')"
1800+
# this branch was originally: "elsif ($newXS eq 'newXS')"
18031801
# but when the standard name for the newXS variant changed in
18041802
# xsubpp, it was changed here too. So this branch no longer actually
18051803
# handles a workaround for '#define newXS ;'. I also don't
18061804
# understand how just omitting the '(void)' fixed the problem.
18071805
push(@{ $self->{InitFileCode} },
1808-
" $self->{newXS}(\"$self->{pname}\", XS_$self->{Full_func_name}$self->{file}$self->{proto});\n");
1806+
" $newXS(\"$self->{pname}\", XS_$self->{Full_func_name}$file_arg$proto_arg);\n");
18091807
}
18101808
else {
18111809
# Default: generate a standard newXS() call
18121810
push(@{ $self->{InitFileCode} },
1813-
" (void)$self->{newXS}(\"$self->{pname}\", XS_$self->{Full_func_name}$self->{file}$self->{proto});\n");
1811+
" (void)$newXS(\"$self->{pname}\", XS_$self->{Full_func_name}$file_arg$proto_arg);\n");
18141812
}
18151813

18161814
# For every overload operator, generate an additional newXS()
@@ -1820,8 +1818,11 @@ EOF
18201818
$self->{Overloaded}->{$self->{Package}} = $self->{Packid};
18211819
my $overload = "$self->{Package}\::($operator";
18221820
push(@{ $self->{InitFileCode} },
1823-
" (void)$self->{newXS}(\"$overload\", XS_$self->{Full_func_name}$self->{file}$self->{proto});\n");
1821+
" (void)$newXS(\"$overload\", XS_$self->{Full_func_name}$file_arg$proto_arg);\n");
18241822
}
1823+
1824+
}
1825+
18251826
} # END 'PARAGRAPH' 'while' loop
18261827

18271828

0 commit comments

Comments
 (0)