3 * Copyright (c) 1991-1994, Larry Wall
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
11 typedef struct hek HEK;
26 char * xhv_array; /* pointer to malloced string */
27 STRLEN xhv_fill; /* how full xhv_array currently is */
28 STRLEN xhv_max; /* subscript of last element of xhv_array */
29 I32 xhv_keys; /* how many elements in the array */
30 double xnv_nv; /* numeric value, if any */
31 MAGIC* xmg_magic; /* magic for scalar array */
32 HV* xmg_stash; /* class package */
34 I32 xhv_riter; /* current root of iterator */
35 HE *xhv_eiter; /* current entry of iterator */
36 PMOP *xhv_pmroot; /* list of pm's for this package */
37 char *xhv_name; /* name, if a symbol table */
40 #define PERL_HASH(hash,str,len) \
42 register char *s_PeRlHaSh = str; \
43 register I32 i_PeRlHaSh = len; \
44 register U32 hash_PeRlHaSh = 0; \
45 while (i_PeRlHaSh--) \
46 hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \
47 (hash) = hash_PeRlHaSh; \
51 /* these hash entry flags ride on hent_klen (for use only in magic/tied HVs) */
52 #define HEf_SVKEY -2 /* hent_key is a SV* */
55 #define Nullhv Null(HV*)
56 #define HvARRAY(hv) ((HE**)((XPVHV*) SvANY(hv))->xhv_array)
57 #define HvFILL(hv) ((XPVHV*) SvANY(hv))->xhv_fill
58 #define HvMAX(hv) ((XPVHV*) SvANY(hv))->xhv_max
59 #define HvKEYS(hv) ((XPVHV*) SvANY(hv))->xhv_keys
60 #define HvRITER(hv) ((XPVHV*) SvANY(hv))->xhv_riter
61 #define HvEITER(hv) ((XPVHV*) SvANY(hv))->xhv_eiter
62 #define HvPMROOT(hv) ((XPVHV*) SvANY(hv))->xhv_pmroot
63 #define HvNAME(hv) ((XPVHV*) SvANY(hv))->xhv_name
65 #define HvSHAREKEYS(hv) (SvFLAGS(hv) & SVphv_SHAREKEYS)
66 #define HvSHAREKEYS_on(hv) (SvFLAGS(hv) |= SVphv_SHAREKEYS)
67 #define HvSHAREKEYS_off(hv) (SvFLAGS(hv) &= ~SVphv_SHAREKEYS)
69 #define HvLAZYDEL(hv) (SvFLAGS(hv) & SVphv_LAZYDEL)
70 #define HvLAZYDEL_on(hv) (SvFLAGS(hv) |= SVphv_LAZYDEL)
71 #define HvLAZYDEL_off(hv) (SvFLAGS(hv) &= ~SVphv_LAZYDEL)
76 /* #define HV_AMAGICmb(hv) (SvFLAGS(hv) & (SVpgv_badAM | SVpgv_AM)) */
78 #define HV_AMAGIC(hv) (SvFLAGS(hv) & SVpgv_AM)
79 #define HV_AMAGIC_on(hv) (SvFLAGS(hv) |= SVpgv_AM)
80 #define HV_AMAGIC_off(hv) (SvFLAGS(hv) &= ~SVpgv_AM)
83 #define HV_AMAGICbad(hv) (SvFLAGS(hv) & SVpgv_badAM)
84 #define HV_badAMAGIC_on(hv) (SvFLAGS(hv) |= SVpgv_badAM)
85 #define HV_badAMAGIC_off(hv) (SvFLAGS(hv) &= ~SVpgv_badAM)
90 #define Nullhe Null(HE*)
91 #define HeNEXT(he) (he)->hent_next
92 #define HeKEY_hek(he) (he)->hent_hek
93 #define HeKEY(he) HEK_KEY(HeKEY_hek(he))
94 #define HeKEY_sv(he) (*(SV**)HeKEY(he))
95 #define HeKLEN(he) HEK_LEN(HeKEY_hek(he))
96 #define HeVAL(he) (he)->hent_val
97 #define HeHASH(he) HEK_HASH(HeKEY_hek(he))
98 #define HePV(he) ((HeKLEN(he) == HEf_SVKEY) ? \
99 SvPV(HeKEY_sv(he),na) : \
101 #define HeSVKEY(he) ((HeKEY(he) && \
102 HeKLEN(he) == HEf_SVKEY) ? \
103 HeKEY_sv(he) : Nullsv)
105 #define HeSVKEY_force(he) (HeKEY(he) ? \
106 ((HeKLEN(he) == HEf_SVKEY) ? \
108 sv_2mortal(newSVpv(HeKEY(he), \
111 #define HeSVKEY_set(he,sv) (HeKEY_sv(he) = sv)
113 #define Nullhek Null(HEK*)
114 #define HEK_BASESIZE STRUCT_OFFSET(HEK, hek_key[0])
115 #define HEK_HASH(hek) (hek)->hek_hash
116 #define HEK_LEN(hek) (hek)->hek_len
117 #define HEK_KEY(hek) (hek)->hek_key