summaryrefslogtreecommitdiff
path: root/regen/mg_vtable.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-05-13 20:24:34 +0100
committerNicholas Clark <nick@ccl4.org>2011-06-11 10:12:19 +0200
commitb7b5e5787c7b4801f734eb833f5850eea594cca9 (patch)
tree2152af65815564ba077020111bcf9f4936a140f4 /regen/mg_vtable.pl
parentca298f7d2a54eb2838d5931d3aac12d5f3209356 (diff)
downloadperl-b7b5e5787c7b4801f734eb833f5850eea594cca9.tar.gz
Replace PL_vtbl_* with an array PL_magic_vtables.
Define each PL_vtbl_* name as a macro which expands to the correct array element. Using a single array instead of multiple named variables will allow the simplification of various pieces of code.
Diffstat (limited to 'regen/mg_vtable.pl')
-rw-r--r--regen/mg_vtable.pl32
1 files changed, 24 insertions, 8 deletions
diff --git a/regen/mg_vtable.pl b/regen/mg_vtable.pl
index 2a88263ec2..d09bfdaaf5 100644
--- a/regen/mg_vtable.pl
+++ b/regen/mg_vtable.pl
@@ -90,9 +90,14 @@ print $h <<'EOH';
local
*/
+#ifdef DOINIT
+EXT_MGVTBL PL_magic_vtables[] = {
EOH
+my @vtable_names;
+
while (my ($name, $data) = splice @sig, 0, 2) {
+ push @vtable_names, $name;
my @funcs = map {
$data->{$_} ? "Perl_magic_$data->{$_}" : 0;
} qw(get set len clear free copy dup local);
@@ -100,17 +105,28 @@ while (my ($name, $data) = splice @sig, 0, 2) {
$funcs[0] = "(int (*)(pTHX_ SV *, MAGIC *))" . $funcs[0] if $data->{const};
my $funcs = join ", ", @funcs;
+ # Because we can't have a , after the last {...}
+ my $comma = @sig ? ',' : '';
+
print $h "$data->{cond}\n" if $data->{cond};
- print $h <<"EOT";
-#ifdef DOINIT
-EXT_MGVTBL PL_vtbl_$name
- = { $funcs };
+ print $h " { $funcs }$comma\n";
+ print $h <<"EOH" if $data->{cond};
#else
-EXT_MGVTBL PL_vtbl_$name;
+ { 0, 0, 0, 0, 0, 0, 0, 0 }$comma
#endif
-EOT
- print $h "#endif\n" if $data->{cond};
- print $h "\n";
+EOH
}
+print $h <<'EOH';
+};
+#else
+EXT_MGVTBL PL_magic_vtables[];
+#endif
+
+EOH
+
+
+print $h "#define PL_vtbl_$_ PL_magic_vtables[want_vtbl_$_]\n"
+ foreach sort @vtable_names;
+
read_only_bottom_close_and_rename($h);