3 * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 * 2000, 2001, 2002, 2003, 2004, 2005, by Larry Wall and others
6 * You may distribute under the terms of either the GNU General Public
7 * License or the Artistic License, as specified in the README file.
12 SV * gp_sv; /* scalar value */
13 U32 gp_refcnt; /* how many globs point to this? */
14 struct io * gp_io; /* filehandle value */
15 CV * gp_form; /* format value */
16 AV * gp_av; /* array value */
17 HV * gp_hv; /* hash value */
18 GV * gp_egv; /* effective gv, if *glob */
19 CV * gp_cv; /* subroutine value */
20 U32 gp_cvgen; /* generational validity of cached gv_cv */
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))
28 # define GvGP(gv) (*(assert(SvTYPE(gv) == SVt_PVGV || \
29 SvTYPE(gv) == SVt_PVLV), \
30 &(GvXPVGV(gv)->xgv_gp)))
32 # define GvGP(gv) (GvXPVGV(gv)->xgv_gp)
35 #define GvNAME(gv) (GvXPVGV(gv)->xgv_name)
36 #define GvNAMELEN(gv) (GvXPVGV(gv)->xgv_namelen)
37 #define GvSTASH(gv) (GvXPVGV(gv)->xgv_stash)
38 #define GvFLAGS(gv) (GvXPVGV(gv)->xgv_flags)
43 =for apidoc Am|SV*|GvSV|GV* gv
45 Return the SV from the GV.
50 #define GvSV(gv) (GvGP(gv)->gp_sv)
51 #ifdef PERL_DONT_CREATE_GVSV
52 #define GvSVn(gv) (*(GvGP(gv)->gp_sv ? \
53 &(GvGP(gv)->gp_sv) : \
54 &(GvGP(gv_SVadd(gv))->gp_sv)))
56 #define GvSVn(gv) GvSV(gv)
59 #define GvREFCNT(gv) (GvGP(gv)->gp_refcnt)
60 #define GvIO(gv) ((gv) && SvTYPE((SV*)gv) == SVt_PVGV && GvGP(gv) ? GvIOp(gv) : 0)
61 #define GvIOp(gv) (GvGP(gv)->gp_io)
62 #define GvIOn(gv) (GvIO(gv) ? GvIOp(gv) : GvIOp(gv_IOadd(gv)))
64 #define GvFORM(gv) (GvGP(gv)->gp_form)
65 #define GvAV(gv) (GvGP(gv)->gp_av)
67 /* This macro is deprecated. Do not use! */
68 #define GvREFCNT_inc(gv) ((GV*)SvREFCNT_inc(gv)) /* DO NOT USE */
70 #define GvAVn(gv) (GvGP(gv)->gp_av ? \
72 GvGP(gv_AVadd(gv))->gp_av)
73 #define GvHV(gv) ((GvGP(gv))->gp_hv)
75 #define GvHVn(gv) (GvGP(gv)->gp_hv ? \
77 GvGP(gv_HVadd(gv))->gp_hv)
79 #define GvCV(gv) (GvGP(gv)->gp_cv)
80 #define GvCVGEN(gv) (GvGP(gv)->gp_cvgen)
81 #define GvCVu(gv) (GvGP(gv)->gp_cvgen ? Nullcv : GvGP(gv)->gp_cv)
83 #define GvLINE(gv) (GvGP(gv)->gp_line)
84 #define GvFILE(gv) (GvGP(gv)->gp_file)
85 #define GvFILEGV(gv) (gv_fetchfile(GvFILE(gv)))
87 #define GvEGV(gv) (GvGP(gv)->gp_egv)
88 #define GvENAME(gv) GvNAME(GvEGV(gv) ? GvEGV(gv) : gv)
89 #define GvESTASH(gv) GvSTASH(GvEGV(gv) ? GvEGV(gv) : gv)
91 #define GVf_INTRO 0x01
92 #define GVf_MULTI 0x02
93 #define GVf_ASSUMECV 0x04
94 #define GVf_IN_PAD 0x08
95 #define GVf_IMPORTED 0xF0
96 #define GVf_IMPORTED_SV 0x10
97 #define GVf_IMPORTED_AV 0x20
98 #define GVf_IMPORTED_HV 0x40
99 #define GVf_IMPORTED_CV 0x80
101 #define GvINTRO(gv) (GvFLAGS(gv) & GVf_INTRO)
102 #define GvINTRO_on(gv) (GvFLAGS(gv) |= GVf_INTRO)
103 #define GvINTRO_off(gv) (GvFLAGS(gv) &= ~GVf_INTRO)
105 #define GvMULTI(gv) (GvFLAGS(gv) & GVf_MULTI)
106 #define GvMULTI_on(gv) (GvFLAGS(gv) |= GVf_MULTI)
107 #define GvMULTI_off(gv) (GvFLAGS(gv) &= ~GVf_MULTI)
109 #define GvASSUMECV(gv) (GvFLAGS(gv) & GVf_ASSUMECV)
110 #define GvASSUMECV_on(gv) (GvFLAGS(gv) |= GVf_ASSUMECV)
111 #define GvASSUMECV_off(gv) (GvFLAGS(gv) &= ~GVf_ASSUMECV)
113 #define GvIMPORTED(gv) (GvFLAGS(gv) & GVf_IMPORTED)
114 #define GvIMPORTED_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED)
115 #define GvIMPORTED_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED)
117 #define GvIMPORTED_SV(gv) (GvFLAGS(gv) & GVf_IMPORTED_SV)
118 #define GvIMPORTED_SV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_SV)
119 #define GvIMPORTED_SV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_SV)
121 #define GvIMPORTED_AV(gv) (GvFLAGS(gv) & GVf_IMPORTED_AV)
122 #define GvIMPORTED_AV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_AV)
123 #define GvIMPORTED_AV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_AV)
125 #define GvIMPORTED_HV(gv) (GvFLAGS(gv) & GVf_IMPORTED_HV)
126 #define GvIMPORTED_HV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_HV)
127 #define GvIMPORTED_HV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_HV)
129 #define GvIMPORTED_CV(gv) (GvFLAGS(gv) & GVf_IMPORTED_CV)
130 #define GvIMPORTED_CV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_CV)
131 #define GvIMPORTED_CV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_CV)
133 #define GvIN_PAD(gv) (GvFLAGS(gv) & GVf_IN_PAD)
134 #define GvIN_PAD_on(gv) (GvFLAGS(gv) |= GVf_IN_PAD)
135 #define GvIN_PAD_off(gv) (GvFLAGS(gv) &= ~GVf_IN_PAD)
137 #define GvUNIQUE(gv) 0
138 #define GvUNIQUE_on(gv)
139 #define GvUNIQUE_off(gv)
142 #define GV_UNIQUE_CHECK
144 #undef GV_UNIQUE_CHECK
147 #define Nullgv Null(GV*)
150 #define DM_RUID 0x001
151 #define DM_EUID 0x002
153 #define DM_RGID 0x010
154 #define DM_EGID 0x020
155 #define DM_DELAY 0x100
158 * symbol creation flags, for use in gv_fetchpv() and get_*v()
160 #define GV_ADD 0x01 /* add, if symbol not already there */
161 #define GV_ADDMULTI 0x02 /* add, pretending it has been added already */
162 #define GV_ADDWARN 0x04 /* add, but warn if symbol wasn't already there */
163 #define GV_ADDINEVAL 0x08 /* add, as though we're doing so within an eval */
164 #define GV_NOINIT 0x10 /* add, but don't init symbol, if type != PVGV */
165 /* SVf_UTF8 (more accurately the return value from SvUTF8) is also valid
166 as a flag to gv_fetch_pvn_flags, so ensure it lies outside this range.
168 #define gv_fullname3(sv,gv,prefix) gv_fullname4(sv,gv,prefix,TRUE)
169 #define gv_efullname3(sv,gv,prefix) gv_efullname4(sv,gv,prefix,TRUE)
170 #define gv_fetchmethod(stash, name) gv_fetchmethod_autoload(stash, name, TRUE)