Skip to content

Commit 7ca700f

Browse files
committed
ParseXS: refactor: rm xsub_interface_macro fields
Remove the following fields from the ExtUtils::ParseXS class: xsub_interface_macro xsub_interface_macro_set and replace them with these new fields in the ExtUtils::ParseXS::Node::xsub class: interface_macro interface_macro_set There is also a slight change in the way these two fields are used. Formerly they were initialised to the default values "XSINTERFACE_FUNC" and "XSINTERFACE_FUNC_SET", then potentially changed by the INTERFACE_MACRO keyword, then the current values were used to emit the interface function pointer getting and setting code. Now, the values are initially undef, and the emitting code checks for defined-ness and if so uses the default value. This means that the logic for using default or overridden value is local to where that value is used rather than being hidden away elsewhere.No change in functionality though.
1 parent 194bb98 commit 7ca700f

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,6 @@ BEGIN {
235235

236236
'cur_xbody', # The Node::xbody currently being parsed
237237

238-
'xsub_interface_macro', # Str: current interface extraction macro.
239-
240-
'xsub_interface_macro_set', # Str: current interface setting macro.
241-
242238
'xsub_prototype', # Str: is set to either the global PROTOTYPES
243239
# values (0 or 1), or to what's been
244240
# overridden for this XSUB with PROTOTYPE
@@ -582,8 +578,6 @@ EOM
582578

583579
# Initialize some per-XSUB instance variables:
584580

585-
$self->{xsub_interface_macro} = 'XSINTERFACE_FUNC';
586-
$self->{xsub_interface_macro_set} = 'XSINTERFACE_FUNC_SET';
587581
$self->{xsub_prototype} = $self->{PROTOTYPES_value};
588582
$self->{xsub_SCOPE_enabled} = 0;
589583
$self->{xsub_map_overload_name_to_seen} = {};

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ BEGIN { $build_subclass->('', # parent
244244
'attributes', # Array of strings: all ATTRIBUTE keywords
245245
# (possibly multiple space-separated
246246
# keywords per string).
247+
248+
# INTERFACE_MACRO state
249+
250+
'interface_macro', # Str: value of interface extraction macro.
251+
'interface_macro_set', # Str: value of interface setting macro.
247252
)};
248253

249254

@@ -569,9 +574,12 @@ EOF
569574
{
570575
my $value = $pxs->{cur_xsub}{map_interface_name_short_to_original}{$yname};
571576
$yname = "$pxs->{PACKAGE_name}\::$yname" unless $yname =~ /::/;
577+
578+
my $macro = $pxs->{cur_xsub}{interface_macro_set};
579+
$macro = 'XSINTERFACE_FUNC_SET' unless defined $macro;
572580
push(@code, ExtUtils::ParseXS::Q(<<"EOF"));
573581
| cv = $newXS(\"$yname\", XS_$cname$file_arg$proto_arg);
574-
| $pxs->{xsub_interface_macro_set}(cv,$value);
582+
| $macro(cv,$value);
575583
EOF
576584
$pxs->{need_boot_cv} = 1;
577585
}
@@ -3180,8 +3188,11 @@ sub as_code {
31803188
my ExtUtils::ParseXS::Node::xsub $xsub = shift;
31813189
my ExtUtils::ParseXS::Node::xbody $xbody = shift;
31823190

3191+
my $macro = $xsub->{interface_macro};
3192+
$macro = 'XSINTERFACE_FUNC' unless defined $macro;
3193+
31833194
print <<"EOF";
3184-
XSFUNCTION = $pxs->{xsub_interface_macro}($xsub->{decl}{return_type}{type},cv,XSANY.any_dptr);
3195+
XSFUNCTION = $macro($xsub->{decl}{return_type}{type},cv,XSANY.any_dptr);
31853196
EOF
31863197
}
31873198

@@ -3218,8 +3229,8 @@ sub parse {
32183229
($m1, $m2) = ($s, 'UNKNOWN_CVT');
32193230
}
32203231

3221-
$self->{get_macro} = $pxs->{xsub_interface_macro} = $m1;
3222-
$self->{set_macro} = $pxs->{xsub_interface_macro_set} = $m2;
3232+
$self->{get_macro} = $pxs->{cur_xsub}{interface_macro} = $m1;
3233+
$self->{set_macro} = $pxs->{cur_xsub}{interface_macro_set} = $m2;
32233234

32243235
1;
32253236
}

0 commit comments

Comments
 (0)