@@ -372,10 +372,6 @@ BEGIN {
372
372
# be emitted *after* all INPUT and PREINIT
373
373
# keywords have been processed.
374
374
375
- ' proto' , # These three are used when generating the
376
- ' newXS' , # newXS code. They should really be just
377
- ' file' , # lexical vars.
378
-
379
375
);
380
376
381
377
# do 'use fields', except: fields needs Hash::Util which is XS, which
@@ -1702,29 +1698,31 @@ EOF
1702
1698
EOF
1703
1699
1704
1700
# ----------------------------------------------------------------
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.
1708
1705
# ----------------------------------------------------------------
1709
1706
1707
+ {
1710
1708
# Depending on whether the XSUB has a prototype, work out how to
1711
1709
# invoke one of the newXS() function variants. Set these:
1712
1710
#
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
1716
1714
1717
- $self -> { proto } = " " ;
1715
+ $proto_arg = " " ;
1718
1716
1719
1717
unless ($self -> {ProtoThisXSUB }) {
1720
1718
# no prototype
1721
- $self -> { newXS } = " newXS_deffile" ;
1722
- $self -> { file } = " " ;
1719
+ $newXS = " newXS_deffile" ;
1720
+ $file_arg = " " ;
1723
1721
}
1724
1722
else {
1725
1723
# needs prototype
1726
- $self -> { newXS } = " newXSproto_portable" ;
1727
- $self -> { file } = " , file" ;
1724
+ $newXS = " newXSproto_portable" ;
1725
+ $file_arg = " , file" ;
1728
1726
1729
1727
if ($self -> {ProtoThisXSUB } eq 2) {
1730
1728
# User has specified an empty prototype
@@ -1742,14 +1740,14 @@ EOF
1742
1740
push @{ $self -> {proto_arg } }, " $s \@ "
1743
1741
if $seen_ellipsis ; # '...' was seen in XSUB signature
1744
1742
1745
- $self -> { proto } = join (" " , grep defined , @{ $self -> {proto_arg } } );
1743
+ $proto_arg = join (" " , grep defined , @{ $self -> {proto_arg } } );
1746
1744
}
1747
1745
else {
1748
1746
# User has manually specified a prototype
1749
- $self -> { proto } = $self -> {ProtoThisXSUB };
1747
+ $proto_arg = $self -> {ProtoThisXSUB };
1750
1748
}
1751
1749
1752
- $self -> { proto } = qq{ , "$self ->{proto} "} ;
1750
+ $proto_arg = qq{ , "$proto_arg "} ;
1753
1751
}
1754
1752
1755
1753
# Now use those values to append suitable newXS() and other code
@@ -1767,7 +1765,7 @@ EOF
1767
1765
foreach my $xname (sort keys %{ $self -> {XsubAliases } }) {
1768
1766
my $value = $self -> {XsubAliases }{$xname };
1769
1767
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 );
1771
1769
# XSANY.any_i32 = $value ;
1772
1770
EOF
1773
1771
}
@@ -1776,7 +1774,7 @@ EOF
1776
1774
# Generate a standard newXS() call, plus a single call to
1777
1775
# apply_attrs_string() call with the string of attributes.
1778
1776
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 );
1780
1778
# apply_attrs_string("$self ->{Package}", cv, "@{ $self ->{Attributes} }", 0);
1781
1779
EOF
1782
1780
}
@@ -1787,30 +1785,30 @@ EOF
1787
1785
my $value = $self -> {Interfaces }{$yname };
1788
1786
$yname = " $self ->{Package}\: :$yname " unless $yname =~ / ::/ ;
1789
1787
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 );
1791
1789
# $self ->{interface_macro_set}(cv,$value );
1792
1790
EOF
1793
1791
}
1794
1792
}
1795
- elsif ($self -> { newXS } eq ' newXS_deffile' ){
1793
+ elsif ($newXS eq ' newXS_deffile' ){
1796
1794
# Modified default: generate a standard newXS() call; but
1797
1795
# work around the CPAN 'P5NCI' distribution doing:
1798
1796
# #undef newXS
1799
1797
# #define newXS ;
1800
1798
# by omitting the initial (void).
1801
1799
# XXX DAPM 2024:
1802
- # this branch was originally: "elsif ($self->{ newXS} eq 'newXS')"
1800
+ # this branch was originally: "elsif ($newXS eq 'newXS')"
1803
1801
# but when the standard name for the newXS variant changed in
1804
1802
# xsubpp, it was changed here too. So this branch no longer actually
1805
1803
# handles a workaround for '#define newXS ;'. I also don't
1806
1804
# understand how just omitting the '(void)' fixed the problem.
1807
1805
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 " );
1809
1807
}
1810
1808
else {
1811
1809
# Default: generate a standard newXS() call
1812
1810
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 " );
1814
1812
}
1815
1813
1816
1814
# For every overload operator, generate an additional newXS()
@@ -1820,8 +1818,11 @@ EOF
1820
1818
$self -> {Overloaded }-> {$self -> {Package }} = $self -> {Packid };
1821
1819
my $overload = " $self ->{Package}\: :($operator " ;
1822
1820
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 " );
1824
1822
}
1823
+
1824
+ }
1825
+
1825
1826
} # END 'PARAGRAPH' 'while' loop
1826
1827
1827
1828
0 commit comments