@@ -856,7 +856,9 @@ sub parse {
856
856
package ExtUtils::ParseXS::Node::Param ;
857
857
858
858
# Node subclass which holds the state of one XSUB parameter, based on the
859
- # XSUB's signature and/or an INPUT line.
859
+ # just the XSUB's signature. See also the Node::IO_Param subclass, which
860
+ # augments the parameter declaration with info from INPUT and OUTPUT
861
+ # lines.
860
862
861
863
BEGIN { $build_subclass -> (' ' , # parent
862
864
# values derived from the XSUB's signature
@@ -875,19 +877,6 @@ BEGIN { $build_subclass->('', # parent
875
877
' type' , # The C type of the parameter
876
878
' no_init' , # don't initialise the parameter
877
879
878
- # values derived from the XSUB's INPUT line
879
- ' init_op' , # initialisation type: one of =/+/;
880
- ' init' , # initialisation template code
881
- ' is_addr' , # INPUT var declared as '&foo'
882
- ' is_alien' , # var declared in INPUT line, but not in signature
883
- ' in_input' , # the parameter has appeared in an INPUT statement
884
- ' defer' , # deferred initialisation template code
885
-
886
- # values derived from the XSUB's OUTPUT line
887
- ' in_output' , # the parameter has appeared in an OUTPUT statement
888
- ' do_setmagic' , # 'SETMAGIC: ENABLE' was active for this parameter
889
- ' output_code' , # the optional setting-code for this parameter
890
-
891
880
# derived values calculated later
892
881
' proto' , # overridden prototype char(s) (if any) from typemap
893
882
)};
@@ -916,13 +905,37 @@ sub set_proto {
916
905
}
917
906
918
907
919
- # $self->as_code():
908
+ # ======================================================================
909
+
910
+ package ExtUtils::ParseXS::Node::IO_Param ;
911
+
912
+ # Subclass of Node::Param which holds the state of one XSUB parameter,
913
+ # based on the XSUB's signature, but also augmented by info from INPUT or
914
+ # OUTPUT lines
915
+
916
+ BEGIN { $build_subclass -> (' Param' , # parent
917
+ # values derived from the XSUB's INPUT line
918
+ ' init_op' , # initialisation type: one of =/+/;
919
+ ' init' , # initialisation template code
920
+ ' is_addr' , # INPUT var declared as '&foo'
921
+ ' is_alien' , # var declared in INPUT line, but not in signature
922
+ ' in_input' , # the parameter has appeared in an INPUT statement
923
+ ' defer' , # deferred initialisation template code
924
+
925
+ # values derived from the XSUB's OUTPUT line
926
+ ' in_output' , # the parameter has appeared in an OUTPUT statement
927
+ ' do_setmagic' , # 'SETMAGIC: ENABLE' was active for this parameter
928
+ ' output_code' , # the optional setting-code for this parameter
929
+ )};
930
+
931
+
932
+ # $self->as_input_code():
920
933
#
921
934
# Emit the param object as C code which declares and initialise the variable.
922
935
# See also the as_output_code() method, which emits code to return the value
923
936
# of that local var.
924
937
925
- sub as_code {
938
+ sub as_input_code {
926
939
my __PACKAGE__ $self = shift ;
927
940
my ExtUtils::ParseXS $pxs = shift ;
928
941
my ExtUtils::ParseXS::Node::xsub $xsub = shift ;
@@ -1789,19 +1802,20 @@ package ExtUtils::ParseXS::Node::Params;
1789
1802
# Node subclass which holds a list of the parameters for an XSUB
1790
1803
# (both directly found in the foo(....) signature, plus possibly synthetic
1791
1804
# ones such as THIS and RETVAL.
1792
- # It is a mainly a list of Node::Param children.
1805
+ # It is a mainly a list of Node::Param or Node::IO_Param children.
1793
1806
1794
1807
BEGIN { $build_subclass -> (' ' , # parent
1795
1808
1796
- # inherited 'kids' field:
1797
- # Array ref of Node::Param objects representing
1798
- # the parameters of this XSUB - either the
1799
- # original ones as seen in the XSUB's signature,
1800
- # or per-xbody ones augmented by info from INPUT
1801
- # and OUTPUT sections.
1809
+ # Inherited 'kids' field:
1810
+ #
1811
+ # Array ref of Node::Param or Node::IO_Param
1812
+ # objects representing the parameters of this
1813
+ # XSUB - either the original ones as seen in the
1814
+ # XSUB's signature, or per-xbody ones augmented
1815
+ # by info from INPUT and OUTPUT sections.
1802
1816
1803
1817
' names' , # Hash ref mapping variable names to Node::Param
1804
- # objects
1818
+ # or Node::IO_Param objects
1805
1819
1806
1820
' params_text' , # The original text of the sig, e.g.
1807
1821
# 'param1, int param2 = 0'
@@ -2325,7 +2339,7 @@ sub parse {
2325
2339
$ioparams -> {names } = {};
2326
2340
2327
2341
for my $op (@{$orig -> {kids }}) {
2328
- my $p = ExtUtils::ParseXS::Node::Param -> new($op );
2342
+ my $p = ExtUtils::ParseXS::Node::IO_Param -> new($op );
2329
2343
# don't copy the current proto state (from the most recent
2330
2344
# CASE) into the new CASE.
2331
2345
undef $p -> {proto };
@@ -2495,8 +2509,8 @@ EOF
2495
2509
2496
2510
# Emit any 'char * CLASS' or 'Foo::Bar *THIS' declaration if needed
2497
2511
2498
- for my $param (grep $_ -> {is_synthetic }, @{$ioparams -> {kids }}) {
2499
- $param -> as_code ($pxs , $xsub , $xbody );
2512
+ for my $ioparam (grep $_ -> {is_synthetic }, @{$ioparams -> {kids }}) {
2513
+ $ioparam -> as_input_code ($pxs , $xsub , $xbody );
2500
2514
}
2501
2515
2502
2516
# Recent code emits a dXSTARG in a tighter scope and under
@@ -2510,7 +2524,7 @@ EOF
2510
2524
# Emit declaration/init code for any parameters which were
2511
2525
# declared with a type or length(foo). Do the length() ones first.
2512
2526
2513
- for my $param (
2527
+ for my $ioparam (
2514
2528
grep $_ -> {is_ansi },
2515
2529
(
2516
2530
grep ( $_ -> {is_length }, @{$ioparams -> {kids }} ),
@@ -2519,7 +2533,7 @@ EOF
2519
2533
)
2520
2534
2521
2535
{
2522
- $param -> as_code ($pxs , $xsub , $xbody );
2536
+ $ioparam -> as_input_code ($pxs , $xsub , $xbody );
2523
2537
}
2524
2538
2525
2539
# ----------------------------------------------------------------
@@ -3967,7 +3981,7 @@ package ExtUtils::ParseXS::Node::INPUT_line;
3967
3981
# Handle one line from an INPUT keyword block
3968
3982
3969
3983
BEGIN { $build_subclass -> (' keyline' , # parent
3970
- ' param' , # The Param object associated with this INPUT line.
3984
+ ' param' , # The IO_Param object associated with this INPUT line.
3971
3985
3972
3986
# The parsed components of this INPUT line:
3973
3987
' type' , # char *
@@ -3984,18 +3998,18 @@ BEGIN { $build_subclass->('keyline', # parent
3984
3998
# INPUT_line object (which aren't further used for parsing or code
3985
3999
# generation)
3986
4000
#
3987
- # It also uses those values to create/update the Param object
4001
+ # It also uses those values to create/update the IO_Param object
3988
4002
# associated with this variable. For example with
3989
4003
#
3990
4004
# void
3991
4005
# foo(a = 0)
3992
4006
# int a
3993
4007
#
3994
- # a Param object will already have been created with the name 'a' and
4008
+ # a IO_Param object will already have been created with the name 'a' and
3995
4009
# default value '0' when the signature was parsed. Parsing the 'int a'
3996
4010
# line will set the INPUT_line object's fields to (type => 'int',
3997
- # name => 'a'), while the Param object will have its type field set to
3998
- # 'int'. The INPUT_line object also stores a ref to the Param object.
4011
+ # name => 'a'), while the IO_Param object will have its type field set to
4012
+ # 'int'. The INPUT_line object also stores a ref to the IO_Param object.
3999
4013
#
4000
4014
4001
4015
sub parse {
@@ -4062,7 +4076,7 @@ sub parse {
4062
4076
4063
4077
my $ioparams = $xbody -> {ioparams };
4064
4078
4065
- my ExtUtils::ParseXS::Node::Param $param = $ioparams -> {names }{$var_name };
4079
+ my ExtUtils::ParseXS::Node::IO_Param $param = $ioparams -> {names }{$var_name };
4066
4080
4067
4081
if (defined $param ) {
4068
4082
# The var appeared in the signature too.
@@ -4106,7 +4120,7 @@ sub parse {
4106
4120
# general var declaration (which really should have been in a
4107
4121
# PREINIT section). Legal but nasty: flag is as 'alien'
4108
4122
$is_alien = 1;
4109
- $param = ExtUtils::ParseXS::Node::Param -> new({
4123
+ $param = ExtUtils::ParseXS::Node::IO_Param -> new({
4110
4124
var => $var_name ,
4111
4125
is_alien => 1,
4112
4126
});
@@ -4192,16 +4206,16 @@ sub as_code {
4192
4206
# Emit "type var" declaration and possibly various forms of
4193
4207
# initialiser code.
4194
4208
4195
- my $param = $self -> {param };
4209
+ my $ioparam = $self -> {param };
4196
4210
4197
4211
# Synthetic params like THIS will be emitted later - they
4198
4212
# are treated like ANSI params, except the type can overridden
4199
4213
# within an INPUT statement
4200
- return if $param -> {is_synthetic };
4214
+ return if $ioparam -> {is_synthetic };
4201
4215
4202
4216
# The param object contains data from both the INPUT line and
4203
4217
# the XSUB signature.
4204
- $param -> as_code ($pxs , $xsub , $xbody );
4218
+ $ioparam -> as_input_code ($pxs , $xsub , $xbody );
4205
4219
}
4206
4220
4207
4221
@@ -4267,7 +4281,7 @@ sub parse {
4267
4281
4268
4282
$self -> {name } = $outarg ;
4269
4283
4270
- my ExtUtils::ParseXS::Node::Param $param =
4284
+ my ExtUtils::ParseXS::Node::IO_Param $param =
4271
4285
$xbody -> {ioparams }{names }{$outarg };
4272
4286
$self -> {param } = $param ;
4273
4287
0 commit comments