minor tweaks in Porting/pumpkin.pod
[p5sagit/p5-mst-13.2.git] / cv.h
CommitLineData
a0d0e21e 1/* cv.h
79072805 2 *
eb1102fc 3 * Copyright (c) 1991-2002, 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
57843af0 10/* This structure much match XPVCV in B/C.pm and the beginning of XPVFM
11 * in sv.h */
44a8e56a 12
79072805 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 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;
4d1ff10f 32#ifdef USE_5005THREADS
12ca11f6 33 perl_mutex *xcv_mutexp;
52e1cb5e 34 struct perl_thread *xcv_owner; /* current owner thread */
4d1ff10f 35#endif /* USE_5005THREADS */
77a005ab 36 cv_flags_t xcv_flags;
79072805 37};
748a9306 38
954c1994 39/*
ccfc67b7 40=head1 Handy Values
41
954c1994 42=for apidoc AmU||Nullcv
43Null CV pointer.
44
ccfc67b7 45=head1 CV Manipulation Functions
46
954c1994 47=for apidoc Am|HV*|CvSTASH|CV* cv
48Returns the stash of the CV.
49
50=cut
51*/
52
79072805 53#define Nullcv Null(CV*)
a5f75d66 54
79072805 55#define CvSTASH(sv) ((XPVCV*)SvANY(sv))->xcv_stash
56#define CvSTART(sv) ((XPVCV*)SvANY(sv))->xcv_start
57#define CvROOT(sv) ((XPVCV*)SvANY(sv))->xcv_root
a0d0e21e 58#define CvXSUB(sv) ((XPVCV*)SvANY(sv))->xcv_xsub
59#define CvXSUBANY(sv) ((XPVCV*)SvANY(sv))->xcv_xsubany
8990e307 60#define CvGV(sv) ((XPVCV*)SvANY(sv))->xcv_gv
57843af0 61#define CvFILE(sv) ((XPVCV*)SvANY(sv))->xcv_file
a636914a 62#ifdef USE_ITHREADS
63# define CvFILE_set_from_cop(sv, cop) (CvFILE(sv) = savepv(CopFILE(cop)))
64#else
65# define CvFILE_set_from_cop(sv, cop) (CvFILE(sv) = CopFILE(cop))
66#endif
9ec2a764 67#define CvFILEGV(sv) (gv_fetchfile(CvFILE(sv)))
79072805 68#define CvDEPTH(sv) ((XPVCV*)SvANY(sv))->xcv_depth
69#define CvPADLIST(sv) ((XPVCV*)SvANY(sv))->xcv_padlist
748a9306 70#define CvOUTSIDE(sv) ((XPVCV*)SvANY(sv))->xcv_outside
4d1ff10f 71#ifdef USE_5005THREADS
11343788 72#define CvMUTEXP(sv) ((XPVCV*)SvANY(sv))->xcv_mutexp
11343788 73#define CvOWNER(sv) ((XPVCV*)SvANY(sv))->xcv_owner
4d1ff10f 74#endif /* USE_5005THREADS */
a5f75d66 75#define CvFLAGS(sv) ((XPVCV*)SvANY(sv))->xcv_flags
76
77a005ab 77#define CVf_CLONE 0x0001 /* anon CV uses external lexicals */
78#define CVf_CLONED 0x0002 /* a clone of one of those */
79#define CVf_ANON 0x0004 /* CvGV() can't be trusted */
80#define CVf_OLDSTYLE 0x0008
81#define CVf_UNIQUE 0x0010 /* can't be cloned */
82#define CVf_NODEBUG 0x0020 /* no DB::sub indirection for this CV
8ebc5c01 83 (esp. useful for special XSUBs) */
77a005ab 84#define CVf_METHOD 0x0040 /* CV is explicitly marked as a method */
85#define CVf_LOCKED 0x0080 /* CV locks itself or first arg on entry */
cd06dffe 86#define CVf_LVALUE 0x0100 /* CV return value can be used as lvalue */
beab0874 87#define CVf_CONST 0x0200 /* inlinable sub */
d3cea301 88/* This symbol for optimised communication between toke.c and op.c: */
89#define CVf_BUILTIN_ATTRS (CVf_METHOD|CVf_LOCKED|CVf_LVALUE)
a5f75d66 90
91#define CvCLONE(cv) (CvFLAGS(cv) & CVf_CLONE)
92#define CvCLONE_on(cv) (CvFLAGS(cv) |= CVf_CLONE)
93#define CvCLONE_off(cv) (CvFLAGS(cv) &= ~CVf_CLONE)
94
95#define CvCLONED(cv) (CvFLAGS(cv) & CVf_CLONED)
96#define CvCLONED_on(cv) (CvFLAGS(cv) |= CVf_CLONED)
97#define CvCLONED_off(cv) (CvFLAGS(cv) &= ~CVf_CLONED)
98
99#define CvANON(cv) (CvFLAGS(cv) & CVf_ANON)
100#define CvANON_on(cv) (CvFLAGS(cv) |= CVf_ANON)
101#define CvANON_off(cv) (CvFLAGS(cv) &= ~CVf_ANON)
79072805 102
67caa1fe 103#ifdef PERL_XSUB_OLDSTYLE
a5f75d66 104#define CvOLDSTYLE(cv) (CvFLAGS(cv) & CVf_OLDSTYLE)
105#define CvOLDSTYLE_on(cv) (CvFLAGS(cv) |= CVf_OLDSTYLE)
106#define CvOLDSTYLE_off(cv) (CvFLAGS(cv) &= ~CVf_OLDSTYLE)
67caa1fe 107#endif
07055b4c 108
109#define CvUNIQUE(cv) (CvFLAGS(cv) & CVf_UNIQUE)
110#define CvUNIQUE_on(cv) (CvFLAGS(cv) |= CVf_UNIQUE)
111#define CvUNIQUE_off(cv) (CvFLAGS(cv) &= ~CVf_UNIQUE)
8ebc5c01 112
113#define CvNODEBUG(cv) (CvFLAGS(cv) & CVf_NODEBUG)
114#define CvNODEBUG_on(cv) (CvFLAGS(cv) |= CVf_NODEBUG)
115#define CvNODEBUG_off(cv) (CvFLAGS(cv) &= ~CVf_NODEBUG)
77a005ab 116
117#define CvMETHOD(cv) (CvFLAGS(cv) & CVf_METHOD)
118#define CvMETHOD_on(cv) (CvFLAGS(cv) |= CVf_METHOD)
119#define CvMETHOD_off(cv) (CvFLAGS(cv) &= ~CVf_METHOD)
120
121#define CvLOCKED(cv) (CvFLAGS(cv) & CVf_LOCKED)
122#define CvLOCKED_on(cv) (CvFLAGS(cv) |= CVf_LOCKED)
123#define CvLOCKED_off(cv) (CvFLAGS(cv) &= ~CVf_LOCKED)
1aff0e91 124
cd06dffe 125#define CvLVALUE(cv) (CvFLAGS(cv) & CVf_LVALUE)
126#define CvLVALUE_on(cv) (CvFLAGS(cv) |= CVf_LVALUE)
127#define CvLVALUE_off(cv) (CvFLAGS(cv) &= ~CVf_LVALUE)
128
1aff0e91 129#define CvEVAL(cv) (CvUNIQUE(cv) && !SvFAKE(cv))
130#define CvEVAL_on(cv) (CvUNIQUE_on(cv),SvFAKE_off(cv))
131#define CvEVAL_off(cv) CvUNIQUE_off(cv)
132
bec31f9a 133/* BEGIN|CHECK|INIT|END */
1aff0e91 134#define CvSPECIAL(cv) (CvUNIQUE(cv) && SvFAKE(cv))
135#define CvSPECIAL_on(cv) (CvUNIQUE_on(cv),SvFAKE_on(cv))
136#define CvSPECIAL_off(cv) (CvUNIQUE_off(cv),SvFAKE_off(cv))
beab0874 137
138#define CvCONST(cv) (CvFLAGS(cv) & CVf_CONST)
139#define CvCONST_on(cv) (CvFLAGS(cv) |= CVf_CONST)
140#define CvCONST_off(cv) (CvFLAGS(cv) &= ~CVf_CONST)
a4f1a029 141