Deprecating the use of C<< \cI<X> >> to specify a printable character.
[perl.git] / feature.h
1 /* -*- buffer-read-only: t -*-
2    !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
3    This file is built by regen/feature.pl.
4    Any changes made here will be lost!
5  */
6
7
8 #if defined(PERL_CORE) || defined (PERL_EXT)
9
10 #define HINT_FEATURE_SHIFT      26
11
12 #define FEATURE_BUNDLE_DEFAULT  0
13 #define FEATURE_BUNDLE_510      1
14 #define FEATURE_BUNDLE_511      2
15 #define FEATURE_BUNDLE_515      3
16 #define FEATURE_BUNDLE_523      4
17 #define FEATURE_BUNDLE_CUSTOM   (HINT_FEATURE_MASK >> HINT_FEATURE_SHIFT)
18
19 #define CURRENT_HINTS \
20     (PL_curcop == &PL_compiling ? PL_hints : PL_curcop->cop_hints)
21 #define CURRENT_FEATURE_BUNDLE \
22     ((CURRENT_HINTS & HINT_FEATURE_MASK) >> HINT_FEATURE_SHIFT)
23
24 /* Avoid using ... && Perl_feature_is_enabled(...) as that triggers a bug in
25    the HP-UX cc on PA-RISC */
26 #define FEATURE_IS_ENABLED(name)                                        \
27         ((CURRENT_HINTS                                                  \
28            & HINT_LOCALIZE_HH)                                            \
29             ? Perl_feature_is_enabled(aTHX_ STR_WITH_LEN(name)) : FALSE)
30 /* The longest string we pass in.  */
31 #define MAX_FEATURE_LEN (sizeof("postderef_qq")-1)
32
33 #define FEATURE_FC_IS_ENABLED \
34     ( \
35         (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_515 && \
36          CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_523) \
37      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
38          FEATURE_IS_ENABLED("fc")) \
39     )
40
41 #define FEATURE_SAY_IS_ENABLED \
42     ( \
43         (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \
44          CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_523) \
45      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
46          FEATURE_IS_ENABLED("say")) \
47     )
48
49 #define FEATURE_STATE_IS_ENABLED \
50     ( \
51         (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \
52          CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_523) \
53      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
54          FEATURE_IS_ENABLED("state")) \
55     )
56
57 #define FEATURE_SWITCH_IS_ENABLED \
58     ( \
59         (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \
60          CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_523) \
61      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
62          FEATURE_IS_ENABLED("switch")) \
63     )
64
65 #define FEATURE_BITWISE_IS_ENABLED \
66     ( \
67         CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
68          FEATURE_IS_ENABLED("bitwise") \
69     )
70
71 #define FEATURE_EVALBYTES_IS_ENABLED \
72     ( \
73         (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_515 && \
74          CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_523) \
75      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
76          FEATURE_IS_ENABLED("evalbytes")) \
77     )
78
79 #define FEATURE_ARYBASE_IS_ENABLED \
80     ( \
81         CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_511 \
82      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
83          FEATURE_IS_ENABLED("arybase")) \
84     )
85
86 #define FEATURE_SIGNATURES_IS_ENABLED \
87     ( \
88         CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
89          FEATURE_IS_ENABLED("signatures") \
90     )
91
92 #define FEATURE___SUB___IS_ENABLED \
93     ( \
94         (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_515 && \
95          CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_523) \
96      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
97          FEATURE_IS_ENABLED("__SUB__")) \
98     )
99
100 #define FEATURE_REFALIASING_IS_ENABLED \
101     ( \
102         CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
103          FEATURE_IS_ENABLED("refaliasing") \
104     )
105
106 #define FEATURE_POSTDEREF_QQ_IS_ENABLED \
107     ( \
108         CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_523 \
109      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
110          FEATURE_IS_ENABLED("postderef_qq")) \
111     )
112
113 #define FEATURE_UNIEVAL_IS_ENABLED \
114     ( \
115         (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_515 && \
116          CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_523) \
117      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
118          FEATURE_IS_ENABLED("unieval")) \
119     )
120
121 #define FEATURE_MYREF_IS_ENABLED \
122     ( \
123         CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
124          FEATURE_IS_ENABLED("myref") \
125     )
126
127 #define FEATURE_UNICODE_IS_ENABLED \
128     ( \
129         (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_511 && \
130          CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_523) \
131      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
132          FEATURE_IS_ENABLED("unicode")) \
133     )
134
135
136 #endif /* PERL_CORE or PERL_EXT */
137
138 #ifdef PERL_IN_OP_C
139 PERL_STATIC_INLINE void
140 S_enable_feature_bundle(pTHX_ SV *ver)
141 {
142     SV *comp_ver = sv_newmortal();
143     PL_hints = (PL_hints &~ HINT_FEATURE_MASK)
144              | (
145                   (sv_setnv(comp_ver, 5.023),
146                    vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
147                         ? FEATURE_BUNDLE_523 :
148                   (sv_setnv(comp_ver, 5.015),
149                    vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
150                         ? FEATURE_BUNDLE_515 :
151                   (sv_setnv(comp_ver, 5.011),
152                    vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
153                         ? FEATURE_BUNDLE_511 :
154                   (sv_setnv(comp_ver, 5.009005),
155                    vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
156                         ? FEATURE_BUNDLE_510 :
157                           FEATURE_BUNDLE_DEFAULT
158                ) << HINT_FEATURE_SHIFT;
159     /* special case */
160     assert(PL_curcop == &PL_compiling);
161     if (FEATURE_UNICODE_IS_ENABLED) PL_hints |=  HINT_UNI_8_BIT;
162     else                            PL_hints &= ~HINT_UNI_8_BIT;
163 }
164 #endif /* PERL_IN_OP_C */
165
166 /* ex: set ro: */