This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Document the hint constants and where they're used.
[perl5.git] / cv.h
CommitLineData
a0d0e21e 1/* cv.h
79072805 2 *
eb1102fc 3 * Copyright (c) 1991-2002, Larry Wall
79072805
LW
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
LW
8 */
9
57843af0
GS
10/* This structure much match XPVCV in B/C.pm and the beginning of XPVFM
11 * in sv.h */
44a8e56a 12
79072805
LW
13struct xpvcv {
14 char * xpv_pv; /* pointer to malloced string */
15 STRLEN xpv_cur; /* length of xp_pv as a C string */
16 STRLEN xpv_len; /* allocated size */
a0d0e21e 17 IV xof_off; /* integer value */
65202027 18 NV xnv_nv; /* numeric value, if any */
79072805
LW
19 MAGIC* xmg_magic; /* magic for scalar array */
20 HV* xmg_stash; /* class package */
21
22 HV * xcv_stash;
23 OP * xcv_start;
24 OP * xcv_root;
acfe0abc 25 void (*xcv_xsub) (pTHX_ CV*);
a0d0e21e 26 ANY xcv_xsubany;
8990e307 27 GV * xcv_gv;
57843af0 28 char * xcv_file;
b195d487 29 long xcv_depth; /* >= 2 indicates recursive call */
dd2155a4 30 PADLIST * xcv_padlist;
748a9306 31 CV * xcv_outside;
77a005ab 32 cv_flags_t xcv_flags;
79072805 33};
748a9306 34
954c1994 35/*
ccfc67b7
JH
36=head1 Handy Values
37
954c1994
GS
38=for apidoc AmU||Nullcv
39Null CV pointer.
40
ccfc67b7
JH
41=head1 CV Manipulation Functions
42
954c1994
GS
43=for apidoc Am|HV*|CvSTASH|CV* cv
44Returns the stash of the CV.
45
46=cut
47*/
48
79072805 49#define Nullcv Null(CV*)
a5f75d66 50
79072805
LW
51#define CvSTASH(sv) ((XPVCV*)SvANY(sv))->xcv_stash
52#define CvSTART(sv) ((XPVCV*)SvANY(sv))->xcv_start
53#define CvROOT(sv) ((XPVCV*)SvANY(sv))->xcv_root
a0d0e21e
LW
54#define CvXSUB(sv) ((XPVCV*)SvANY(sv))->xcv_xsub
55#define CvXSUBANY(sv) ((XPVCV*)SvANY(sv))->xcv_xsubany
8990e307 56#define CvGV(sv) ((XPVCV*)SvANY(sv))->xcv_gv
57843af0 57#define CvFILE(sv) ((XPVCV*)SvANY(sv))->xcv_file
a636914a
RH
58#ifdef USE_ITHREADS
59# define CvFILE_set_from_cop(sv, cop) (CvFILE(sv) = savepv(CopFILE(cop)))
60#else
61# define CvFILE_set_from_cop(sv, cop) (CvFILE(sv) = CopFILE(cop))
62#endif
9ec2a764 63#define CvFILEGV(sv) (gv_fetchfile(CvFILE(sv)))
79072805
LW
64#define CvDEPTH(sv) ((XPVCV*)SvANY(sv))->xcv_depth
65#define CvPADLIST(sv) ((XPVCV*)SvANY(sv))->xcv_padlist
748a9306 66#define CvOUTSIDE(sv) ((XPVCV*)SvANY(sv))->xcv_outside
a5f75d66
AD
67#define CvFLAGS(sv) ((XPVCV*)SvANY(sv))->xcv_flags
68
77a005ab
MB
69#define CVf_CLONE 0x0001 /* anon CV uses external lexicals */
70#define CVf_CLONED 0x0002 /* a clone of one of those */
71#define CVf_ANON 0x0004 /* CvGV() can't be trusted */
72#define CVf_OLDSTYLE 0x0008
73#define CVf_UNIQUE 0x0010 /* can't be cloned */
74#define CVf_NODEBUG 0x0020 /* no DB::sub indirection for this CV
8ebc5c01 75 (esp. useful for special XSUBs) */
77a005ab
MB
76#define CVf_METHOD 0x0040 /* CV is explicitly marked as a method */
77#define CVf_LOCKED 0x0080 /* CV locks itself or first arg on entry */
cd06dffe 78#define CVf_LVALUE 0x0100 /* CV return value can be used as lvalue */
beab0874 79#define CVf_CONST 0x0200 /* inlinable sub */
d3cea301
SB
80/* This symbol for optimised communication between toke.c and op.c: */
81#define CVf_BUILTIN_ATTRS (CVf_METHOD|CVf_LOCKED|CVf_LVALUE)
a5f75d66
AD
82
83#define CvCLONE(cv) (CvFLAGS(cv) & CVf_CLONE)
84#define CvCLONE_on(cv) (CvFLAGS(cv) |= CVf_CLONE)
85#define CvCLONE_off(cv) (CvFLAGS(cv) &= ~CVf_CLONE)
86
87#define CvCLONED(cv) (CvFLAGS(cv) & CVf_CLONED)
88#define CvCLONED_on(cv) (CvFLAGS(cv) |= CVf_CLONED)
89#define CvCLONED_off(cv) (CvFLAGS(cv) &= ~CVf_CLONED)
90
91#define CvANON(cv) (CvFLAGS(cv) & CVf_ANON)
92#define CvANON_on(cv) (CvFLAGS(cv) |= CVf_ANON)
93#define CvANON_off(cv) (CvFLAGS(cv) &= ~CVf_ANON)
79072805 94
67caa1fe 95#ifdef PERL_XSUB_OLDSTYLE
a5f75d66
AD
96#define CvOLDSTYLE(cv) (CvFLAGS(cv) & CVf_OLDSTYLE)
97#define CvOLDSTYLE_on(cv) (CvFLAGS(cv) |= CVf_OLDSTYLE)
98#define CvOLDSTYLE_off(cv) (CvFLAGS(cv) &= ~CVf_OLDSTYLE)
67caa1fe 99#endif
07055b4c
CS
100
101#define CvUNIQUE(cv) (CvFLAGS(cv) & CVf_UNIQUE)
102#define CvUNIQUE_on(cv) (CvFLAGS(cv) |= CVf_UNIQUE)
103#define CvUNIQUE_off(cv) (CvFLAGS(cv) &= ~CVf_UNIQUE)
8ebc5c01
PP
104
105#define CvNODEBUG(cv) (CvFLAGS(cv) & CVf_NODEBUG)
106#define CvNODEBUG_on(cv) (CvFLAGS(cv) |= CVf_NODEBUG)
107#define CvNODEBUG_off(cv) (CvFLAGS(cv) &= ~CVf_NODEBUG)
77a005ab
MB
108
109#define CvMETHOD(cv) (CvFLAGS(cv) & CVf_METHOD)
110#define CvMETHOD_on(cv) (CvFLAGS(cv) |= CVf_METHOD)
111#define CvMETHOD_off(cv) (CvFLAGS(cv) &= ~CVf_METHOD)
112
113#define CvLOCKED(cv) (CvFLAGS(cv) & CVf_LOCKED)
114#define CvLOCKED_on(cv) (CvFLAGS(cv) |= CVf_LOCKED)
115#define CvLOCKED_off(cv) (CvFLAGS(cv) &= ~CVf_LOCKED)
1aff0e91 116
cd06dffe
GS
117#define CvLVALUE(cv) (CvFLAGS(cv) & CVf_LVALUE)
118#define CvLVALUE_on(cv) (CvFLAGS(cv) |= CVf_LVALUE)
119#define CvLVALUE_off(cv) (CvFLAGS(cv) &= ~CVf_LVALUE)
120
1aff0e91
GS
121#define CvEVAL(cv) (CvUNIQUE(cv) && !SvFAKE(cv))
122#define CvEVAL_on(cv) (CvUNIQUE_on(cv),SvFAKE_off(cv))
123#define CvEVAL_off(cv) CvUNIQUE_off(cv)
124
bec31f9a 125/* BEGIN|CHECK|INIT|END */
1aff0e91
GS
126#define CvSPECIAL(cv) (CvUNIQUE(cv) && SvFAKE(cv))
127#define CvSPECIAL_on(cv) (CvUNIQUE_on(cv),SvFAKE_on(cv))
128#define CvSPECIAL_off(cv) (CvUNIQUE_off(cv),SvFAKE_off(cv))
beab0874
JT
129
130#define CvCONST(cv) (CvFLAGS(cv) & CVf_CONST)
131#define CvCONST_on(cv) (CvFLAGS(cv) |= CVf_CONST)
132#define CvCONST_off(cv) (CvFLAGS(cv) &= ~CVf_CONST)
a4f1a029 133