diff options
Diffstat (limited to 'hv.h')
-rw-r--r-- | hv.h | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -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) |