This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
initial implementation of lvalue subroutines (slightly fixed
[perl5.git] / cv.h
CommitLineData
a0d0e21e 1/* cv.h
79072805 2 *
4eb8286e 3 * Copyright (c) 1991-1999, 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
44a8e56a
PP
10/* This structure much match the beginning of XPVFM */
11
79072805
LW
12struct xpvcv {
13 char * xpv_pv; /* pointer to malloced string */
14 STRLEN xpv_cur; /* length of xp_pv as a C string */
15 STRLEN xpv_len; /* allocated size */
a0d0e21e 16 IV xof_off; /* integer value */
65202027 17 NV xnv_nv; /* numeric value, if any */
79072805
LW
18 MAGIC* xmg_magic; /* magic for scalar array */
19 HV* xmg_stash; /* class package */
20
21 HV * xcv_stash;
22 OP * xcv_start;
23 OP * xcv_root;
0cb96387 24 void (*xcv_xsub) (pTHXo_ CV*);
a0d0e21e 25 ANY xcv_xsubany;
8990e307 26 GV * xcv_gv;
79072805
LW
27 GV * xcv_filegv;
28 long xcv_depth; /* >= 2 indicates recursive call */
29 AV * xcv_padlist;
748a9306 30 CV * xcv_outside;
11343788 31#ifdef USE_THREADS
12ca11f6 32 perl_mutex *xcv_mutexp;
52e1cb5e 33 struct perl_thread *xcv_owner; /* current owner thread */
11343788 34#endif /* USE_THREADS */
77a005ab 35 cv_flags_t xcv_flags;
79072805 36};
748a9306 37
79072805 38#define Nullcv Null(CV*)
a5f75d66 39
79072805
LW
40#define CvSTASH(sv) ((XPVCV*)SvANY(sv))->xcv_stash
41#define CvSTART(sv) ((XPVCV*)SvANY(sv))->xcv_start
42#define CvROOT(sv) ((XPVCV*)SvANY(sv))->xcv_root
a0d0e21e
LW
43#define CvXSUB(sv) ((XPVCV*)SvANY(sv))->xcv_xsub
44#define CvXSUBANY(sv) ((XPVCV*)SvANY(sv))->xcv_xsubany
8990e307 45#define CvGV(sv) ((XPVCV*)SvANY(sv))->xcv_gv
79072805
LW
46#define CvFILEGV(sv) ((XPVCV*)SvANY(sv))->xcv_filegv
47#define CvDEPTH(sv) ((XPVCV*)SvANY(sv))->xcv_depth
48#define CvPADLIST(sv) ((XPVCV*)SvANY(sv))->xcv_padlist
748a9306 49#define CvOUTSIDE(sv) ((XPVCV*)SvANY(sv))->xcv_outside
11343788
MB
50#ifdef USE_THREADS
51#define CvMUTEXP(sv) ((XPVCV*)SvANY(sv))->xcv_mutexp
11343788
MB
52#define CvOWNER(sv) ((XPVCV*)SvANY(sv))->xcv_owner
53#endif /* USE_THREADS */
a5f75d66
AD
54#define CvFLAGS(sv) ((XPVCV*)SvANY(sv))->xcv_flags
55
77a005ab
MB
56#define CVf_CLONE 0x0001 /* anon CV uses external lexicals */
57#define CVf_CLONED 0x0002 /* a clone of one of those */
58#define CVf_ANON 0x0004 /* CvGV() can't be trusted */
59#define CVf_OLDSTYLE 0x0008
60#define CVf_UNIQUE 0x0010 /* can't be cloned */
61#define CVf_NODEBUG 0x0020 /* no DB::sub indirection for this CV
8ebc5c01 62 (esp. useful for special XSUBs) */
77a005ab
MB
63#define CVf_METHOD 0x0040 /* CV is explicitly marked as a method */
64#define CVf_LOCKED 0x0080 /* CV locks itself or first arg on entry */
cd06dffe 65#define CVf_LVALUE 0x0100 /* CV return value can be used as lvalue */
a5f75d66
AD
66
67#define CvCLONE(cv) (CvFLAGS(cv) & CVf_CLONE)
68#define CvCLONE_on(cv) (CvFLAGS(cv) |= CVf_CLONE)
69#define CvCLONE_off(cv) (CvFLAGS(cv) &= ~CVf_CLONE)
70
71#define CvCLONED(cv) (CvFLAGS(cv) & CVf_CLONED)
72#define CvCLONED_on(cv) (CvFLAGS(cv) |= CVf_CLONED)
73#define CvCLONED_off(cv) (CvFLAGS(cv) &= ~CVf_CLONED)
74
75#define CvANON(cv) (CvFLAGS(cv) & CVf_ANON)
76#define CvANON_on(cv) (CvFLAGS(cv) |= CVf_ANON)
77#define CvANON_off(cv) (CvFLAGS(cv) &= ~CVf_ANON)
79072805 78
67caa1fe 79#ifdef PERL_XSUB_OLDSTYLE
a5f75d66
AD
80#define CvOLDSTYLE(cv) (CvFLAGS(cv) & CVf_OLDSTYLE)
81#define CvOLDSTYLE_on(cv) (CvFLAGS(cv) |= CVf_OLDSTYLE)
82#define CvOLDSTYLE_off(cv) (CvFLAGS(cv) &= ~CVf_OLDSTYLE)
67caa1fe 83#endif
07055b4c
CS
84
85#define CvUNIQUE(cv) (CvFLAGS(cv) & CVf_UNIQUE)
86#define CvUNIQUE_on(cv) (CvFLAGS(cv) |= CVf_UNIQUE)
87#define CvUNIQUE_off(cv) (CvFLAGS(cv) &= ~CVf_UNIQUE)
8ebc5c01
PP
88
89#define CvNODEBUG(cv) (CvFLAGS(cv) & CVf_NODEBUG)
90#define CvNODEBUG_on(cv) (CvFLAGS(cv) |= CVf_NODEBUG)
91#define CvNODEBUG_off(cv) (CvFLAGS(cv) &= ~CVf_NODEBUG)
77a005ab
MB
92
93#define CvMETHOD(cv) (CvFLAGS(cv) & CVf_METHOD)
94#define CvMETHOD_on(cv) (CvFLAGS(cv) |= CVf_METHOD)
95#define CvMETHOD_off(cv) (CvFLAGS(cv) &= ~CVf_METHOD)
96
97#define CvLOCKED(cv) (CvFLAGS(cv) & CVf_LOCKED)
98#define CvLOCKED_on(cv) (CvFLAGS(cv) |= CVf_LOCKED)
99#define CvLOCKED_off(cv) (CvFLAGS(cv) &= ~CVf_LOCKED)
1aff0e91 100
cd06dffe
GS
101#define CvLVALUE(cv) (CvFLAGS(cv) & CVf_LVALUE)
102#define CvLVALUE_on(cv) (CvFLAGS(cv) |= CVf_LVALUE)
103#define CvLVALUE_off(cv) (CvFLAGS(cv) &= ~CVf_LVALUE)
104
1aff0e91
GS
105#define CvEVAL(cv) (CvUNIQUE(cv) && !SvFAKE(cv))
106#define CvEVAL_on(cv) (CvUNIQUE_on(cv),SvFAKE_off(cv))
107#define CvEVAL_off(cv) CvUNIQUE_off(cv)
108
109/* BEGIN|INIT|END */
110#define CvSPECIAL(cv) (CvUNIQUE(cv) && SvFAKE(cv))
111#define CvSPECIAL_on(cv) (CvUNIQUE_on(cv),SvFAKE_on(cv))
112#define CvSPECIAL_off(cv) (CvUNIQUE_off(cv),SvFAKE_off(cv))