This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Quote string argument in example -- necessary if using strict subs
[perl5.git] / hv.h
1 /*    hv.h
2  *
3  *    Copyright (c) 1991-1994, Larry Wall
4  *
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.
7  *
8  */
9
10 typedef struct he HE;
11
12 struct he {
13     HE          *hent_next;
14     char        *hent_key;
15     SV          *hent_val;
16     U32         hent_hash;
17     I32         hent_klen;
18 };
19
20 struct xpvhv {
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 */
28
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 */
33 };
34
35 #define Nullhv Null(HV*)
36 #define HvARRAY(hv)     ((HE**)((XPVHV*)  SvANY(hv))->xhv_array)
37 #define HvFILL(hv)      ((XPVHV*)  SvANY(hv))->xhv_fill
38 #define HvMAX(hv)       ((XPVHV*)  SvANY(hv))->xhv_max
39 #define HvKEYS(hv)      ((XPVHV*)  SvANY(hv))->xhv_keys
40 #define HvRITER(hv)     ((XPVHV*)  SvANY(hv))->xhv_riter
41 #define HvEITER(hv)     ((XPVHV*)  SvANY(hv))->xhv_eiter
42 #define HvPMROOT(hv)    ((XPVHV*)  SvANY(hv))->xhv_pmroot
43 #define HvNAME(hv)      ((XPVHV*)  SvANY(hv))->xhv_name
44
45 #ifdef OVERLOAD
46
47 /* Maybe amagical: */
48 /* #define HV_AMAGICmb(hv)      (SvFLAGS(hv) & (SVpgv_badAM | SVpgv_AM)) */
49
50 #define HV_AMAGIC(hv)        (SvFLAGS(hv) &   SVpgv_AM)
51 #define HV_AMAGIC_on(hv)     (SvFLAGS(hv) |=  SVpgv_AM)
52 #define HV_AMAGIC_off(hv)    (SvFLAGS(hv) &= ~SVpgv_AM)
53
54 /*
55 #define HV_AMAGICbad(hv)     (SvFLAGS(hv) & SVpgv_badAM)
56 #define HV_badAMAGIC_on(hv)  (SvFLAGS(hv) |= SVpgv_badAM)
57 #define HV_badAMAGIC_off(hv) (SvFLAGS(hv) &= ~SVpgv_badAM)
58 */
59
60 #endif /* OVERLOAD */