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.
21 char * xhv_array; /* pointer to malloced string */
22 STRLEN xhv_fill; /* how full xhv_array currently is */
23 STRLEN xhv_max; /* subscript of last element of xhv_array */
24 I32 xhv_keys; /* how many elements in the array */
25 double xnv_nv; /* numeric value, if any */
26 MAGIC* xmg_magic; /* magic for scalar array */
27 HV* xmg_stash; /* class package */
29 I32 xhv_riter; /* current root of iterator */
30 HE *xhv_eiter; /* current entry of iterator */
31 PMOP *xhv_pmroot; /* list of pm's for this package */
32 char *xhv_name; /* name, if a symbol table */
35 #define PERL_HASH(hash,str,len) \
37 register char *s_PeRlHaSh = str; \
38 register I32 i_PeRlHaSh = len; \
39 register U32 hash_PeRlHaSh = 0; \
40 while (i_PeRlHaSh--) \
41 hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \
42 (hash) = hash_PeRlHaSh; \
46 /* these hash entry flags ride on hent_klen */
48 #define HEf_LAZYDEL -1 /* entry must be deleted during next iter step */
49 #define HEf_SVKEY -2 /* hent_key is a SV* (only for magic/tied HVs) */
52 #define Nullhv Null(HV*)
53 #define HvARRAY(hv) ((HE**)((XPVHV*) SvANY(hv))->xhv_array)
54 #define HvFILL(hv) ((XPVHV*) SvANY(hv))->xhv_fill
55 #define HvMAX(hv) ((XPVHV*) SvANY(hv))->xhv_max
56 #define HvKEYS(hv) ((XPVHV*) SvANY(hv))->xhv_keys
57 #define HvRITER(hv) ((XPVHV*) SvANY(hv))->xhv_riter
58 #define HvEITER(hv) ((XPVHV*) SvANY(hv))->xhv_eiter
59 #define HvPMROOT(hv) ((XPVHV*) SvANY(hv))->xhv_pmroot
60 #define HvNAME(hv) ((XPVHV*) SvANY(hv))->xhv_name
62 #define HvSHAREKEYS(hv) (SvFLAGS(hv) & SVphv_SHAREKEYS)
63 #define HvSHAREKEYS_on(hv) (SvFLAGS(hv) |= SVphv_SHAREKEYS)
64 #define HvSHAREKEYS_off(hv) (SvFLAGS(hv) &= ~SVphv_SHAREKEYS)
69 /* #define HV_AMAGICmb(hv) (SvFLAGS(hv) & (SVpgv_badAM | SVpgv_AM)) */
71 #define HV_AMAGIC(hv) (SvFLAGS(hv) & SVpgv_AM)
72 #define HV_AMAGIC_on(hv) (SvFLAGS(hv) |= SVpgv_AM)
73 #define HV_AMAGIC_off(hv) (SvFLAGS(hv) &= ~SVpgv_AM)
76 #define HV_AMAGICbad(hv) (SvFLAGS(hv) & SVpgv_badAM)
77 #define HV_badAMAGIC_on(hv) (SvFLAGS(hv) |= SVpgv_badAM)
78 #define HV_badAMAGIC_off(hv) (SvFLAGS(hv) &= ~SVpgv_badAM)
83 #define Nullhe Null(HE*)
84 #define HeNEXT(he) (he)->hent_next
85 #define HeKEY(he) (he)->hent_key
86 #define HeKLEN(he) (he)->hent_klen
87 #define HeVAL(he) (he)->hent_val
88 #define HeHASH(he) (he)->hent_hash
89 #define HePV(he) ((he)->hent_klen == HEf_SVKEY) ? \
90 SvPV((SV*)((he)->hent_key),na) : \
92 #define HeSVKEY(he) (((he)->hent_key && \
93 (he)->hent_klen == HEf_SVKEY) ? \
94 (SV*)((he)->hent_key) : Nullsv)
96 #define HeSVKEY_force(he) ((he)->hent_key ? \
97 (((he)->hent_klen == HEf_SVKEY) ? \
98 (SV*)((he)->hent_key) : \
99 sv_2mortal(newSVpv((he)->hent_key, \
100 (he)->hent_klen))) : \