This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.0 alpha 2
[perl5.git] / gv.h
CommitLineData
79072805
LW
1/* $RCSfile: gv.h,v $$Revision: 4.1 $$Date: 92/08/07 18:26:42 $
2 *
3 * Copyright (c) 1991, 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 * $Log: gv.h,v $
9 * Revision 4.1 92/08/07 18:26:42 lwall
10 *
11 * Revision 4.0.1.3 92/06/08 15:33:44 lwall
12 * patch20: fixed confusion between a *var's real name and its effective name
13 * patch20: ($<,$>) = ... didn't work on some architectures
14 *
15 * Revision 4.0.1.2 91/11/05 18:36:15 lwall
16 * patch11: length($x) was sometimes wrong for numeric $x
17 *
18 * Revision 4.0.1.1 91/06/07 11:56:35 lwall
19 * patch4: new copyright notice
20 * patch4: length($`), length($&), length($') now optimized to avoid string copy
21 *
22 * Revision 4.0 91/03/20 01:39:49 lwall
23 * 4.0 baseline.
24 *
25 */
26
27struct gp {
28 SV * gp_sv; /* scalar value */
29 U32 gp_refcnt; /* how many globs point to this? */
30 struct io * gp_io; /* filehandle value */
31 CV * gp_form; /* format value */
32 AV * gp_av; /* array value */
33 HV * gp_hv; /* associative array value */
34 GV * gp_egv; /* effective gv, if *glob */
35 CV * gp_cv; /* subroutine value */
36 I32 gp_lastexpr; /* used by nothing_in_common() */
37 line_t gp_line; /* line first declared at (for -w) */
38 char gp_flags;
39};
40
41#if defined(CRIPPLED_CC) && (defined(iAPX286) || defined(M_I286) || defined(I80286))
42#define MICROPORT
43#endif
44
45#define GvXPVGV(gv) ((XPVGV*)SvANY(gv))
46
47#define GvMAGIC(gv) (GvGP(gv)->gp_magic)
48#define GvSV(gv) (GvGP(gv)->gp_sv)
49#define GvREFCNT(gv) (GvGP(gv)->gp_refcnt)
50#define GvIO(gv) (GvGP(gv)->gp_io)
51#define GvIOn(gv) (GvIO(gv) ? \
52 GvIO(gv) : \
53 (GvIO(gv) = newIO()))
54
55#define GvFORM(gv) (GvGP(gv)->gp_form)
56#define GvAV(gv) (GvGP(gv)->gp_av)
57
58#ifdef MICROPORT /* Microport 2.4 hack */
59AV *GvAVn();
60#else
61#define GvAVn(gv) (GvGP(gv)->gp_av ? \
62 GvGP(gv)->gp_av : \
63 GvGP(gv_AVadd(gv))->gp_av)
64#endif
65#define GvHV(gv) ((GvGP(gv))->gp_hv)
66
67#ifdef MICROPORT /* Microport 2.4 hack */
68HV *GvHVn();
69#else
70#define GvHVn(gv) (GvGP(gv)->gp_hv ? \
71 GvGP(gv)->gp_hv : \
72 GvGP(gv_HVadd(gv))->gp_hv)
73#endif /* Microport 2.4 hack */
74
75#define GvCV(gv) (GvGP(gv)->gp_cv)
76
77#define GvLASTEXPR(gv) (GvGP(gv)->gp_lastexpr)
78
79#define GvLINE(gv) (GvGP(gv)->gp_line)
80
81#define GvFLAGS(gv) (GvGP(gv)->gp_flags)
82
83#define GvEGV(gv) (GvGP(gv)->gp_egv)
84
85#define GvGP(gv) (GvXPVGV(gv)->xgv_gp)
86#define GvNAME(gv) (GvXPVGV(gv)->xgv_name)
87#define GvNAMELEN(gv) (GvXPVGV(gv)->xgv_namelen)
88#define GvENAME(gv) GvNAME(GvEGV(gv))
89
90#define GvSTASH(gv) (GvXPVGV(gv)->xgv_stash)
91#define GvESTASH(gv) GvSTASH(GvEGV(gv))
92
93struct io {
94 FILE * ifp; /* ifp and ofp are normally the same */
95 FILE * ofp; /* but sockets need separate streams */
96#ifdef HAS_READDIR
97 DIR * dirp; /* for opendir, readdir, etc */
98#endif
99 long lines; /* $. */
100 long page; /* $% */
101 long page_len; /* $= */
102 long lines_left; /* $- */
103 char * top_name; /* $^ */
104 GV * top_gv; /* $^ */
105 char * fmt_name; /* $~ */
106 GV * fmt_gv; /* $~ */
107 short subprocess; /* -| or |- */
108 char type;
109 char flags;
110};
111
112#define IOf_ARGV 1 /* this fp iterates over ARGV */
113#define IOf_START 2 /* check for null ARGV and substitute '-' */
114#define IOf_FLUSH 4 /* this fp wants a flush after write op */
115
116#define Nullgv Null(GV*)
117
118#define DM_UID 0x003
119#define DM_RUID 0x001
120#define DM_EUID 0x002
121#define DM_GID 0x030
122#define DM_RGID 0x010
123#define DM_EGID 0x020
124#define DM_DELAY 0x100
125