Commit | Line | Data |
a0d0e21e |
1 | /* gv.h |
79072805 |
2 | * |
4eb8286e |
3 | * Copyright (c) 1991-1999, 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 | |
79072805 |
37 | #define GvSV(gv) (GvGP(gv)->gp_sv) |
38 | #define GvREFCNT(gv) (GvGP(gv)->gp_refcnt) |
a0d0e21e |
39 | #define GvIO(gv) ((gv) && SvTYPE((SV*)gv) == SVt_PVGV ? GvIOp(gv) : 0) |
40 | #define GvIOp(gv) (GvGP(gv)->gp_io) |
41 | #define GvIOn(gv) (GvIO(gv) ? GvIOp(gv) : GvIOp(gv_IOadd(gv))) |
79072805 |
42 | |
43 | #define GvFORM(gv) (GvGP(gv)->gp_form) |
44 | #define GvAV(gv) (GvGP(gv)->gp_av) |
44a8e56a |
45 | |
46 | /* This macro is deprecated. Do not use! */ |
47 | #define GvREFCNT_inc(gv) ((GV*)SvREFCNT_inc(gv)) /* DO NOT USE */ |
79072805 |
48 | |
49 | #ifdef MICROPORT /* Microport 2.4 hack */ |
50 | AV *GvAVn(); |
51 | #else |
52 | #define GvAVn(gv) (GvGP(gv)->gp_av ? \ |
53 | GvGP(gv)->gp_av : \ |
54 | GvGP(gv_AVadd(gv))->gp_av) |
55 | #endif |
56 | #define GvHV(gv) ((GvGP(gv))->gp_hv) |
57 | |
58 | #ifdef MICROPORT /* Microport 2.4 hack */ |
59 | HV *GvHVn(); |
60 | #else |
61 | #define GvHVn(gv) (GvGP(gv)->gp_hv ? \ |
62 | GvGP(gv)->gp_hv : \ |
63 | GvGP(gv_HVadd(gv))->gp_hv) |
64 | #endif /* Microport 2.4 hack */ |
65 | |
66 | #define GvCV(gv) (GvGP(gv)->gp_cv) |
463ee0b2 |
67 | #define GvCVGEN(gv) (GvGP(gv)->gp_cvgen) |
8ebc5c01 |
68 | #define GvCVu(gv) (GvGP(gv)->gp_cvgen ? Nullcv : GvGP(gv)->gp_cv) |
79072805 |
69 | |
f4c556ac |
70 | #define GvGPFLAGS(gv) (GvGP(gv)->gp_flags) |
79072805 |
71 | |
72 | #define GvLINE(gv) (GvGP(gv)->gp_line) |
b195d487 |
73 | #define GvFILE(gv) (GvGP(gv)->gp_file) |
57843af0 |
74 | #define GvFILEGV(gv) (gv_fetchfile(GvFILE(gv))) |
79072805 |
75 | |
79072805 |
76 | #define GvEGV(gv) (GvGP(gv)->gp_egv) |
748a9306 |
77 | #define GvENAME(gv) GvNAME(GvEGV(gv) ? GvEGV(gv) : gv) |
748a9306 |
78 | #define GvESTASH(gv) GvSTASH(GvEGV(gv) ? GvEGV(gv) : gv) |
79072805 |
79 | |
a5f75d66 |
80 | #define GVf_INTRO 0x01 |
81 | #define GVf_MULTI 0x02 |
82 | #define GVf_ASSUMECV 0x04 |
743e66e6 |
83 | #define GVf_IN_PAD 0x08 |
a5f75d66 |
84 | #define GVf_IMPORTED 0xF0 |
85 | #define GVf_IMPORTED_SV 0x10 |
86 | #define GVf_IMPORTED_AV 0x20 |
87 | #define GVf_IMPORTED_HV 0x40 |
88 | #define GVf_IMPORTED_CV 0x80 |
89 | |
90 | #define GvINTRO(gv) (GvFLAGS(gv) & GVf_INTRO) |
91 | #define GvINTRO_on(gv) (GvFLAGS(gv) |= GVf_INTRO) |
92 | #define GvINTRO_off(gv) (GvFLAGS(gv) &= ~GVf_INTRO) |
93 | |
94 | #define GvMULTI(gv) (GvFLAGS(gv) & GVf_MULTI) |
95 | #define GvMULTI_on(gv) (GvFLAGS(gv) |= GVf_MULTI) |
96 | #define GvMULTI_off(gv) (GvFLAGS(gv) &= ~GVf_MULTI) |
97 | |
98 | #define GvASSUMECV(gv) (GvFLAGS(gv) & GVf_ASSUMECV) |
99 | #define GvASSUMECV_on(gv) (GvFLAGS(gv) |= GVf_ASSUMECV) |
100 | #define GvASSUMECV_off(gv) (GvFLAGS(gv) &= ~GVf_ASSUMECV) |
101 | |
102 | #define GvIMPORTED(gv) (GvFLAGS(gv) & GVf_IMPORTED) |
103 | #define GvIMPORTED_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED) |
104 | #define GvIMPORTED_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED) |
105 | |
106 | #define GvIMPORTED_SV(gv) (GvFLAGS(gv) & GVf_IMPORTED_SV) |
107 | #define GvIMPORTED_SV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_SV) |
108 | #define GvIMPORTED_SV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_SV) |
109 | |
110 | #define GvIMPORTED_AV(gv) (GvFLAGS(gv) & GVf_IMPORTED_AV) |
111 | #define GvIMPORTED_AV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_AV) |
112 | #define GvIMPORTED_AV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_AV) |
113 | |
114 | #define GvIMPORTED_HV(gv) (GvFLAGS(gv) & GVf_IMPORTED_HV) |
115 | #define GvIMPORTED_HV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_HV) |
116 | #define GvIMPORTED_HV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_HV) |
117 | |
118 | #define GvIMPORTED_CV(gv) (GvFLAGS(gv) & GVf_IMPORTED_CV) |
119 | #define GvIMPORTED_CV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_CV) |
120 | #define GvIMPORTED_CV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_CV) |
121 | |
743e66e6 |
122 | #define GvIN_PAD(gv) (GvFLAGS(gv) & GVf_IN_PAD) |
123 | #define GvIN_PAD_on(gv) (GvFLAGS(gv) |= GVf_IN_PAD) |
124 | #define GvIN_PAD_off(gv) (GvFLAGS(gv) &= ~GVf_IN_PAD) |
125 | |
79072805 |
126 | #define Nullgv Null(GV*) |
127 | |
128 | #define DM_UID 0x003 |
129 | #define DM_RUID 0x001 |
130 | #define DM_EUID 0x002 |
131 | #define DM_GID 0x030 |
132 | #define DM_RGID 0x010 |
133 | #define DM_EGID 0x020 |
134 | #define DM_DELAY 0x100 |
135 | |
0f303493 |
136 | /* |
864dbfa3 |
137 | * symbol creation flags, for use in gv_fetchpv() and get_*v() |
0f303493 |
138 | */ |
139 | #define GV_ADD 0x01 /* add, if symbol not already there */ |
140 | #define GV_ADDMULTI 0x02 /* add, pretending it has been added already */ |
141 | #define GV_ADDWARN 0x04 /* add, but warn if symbol wasn't already there */ |
142 | #define GV_ADDINEVAL 0x08 /* add, as though we're doing so within an eval */ |
143 | #define GV_NOINIT 0x10 /* add, but don't init symbol, if type != PVGV */ |
77ca0c92 |
144 | #define GV_ADDOUR 0x20 /* add "our" variable */ |