This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #77810] Scalars vs globs
[perl5.git] / hv.h
diff --git a/hv.h b/hv.h
index 0303b9f..3e4040c 100644 (file)
--- a/hv.h
+++ b/hv.h
@@ -67,6 +67,7 @@ struct mro_meta {
     (((smeta)->mro_which && (which) == (smeta)->mro_which) \
      ? (smeta)->mro_linear_current                        \
      : Perl_mro_get_private_data(aTHX_ (smeta), (which)))
+#define mro_isa_changed_in(stash) mro_isa_changed_in3(stash, NULL, 0)
 
 /* Subject to change.
    Don't access this directly.
@@ -78,16 +79,17 @@ 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. */
 struct xpvhv {
     HV*                xmg_stash;      /* class package */
     union _xmgu        xmg_u;
-    STRLEN      xhv_fill;       /* how full xhv_array currently is */
+    STRLEN      xhv_keys;       /* total keys, including placeholders */
     STRLEN      xhv_max;        /* subscript of last element of xhv_array */
-    STRLEN     xhv_keys;       /* total keys, including placeholders */
 };
 
 /* hash a key */
@@ -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)
@@ -453,6 +462,9 @@ C<SV*>.
 
 struct refcounted_he;
 
+/* flags for the refcounted_he API */
+#define REFCOUNTED_HE_KEY_UTF8         0x00000001
+
 #ifdef PERL_CORE
 
 /* Gosh. This really isn't a good name any longer.  */
@@ -476,6 +488,30 @@ struct refcounted_he {
     char                  refcounted_he_data[1];
 };
 
+/*
+=for apidoc m|SV *|refcounted_he_fetch_pvs|const struct refcounted_he *chain|const char *key|U32 flags
+
+Like L</refcounted_he_fetch_pvn>, but takes a literal string instead of
+a string/length pair, and no precomputed hash.
+
+=cut
+*/
+
+#define refcounted_he_fetch_pvs(chain, key, flags) \
+    Perl_refcounted_he_fetch_pvn(aTHX_ chain, STR_WITH_LEN(key), 0, flags)
+
+/*
+=for apidoc m|struct refcounted_he *|refcounted_he_new_pvs|struct refcounted_he *parent|const char *key|SV *value|U32 flags
+
+Like L</refcounted_he_new_pvn>, but takes a literal string instead of
+a string/length pair, and no precomputed hash.
+
+=cut
+*/
+
+#define refcounted_he_new_pvs(parent, key, value, flags) \
+    Perl_refcounted_he_new_pvn(aTHX_ parent, STR_WITH_LEN(key), 0, value, flags)
+
 /* Flag bits are HVhek_UTF8, HVhek_WASUTF8, then */
 #define HVrhek_undef   0x00 /* Value is undef. */
 #define HVrhek_delete  0x10 /* Value is placeholder - signifies delete. */