language_support.hpp 9.2 KB

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