summaryrefslogtreecommitdiff
path: root/hv.h
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2010-10-20 21:33:53 -0700
committerFather Chrysostomos <sprout@cpan.org>2010-10-21 08:18:29 -0700
commitb7247a80ab6b02ec8a01b2c7c8d927ad173700ea (patch)
tree269850bf6f9a06ec8b0ce51d2b118db220518eaf /hv.h
parentc035a075a240f10383292128a8d3f3746c4ac857 (diff)
downloadperl-b7247a80ab6b02ec8a01b2c7c8d927ad173700ea.tar.gz
Allow stashes to have multiple names
This commits modifies the HvAUX structure as follows: A new field is added, named xhv_name_count, indicating the number of names. If it is zero (the default and most common case), then xhv_name is a HEK * as usual. If it is non-zero, then xhv_name actually holds a pointer to an array of HEK*s, the first being the default or ‘canonical’ name. This code is a little repetitious, but more refactorings are to come, so it is too soon to turn these repetitions into macros. This is yet another commit in preparation for fixing [perl #75176]. Basically, whenever a stash is deleted from its containing stash, if it has an alias elsewhere, it needs to assume the new name (of that alias; so it needs to know its other names already) and update isarev entries. Forthcoming commits will do that.
Diffstat (limited to 'hv.h')
-rw-r--r--hv.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/hv.h b/hv.h
index 6fa3252e7a..3e4040c168 100644
--- a/hv.h
+++ b/hv.h
@@ -79,7 +79,9 @@ struct xpvhv_aux {
HE *xhv_eiter; /* current entry of iterator */
I32 xhv_riter; /* current root of iterator */
struct mro_meta *xhv_mro_meta;
-};
+ U32 xhv_name_count; /* When non-zero, xhv_name is actually */
+ /* a pointer to an array of HEKs, this */
+}; /* being the length. */
/* hash structure: */
/* This structure must match the beginning of struct xpvmg in sv.h. */
@@ -256,12 +258,19 @@ C<SV*>.
/* FIXME - all of these should use a UTF8 aware API, which should also involve
getting the length. */
+#define HvNAME_HEK_NN(hv) \
+ ( \
+ HvAUX(hv)->xhv_name_count \
+ ? *(HEK **)HvAUX(hv)->xhv_name \
+ : HvAUX(hv)->xhv_name \
+ )
/* This macro may go away without notice. */
-#define HvNAME_HEK(hv) (SvOOK(hv) ? HvAUX(hv)->xhv_name : NULL)
+#define HvNAME_HEK(hv) \
+ (SvOOK(hv) && HvAUX(hv)->xhv_name ? HvNAME_HEK_NN(hv) : NULL)
#define HvNAME_get(hv) ((SvOOK(hv) && (HvAUX(hv)->xhv_name)) \
- ? HEK_KEY(HvAUX(hv)->xhv_name) : NULL)
+ ? HEK_KEY(HvNAME_HEK_NN(hv)) : NULL)
#define HvNAMELEN_get(hv) ((SvOOK(hv) && (HvAUX(hv)->xhv_name)) \
- ? HEK_LEN(HvAUX(hv)->xhv_name) : 0)
+ ? HEK_LEN(HvNAME_HEK_NN(hv)) : 0)
/* the number of keys (including any placeholers) */
#define XHvTOTALKEYS(xhv) ((xhv)->xhv_keys)