Commit | Line | Data |
a0d0e21e |
1 | /* gv.h |
79072805 |
2 | * |
bc89e66f |
3 | * Copyright (c) 1991-2001, Larry Wall |
79072805 |
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 | * |
79072805 |
8 | */ |
9 | |
10 | struct gp { |
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 */ |
aa689395 |
16 | HV * gp_hv; /* hash value */ |
79072805 |
17 | GV * gp_egv; /* effective gv, if *glob */ |
18 | CV * gp_cv; /* subroutine value */ |
463ee0b2 |
19 | U32 gp_cvgen; /* generational validity of cached gv_cv */ |
f4c556ac |
20 | U32 gp_flags; /* XXX unused */ |
79072805 |
21 | line_t gp_line; /* line first declared at (for -w) */ |
b195d487 |
22 | char * gp_file; /* file first declared in (for -w) */ |
79072805 |
23 | }; |
24 | |
25 | #if defined(CRIPPLED_CC) && (defined(iAPX286) || defined(M_I286) || defined(I80286)) |
26 | #define MICROPORT |
27 | #endif |
28 | |
29 | #define GvXPVGV(gv) ((XPVGV*)SvANY(gv)) |
30 | |
a5f75d66 |
31 | #define GvGP(gv) (GvXPVGV(gv)->xgv_gp) |
32 | #define GvNAME(gv) (GvXPVGV(gv)->xgv_name) |
33 | #define GvNAMELEN(gv) (GvXPVGV(gv)->xgv_namelen) |
34 | #define GvSTASH(gv) (GvXPVGV(gv)->xgv_stash) |
35 | #define GvFLAGS(gv) (GvXPVGV(gv)->xgv_flags) |
36 | |
954c1994 |
37 | /* |
38 | =for apidoc Am|SV*|GvSV|GV* gv |
39 | |
40 | Return the SV from the GV. |
41 | |
42 | =cut |
43 | */ |
44 | |
79072805 |
45 | #define GvSV(gv) (GvGP(gv)->gp_sv) |
46 | #define GvREFCNT(gv) (GvGP(gv)->gp_refcnt) |
a0d0e21e |
47 | #define GvIO(gv) ((gv) && SvTYPE((SV*)gv) == SVt_PVGV ? GvIOp(gv) : 0) |
48 | #define GvIOp(gv) (GvGP(gv)->gp_io) |
49 | #define GvIOn(gv) (GvIO(gv) ? GvIOp(gv) : GvIOp(gv_IOadd(gv))) |
79072805 |
50 | |
51 | #define GvFORM(gv) (GvGP(gv)->gp_form) |
52 | #define GvAV(gv) (GvGP(gv)->gp_av) |
44a8e56a |
53 | |
54 | /* This macro is deprecated. Do not use! */ |
55 | #define GvREFCNT_inc(gv) ((GV*)SvREFCNT_inc(gv)) /* DO NOT USE */ |
79072805 |
56 | |
57 | #ifdef MICROPORT /* Microport 2.4 hack */ |
58 | AV *GvAVn(); |
59 | #else |
60 | #define GvAVn(gv) (GvGP(gv)->gp_av ? \ |
61 | GvGP(gv)->gp_av : \ |
62 | GvGP(gv_AVadd(gv))->gp_av) |
63 | #endif |
64 | #define GvHV(gv) ((GvGP(gv))->gp_hv) |
65 | |
66 | #ifdef MICROPORT /* Microport 2.4 hack */ |
67 | HV *GvHVn(); |
68 | #else |
69 | #define GvHVn(gv) (GvGP(gv)->gp_hv ? \ |
70 | GvGP(gv)->gp_hv : \ |
71 | GvGP(gv_HVadd(gv))->gp_hv) |
72 | #endif /* Microport 2.4 hack */ |
73 | |
74 | #define GvCV(gv) (GvGP(gv)->gp_cv) |
463ee0b2 |
75 | #define GvCVGEN(gv) (GvGP(gv)->gp_cvgen) |
8ebc5c01 |
76 | #define GvCVu(gv) (GvGP(gv)->gp_cvgen ? Nullcv : GvGP(gv)->gp_cv) |
79072805 |
77 | |
f4c556ac |
78 | #define GvGPFLAGS(gv) (GvGP(gv)->gp_flags) |
79072805 |
79 | |
80 | #define GvLINE(gv) (GvGP(gv)->gp_line) |
b195d487 |
81 | #define GvFILE(gv) (GvGP(gv)->gp_file) |
57843af0 |
82 | #define GvFILEGV(gv) (gv_fetchfile(GvFILE(gv))) |
79072805 |
83 | |
79072805 |
84 | #define GvEGV(gv) (GvGP(gv)->gp_egv) |
748a9306 |
85 | #define GvENAME(gv) GvNAME(GvEGV(gv) ? GvEGV(gv) : gv) |
748a9306 |
86 | #define GvESTASH(gv) GvSTASH(GvEGV(gv) ? GvEGV(gv) : gv) |
79072805 |
87 | |
a5f75d66 |
88 | #define GVf_INTRO 0x01 |
89 | #define GVf_MULTI 0x02 |
90 | #define GVf_ASSUMECV 0x04 |
743e66e6 |
91 | #define GVf_IN_PAD 0x08 |
a5f75d66 |
92 | #define GVf_IMPORTED 0xF0 |
93 | #define GVf_IMPORTED_SV 0x10 |
94 | #define GVf_IMPORTED_AV 0x20 |
95 | #define GVf_IMPORTED_HV 0x40 |
96 | #define GVf_IMPORTED_CV 0x80 |
97 | |
98 | #define GvINTRO(gv) (GvFLAGS(gv) & GVf_INTRO) |
99 | #define GvINTRO_on(gv) (GvFLAGS(gv) |= GVf_INTRO) |
100 | #define GvINTRO_off(gv) (GvFLAGS(gv) &= ~GVf_INTRO) |
101 | |
102 | #define GvMULTI(gv) (GvFLAGS(gv) & GVf_MULTI) |
103 | #define GvMULTI_on(gv) (GvFLAGS(gv) |= GVf_MULTI) |
104 | #define GvMULTI_off(gv) (GvFLAGS(gv) &= ~GVf_MULTI) |
105 | |
106 | #define GvASSUMECV(gv) (GvFLAGS(gv) & GVf_ASSUMECV) |
107 | #define GvASSUMECV_on(gv) (GvFLAGS(gv) |= GVf_ASSUMECV) |
108 | #define GvASSUMECV_off(gv) (GvFLAGS(gv) &= ~GVf_ASSUMECV) |
109 | |
110 | #define GvIMPORTED(gv) (GvFLAGS(gv) & GVf_IMPORTED) |
111 | #define GvIMPORTED_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED) |
112 | #define GvIMPORTED_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED) |
113 | |
114 | #define GvIMPORTED_SV(gv) (GvFLAGS(gv) & GVf_IMPORTED_SV) |
115 | #define GvIMPORTED_SV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_SV) |
116 | #define GvIMPORTED_SV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_SV) |
117 | |
118 | #define GvIMPORTED_AV(gv) (GvFLAGS(gv) & GVf_IMPORTED_AV) |
119 | #define GvIMPORTED_AV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_AV) |
120 | #define GvIMPORTED_AV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_AV) |
121 | |
122 | #define GvIMPORTED_HV(gv) (GvFLAGS(gv) & GVf_IMPORTED_HV) |
123 | #define GvIMPORTED_HV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_HV) |
124 | #define GvIMPORTED_HV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_HV) |
125 | |
126 | #define GvIMPORTED_CV(gv) (GvFLAGS(gv) & GVf_IMPORTED_CV) |
127 | #define GvIMPORTED_CV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_CV) |
128 | #define GvIMPORTED_CV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_CV) |
129 | |
743e66e6 |
130 | #define GvIN_PAD(gv) (GvFLAGS(gv) & GVf_IN_PAD) |
131 | #define GvIN_PAD_on(gv) (GvFLAGS(gv) |= GVf_IN_PAD) |
132 | #define GvIN_PAD_off(gv) (GvFLAGS(gv) &= ~GVf_IN_PAD) |
133 | |
5bd07a3d |
134 | /* XXX: all GvFLAGS options are used, borrowing GvGPFLAGS for the moment */ |
135 | |
7fb37951 |
136 | #define GVf_UNIQUE 0x0001 |
137 | #define GvUNIQUE(gv) (GvGP(gv) && (GvGPFLAGS(gv) & GVf_UNIQUE)) |
138 | #define GvUNIQUE_on(gv) (GvGPFLAGS(gv) |= GVf_UNIQUE) |
139 | #define GvUNIQUE_off(gv) (GvGPFLAGS(gv) &= ~GVf_UNIQUE) |
5bd07a3d |
140 | |
141 | #ifdef USE_ITHREADS |
7fb37951 |
142 | #define GV_UNIQUE_CHECK |
5bd07a3d |
143 | #else |
7fb37951 |
144 | #undef GV_UNIQUE_CHECK |
5bd07a3d |
145 | #endif |
146 | |
79072805 |
147 | #define Nullgv Null(GV*) |
148 | |
149 | #define DM_UID 0x003 |
150 | #define DM_RUID 0x001 |
151 | #define DM_EUID 0x002 |
152 | #define DM_GID 0x030 |
153 | #define DM_RGID 0x010 |
154 | #define DM_EGID 0x020 |
155 | #define DM_DELAY 0x100 |
156 | |
0f303493 |
157 | /* |
864dbfa3 |
158 | * symbol creation flags, for use in gv_fetchpv() and get_*v() |
0f303493 |
159 | */ |
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 */ |