summaryrefslogtreecommitdiff
path: root/mg_vtable.h
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-05-14 12:26:37 +0100
committerNicholas Clark <nick@ccl4.org>2011-06-11 10:39:58 +0200
commit2d1f1fe5758d1f7ec388be4bc09f029dd0df5b7c (patch)
tree5a687231add1e5afc45981f9d7347df80776e0ad /mg_vtable.h
parentb76b0bf9b926e6a5504a59a935a232eb91d44437 (diff)
downloadperl-2d1f1fe5758d1f7ec388be4bc09f029dd0df5b7c.tar.gz
Provide the names of the magic vtables in PL_magic_vtable_names[].
As it's a 1 to 1 mapping with the vtables in PL_magic_vtables[], refactor Perl_do_magic_dump() to index into it directly to find the name for an arbitrary mg_virtual, avoiding a long switch statement.
Diffstat (limited to 'mg_vtable.h')
-rw-r--r--mg_vtable.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/mg_vtable.h b/mg_vtable.h
index 52937d7460..516d2c949e 100644
--- a/mg_vtable.h
+++ b/mg_vtable.h
@@ -40,6 +40,43 @@ enum { /* pass one of these to get_vtbl */
magic_vtable_max
};
+#ifdef DOINIT
+EXTCONST char *PL_magic_vtable_names[magic_vtable_max] = {
+ "sv",
+ "env",
+ "envelem",
+ "sigelem",
+ "pack",
+ "packelem",
+ "dbline",
+ "isa",
+ "isaelem",
+ "arylen",
+ "arylen_p",
+ "mglob",
+ "nkeys",
+ "taint",
+ "substr",
+ "vec",
+ "pos",
+ "uvar",
+ "defelem",
+ "regexp",
+ "regdata",
+ "regdatum",
+ "amagic",
+ "amagicelem",
+ "backref",
+ "ovrld",
+ "utf8",
+ "collxfrm",
+ "hintselem",
+ "hints"
+};
+#else
+EXTCONST char *PL_magic_vtable_names[magic_vtable_max];
+#endif
+
/* These all need to be 0, not NULL, as NULL can be (void*)0, which is a
* pointer to data, whereas we're assigning pointers to functions, which are
* not the same beast. ANSI doesn't allow the assignment from one to the other.