Skip to content

Commit b25f1d3

Browse files
committed
ParseXS: refactor: rm xsub_attributes field
Remove the following field from the ExtUtils::ParseXS class: xsub_attributes and replace it with this new field in the ExtUtils::ParseXS::Node::xsub class: attributes
1 parent 8dec29e commit b25f1d3

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,6 @@ BEGIN {
254254
# whether that method has been listed by
255255
# OVERLOAD (for duplicate spotting).
256256

257-
'xsub_attributes', # Array of strings: all ATTRIBUTE keywords
258-
# (possibly multiple space-separated
259-
# keywords per string).
260-
261257
# Per-XSUB OUTPUT section parsing state:
262258

263259
'xsub_SETMAGIC_state', # Bool: most recent value of SETMAGIC in an
@@ -660,7 +656,6 @@ EOM
660656

661657
# Initialise more per-XSUB state
662658

663-
@{ $self->{xsub_attributes} } = (); # ATTRS: lvalue method
664659
$self->{xsub_SETMAGIC_state} = 1; # SETMAGIC: ENABLE
665660

666661

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ BEGIN { $build_subclass->('', # parent
238238
'map_interface_name_short_to_original', # Hash: for each INTERFACE
239239
# name, map the short (PREFIX removed) name
240240
# to the original name.
241+
242+
'attributes', # Array of strings: all ATTRIBUTE keywords
243+
# (possibly multiple space-separated
244+
# keywords per string).
245+
241246
)};
242247

243248

@@ -543,12 +548,13 @@ EOF
543548
$pxs->{need_boot_cv} = 1;
544549
}
545550
}
546-
elsif (@{ $pxs->{xsub_attributes} }) {
551+
elsif ($pxs->{cur_xsub}{attributes}) {
547552
# Generate a standard newXS() call, plus a single call to
548553
# apply_attrs_string() call with the string of attributes.
554+
my $attrs = "@{$pxs->{cur_xsub}{attributes}}";
549555
push(@code, ExtUtils::ParseXS::Q(<<"EOF"));
550556
| cv = $newXS(\"$pname\", XS_$cname$file_arg$proto_arg);
551-
| apply_attrs_string("$pxs->{PACKAGE_name}", cv, "@{ $pxs->{xsub_attributes} }", 0);
557+
| apply_attrs_string("$pxs->{PACKAGE_name}", cv, "$attrs", 0);
552558
EOF
553559
$pxs->{need_boot_cv} = 1;
554560
}
@@ -3227,7 +3233,7 @@ BEGIN { $build_subclass->('multiline', # parent
32273233

32283234

32293235
# Read each lines's worth of attributes into a string that is pushed
3230-
# to the {xsub_attributes} array. Note that it doesn't matter that multiple
3236+
# to the $xsub->{attributes} array. Note that it doesn't matter that multiple
32313237
# space-separated attributes on the same line are stored as a single
32323238
# string; later, all the attribute lines are joined together into a single
32333239
# string to pass to apply_attrs_string().
@@ -3239,7 +3245,7 @@ sub parse {
32393245
$self->SUPER::parse($pxs); # set file/line_no, get lines
32403246
for (@{$self->{lines}}) {
32413247
ExtUtils::ParseXS::Utilities::trim_whitespace($_);
3242-
push @{ $pxs->{xsub_attributes} }, $_;
3248+
push @{$pxs->{cur_xsub}{attributes}}, $_;
32433249
}
32443250
1;
32453251
}

0 commit comments

Comments
 (0)