• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Boost.Wave: A Standard compliant C++ preprocessor library
3     Definition of the various language support constants
4 
5     http://www.boost.org/
6 
7     Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
8     Software License, Version 1.0. (See accompanying file
9     LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 =============================================================================*/
11 #if !defined(BOOST_LANGUAGE_SUPPORT_HPP_93EDD057_2DEF_44BC_BC9F_FDABB9F51AFA_INCLUDED)
12 #define BOOST_LANGUAGE_SUPPORT_HPP_93EDD057_2DEF_44BC_BC9F_FDABB9F51AFA_INCLUDED
13 
14 #include <boost/wave/wave_config.hpp>
15 
16 // this must occur after all of the includes and before any code appears
17 #ifdef BOOST_HAS_ABI_HEADERS
18 #include BOOST_ABI_PREFIX
19 #endif
20 
21 ///////////////////////////////////////////////////////////////////////////////
22 namespace boost {
23 namespace wave {
24 
25 enum language_support {
26 //  support flags for C++98
27     support_normal = 0x01,
28     support_cpp = support_normal,
29 
30     support_option_long_long = 0x02,
31 
32 #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
33 //  support flags for C99
34     support_option_variadics = 0x04,
35     support_c99 = support_option_variadics | support_option_long_long | 0x08,
36 #endif
37 #if BOOST_WAVE_SUPPORT_CPP0X != 0
38 //  support flags for C++11
39     support_option_no_newline_at_end_of_file = 0x20,
40 
41     support_cpp0x = support_option_variadics | support_option_long_long |
42         support_option_no_newline_at_end_of_file | 0x10,
43     support_cpp11 = support_cpp0x,
44 #if BOOST_WAVE_SUPPORT_CPP1Z != 0
45 // support flags for C++17
46     support_option_has_include = 0x10000,
47 
48     support_cpp1z = support_option_variadics | support_option_long_long |
49         support_option_no_newline_at_end_of_file | support_option_has_include |
50         0x20000,
51     support_cpp17 = support_cpp1z,
52 #if BOOST_WAVE_SUPPORT_CPP2A != 0
53 //  support flags for C++20
54     support_option_va_opt = 0x40000,
55 
56     support_cpp2a = support_option_variadics | support_option_long_long |
57         support_option_no_newline_at_end_of_file | support_option_has_include |
58         support_option_va_opt | 0x80000,
59     support_cpp20 = support_cpp2a,
60 #endif
61 #endif
62 #endif
63 
64     support_option_mask = 0xFFC0,
65     support_option_emit_contnewlines = 0x0040,
66     support_option_insert_whitespace = 0x0080,
67     support_option_preserve_comments = 0x0100,
68     support_option_no_character_validation = 0x0200,
69     support_option_convert_trigraphs = 0x0400,
70     support_option_single_line = 0x0800,
71     support_option_prefer_pp_numbers = 0x1000,
72     support_option_emit_line_directives = 0x2000,
73     support_option_include_guard_detection = 0x4000,
74     support_option_emit_pragma_directives = 0x8000
75 };
76 
77 ///////////////////////////////////////////////////////////////////////////////
78 //
79 //  need_cpp
80 //
81 //      Extract, if the language to support is C++98
82 //
83 ///////////////////////////////////////////////////////////////////////////////
84 inline bool
need_cpp(language_support language)85 need_cpp(language_support language)
86 {
87     return (language & ~support_option_mask) == support_cpp;
88 }
89 
90 ///////////////////////////////////////////////////////////////////////////////
91 //
92 //  need_cpp0x
93 //
94 //      Extract, if the language to support is C++11
95 //
96 ///////////////////////////////////////////////////////////////////////////////
97 #if BOOST_WAVE_SUPPORT_CPP0X != 0
98 
99 inline bool
need_cpp0x(language_support language)100 need_cpp0x(language_support language)
101 {
102     return (language & ~support_option_mask) == support_cpp0x;
103 }
104 
105 #else
106 
107 inline bool
need_cpp0x(language_support language)108 need_cpp0x(language_support language)
109 {
110     return false;
111 }
112 
113 #endif
114 
115 ///////////////////////////////////////////////////////////////////////////////
116 //
117 //  need_cpp2a
118 //
119 //      Extract if the language to support is C++20
120 //
121 ///////////////////////////////////////////////////////////////////////////////
122 #if BOOST_WAVE_SUPPORT_CPP2A != 0
123 
124 inline bool
need_cpp2a(language_support language)125 need_cpp2a(language_support language)
126 {
127     return (language & ~support_option_mask) == support_cpp2a;
128 }
129 
130 #else
131 
132 inline bool
need_cpp2a(language_support language)133 need_cpp2a(language_support language)
134 {
135     return false;
136 }
137 
138 #endif
139 
140 #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
141 ///////////////////////////////////////////////////////////////////////////////
142 //
143 //  need_c99
144 //
145 //      Extract, if the language to support is C99
146 //
147 ///////////////////////////////////////////////////////////////////////////////
148 inline bool
need_c99(language_support language)149 need_c99(language_support language)
150 {
151     return (language & ~support_option_mask) == support_c99;
152 }
153 
154 #else  // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
155 
156 ///////////////////////////////////////////////////////////////////////////////
157 inline bool
need_variadics(language_support language)158 need_variadics(language_support language)
159 {
160     return false;
161 }
162 
163 ///////////////////////////////////////////////////////////////////////////////
164 inline language_support
enable_variadics(language_support language,bool enable=true)165 enable_variadics(language_support language, bool enable = true)
166 {
167     return language;
168 }
169 
170 //////////////////////////////////////////////////////////////////////////////
171 inline bool
need_c99(language_support language)172 need_c99(language_support language)
173 {
174     return false;
175 }
176 
177 #endif // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
178 
179 ///////////////////////////////////////////////////////////////////////////////
180 //
181 //  get_support_options
182 //
183 //      Set preserve comments support in the language to support
184 //
185 ///////////////////////////////////////////////////////////////////////////////
186 inline language_support
get_support_options(language_support language)187 get_support_options(language_support language)
188 {
189     return static_cast<language_support>(language & support_option_mask);
190 }
191 
192 ///////////////////////////////////////////////////////////////////////////////
193 //
194 //  set_support_options
195 //
196 //      Set language option (for fine tuning of lexer behavior)
197 //
198 ///////////////////////////////////////////////////////////////////////////////
199 inline language_support
set_support_options(language_support language,language_support option)200 set_support_options(language_support language, language_support option)
201 {
202     return static_cast<language_support>(
203         (language & ~support_option_mask) | (option & support_option_mask));
204 }
205 
206 ///////////////////////////////////////////////////////////////////////////////
207 //  Get and set different language options
208 #define BOOST_WAVE_NEED_OPTION(option)                                        \
209     inline bool need_ ## option(language_support language)                    \
210     {                                                                         \
211         return (language & support_option_ ## option) ? true : false;         \
212     }                                                                         \
213     /**/
214 
215 #define BOOST_WAVE_ENABLE_OPTION(option)                                      \
216     inline language_support                                                   \
217     enable_ ## option(language_support language, bool enable = true)          \
218     {                                                                         \
219         if (enable)                                                           \
220             return static_cast<language_support>(language | support_option_ ## option); \
221         return static_cast<language_support>(language & ~support_option_ ## option);    \
222     }                                                                         \
223     /**/
224 
225 #define BOOST_WAVE_OPTION(option)                                             \
226     BOOST_WAVE_NEED_OPTION(option)                                            \
227     BOOST_WAVE_ENABLE_OPTION(option)                                          \
228     /**/
229 
230 ///////////////////////////////////////////////////////////////////////////////
231 BOOST_WAVE_OPTION(long_long)                 // support_option_long_long
232 BOOST_WAVE_OPTION(no_character_validation)   // support_option_no_character_validation
233 BOOST_WAVE_OPTION(preserve_comments)         // support_option_preserve_comments
234 BOOST_WAVE_OPTION(prefer_pp_numbers)         // support_option_prefer_pp_numbers
235 BOOST_WAVE_OPTION(emit_line_directives)      // support_option_emit_line_directives
236 BOOST_WAVE_OPTION(single_line)               // support_option_single_line
237 BOOST_WAVE_OPTION(convert_trigraphs)         // support_option_convert_trigraphs
238 #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
239 BOOST_WAVE_OPTION(include_guard_detection)   // support_option_include_guard_detection
240 #endif
241 #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
242 BOOST_WAVE_OPTION(variadics)                 // support_option_variadics
243 #endif
244 #if BOOST_WAVE_SUPPORT_VA_OPT != 0
245 BOOST_WAVE_OPTION(va_opt)                    // support_option_va_opt
246 #endif
247 #if BOOST_WAVE_EMIT_PRAGMA_DIRECTIVES != 0
248 BOOST_WAVE_OPTION(emit_pragma_directives)    // support_option_emit_pragma_directives
249 #endif
250 BOOST_WAVE_OPTION(insert_whitespace)         // support_option_insert_whitespace
251 BOOST_WAVE_OPTION(emit_contnewlines)         // support_option_emit_contnewlines
252 #if BOOST_WAVE_SUPPORT_CPP0X != 0
253 BOOST_WAVE_OPTION(no_newline_at_end_of_file) // support_no_newline_at_end_of_file
254 #endif
255 #if BOOST_WAVE_SUPPORT_HAS_INCLUDE != 0
256 BOOST_WAVE_OPTION(has_include)               // support_option_has_include
257 #endif
258 
259 #undef BOOST_WAVE_NEED_OPTION
260 #undef BOOST_WAVE_ENABLE_OPTION
261 #undef BOOST_WAVE_OPTION
262 
263 ///////////////////////////////////////////////////////////////////////////////
264 }   // namespace wave
265 }   // namespace boost
266 
267 // the suffix header occurs after all of the code
268 #ifdef BOOST_HAS_ABI_HEADERS
269 #include BOOST_ABI_SUFFIX
270 #endif
271 
272 #endif // !defined(BOOST_LANGUAGE_SUPPORT_HPP_93EDD057_2DEF_44BC_BC9F_FDABB9F51AFA_INCLUDED)
273