summaryrefslogtreecommitdiff
path: root/hv.h
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1996-06-19 20:12:08 +0000
committerCharles Bailey <bailey@genetics.upenn.edu>1996-06-19 20:12:08 +0000
commitbf6bd8876f5c82478753ddc8ce036db60ddde40e (patch)
tree0c2479a22faf0c13e641f73b56a0fa1b336a6004 /hv.h
parentfde52b5cc5a5093c19adc4c8444d3cef2f199541 (diff)
downloadperl-bf6bd8876f5c82478753ddc8ce036db60ddde40e.tar.gz
Add shared hash key support
Diffstat (limited to 'hv.h')
-rw-r--r--hv.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/hv.h b/hv.h
index 49703632b8..a9de8caef1 100644
--- a/hv.h
+++ b/hv.h
@@ -32,6 +32,23 @@ struct xpvhv {
char *xhv_name; /* name, if a symbol table */
};
+#define PERL_HASH(hash,str,len) \
+ STMT_START { \
+ register char *s_PeRlHaSh = str; \
+ register I32 i_PeRlHaSh = len; \
+ register U32 hash_PeRlHaSh = 0; \
+ while (i_PeRlHaSh--) \
+ hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \
+ (hash) = hash_PeRlHaSh; \
+ } STMT_END
+
+
+/* these hash entry flags ride on hent_klen */
+
+#define HEf_LAZYDEL -1 /* entry must be deleted during next iter step */
+#define HEf_SVKEY -2 /* hent_key is a SV* (only for magic/tied HVs) */
+
+
#define Nullhv Null(HV*)
#define HvARRAY(hv) ((HE**)((XPVHV*) SvANY(hv))->xhv_array)
#define HvFILL(hv) ((XPVHV*) SvANY(hv))->xhv_fill
@@ -42,6 +59,10 @@ struct xpvhv {
#define HvPMROOT(hv) ((XPVHV*) SvANY(hv))->xhv_pmroot
#define HvNAME(hv) ((XPVHV*) SvANY(hv))->xhv_name
+#define HvSHAREKEYS(hv) (SvFLAGS(hv) & SVphv_SHAREKEYS)
+#define HvSHAREKEYS_on(hv) (SvFLAGS(hv) |= SVphv_SHAREKEYS)
+#define HvSHAREKEYS_off(hv) (SvFLAGS(hv) &= ~SVphv_SHAREKEYS)
+
#ifdef OVERLOAD
/* Maybe amagical: */
@@ -58,3 +79,23 @@ struct xpvhv {
*/
#endif /* OVERLOAD */
+
+#define Nullhe Null(HE*)
+#define HeNEXT(he) (he)->hent_next
+#define HeKEY(he) (he)->hent_key
+#define HeKLEN(he) (he)->hent_klen
+#define HeVAL(he) (he)->hent_val
+#define HeHASH(he) (he)->hent_hash
+#define HePV(he) ((he)->hent_klen == HEf_SVKEY) ? \
+ SvPV((SV*)((he)->hent_key),na) : \
+ (he)->hent_key))
+#define HeSVKEY(he) (((he)->hent_key && \
+ (he)->hent_klen == HEf_SVKEY) ? \
+ (SV*)((he)->hent_key) : Nullsv)
+
+#define HeSVKEY_force(he) ((he)->hent_key ? \
+ (((he)->hent_klen == HEf_SVKEY) ? \
+ (SV*)((he)->hent_key) : \
+ sv_2mortal(newSVpv((he)->hent_key, \
+ (he)->hent_klen))) : \
+ &sv_undef)