1 | /* cv.h |
---|
2 | * |
---|
3 | * Copyright (c) 1991-2000, 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 | */ |
---|
9 | |
---|
10 | /* This structure much match XPVCV in B/C.pm and the beginning of XPVFM |
---|
11 | * in sv.h */ |
---|
12 | |
---|
13 | struct 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 */ |
---|
17 | IV xof_off; /* integer value */ |
---|
18 | NV xnv_nv; /* numeric value, if any */ |
---|
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; |
---|
25 | void (*xcv_xsub) (pTHXo_ CV*); |
---|
26 | ANY xcv_xsubany; |
---|
27 | GV * xcv_gv; |
---|
28 | char * xcv_file; |
---|
29 | long xcv_depth; /* >= 2 indicates recursive call */ |
---|
30 | AV * xcv_padlist; |
---|
31 | CV * xcv_outside; |
---|
32 | #ifdef USE_THREADS |
---|
33 | perl_mutex *xcv_mutexp; |
---|
34 | struct perl_thread *xcv_owner; /* current owner thread */ |
---|
35 | #endif /* USE_THREADS */ |
---|
36 | cv_flags_t xcv_flags; |
---|
37 | }; |
---|
38 | |
---|
39 | /* |
---|
40 | =for apidoc AmU||Nullcv |
---|
41 | Null CV pointer. |
---|
42 | |
---|
43 | =for apidoc Am|HV*|CvSTASH|CV* cv |
---|
44 | Returns the stash of the CV. |
---|
45 | |
---|
46 | =cut |
---|
47 | */ |
---|
48 | |
---|
49 | #define Nullcv Null(CV*) |
---|
50 | |
---|
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 |
---|
54 | #define CvXSUB(sv) ((XPVCV*)SvANY(sv))->xcv_xsub |
---|
55 | #define CvXSUBANY(sv) ((XPVCV*)SvANY(sv))->xcv_xsubany |
---|
56 | #define CvGV(sv) ((XPVCV*)SvANY(sv))->xcv_gv |
---|
57 | #define CvFILE(sv) ((XPVCV*)SvANY(sv))->xcv_file |
---|
58 | #define CvFILEGV(sv) (gv_fetchfile(CvFILE(sv)) |
---|
59 | #define CvDEPTH(sv) ((XPVCV*)SvANY(sv))->xcv_depth |
---|
60 | #define CvPADLIST(sv) ((XPVCV*)SvANY(sv))->xcv_padlist |
---|
61 | #define CvOUTSIDE(sv) ((XPVCV*)SvANY(sv))->xcv_outside |
---|
62 | #ifdef USE_THREADS |
---|
63 | #define CvMUTEXP(sv) ((XPVCV*)SvANY(sv))->xcv_mutexp |
---|
64 | #define CvOWNER(sv) ((XPVCV*)SvANY(sv))->xcv_owner |
---|
65 | #endif /* USE_THREADS */ |
---|
66 | #define CvFLAGS(sv) ((XPVCV*)SvANY(sv))->xcv_flags |
---|
67 | |
---|
68 | #define CVf_CLONE 0x0001 /* anon CV uses external lexicals */ |
---|
69 | #define CVf_CLONED 0x0002 /* a clone of one of those */ |
---|
70 | #define CVf_ANON 0x0004 /* CvGV() can't be trusted */ |
---|
71 | #define CVf_OLDSTYLE 0x0008 |
---|
72 | #define CVf_UNIQUE 0x0010 /* can't be cloned */ |
---|
73 | #define CVf_NODEBUG 0x0020 /* no DB::sub indirection for this CV |
---|
74 | (esp. useful for special XSUBs) */ |
---|
75 | #define CVf_METHOD 0x0040 /* CV is explicitly marked as a method */ |
---|
76 | #define CVf_LOCKED 0x0080 /* CV locks itself or first arg on entry */ |
---|
77 | #define CVf_LVALUE 0x0100 /* CV return value can be used as lvalue */ |
---|
78 | |
---|
79 | #define CvCLONE(cv) (CvFLAGS(cv) & CVf_CLONE) |
---|
80 | #define CvCLONE_on(cv) (CvFLAGS(cv) |= CVf_CLONE) |
---|
81 | #define CvCLONE_off(cv) (CvFLAGS(cv) &= ~CVf_CLONE) |
---|
82 | |
---|
83 | #define CvCLONED(cv) (CvFLAGS(cv) & CVf_CLONED) |
---|
84 | #define CvCLONED_on(cv) (CvFLAGS(cv) |= CVf_CLONED) |
---|
85 | #define CvCLONED_off(cv) (CvFLAGS(cv) &= ~CVf_CLONED) |
---|
86 | |
---|
87 | #define CvANON(cv) (CvFLAGS(cv) & CVf_ANON) |
---|
88 | #define CvANON_on(cv) (CvFLAGS(cv) |= CVf_ANON) |
---|
89 | #define CvANON_off(cv) (CvFLAGS(cv) &= ~CVf_ANON) |
---|
90 | |
---|
91 | #ifdef PERL_XSUB_OLDSTYLE |
---|
92 | #define CvOLDSTYLE(cv) (CvFLAGS(cv) & CVf_OLDSTYLE) |
---|
93 | #define CvOLDSTYLE_on(cv) (CvFLAGS(cv) |= CVf_OLDSTYLE) |
---|
94 | #define CvOLDSTYLE_off(cv) (CvFLAGS(cv) &= ~CVf_OLDSTYLE) |
---|
95 | #endif |
---|
96 | |
---|
97 | #define CvUNIQUE(cv) (CvFLAGS(cv) & CVf_UNIQUE) |
---|
98 | #define CvUNIQUE_on(cv) (CvFLAGS(cv) |= CVf_UNIQUE) |
---|
99 | #define CvUNIQUE_off(cv) (CvFLAGS(cv) &= ~CVf_UNIQUE) |
---|
100 | |
---|
101 | #define CvNODEBUG(cv) (CvFLAGS(cv) & CVf_NODEBUG) |
---|
102 | #define CvNODEBUG_on(cv) (CvFLAGS(cv) |= CVf_NODEBUG) |
---|
103 | #define CvNODEBUG_off(cv) (CvFLAGS(cv) &= ~CVf_NODEBUG) |
---|
104 | |
---|
105 | #define CvMETHOD(cv) (CvFLAGS(cv) & CVf_METHOD) |
---|
106 | #define CvMETHOD_on(cv) (CvFLAGS(cv) |= CVf_METHOD) |
---|
107 | #define CvMETHOD_off(cv) (CvFLAGS(cv) &= ~CVf_METHOD) |
---|
108 | |
---|
109 | #define CvLOCKED(cv) (CvFLAGS(cv) & CVf_LOCKED) |
---|
110 | #define CvLOCKED_on(cv) (CvFLAGS(cv) |= CVf_LOCKED) |
---|
111 | #define CvLOCKED_off(cv) (CvFLAGS(cv) &= ~CVf_LOCKED) |
---|
112 | |
---|
113 | #define CvLVALUE(cv) (CvFLAGS(cv) & CVf_LVALUE) |
---|
114 | #define CvLVALUE_on(cv) (CvFLAGS(cv) |= CVf_LVALUE) |
---|
115 | #define CvLVALUE_off(cv) (CvFLAGS(cv) &= ~CVf_LVALUE) |
---|
116 | |
---|
117 | #define CvEVAL(cv) (CvUNIQUE(cv) && !SvFAKE(cv)) |
---|
118 | #define CvEVAL_on(cv) (CvUNIQUE_on(cv),SvFAKE_off(cv)) |
---|
119 | #define CvEVAL_off(cv) CvUNIQUE_off(cv) |
---|
120 | |
---|
121 | /* BEGIN|INIT|END */ |
---|
122 | #define CvSPECIAL(cv) (CvUNIQUE(cv) && SvFAKE(cv)) |
---|
123 | #define CvSPECIAL_on(cv) (CvUNIQUE_on(cv),SvFAKE_on(cv)) |
---|
124 | #define CvSPECIAL_off(cv) (CvUNIQUE_off(cv),SvFAKE_off(cv)) |
---|