3 * Copyright (c) 1991-2002, 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 SV * gp_sv; /* scalar value */
12 U32 gp_refcnt; /* how many globs point to this? */
13 struct io * gp_io; /* filehandle value */
14 CV * gp_form; /* format value */
15 AV * gp_av; /* array value */
16 HV * gp_hv; /* hash value */
17 GV * gp_egv; /* effective gv, if *glob */
18 CV * gp_cv; /* subroutine value */
19 U32 gp_cvgen; /* generational validity of cached gv_cv */
20 U32 gp_flags; /* XXX unused */
21 line_t gp_line; /* line first declared at (for -w) */
22 char * gp_file; /* file first declared in (for -w) */
25 #define GvXPVGV(gv) ((XPVGV*)SvANY(gv))
27 #define GvGP(gv) (GvXPVGV(gv)->xgv_gp)
28 #define GvNAME(gv) (GvXPVGV(gv)->xgv_name)
29 #define GvNAMELEN(gv) (GvXPVGV(gv)->xgv_namelen)
30 #define GvSTASH(gv) (GvXPVGV(gv)->xgv_stash)
31 #define GvFLAGS(gv) (GvXPVGV(gv)->xgv_flags)
36 =for apidoc Am|SV*|GvSV|GV* gv
38 Return the SV from the GV.
43 #define GvSV(gv) (GvGP(gv)->gp_sv)
44 #define GvREFCNT(gv) (GvGP(gv)->gp_refcnt)
45 #define GvIO(gv) ((gv) && SvTYPE((SV*)gv) == SVt_PVGV && GvGP(gv) ? GvIOp(gv) : 0)
46 #define GvIOp(gv) (GvGP(gv)->gp_io)
47 #define GvIOn(gv) (GvIO(gv) ? GvIOp(gv) : GvIOp(gv_IOadd(gv)))
49 #define GvFORM(gv) (GvGP(gv)->gp_form)
50 #define GvAV(gv) (GvGP(gv)->gp_av)
52 /* This macro is deprecated. Do not use! */
53 #define GvREFCNT_inc(gv) ((GV*)SvREFCNT_inc(gv)) /* DO NOT USE */
55 #define GvAVn(gv) (GvGP(gv)->gp_av ? \
57 GvGP(gv_AVadd(gv))->gp_av)
58 #define GvHV(gv) ((GvGP(gv))->gp_hv)
60 #define GvHVn(gv) (GvGP(gv)->gp_hv ? \
62 GvGP(gv_HVadd(gv))->gp_hv)
64 #define GvCV(gv) (GvGP(gv)->gp_cv)
65 #define GvCVGEN(gv) (GvGP(gv)->gp_cvgen)
66 #define GvCVu(gv) (GvGP(gv)->gp_cvgen ? Nullcv : GvGP(gv)->gp_cv)
68 #define GvGPFLAGS(gv) (GvGP(gv)->gp_flags)
70 #define GvLINE(gv) (GvGP(gv)->gp_line)
71 #define GvFILE(gv) (GvGP(gv)->gp_file)
72 #define GvFILEGV(gv) (gv_fetchfile(GvFILE(gv)))
74 #define GvEGV(gv) (GvGP(gv)->gp_egv)
75 #define GvENAME(gv) GvNAME(GvEGV(gv) ? GvEGV(gv) : gv)
76 #define GvESTASH(gv) GvSTASH(GvEGV(gv) ? GvEGV(gv) : gv)
78 #define GVf_INTRO 0x01
79 #define GVf_MULTI 0x02
80 #define GVf_ASSUMECV 0x04
81 #define GVf_IN_PAD 0x08
82 #define GVf_IMPORTED 0xF0
83 #define GVf_IMPORTED_SV 0x10
84 #define GVf_IMPORTED_AV 0x20
85 #define GVf_IMPORTED_HV 0x40
86 #define GVf_IMPORTED_CV 0x80
88 #define GvINTRO(gv) (GvFLAGS(gv) & GVf_INTRO)
89 #define GvINTRO_on(gv) (GvFLAGS(gv) |= GVf_INTRO)
90 #define GvINTRO_off(gv) (GvFLAGS(gv) &= ~GVf_INTRO)
92 #define GvMULTI(gv) (GvFLAGS(gv) & GVf_MULTI)
93 #define GvMULTI_on(gv) (GvFLAGS(gv) |= GVf_MULTI)
94 #define GvMULTI_off(gv) (GvFLAGS(gv) &= ~GVf_MULTI)
96 #define GvASSUMECV(gv) (GvFLAGS(gv) & GVf_ASSUMECV)
97 #define GvASSUMECV_on(gv) (GvFLAGS(gv) |= GVf_ASSUMECV)
98 #define GvASSUMECV_off(gv) (GvFLAGS(gv) &= ~GVf_ASSUMECV)
100 #define GvIMPORTED(gv) (GvFLAGS(gv) & GVf_IMPORTED)
101 #define GvIMPORTED_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED)
102 #define GvIMPORTED_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED)
104 #define GvIMPORTED_SV(gv) (GvFLAGS(gv) & GVf_IMPORTED_SV)
105 #define GvIMPORTED_SV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_SV)
106 #define GvIMPORTED_SV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_SV)
108 #define GvIMPORTED_AV(gv) (GvFLAGS(gv) & GVf_IMPORTED_AV)
109 #define GvIMPORTED_AV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_AV)
110 #define GvIMPORTED_AV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_AV)
112 #define GvIMPORTED_HV(gv) (GvFLAGS(gv) & GVf_IMPORTED_HV)
113 #define GvIMPORTED_HV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_HV)
114 #define GvIMPORTED_HV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_HV)
116 #define GvIMPORTED_CV(gv) (GvFLAGS(gv) & GVf_IMPORTED_CV)
117 #define GvIMPORTED_CV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_CV)
118 #define GvIMPORTED_CV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_CV)
120 #define GvIN_PAD(gv) (GvFLAGS(gv) & GVf_IN_PAD)
121 #define GvIN_PAD_on(gv) (GvFLAGS(gv) |= GVf_IN_PAD)
122 #define GvIN_PAD_off(gv) (GvFLAGS(gv) &= ~GVf_IN_PAD)
124 /* XXX: all GvFLAGS options are used, borrowing GvGPFLAGS for the moment */
126 #define GVf_UNIQUE 0x0001
127 #define GvUNIQUE(gv) (GvGP(gv) && (GvGPFLAGS(gv) & GVf_UNIQUE))
128 #define GvUNIQUE_on(gv) (GvGPFLAGS(gv) |= GVf_UNIQUE)
129 #define GvUNIQUE_off(gv) (GvGPFLAGS(gv) &= ~GVf_UNIQUE)
132 #define GV_UNIQUE_CHECK
134 #undef GV_UNIQUE_CHECK
137 #define Nullgv Null(GV*)
140 #define DM_RUID 0x001
141 #define DM_EUID 0x002
143 #define DM_RGID 0x010
144 #define DM_EGID 0x020
145 #define DM_DELAY 0x100
148 * symbol creation flags, for use in gv_fetchpv() and get_*v()
150 #define GV_ADD 0x01 /* add, if symbol not already there */
151 #define GV_ADDMULTI 0x02 /* add, pretending it has been added already */
152 #define GV_ADDWARN 0x04 /* add, but warn if symbol wasn't already there */
153 #define GV_ADDINEVAL 0x08 /* add, as though we're doing so within an eval */
154 #define GV_NOINIT 0x10 /* add, but don't init symbol, if type != PVGV */