diff options
author | Anas Nashif <anas.nashif@intel.com> | 2013-08-26 08:15:55 -0400 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2013-08-26 08:15:55 -0400 |
commit | bb4dd8289b351fae6b55e303f189127a394a1edd (patch) | |
tree | 77c9c35a31b1459dd7988c2448e797d142530c41 /boost/wave | |
parent | 1a78a62555be32868418fe52f8e330c9d0f95d5a (diff) | |
download | boost-bb4dd8289b351fae6b55e303f189127a394a1edd.tar.gz boost-bb4dd8289b351fae6b55e303f189127a394a1edd.tar.bz2 boost-bb4dd8289b351fae6b55e303f189127a394a1edd.zip |
Imported Upstream version 1.51.0upstream/1.51.0
Diffstat (limited to 'boost/wave')
56 files changed, 820 insertions, 778 deletions
diff --git a/boost/wave/cpp_context.hpp b/boost/wave/cpp_context.hpp index f053cdb815..50c1d1ced9 100644 --- a/boost/wave/cpp_context.hpp +++ b/boost/wave/cpp_context.hpp @@ -4,7 +4,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/cpp_exceptions.hpp b/boost/wave/cpp_exceptions.hpp index 3fbd61af96..3af69ea0ce 100644 --- a/boost/wave/cpp_exceptions.hpp +++ b/boost/wave/cpp_exceptions.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ @@ -283,7 +283,7 @@ public: "a macro or scope name", // alreadydefined_name "undefined macro or scope name may not be imported", // undefined_macroname "ill formed macro name", // invalid_macroname - "qualified names are supported in C++0x mode only", // unexpected_qualified_name + "qualified names are supported in C++11 mode only", // unexpected_qualified_name "division by zero in preprocessor expression", // division_by_zero "integer overflow in preprocessor expression", // integer_overflow "this cannot be used as a macro name as it is " diff --git a/boost/wave/cpp_iteration_context.hpp b/boost/wave/cpp_iteration_context.hpp index bf9f734cdb..78c5590ce4 100644 --- a/boost/wave/cpp_iteration_context.hpp +++ b/boost/wave/cpp_iteration_context.hpp @@ -1,10 +1,10 @@ /*============================================================================= Boost.Wave: A Standard compliant C++ preprocessor library Definition of the preprocessor context - + http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ @@ -22,7 +22,7 @@ #include <boost/wave/cpp_exceptions.hpp> #include <boost/wave/language_support.hpp> #include <boost/wave/util/file_position.hpp> -// #include <boost/spirit/include/iterator/classic_multi_pass.hpp> // make_multi_pass +// #include <boost/spirit/include/iterator/classic_multi_pass.hpp> // make_multi_pass // this must occur after all of the includes and before any code appears #ifdef BOOST_HAS_ABI_HEADERS @@ -36,9 +36,9 @@ namespace iteration_context_policies { /////////////////////////////////////////////////////////////////////////////// // -// The iteration_context_policies templates are policies for the -// boost::wave::iteration_context which allows to control, how a given -// input file is to be represented by a pair of iterators pointing to the +// The iteration_context_policies templates are policies for the +// boost::wave::iteration_context which allows to control, how a given +// input file is to be represented by a pair of iterators pointing to the // begin and the end of the resulting input sequence. // /////////////////////////////////////////////////////////////////////////////// @@ -47,18 +47,18 @@ namespace iteration_context_policies { // // load_file_to_string // - // Loads a file into a string and returns the iterators pointing to + // Loads a file into a string and returns the iterators pointing to // the beginning and the end of the loaded string. // /////////////////////////////////////////////////////////////////////////// - struct load_file_to_string + struct load_file_to_string { template <typename IterContextT> - class inner + class inner { public: template <typename PositionT> - static void init_iterators(IterContextT &iter_ctx, + static void init_iterators(IterContextT &iter_ctx, PositionT const &act_pos, language_support language) { typedef typename IterContextT::iterator_type iterator_type; @@ -66,7 +66,7 @@ namespace iteration_context_policies { // read in the file std::ifstream instream(iter_ctx.filename.c_str()); if (!instream.is_open()) { - BOOST_WAVE_THROW_CTX(iter_ctx.ctx, preprocess_exception, + BOOST_WAVE_THROW_CTX(iter_ctx.ctx, preprocess_exception, bad_include_file, iter_ctx.filename.c_str(), act_pos); return; } @@ -77,7 +77,7 @@ namespace iteration_context_policies { std::istreambuf_iterator<char>()); iter_ctx.first = iterator_type( - iter_ctx.instring.begin(), iter_ctx.instring.end(), + iter_ctx.instring.begin(), iter_ctx.instring.end(), PositionT(iter_ctx.filename), language); iter_ctx.last = iterator_type(); } @@ -92,7 +92,7 @@ namespace iteration_context_policies { /////////////////////////////////////////////////////////////////////////////// // Base class for iteration contexts template <typename ContextT, typename IteratorT> -struct base_iteration_context +struct base_iteration_context { enum file_type { @@ -103,21 +103,23 @@ struct base_iteration_context }; base_iteration_context(ContextT& ctx_, - BOOST_WAVE_STRINGTYPE const &fname, std::size_t if_block_depth = 0) - : real_filename(fname), real_relative_filename(fname), filename(fname), - line(1), emitted_lines(0), if_block_depth(if_block_depth), ctx(ctx_) + BOOST_WAVE_STRINGTYPE const &fname, std::size_t if_block_depth = 0) + : real_filename(fname), real_relative_filename(fname), filename(fname), + line(1), emitted_lines(0), if_block_depth(if_block_depth), ctx(ctx_), + type(main_file) {} - base_iteration_context(ContextT& ctx_, - IteratorT const &first_, IteratorT const &last_, + base_iteration_context(ContextT& ctx_, + IteratorT const &first_, IteratorT const &last_, BOOST_WAVE_STRINGTYPE const &fname, std::size_t if_block_depth = 0, - file_type type = main_file) - : first(first_), last(last_), real_filename(fname), - real_relative_filename(fname), filename(fname), - line(1), emitted_lines(0), if_block_depth(if_block_depth), ctx(ctx_) + file_type type_ = main_file) + : first(first_), last(last_), real_filename(fname), + real_relative_filename(fname), filename(fname), + line(1), emitted_lines(0), if_block_depth(if_block_depth), ctx(ctx_), + type(type_) {} // the actual input stream - IteratorT first; // actual input stream position + IteratorT first; // actual input stream position IteratorT last; // end of input stream BOOST_WAVE_STRINGTYPE real_filename; // real name of the current file BOOST_WAVE_STRINGTYPE real_relative_filename; // real relative name of the current file @@ -130,14 +132,14 @@ struct base_iteration_context }; /////////////////////////////////////////////////////////////////////////////// -// +// template < - typename ContextT, typename IteratorT, - typename InputPolicyT = typename ContextT::input_policy_type + typename ContextT, typename IteratorT, + typename InputPolicyT = typename ContextT::input_policy_type > struct iteration_context : public base_iteration_context<ContextT, IteratorT>, - public InputPolicyT::template + public InputPolicyT::template inner<iteration_context<ContextT, IteratorT, InputPolicyT> > { typedef IteratorT iterator_type; @@ -146,10 +148,10 @@ struct iteration_context typedef base_iteration_context<ContextT, IteratorT> base_type; typedef iteration_context<ContextT, IteratorT, InputPolicyT> self_type; - iteration_context(ContextT& ctx, BOOST_WAVE_STRINGTYPE const &fname, - position_type const &act_pos, + iteration_context(ContextT& ctx, BOOST_WAVE_STRINGTYPE const &fname, + position_type const &act_pos, boost::wave::language_support language_, - typename base_type::file_type type = base_type::main_file) + typename base_type::file_type type = base_type::main_file) : base_iteration_context<ContextT, IteratorT>(ctx, fname, type) { InputPolicyT::template inner<self_type>::init_iterators( diff --git a/boost/wave/cpp_throw.hpp b/boost/wave/cpp_throw.hpp index 010e5719db..dbbd85865f 100644 --- a/boost/wave/cpp_throw.hpp +++ b/boost/wave/cpp_throw.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/cpplexer/convert_trigraphs.hpp b/boost/wave/cpplexer/convert_trigraphs.hpp index 8f80cfba49..0b478c396c 100644 --- a/boost/wave/cpplexer/convert_trigraphs.hpp +++ b/boost/wave/cpplexer/convert_trigraphs.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/cpplexer/cpp_lex_interface.hpp b/boost/wave/cpplexer/cpp_lex_interface.hpp index c69f8aaa53..d93a2e5b10 100644 --- a/boost/wave/cpplexer/cpp_lex_interface.hpp +++ b/boost/wave/cpplexer/cpp_lex_interface.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/cpplexer/cpp_lex_interface_generator.hpp b/boost/wave/cpplexer/cpp_lex_interface_generator.hpp index 8e1bd7726c..73688ee5c4 100644 --- a/boost/wave/cpplexer/cpp_lex_interface_generator.hpp +++ b/boost/wave/cpplexer/cpp_lex_interface_generator.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/cpplexer/cpp_lex_iterator.hpp b/boost/wave/cpplexer/cpp_lex_iterator.hpp index fe93888af5..580873cc0b 100644 --- a/boost/wave/cpplexer/cpp_lex_iterator.hpp +++ b/boost/wave/cpplexer/cpp_lex_iterator.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ @@ -133,7 +133,7 @@ typename lex_iterator_functor_shim<TokenT>::result_type const // a third parameter containing the name of the parsed input file // and a 4th parameter of the type boost::wave::language_support // which specifies, which language subset should be supported (C++, -// C99, C++0x etc.). +// C99, C++11 etc.). // /////////////////////////////////////////////////////////////////////////////// diff --git a/boost/wave/cpplexer/cpp_lex_token.hpp b/boost/wave/cpplexer/cpp_lex_token.hpp index 81e589539f..c69ea504d3 100644 --- a/boost/wave/cpplexer/cpp_lex_token.hpp +++ b/boost/wave/cpplexer/cpp_lex_token.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/cpplexer/cpplexer_exceptions.hpp b/boost/wave/cpplexer/cpplexer_exceptions.hpp index 5ef0ca26e6..933c400b5f 100644 --- a/boost/wave/cpplexer/cpplexer_exceptions.hpp +++ b/boost/wave/cpplexer/cpplexer_exceptions.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/cpplexer/detect_include_guards.hpp b/boost/wave/cpplexer/detect_include_guards.hpp index 09463ff8ea..286cd86acf 100644 --- a/boost/wave/cpplexer/detect_include_guards.hpp +++ b/boost/wave/cpplexer/detect_include_guards.hpp @@ -22,7 +22,7 @@ will work as well). The code allows for any whitespace, newline and single '#' tokens before the #if/#ifndef and after the final #endif. - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/cpplexer/re2clex/aq.hpp b/boost/wave/cpplexer/re2clex/aq.hpp index 7b24359a48..daf90657fe 100644 --- a/boost/wave/cpplexer/re2clex/aq.hpp +++ b/boost/wave/cpplexer/re2clex/aq.hpp @@ -4,7 +4,7 @@ http://www.boost.org/ Copyright (c) 2001 Daniel C. Nuffer. - Copyright (c) 2001-2011 Hartmut Kaiser. + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/cpplexer/re2clex/cpp_re.hpp b/boost/wave/cpplexer/re2clex/cpp_re.hpp index 5febbb4a20..527342bac4 100644 --- a/boost/wave/cpplexer/re2clex/cpp_re.hpp +++ b/boost/wave/cpplexer/re2clex/cpp_re.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp b/boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp index 748738544b..d22a0154ae 100644 --- a/boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp +++ b/boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ @@ -219,7 +219,7 @@ lexer<IteratorT, PositionT, TokenT>::get(TokenT& result) } #endif - case T_LONGINTLIT: // supported in C++0x, C99 and long_long mode + case T_LONGINTLIT: // supported in C++11, C99 and long_long mode value = string_type((char const *)scanner.tok, scanner.cur-scanner.tok); if (!boost::wave::need_long_long(language)) { diff --git a/boost/wave/cpplexer/re2clex/scanner.hpp b/boost/wave/cpplexer/re2clex/scanner.hpp index e052558e6d..1c696cf69b 100644 --- a/boost/wave/cpplexer/re2clex/scanner.hpp +++ b/boost/wave/cpplexer/re2clex/scanner.hpp @@ -4,7 +4,7 @@ http://www.boost.org/ Copyright (c) 2001 Daniel C. Nuffer. - Copyright (c) 2001-2011 Hartmut Kaiser. + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ @@ -57,7 +57,7 @@ typedef struct Scanner { bool detect_pp_numbers; /* lexer should prefer to detect pp-numbers */ bool enable_import_keyword; /* recognize import as a keyword */ bool single_line_only; /* don't report missing eol's in C++ comments */ - bool act_in_cpp0x_mode; /* lexer works in C++0x mode */ + bool act_in_cpp0x_mode; /* lexer works in C++11 mode */ } Scanner; /////////////////////////////////////////////////////////////////////////////// diff --git a/boost/wave/cpplexer/token_cache.hpp b/boost/wave/cpplexer/token_cache.hpp index 4dedb48f24..39f75a2d92 100644 --- a/boost/wave/cpplexer/token_cache.hpp +++ b/boost/wave/cpplexer/token_cache.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/cpplexer/validate_universal_char.hpp b/boost/wave/cpplexer/validate_universal_char.hpp index 09b0a06c92..9429bd12f3 100644 --- a/boost/wave/cpplexer/validate_universal_char.hpp +++ b/boost/wave/cpplexer/validate_universal_char.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/grammars/cpp_chlit_grammar.hpp b/boost/wave/grammars/cpp_chlit_grammar.hpp index c494f9f973..ae563d056c 100644 --- a/boost/wave/grammars/cpp_chlit_grammar.hpp +++ b/boost/wave/grammars/cpp_chlit_grammar.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/grammars/cpp_defined_grammar.hpp b/boost/wave/grammars/cpp_defined_grammar.hpp index d6d3422fe8..2e555cf39a 100644 --- a/boost/wave/grammars/cpp_defined_grammar.hpp +++ b/boost/wave/grammars/cpp_defined_grammar.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/grammars/cpp_defined_grammar_gen.hpp b/boost/wave/grammars/cpp_defined_grammar_gen.hpp index 3da519e917..fd41a2bd3f 100644 --- a/boost/wave/grammars/cpp_defined_grammar_gen.hpp +++ b/boost/wave/grammars/cpp_defined_grammar_gen.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/grammars/cpp_expression_grammar.hpp b/boost/wave/grammars/cpp_expression_grammar.hpp index a52d36a5c8..54c7477d34 100644 --- a/boost/wave/grammars/cpp_expression_grammar.hpp +++ b/boost/wave/grammars/cpp_expression_grammar.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/grammars/cpp_expression_grammar_gen.hpp b/boost/wave/grammars/cpp_expression_grammar_gen.hpp index 593c97786b..a575c9f701 100644 --- a/boost/wave/grammars/cpp_expression_grammar_gen.hpp +++ b/boost/wave/grammars/cpp_expression_grammar_gen.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/grammars/cpp_expression_value.hpp b/boost/wave/grammars/cpp_expression_value.hpp index 0cd6e13bc1..9703b3aebe 100644 --- a/boost/wave/grammars/cpp_expression_value.hpp +++ b/boost/wave/grammars/cpp_expression_value.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/grammars/cpp_grammar.hpp b/boost/wave/grammars/cpp_grammar.hpp index d309e2e39b..9ef3559cd0 100644 --- a/boost/wave/grammars/cpp_grammar.hpp +++ b/boost/wave/grammars/cpp_grammar.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/grammars/cpp_grammar_gen.hpp b/boost/wave/grammars/cpp_grammar_gen.hpp index d582a07144..d2d2212814 100644 --- a/boost/wave/grammars/cpp_grammar_gen.hpp +++ b/boost/wave/grammars/cpp_grammar_gen.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/grammars/cpp_intlit_grammar.hpp b/boost/wave/grammars/cpp_intlit_grammar.hpp index 96ac8f62c1..b09ed71e56 100644 --- a/boost/wave/grammars/cpp_intlit_grammar.hpp +++ b/boost/wave/grammars/cpp_intlit_grammar.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/grammars/cpp_literal_grammar_gen.hpp b/boost/wave/grammars/cpp_literal_grammar_gen.hpp index f6e24159bd..b06b98dc97 100644 --- a/boost/wave/grammars/cpp_literal_grammar_gen.hpp +++ b/boost/wave/grammars/cpp_literal_grammar_gen.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/grammars/cpp_predef_macros_gen.hpp b/boost/wave/grammars/cpp_predef_macros_gen.hpp index 4e66a53cbd..dcbefda469 100644 --- a/boost/wave/grammars/cpp_predef_macros_gen.hpp +++ b/boost/wave/grammars/cpp_predef_macros_gen.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/grammars/cpp_predef_macros_grammar.hpp b/boost/wave/grammars/cpp_predef_macros_grammar.hpp index 9d35a2f461..bb7fd8a734 100644 --- a/boost/wave/grammars/cpp_predef_macros_grammar.hpp +++ b/boost/wave/grammars/cpp_predef_macros_grammar.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/grammars/cpp_value_error.hpp b/boost/wave/grammars/cpp_value_error.hpp index 9cba99a264..b1043ea2e6 100644 --- a/boost/wave/grammars/cpp_value_error.hpp +++ b/boost/wave/grammars/cpp_value_error.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/language_support.hpp b/boost/wave/language_support.hpp index f4e599894a..df8839c463 100644 --- a/boost/wave/language_support.hpp +++ b/boost/wave/language_support.hpp @@ -1,10 +1,10 @@ /*============================================================================= Boost.Wave: A Standard compliant C++ preprocessor library Definition of the various language support constants - + http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ @@ -33,9 +33,10 @@ enum language_support { // support flags for C99 support_option_variadics = 0x04, support_c99 = support_option_variadics | support_option_long_long | 0x08, -#endif +#endif #if BOOST_WAVE_SUPPORT_CPP0X != 0 support_cpp0x = support_option_variadics | support_option_long_long | 0x10, + support_cpp11 = support_cpp0x, #endif support_option_mask = 0xFFB0, @@ -52,29 +53,29 @@ enum language_support { }; /////////////////////////////////////////////////////////////////////////////// -// +// // need_cpp // // Extract, if the language to support is C++98 // /////////////////////////////////////////////////////////////////////////////// inline bool -need_cpp(language_support language) +need_cpp(language_support language) { return (language & ~support_option_mask) == support_cpp; } /////////////////////////////////////////////////////////////////////////////// -// +// // need_cpp0x // -// Extract, if the language to support is C++0x +// Extract, if the language to support is C++11 // /////////////////////////////////////////////////////////////////////////////// #if BOOST_WAVE_SUPPORT_CPP0X != 0 inline bool -need_cpp0x(language_support language) +need_cpp0x(language_support language) { return (language & ~support_option_mask) == support_cpp0x; } @@ -82,7 +83,7 @@ need_cpp0x(language_support language) #else inline bool -need_cpp0x(language_support language) +need_cpp0x(language_support language) { return false; } @@ -91,14 +92,14 @@ need_cpp0x(language_support language) #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 /////////////////////////////////////////////////////////////////////////////// -// +// // need_c99 // // Extract, if the language to support is C99 // /////////////////////////////////////////////////////////////////////////////// inline bool -need_c99(language_support language) +need_c99(language_support language) { return (language & ~support_option_mask) == support_c99; } @@ -106,8 +107,8 @@ need_c99(language_support language) #else // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 /////////////////////////////////////////////////////////////////////////////// -inline bool -need_variadics(language_support language) +inline bool +need_variadics(language_support language) { return false; } @@ -121,7 +122,7 @@ enable_variadics(language_support language, bool enable = true) ////////////////////////////////////////////////////////////////////////////// inline bool -need_c99(language_support language) +need_c99(language_support language) { return false; } @@ -129,7 +130,7 @@ need_c99(language_support language) #endif // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 /////////////////////////////////////////////////////////////////////////////// -// +// // get_support_options // // Set preserve comments support in the language to support @@ -142,7 +143,7 @@ get_support_options(language_support language) } /////////////////////////////////////////////////////////////////////////////// -// +// // set_support_options // // Set language option (for fine tuning of lexer behavior) @@ -178,7 +179,7 @@ set_support_options(language_support language, language_support option) BOOST_WAVE_NEED_OPTION(option) \ BOOST_WAVE_ENABLE_OPTION(option) \ /**/ - + /////////////////////////////////////////////////////////////////////////////// BOOST_WAVE_OPTION(long_long) // support_option_long_long BOOST_WAVE_OPTION(no_character_validation) // support_option_no_character_validation @@ -192,7 +193,7 @@ BOOST_WAVE_OPTION(include_guard_detection) // support_option_include_guard_dete #endif #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 BOOST_WAVE_OPTION(variadics) // support_option_variadics -#endif +#endif #if BOOST_WAVE_EMIT_PRAGMA_DIRECTIVES != 0 BOOST_WAVE_OPTION(emit_pragma_directives) // support_option_emit_pragma_directives #endif @@ -205,7 +206,7 @@ BOOST_WAVE_OPTION(emit_contnewlines) // support_option_emit_contnewlines /////////////////////////////////////////////////////////////////////////////// } // namespace wave -} // namespace boost +} // namespace boost // the suffix header occurs after all of the code #ifdef BOOST_HAS_ABI_HEADERS diff --git a/boost/wave/preprocessing_hooks.hpp b/boost/wave/preprocessing_hooks.hpp index b57311323b..212fad6995 100644 --- a/boost/wave/preprocessing_hooks.hpp +++ b/boost/wave/preprocessing_hooks.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/token_ids.hpp b/boost/wave/token_ids.hpp index a2edba7e08..eb4368c280 100644 --- a/boost/wave/token_ids.hpp +++ b/boost/wave/token_ids.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ @@ -287,7 +287,7 @@ enum token_id { // import is needed to be a keyword for the C++ module Standards proposal T_IMPORT = TOKEN_FROM_ID(421, KeywordTokenType), -// C++0x keywords +// C++11 keywords T_ALIGNAS = TOKEN_FROM_ID(422, KeywordTokenType), T_ALIGNOF = TOKEN_FROM_ID(423, KeywordTokenType), T_CHAR16_T = TOKEN_FROM_ID(424, KeywordTokenType), diff --git a/boost/wave/util/cpp_ifblock.hpp b/boost/wave/util/cpp_ifblock.hpp index f89f9eaf66..34960de9a2 100644 --- a/boost/wave/util/cpp_ifblock.hpp +++ b/boost/wave/util/cpp_ifblock.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/util/cpp_include_paths.hpp b/boost/wave/util/cpp_include_paths.hpp index 29c2bec3c9..d0f2fcbaa8 100644 --- a/boost/wave/util/cpp_include_paths.hpp +++ b/boost/wave/util/cpp_include_paths.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/util/cpp_iterator.hpp b/boost/wave/util/cpp_iterator.hpp index 8441b41faa..8b378d6707 100644 --- a/boost/wave/util/cpp_iterator.hpp +++ b/boost/wave/util/cpp_iterator.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ @@ -61,32 +61,32 @@ namespace util { /////////////////////////////////////////////////////////////////////////////// // retrieve the macro name from the parse tree template < - typename ContextT, typename ParseNodeT, typename TokenT, + typename ContextT, typename ParseNodeT, typename TokenT, typename PositionT > -inline bool -retrieve_macroname(ContextT& ctx, ParseNodeT const &node, +inline bool +retrieve_macroname(ContextT& ctx, ParseNodeT const &node, boost::spirit::classic::parser_id id, TokenT ¯oname, PositionT& act_pos, bool update_position) { ParseNodeT const *name_node = 0; using boost::spirit::classic::find_node; - if (!find_node(node, id, &name_node)) + if (!find_node(node, id, &name_node)) { // ill formed define statement (unexpected, should not happen) - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_define_statement, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_define_statement, "bad parse tree (unexpected)", act_pos); return false; } typename ParseNodeT::children_t const &children = name_node->children; - if (0 == children.size() || - children.front().value.begin() == children.front().value.end()) + if (0 == children.size() || + children.front().value.begin() == children.front().value.end()) { // ill formed define statement (unexpected, should not happen) - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_define_statement, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_define_statement, "bad parse tree (unexpected)", act_pos); return false; } @@ -103,9 +103,9 @@ typename ParseNodeT::children_t const &children = name_node->children; /////////////////////////////////////////////////////////////////////////////// // retrieve the macro parameters or the macro definition from the parse tree template <typename ParseNodeT, typename ContainerT, typename PositionT> -inline bool +inline bool retrieve_macrodefinition( - ParseNodeT const &node, boost::spirit::classic::parser_id id, + ParseNodeT const &node, boost::spirit::classic::parser_id id, ContainerT ¯odefinition, PositionT& act_pos, bool update_position) { using namespace boost::wave; @@ -163,7 +163,7 @@ bool add_macro_definition(ContextT &ctx, std::string macrostring, typedef typename ContextT::token_type token_type; typedef typename ContextT::lexer_type lexer_type; typedef typename token_type::position_type position_type; - typedef boost::wave::grammars::predefined_macros_grammar_gen<lexer_type> + typedef boost::wave::grammars::predefined_macros_grammar_gen<lexer_type> predef_macros_type; using namespace boost::wave; @@ -178,12 +178,12 @@ std::string::iterator end = macrostring.end(); // parse the macro definition position_type act_pos("<command line>"); -boost::spirit::classic::tree_parse_info<lexer_type> hit = +boost::spirit::classic::tree_parse_info<lexer_type> hit = predef_macros_type::parse_predefined_macro( lexer_type(begin, end, position_type(), language), lexer_type()); if (!hit.match || (!hit.full && T_EOF != token_id(*hit.stop))) { - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_macro_definition, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_macro_definition, macrostring.c_str(), act_pos); return false; } @@ -194,24 +194,24 @@ std::vector<token_type> macroparameters; typename ContextT::token_sequence_type macrodefinition; bool has_parameters = false; - if (!boost::wave::util::retrieve_macroname(ctx, *hit.trees.begin(), + if (!boost::wave::util::retrieve_macroname(ctx, *hit.trees.begin(), BOOST_WAVE_PLAIN_DEFINE_ID, macroname, act_pos, true)) return false; - has_parameters = boost::wave::util::retrieve_macrodefinition(*hit.trees.begin(), + has_parameters = boost::wave::util::retrieve_macrodefinition(*hit.trees.begin(), BOOST_WAVE_MACRO_PARAMETERS_ID, macroparameters, act_pos, true); - boost::wave::util::retrieve_macrodefinition(*hit.trees.begin(), + boost::wave::util::retrieve_macrodefinition(*hit.trees.begin(), BOOST_WAVE_MACRO_DEFINITION_ID, macrodefinition, act_pos, true); -// If no macrodefinition is given, and the macro string does not end with a +// If no macrodefinition is given, and the macro string does not end with a // '=', then the macro should be defined with the value '1' - if (0 == macrodefinition.size() && + if (0 == macrodefinition.size() && '=' != macrostring[macrostring.size()-1]) { macrodefinition.push_back(token_type(T_INTLIT, "1", act_pos)); } // add the new macro to the macromap - return ctx.add_macro_definition(macroname, has_parameters, macroparameters, + return ctx.add_macro_definition(macroname, has_parameters, macroparameters, macrodefinition, is_predefined); } #endif // BOOST_WAVE_ENABLE_COMMANDLINE_MACROS != 0 @@ -226,11 +226,11 @@ template <typename ContextT> class pp_iterator; namespace impl { /////////////////////////////////////////////////////////////////////////////// -// +// // pp_iterator_functor // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> +template <typename ContextT> class pp_iterator_functor { public: @@ -247,7 +247,7 @@ private: typedef typename ContextT::lexer_type lexer_type; typedef typename result_type::string_type string_type; typedef typename result_type::position_type position_type; - typedef boost::wave::grammars::cpp_grammar_gen<lexer_type, token_sequence_type> + typedef boost::wave::grammars::cpp_grammar_gen<lexer_type, token_sequence_type> cpp_grammar_type; // iteration context related types (an iteration context represents a current @@ -258,9 +258,9 @@ private: // parse tree related types typedef typename cpp_grammar_type::node_factory_type node_factory_type; - typedef boost::spirit::classic::tree_parse_info<lexer_type, node_factory_type> + typedef boost::spirit::classic::tree_parse_info<lexer_type, node_factory_type> tree_parse_info_type; - typedef boost::spirit::classic::tree_match<lexer_type, node_factory_type> + typedef boost::spirit::classic::tree_match<lexer_type, node_factory_type> parse_tree_match_type; typedef typename parse_tree_match_type::node_t parse_node_type; // tree_node<node_val_data<> > typedef typename parse_tree_match_type::parse_node_t parse_node_value_type; // node_val_data<> @@ -268,16 +268,16 @@ private: public: template <typename IteratorT> - pp_iterator_functor(ContextT &ctx_, IteratorT const &first_, + pp_iterator_functor(ContextT &ctx_, IteratorT const &first_, IteratorT const &last_, typename ContextT::position_type const &pos_) - : ctx(ctx_), + : ctx(ctx_), iter_ctx(new base_iteration_context_type(ctx, - lexer_type(first_, last_, pos_, - boost::wave::enable_prefer_pp_numbers(ctx.get_language())), - lexer_type(), + lexer_type(first_, last_, pos_, + boost::wave::enable_prefer_pp_numbers(ctx.get_language())), + lexer_type(), pos_.get_file().c_str() - )), - seen_newline(true), skipped_newline(false), + )), + seen_newline(true), skipped_newline(false), must_emit_line_directive(false), act_pos(ctx_.get_main_pos()), whitespace(boost::wave::need_insert_whitespace(ctx.get_language())) { @@ -296,7 +296,7 @@ public: protected: friend class pp_iterator<ContextT>; - bool on_include_helper(char const *t, char const *s, bool is_system, + bool on_include_helper(char const *t, char const *s, bool is_system, bool include_next); protected: @@ -369,10 +369,10 @@ private: token_sequence_type unput_queue; // tokens to be preprocessed again token_sequence_type pending_queue; // tokens already preprocessed - // detect whether to insert additional whitespace in between two adjacent - // tokens, which otherwise would form a different token type, if + // detect whether to insert additional whitespace in between two adjacent + // tokens, which otherwise would form a different token type, if // re-tokenized - boost::wave::util::insert_whitespace_detection whitespace; + boost::wave::util::insert_whitespace_detection whitespace; }; /////////////////////////////////////////////////////////////////////////////// @@ -384,14 +384,14 @@ typename pp_iterator_functor<ContextT>::result_type const /////////////////////////////////////////////////////////////////////////////// // // returned_from_include() -// +// // Tests if it is necessary to pop the include file context (eof inside // a file was reached). If yes, it pops this context. Preprocessing will // continue with the next outer file scope. // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> -inline bool +template <typename ContextT> +inline bool pp_iterator_functor<ContextT>::returned_from_include() { if (iter_ctx->first == iter_ctx->last && ctx.get_iteration_depth() > 0) { @@ -402,7 +402,7 @@ pp_iterator_functor<ContextT>::returned_from_include() ctx.get_hooks().returning_from_include_file(ctx.derived()); #endif - // restore the previous iteration context after finishing the preprocessing + // restore the previous iteration context after finishing the preprocessing // of the included file BOOST_WAVE_STRINGTYPE oldfile = iter_ctx->real_filename; position_type old_pos (act_pos); @@ -414,7 +414,7 @@ pp_iterator_functor<ContextT>::returned_from_include() if (iter_ctx->first.has_include_guards(guard_name)) ctx.add_pragma_once_header(ctx.get_current_filename(), guard_name); } -#endif +#endif iter_ctx = ctx.pop_iteration_context(); must_emit_line_directive = true; @@ -426,13 +426,13 @@ pp_iterator_functor<ContextT>::returned_from_include() act_pos.set_line(iter_ctx->line); act_pos.set_column(0); - // restore the actual current file and directory + // restore the actual current file and directory #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0 namespace fs = boost::filesystem; fs::path rfp(wave::util::create_path(iter_ctx->real_filename.c_str())); std::string real_filename(rfp.string()); ctx.set_current_filename(real_filename.c_str()); -#endif +#endif ctx.set_current_directory(iter_ctx->real_filename.c_str()); ctx.set_current_relative_filename(iter_ctx->real_relative_filename.c_str()); @@ -441,7 +441,7 @@ pp_iterator_functor<ContextT>::returned_from_include() if (iter_ctx->if_block_depth != ctx.get_if_block_depth()) { using boost::wave::util::impl::escape_lit; BOOST_WAVE_STRINGTYPE msg(escape_lit(oldfile)); - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, unbalanced_if_endif, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, unbalanced_if_endif, msg.c_str(), old_pos); } return true; @@ -458,30 +458,31 @@ pp_iterator_functor<ContextT>::returned_from_include() /////////////////////////////////////////////////////////////////////////////// namespace impl { - // It may be necessary to emit a #line directive either - // - when comments need to be preserved: if the current token is not a + // It may be necessary to emit a #line directive either + // - when comments need to be preserved: if the current token is not a // whitespace, except comments - // - when comments are to be skipped: if the current token is not a + // - when comments are to be skipped: if the current token is not a // whitespace token. - template <typename ContextT> + template <typename ContextT> bool consider_emitting_line_directive(ContextT const& ctx, token_id id) { - if (need_preserve_comments(ctx.get_language())) { + if (need_preserve_comments(ctx.get_language())) + { if (!IS_CATEGORY(id, EOLTokenType) && !IS_CATEGORY(id, EOFTokenType)) { return true; } } - if (!IS_CATEGORY(id, WhiteSpaceTokenType) && + if (!IS_CATEGORY(id, WhiteSpaceTokenType) && !IS_CATEGORY(id, EOLTokenType) && !IS_CATEGORY(id, EOFTokenType)) { - return true; + return true; } return false; } } -template <typename ContextT> +template <typename ContextT> inline typename pp_iterator_functor<ContextT>::result_type const & pp_iterator_functor<ContextT>::operator()() { @@ -492,13 +493,17 @@ pp_iterator_functor<ContextT>::operator()() // loop over skip able whitespace until something significant is found bool was_seen_newline = seen_newline; + bool was_skipped_newline = skipped_newline; token_id id = T_UNKNOWN; try { // catch lexer exceptions do { + if (skipped_newline) { + was_skipped_newline = true; + skipped_newline = false; + } + // get_next_token assigns result to act_token member - if (skipped_newline) - seen_newline = true; get_next_token(); // if comments shouldn't be preserved replace them with newlines @@ -510,6 +515,9 @@ pp_iterator_functor<ContextT>::operator()() act_token.set_value("\n"); } + if (IS_CATEGORY(id, EOLTokenType)) + seen_newline = true; + } while (ctx.get_hooks().may_skip_whitespace(ctx.derived(), act_token, skipped_newline)); } catch (boost::wave::cpplexer::lexing_exception const& e) { @@ -518,12 +526,16 @@ pp_iterator_functor<ContextT>::operator()() return act_token; } +// restore the accumulated skipped_newline state for next invocation + if (was_skipped_newline) + skipped_newline = true; + // if there were skipped any newlines, we must emit a #line directive - if ((must_emit_line_directive || (was_seen_newline && skipped_newline)) && - impl::consider_emitting_line_directive(ctx, id)) + if ((must_emit_line_directive || (was_seen_newline && skipped_newline)) && + impl::consider_emitting_line_directive(ctx, id)) { // must emit a #line directive - if (need_emit_line_directives(ctx.get_language()) && emit_line_directive()) + if (need_emit_line_directives(ctx.get_language()) && emit_line_directive()) { skipped_newline = false; ctx.get_hooks().may_skip_whitespace(ctx.derived(), act_token, skipped_newline); // feed ws eater FSM @@ -552,13 +564,13 @@ pp_iterator_functor<ContextT>::operator()() #if BOOST_WAVE_SUPPORT_CPP0X != 0 case T_RAWSTRINGLIT: - iter_ctx->emitted_lines += + iter_ctx->emitted_lines += context_policies::util::rawstring_count_newlines(act_token); break; #endif case T_CCOMMENT: // will come here only if whitespace is preserved - iter_ctx->emitted_lines += + iter_ctx->emitted_lines += context_policies::util::ccomment_count_newlines(act_token); break; @@ -569,12 +581,12 @@ pp_iterator_functor<ContextT>::operator()() std::string pp_number( util::to_string<std::string>(act_token.get_value())); - lexer_type it = lexer_type(pp_number.begin(), - pp_number.end(), act_token.get_position(), + lexer_type it = lexer_type(pp_number.begin(), + pp_number.end(), act_token.get_position(), ctx.get_language()); lexer_type end = lexer_type(); - for (/**/; it != end && T_EOF != token_id(*it); ++it) + for (/**/; it != end && T_EOF != token_id(*it); ++it) rescanned.push_back(*it); pending_queue.splice(pending_queue.begin(), rescanned); @@ -599,8 +611,8 @@ pp_iterator_functor<ContextT>::operator()() // tokens, which would form different (and wrong) tokens whitespace.shift_tokens(T_SPACE); pending_queue.push_front(act_token); // push this token back - return act_token = result_type(T_SPACE, - typename result_type::string_type(" "), + return act_token = result_type(T_SPACE, + typename result_type::string_type(" "), act_token.get_position()); } whitespace.shift_tokens(id); @@ -608,7 +620,7 @@ pp_iterator_functor<ContextT>::operator()() } /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> +template <typename ContextT> inline typename pp_iterator_functor<ContextT>::result_type const & pp_iterator_functor<ContextT>::get_next_token() { @@ -616,21 +628,21 @@ pp_iterator_functor<ContextT>::get_next_token() // if there is something in the unput_queue, then return the next token from // there (all tokens in the queue are preprocessed already) - if (!pending_queue.empty() || !unput_queue.empty()) + if (!pending_queue.empty() || !unput_queue.empty()) return pp_token(); // return next token // test for EOF, if there is a pending input context, pop it back and continue // parsing with it bool returned_from_include_file = returned_from_include(); -// try to generate the next token +// try to generate the next token if (iter_ctx->first != iter_ctx->last) { do { - // If there are pending tokens in the queue, we'll have to return + // If there are pending tokens in the queue, we'll have to return // these. This may happen from a #pragma directive, which got replaced // by some token sequence. if (!pending_queue.empty()) { - util::on_exit::pop_front<token_sequence_type> + util::on_exit::pop_front<token_sequence_type> pop_front_token(pending_queue); return act_token = pending_queue.front(); @@ -652,16 +664,16 @@ bool returned_from_include_file = returned_from_include(); ++iter_ctx->first; // now make sure this line has a newline - if ((!seen_newline || act_pos.get_column() > 1) && - !need_single_line(ctx.get_language())) + if ((!seen_newline || act_pos.get_column() > 1) && + !need_single_line(ctx.get_language())) { // warn, if this file does not end with a newline - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, last_line_not_terminated, "", act_pos); } continue; // if this is the main file, the while loop breaks } - else if (T_NEWLINE == id || T_CPPCOMMENT == id) { + else if (T_NEWLINE == id || T_CPPCOMMENT == id) { // a newline is to be returned ASAP, a C++ comment too // (the C++ comment token includes the trailing newline) seen_newline = true; @@ -673,7 +685,7 @@ bool returned_from_include_file = returned_from_include(); util::impl::call_skipped_token_hook(ctx, act_token); continue; } - return act_token; + return act_token; } seen_newline = false; @@ -684,17 +696,17 @@ bool returned_from_include_file = returned_from_include(); // must_emit_line_directive = true; // loop to the next token to analyze - // simply fall through, since the iterator was already adjusted + // simply fall through, since the iterator was already adjusted // correctly } else if (ctx.get_if_block_status()) { - // preprocess this token, eat up more, if appropriate, return + // preprocess this token, eat up more, if appropriate, return // the next preprocessed token return pp_token(); } else { - // compilation condition is false: if the current token is a - // newline, account for it, otherwise discard the actual token and + // compilation condition is false: if the current token is a + // newline, account for it, otherwise discard the actual token and // try the next one if (T_NEWLINE == token_id(act_token)) { seen_newline = true; @@ -706,14 +718,14 @@ bool returned_from_include_file = returned_from_include(); ++iter_ctx->first; } - } while ((iter_ctx->first != iter_ctx->last) || + } while ((iter_ctx->first != iter_ctx->last) || (returned_from_include_file = returned_from_include())); // overall eof reached - if (ctx.get_if_block_depth() > 0 && !need_single_line(ctx.get_language())) + if (ctx.get_if_block_depth() > 0 && !need_single_line(ctx.get_language())) { // missing endif directive(s) - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_endif, "", act_pos); } } @@ -730,7 +742,7 @@ bool returned_from_include_file = returned_from_include(); // emit_line_directive(): emits a line directive from the act_token data // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> +template <typename ContextT> inline bool pp_iterator_functor<ContextT>::emit_line_directive() { @@ -738,7 +750,7 @@ pp_iterator_functor<ContextT>::emit_line_directive() typename ContextT::position_type pos = act_token.get_position(); -// if (must_emit_line_directive && +// if (must_emit_line_directive && // iter_ctx->emitted_lines+1 == act_pos.get_line() && // iter_ctx->filename == act_pos.get_file()) // { @@ -746,14 +758,14 @@ typename ContextT::position_type pos = act_token.get_position(); // return false; // } - if (must_emit_line_directive || - iter_ctx->emitted_lines+1 != act_pos.get_line()) + if (must_emit_line_directive || + iter_ctx->emitted_lines+1 != act_pos.get_line()) { // unput the current token pending_queue.push_front(act_token); pos.set_line(act_pos.get_line()); - if (iter_ctx->emitted_lines+2 == act_pos.get_line()) { + if (iter_ctx->emitted_lines+2 == act_pos.get_line() && act_pos.get_line() != 1) { // prefer to output a single newline instead of the #line directive // whitespace.shift_tokens(T_NEWLINE); act_token = result_type(T_NEWLINE, "\n", pos); @@ -776,7 +788,7 @@ typename ContextT::position_type pos = act_token.get_position(); pos.set_column(column); // account for '#line' pending.push_back(result_type(T_SPACE, " ", pos)); - // 21 is the max required size for a 64 bit integer represented as a + // 21 is the max required size for a 64 bit integer represented as a // string char buffer[22]; @@ -822,7 +834,7 @@ typename ContextT::position_type pos = act_token.get_position(); // pptoken(): return the next preprocessed token // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> +template <typename ContextT> inline typename pp_iterator_functor<ContextT>::result_type const & pp_iterator_functor<ContextT>::pp_token() { @@ -832,7 +844,7 @@ token_id id = token_id(*iter_ctx->first); // eat all T_PLACEHOLDER tokens, eventually slipped through out of the // macro engine - do { + do { if (!pending_queue.empty()) { // if there are pending tokens in the queue, return the first one act_token = pending_queue.front(); @@ -840,14 +852,14 @@ token_id id = token_id(*iter_ctx->first); act_pos = act_token.get_position(); } else if (!unput_queue.empty() - || T_IDENTIFIER == id + || T_IDENTIFIER == id || IS_CATEGORY(id, KeywordTokenType) || IS_EXTCATEGORY(id, OperatorTokenType|AltExtTokenType) || IS_CATEGORY(id, BoolLiteralTokenType)) { // call the lexer, preprocess the required number of tokens, put them // into the unput queue - act_token = ctx.expand_tokensequence(iter_ctx->first, + act_token = ctx.expand_tokensequence(iter_ctx->first, iter_ctx->last, pending_queue, unput_queue, skipped_newline); } else { @@ -870,11 +882,11 @@ namespace impl { // call 'found_directive' preprocessing hook template <typename ContextT> - bool call_found_directive_hook(ContextT& ctx, + bool call_found_directive_hook(ContextT& ctx, typename ContextT::token_type const& found_directive) { #if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0 - ctx.get_hooks().found_directive(found_directive); + ctx.get_hooks().found_directive(found_directive); #else if (ctx.get_hooks().found_directive(ctx.derived(), found_directive)) return true; // skip this directive and return newline only @@ -884,11 +896,11 @@ namespace impl { // // call 'skipped_token' preprocessing hook // template <typename ContextT> -// void call_skipped_token_hook(ContextT& ctx, +// void call_skipped_token_hook(ContextT& ctx, // typename ContextT::token_type const& skipped) // { // #if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0 -// ctx.get_hooks().skipped_token(skipped); +// ctx.get_hooks().skipped_token(skipped); // #else // ctx.get_hooks().skipped_token(ctx.derived(), skipped); // #endif @@ -907,7 +919,7 @@ namespace impl { if (IS_CATEGORY(id, EOLTokenType) || IS_CATEGORY(id, EOFTokenType)) break; // do not enter a new line if (T_CPPCOMMENT == id || - context_policies::util::ccomment_has_newline(*it)) + context_policies::util::ccomment_has_newline(*it)) { break; } @@ -934,7 +946,7 @@ namespace impl { token_id id = token_id(*it); if (T_CPPCOMMENT == id || T_NEWLINE == id || - context_policies::util::ccomment_has_newline(*it)) + context_policies::util::ccomment_has_newline(*it)) { if (call_hook) util::impl::call_skipped_token_hook(ctx, *it); @@ -954,7 +966,7 @@ namespace impl { /////////////////////////////////////////////////////////////////////////// template <typename ContextT, typename IteratorT> - bool skip_to_eol(ContextT &ctx, IteratorT &it, IteratorT const &end, + bool skip_to_eol(ContextT &ctx, IteratorT &it, IteratorT const &end, bool call_hook = true) { using namespace boost::wave; @@ -963,9 +975,9 @@ namespace impl { token_id id = token_id(*it); if (T_CPPCOMMENT == id || T_NEWLINE == id || - context_policies::util::ccomment_has_newline(*it)) + context_policies::util::ccomment_has_newline(*it)) { - // always call hook for eol + // always call hook for eol util::impl::call_skipped_token_hook(ctx, *it); ++it; // skip eol/C/C++ comment return true; // found eol @@ -995,12 +1007,12 @@ namespace impl { /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> template <typename IteratorT> -inline bool +inline bool pp_iterator_functor<ContextT>::extract_identifier(IteratorT &it) { token_id id = util::impl::skip_whitespace(it, iter_ctx->last); - if (T_IDENTIFIER == id || IS_CATEGORY(id, KeywordTokenType) || - IS_EXTCATEGORY(id, OperatorTokenType|AltExtTokenType) || + if (T_IDENTIFIER == id || IS_CATEGORY(id, KeywordTokenType) || + IS_EXTCATEGORY(id, OperatorTokenType|AltExtTokenType) || IS_CATEGORY(id, BoolLiteralTokenType)) { IteratorT save = it; @@ -1022,10 +1034,10 @@ string_type str(util::impl::as_string<string_type>(iter_ctx->first, it)); /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> template <typename IteratorT> -inline bool +inline bool pp_iterator_functor<ContextT>::ensure_is_last_on_line(IteratorT& it, bool call_hook) { - if (!impl::pp_is_last_on_line(ctx, it, iter_ctx->last, call_hook)) + if (!impl::pp_is_last_on_line(ctx, it, iter_ctx->last, call_hook)) { // enable error recovery (start over with the next line) impl::skip_to_eol(ctx, it, iter_ctx->last); @@ -1041,15 +1053,15 @@ pp_iterator_functor<ContextT>::ensure_is_last_on_line(IteratorT& it, bool call_h return false; } - if (it == iter_ctx->last && !need_single_line(ctx.get_language())) + if (it == iter_ctx->last && !need_single_line(ctx.get_language())) { // The line doesn't end with an eol but eof token. seen_newline = true; // allow to resume after warning iter_ctx->first = it; - // Trigger a warning that the last line was not terminated with a + // Trigger a warning that the last line was not terminated with a // newline. - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, last_line_not_terminated, "", act_pos); return false; @@ -1059,20 +1071,20 @@ pp_iterator_functor<ContextT>::ensure_is_last_on_line(IteratorT& it, bool call_h template <typename ContextT> template <typename IteratorT> -inline bool +inline bool pp_iterator_functor<ContextT>::skip_to_eol_with_check(IteratorT &it, bool call_hook) { typename ContextT::string_type value ((*it).get_value()); if (!impl::skip_to_eol(ctx, it, iter_ctx->last, call_hook) && - !need_single_line(ctx.get_language())) + !need_single_line(ctx.get_language())) { // The line doesn't end with an eol but eof token. seen_newline = true; // allow to resume after warning iter_ctx->first = it; - // Trigger a warning, that the last line was not terminated with a + // Trigger a warning, that the last line was not terminated with a // newline. - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, last_line_not_terminated, "", act_pos); return false; } @@ -1084,8 +1096,8 @@ pp_iterator_functor<ContextT>::skip_to_eol_with_check(IteratorT &it, bool call_h } /////////////////////////////////////////////////////////////////////////////// -// handle_pp_directive: handle certain pp_directives -template <typename ContextT> +// handle_pp_directive: handle certain pp_directives +template <typename ContextT> template <typename IteratorT> inline bool pp_iterator_functor<ContextT>::handle_pp_directive(IteratorT &it) @@ -1105,9 +1117,9 @@ pp_iterator_functor<ContextT>::handle_pp_directive(IteratorT &it) case T_PP_ELIF: // #elif if (!ctx.get_enclosing_if_block_status()) { - if (!ctx.enter_elif_block(false)) { + if (!ctx.enter_elif_block(false)) { // #else without matching #if - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_if, "#elif", act_pos); return true; // do not analyze this directive any further } @@ -1126,7 +1138,7 @@ pp_iterator_functor<ContextT>::handle_pp_directive(IteratorT &it) else on_endif(); - // make sure, there are no (non-whitespace) tokens left on + // make sure, there are no (non-whitespace) tokens left on // this line ensure_is_last_on_line(it); @@ -1156,11 +1168,11 @@ pp_iterator_functor<ContextT>::handle_pp_directive(IteratorT &it) case T_PP_QHEADER_NEXT: #endif include_next = (T_PP_QHEADER_NEXT == id) ? true : false; - if (!impl::call_found_directive_hook(ctx, *it)) + if (!impl::call_found_directive_hook(ctx, *it)) { string_type dir((*it).get_value()); - // make sure, there are no (non-whitespace) tokens left on + // make sure, there are no (non-whitespace) tokens left on // this line if (ensure_is_last_on_line(it)) { @@ -1177,11 +1189,11 @@ pp_iterator_functor<ContextT>::handle_pp_directive(IteratorT &it) case T_PP_HHEADER_NEXT: #endif include_next = (T_PP_HHEADER_NEXT == id) ? true : false; - if (!impl::call_found_directive_hook(ctx, *it)) + if (!impl::call_found_directive_hook(ctx, *it)) { string_type dir((*it).get_value()); - // make sure, there are no (non-whitespace) tokens left on + // make sure, there are no (non-whitespace) tokens left on // this line if (ensure_is_last_on_line(it)) { @@ -1203,7 +1215,7 @@ pp_iterator_functor<ContextT>::handle_pp_directive(IteratorT &it) else on_endif(); - // make sure, there are no (non-whitespace) tokens left on + // make sure, there are no (non-whitespace) tokens left on // this line ensure_is_last_on_line(it); @@ -1225,8 +1237,8 @@ pp_iterator_functor<ContextT>::handle_pp_directive(IteratorT &it) // extract first non-whitespace token as argument case T_PP_UNDEF: // #undef - if (!impl::call_found_directive_hook(ctx, *it) && - extract_identifier(it)) + if (!impl::call_found_directive_hook(ctx, *it) && + extract_identifier(it)) { on_undefine(it); } @@ -1234,8 +1246,8 @@ pp_iterator_functor<ContextT>::handle_pp_directive(IteratorT &it) break; case T_PP_IFDEF: // #ifdef - if (!impl::call_found_directive_hook(ctx, *it) && - extract_identifier(it)) + if (!impl::call_found_directive_hook(ctx, *it) && + extract_identifier(it)) { on_ifdef(directive, it); } @@ -1243,8 +1255,8 @@ pp_iterator_functor<ContextT>::handle_pp_directive(IteratorT &it) break; case T_PP_IFNDEF: // #ifndef - if (!impl::call_found_directive_hook(ctx, *it) && - extract_identifier(it)) + if (!impl::call_found_directive_hook(ctx, *it) && + extract_identifier(it)) { on_ifndef(directive, it); } @@ -1254,8 +1266,8 @@ pp_iterator_functor<ContextT>::handle_pp_directive(IteratorT &it) #if BOOST_WAVE_SUPPORT_MS_EXTENSIONS != 0 // case T_MSEXT_PP_REGION: // #region ... // break; -// -// case T_MSEXT_PP_ENDREGION: // #endregion +// +// case T_MSEXT_PP_ENDREGION: // #endregion // break; #endif @@ -1275,7 +1287,7 @@ pp_iterator_functor<ContextT>::handle_pp_directive(IteratorT &it) /////////////////////////////////////////////////////////////////////////////// // pp_directive(): recognize a preprocessor directive -template <typename ContextT> +template <typename ContextT> inline bool pp_iterator_functor<ContextT>::pp_directive() { @@ -1331,7 +1343,7 @@ lexer_type it = iter_ctx->first; // ignore/handle all pp directives not related to conditional compilation while // if block status is false if (handle_pp_directive(it)) { - // we may skip pp directives only if the current if block status is + // we may skip pp directives only if the current if block status is // false or if it was a #include directive we could handle directly return true; // the pp directive has been handled/skipped } @@ -1345,21 +1357,21 @@ tree_parse_info_type hit = cpp_grammar_type::parse_cpp_grammar( it, iter_ctx->last, act_pos, found_eof, found_directive, found_eoltokens); if (hit.match) { - // position the iterator past the matched sequence to allow + // position the iterator past the matched sequence to allow // resynchronization, if an error occurs iter_ctx->first = hit.stop; seen_newline = true; must_emit_line_directive = true; - // found a valid pp directive, dispatch to the correct function to handle + // found a valid pp directive, dispatch to the correct function to handle // the found pp directive bool result = dispatch_directive (hit, found_directive, found_eoltokens); if (found_eof && !need_single_line(ctx.get_language())) { // The line was terminated with an end of file token. - // So trigger a warning, that the last line was not terminated with a + // So trigger a warning, that the last line was not terminated with a // newline. - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, last_line_not_terminated, "", act_pos); } return result; @@ -1384,7 +1396,7 @@ tree_parse_info_type hit = cpp_grammar_type::parse_cpp_grammar( // dispatch_directive(): dispatch a recognized preprocessor directive // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> +template <typename ContextT> inline bool pp_iterator_functor<ContextT>::dispatch_directive( tree_parse_info_type const &hit, result_type const& found_directive, @@ -1408,30 +1420,30 @@ const_child_iterator_t end_child_it = (*root.begin()).children.end(); token_id id = token_id(found_directive); // call preprocessing hook - if (impl::call_found_directive_hook(ctx, found_directive)) + if (impl::call_found_directive_hook(ctx, found_directive)) return true; // skip this directive and return newline only switch (static_cast<unsigned int>(id)) { // case T_PP_QHEADER: // #include "..." // #if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0 // case T_PP_QHEADER_NEXT: // #include_next "..." -// #endif -// on_include ((*nodeval.begin()).get_value(), false, +// #endif +// on_include ((*nodeval.begin()).get_value(), false, // T_PP_QHEADER_NEXT == id); // break; // case T_PP_HHEADER: // #include <...> // #if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0 // case T_PP_HHEADER_NEXT: // #include_next <...> -// #endif -// on_include ((*nodeval.begin()).get_value(), true, +// #endif +// on_include ((*nodeval.begin()).get_value(), true, // T_PP_HHEADER_NEXT == id); // break; - + case T_PP_INCLUDE: // #include ... #if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0 case T_PP_INCLUDE_NEXT: // #include_next ... -#endif +#endif on_include (begin_child_it, end_child_it, T_PP_INCLUDE_NEXT == id); break; @@ -1442,11 +1454,11 @@ token_id id = token_id(found_directive); // case T_PP_UNDEF: // #undef // on_undefine(*nodeval.begin()); // break; -// +// // case T_PP_IFDEF: // #ifdef // on_ifdef(found_directive, begin_child_it, end_child_it); // break; -// +// // case T_PP_IFNDEF: // #ifndef // on_ifndef(found_directive, begin_child_it, end_child_it); // break; @@ -1479,7 +1491,7 @@ token_id id = token_id(found_directive); case T_PP_WARNING: // #warning on_warning(begin_child_it, end_child_it); break; -#endif +#endif case T_PP_PRAGMA: // #pragma return on_pragma(begin_child_it, end_child_it); @@ -1492,14 +1504,14 @@ token_id id = token_id(found_directive); default: // #something else on_illformed((*nodeval.begin()).get_value()); - - // if we end up here, we have been instructed to ignore the error, so + + // if we end up here, we have been instructed to ignore the error, so // we simply copy the whole construct to the output { token_sequence_type expanded; get_token_value<result_type, parse_node_type> get_value; - std::copy(make_ref_transform_iterator(begin_child_it, get_value), + std::copy(make_ref_transform_iterator(begin_child_it, get_value), make_ref_transform_iterator(end_child_it, get_value), std::inserter(expanded, expanded.end())); pending_queue.splice(pending_queue.begin(), expanded); @@ -1514,14 +1526,14 @@ token_id id = token_id(found_directive); } /////////////////////////////////////////////////////////////////////////////// -// +// // on_include: handle #include <...> or #include "..." directives // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> -inline void -pp_iterator_functor<ContextT>::on_include (string_type const &s, - bool is_system, bool include_next) +template <typename ContextT> +inline void +pp_iterator_functor<ContextT>::on_include (string_type const &s, + bool is_system, bool include_next) { BOOST_ASSERT(ctx.get_if_block_status()); @@ -1529,16 +1541,16 @@ pp_iterator_functor<ContextT>::on_include (string_type const &s, typename string_type::size_type pos_end = s.find_last_of(is_system ? '>' : '\"'); if (string_type::npos == pos_end) { - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_statement, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_statement, s.c_str(), act_pos); return; } -typename string_type::size_type pos_begin = +typename string_type::size_type pos_begin = s.find_last_of(is_system ? '<' : '\"', pos_end-1); if (string_type::npos == pos_begin) { - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_statement, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_statement, s.c_str(), act_pos); return; } @@ -1547,14 +1559,14 @@ std::string file_token(s.substr(pos_begin, pos_end-pos_begin+1).c_str()); std::string file_path(s.substr(pos_begin+1, pos_end-pos_begin-1).c_str()); // finally include the file - on_include_helper(file_token.c_str(), file_path.c_str(), is_system, + on_include_helper(file_token.c_str(), file_path.c_str(), is_system, include_next); } -template <typename ContextT> -inline bool -pp_iterator_functor<ContextT>::on_include_helper (char const *f, char const *s, - bool is_system, bool include_next) +template <typename ContextT> +inline bool +pp_iterator_functor<ContextT>::on_include_helper (char const *f, char const *s, + bool is_system, bool include_next) { namespace fs = boost::filesystem; @@ -1572,31 +1584,31 @@ char const *current_name = 0; // never try to match current file name ctx.get_hooks().found_include_directive(f, include_next); #else if (ctx.get_hooks().found_include_directive(ctx.derived(), f, include_next)) - return true; // client returned false: skip file to include + return true; // client returned false: skip file to include #endif file_path = util::impl::unescape_lit(file_path); std::string native_path_str; - if (!ctx.get_hooks().locate_include_file(ctx, file_path, is_system, - current_name, dir_path, native_path_str)) + if (!ctx.get_hooks().locate_include_file(ctx, file_path, is_system, + current_name, dir_path, native_path_str)) { - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_file, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_file, file_path.c_str(), act_pos); return false; } // test, if this file is known through a #pragma once directive #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0 - if (!ctx.has_pragma_once(native_path_str)) -#endif + if (!ctx.has_pragma_once(native_path_str)) +#endif { // the new include file determines the actual current directory ctx.set_current_directory(native_path_str.c_str()); // preprocess the opened file boost::shared_ptr<base_iteration_context_type> new_iter_ctx ( - new iteration_context_type(ctx, native_path_str.c_str(), act_pos, + new iteration_context_type(ctx, native_path_str.c_str(), act_pos, boost::wave::enable_prefer_pp_numbers(ctx.get_language()), is_system ? base_iteration_context_type::system_header : base_iteration_context_type::user_header)); @@ -1628,7 +1640,7 @@ char const *current_name = 0; // never try to match current file name fs::path rfp(wave::util::create_path(iter_ctx->real_filename.c_str())); std::string real_filename(rfp.string()); ctx.set_current_filename(real_filename.c_str()); -#endif +#endif ctx.set_current_relative_filename(dir_path.c_str()); iter_ctx->real_relative_filename = dir_path.c_str(); @@ -1640,7 +1652,7 @@ char const *current_name = 0; // never try to match current file name } /////////////////////////////////////////////////////////////////////////////// -// +// // on_include(): handle #include ... directives // /////////////////////////////////////////////////////////////////////////////// @@ -1649,7 +1661,7 @@ namespace impl { // trim all whitespace from the beginning and the end of the given string template <typename StringT> - inline StringT + inline StringT trim_whitespace(StringT const &s) { typedef typename StringT::size_type size_type; @@ -1662,8 +1674,8 @@ namespace impl { } } -template <typename ContextT> -inline void +template <typename ContextT> +inline void pp_iterator_functor<ContextT>::on_include( typename parse_tree_type::const_iterator const &begin, typename parse_tree_type::const_iterator const &end, bool include_next) @@ -1675,12 +1687,12 @@ get_token_value<result_type, parse_node_type> get_value; token_sequence_type expanded; token_sequence_type toexpand; - std::copy(make_ref_transform_iterator(begin, get_value), + std::copy(make_ref_transform_iterator(begin, get_value), make_ref_transform_iterator(end, get_value), std::inserter(toexpand, toexpand.end())); typename token_sequence_type::iterator begin2 = toexpand.begin(); - ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded, + ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded, false); // now, include the file @@ -1689,7 +1701,7 @@ bool is_system = '<' == s[0] && '>' == s[s.size()-1]; if (!is_system && !('\"' == s[0] && '\"' == s[s.size()-1])) { // should resolve into something like <...> or "..." - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_statement, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_statement, s.c_str(), act_pos); return; } @@ -1697,14 +1709,14 @@ bool is_system = '<' == s[0] && '>' == s[s.size()-1]; } /////////////////////////////////////////////////////////////////////////////// -// +// // on_define(): handle #define directives // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> -inline void -pp_iterator_functor<ContextT>::on_define (parse_node_type const &node) +template <typename ContextT> +inline void +pp_iterator_functor<ContextT>::on_define (parse_node_type const &node) { BOOST_ASSERT(ctx.get_if_block_status()); @@ -1715,12 +1727,12 @@ token_sequence_type macrodefinition; bool has_parameters = false; position_type pos(act_token.get_position()); - if (!boost::wave::util::retrieve_macroname(ctx, node, + if (!boost::wave::util::retrieve_macroname(ctx, node, BOOST_WAVE_PLAIN_DEFINE_ID, macroname, pos, false)) return; - has_parameters = boost::wave::util::retrieve_macrodefinition(node, + has_parameters = boost::wave::util::retrieve_macrodefinition(node, BOOST_WAVE_MACRO_PARAMETERS_ID, macroparameters, pos, false); - boost::wave::util::retrieve_macrodefinition(node, + boost::wave::util::retrieve_macrodefinition(node, BOOST_WAVE_MACRO_DEFINITION_ID, macrodefinition, pos, false); if (has_parameters) { @@ -1729,44 +1741,44 @@ position_type pos(act_token.get_position()); // test whether ellipsis are given, and if yes, if these are placed as the // last argument, test if __VA_ARGS__ is used as a macro parameter name using namespace cpplexer; - typedef typename std::vector<result_type>::iterator + typedef typename std::vector<result_type>::iterator parameter_iterator_t; bool seen_ellipses = false; parameter_iterator_t end = macroparameters.end(); - for (parameter_iterator_t pit = macroparameters.begin(); - pit != end; ++pit) + for (parameter_iterator_t pit = macroparameters.begin(); + pit != end; ++pit) { if (seen_ellipses) { // ellipses are not the last given formal argument - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, - bad_define_statement, macroname.get_value().c_str(), + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + bad_define_statement, macroname.get_value().c_str(), (*pit).get_position()); return; } - if (T_ELLIPSIS == token_id(*pit)) + if (T_ELLIPSIS == token_id(*pit)) seen_ellipses = true; // can't use __VA_ARGS__ as a argument name if ("__VA_ARGS__" == (*pit).get_value()) { - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, - bad_define_statement_va_args, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + bad_define_statement_va_args, macroname.get_value().c_str(), (*pit).get_position()); return; } } - // if there wasn't an ellipsis, then there shouldn't be a __VA_ARGS__ + // if there wasn't an ellipsis, then there shouldn't be a __VA_ARGS__ // placeholder in the definition too [C99 Standard 6.10.3.5] if (!seen_ellipses) { typedef typename token_sequence_type::iterator definition_iterator_t; bool seen_va_args = false; definition_iterator_t pend = macrodefinition.end(); - for (definition_iterator_t dit = macrodefinition.begin(); - dit != pend; ++dit) + for (definition_iterator_t dit = macrodefinition.begin(); + dit != pend; ++dit) { - if (T_IDENTIFIER == token_id(*dit) && + if (T_IDENTIFIER == token_id(*dit) && "__VA_ARGS__" == (*dit).get_value()) { seen_va_args = true; @@ -1774,8 +1786,8 @@ position_type pos(act_token.get_position()); } if (seen_va_args) { // must not have seen __VA_ARGS__ placeholder - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, - bad_define_statement_va_args, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + bad_define_statement_va_args, macroname.get_value().c_str(), act_token.get_position()); return; } @@ -1786,17 +1798,17 @@ position_type pos(act_token.get_position()); { // test, that there is no T_ELLIPSES given using namespace cpplexer; - typedef typename std::vector<result_type>::iterator + typedef typename std::vector<result_type>::iterator parameter_iterator_t; parameter_iterator_t end = macroparameters.end(); - for (parameter_iterator_t pit = macroparameters.begin(); - pit != end; ++pit) + for (parameter_iterator_t pit = macroparameters.begin(); + pit != end; ++pit) { if (T_ELLIPSIS == token_id(*pit)) { // if variadics are disabled, no ellipses should be given - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, - bad_define_statement, macroname.get_value().c_str(), + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + bad_define_statement, macroname.get_value().c_str(), (*pit).get_position()); return; } @@ -1805,17 +1817,17 @@ position_type pos(act_token.get_position()); } // add the new macro to the macromap - ctx.add_macro_definition(macroname, has_parameters, macroparameters, + ctx.add_macro_definition(macroname, has_parameters, macroparameters, macrodefinition); } /////////////////////////////////////////////////////////////////////////////// -// +// // on_undefine(): handle #undef directives // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> -inline void +template <typename ContextT> +inline void pp_iterator_functor<ContextT>::on_undefine (lexer_type const &it) { BOOST_ASSERT(ctx.get_if_block_status()); @@ -1825,12 +1837,12 @@ pp_iterator_functor<ContextT>::on_undefine (lexer_type const &it) } /////////////////////////////////////////////////////////////////////////////// -// +// // on_ifdef(): handle #ifdef directives // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> -inline void +template <typename ContextT> +inline void pp_iterator_functor<ContextT>::on_ifdef( result_type const& found_directive, lexer_type const &it) // typename parse_tree_type::const_iterator const &it) @@ -1838,8 +1850,8 @@ pp_iterator_functor<ContextT>::on_ifdef( { // get_token_value<result_type, parse_node_type> get_value; // token_sequence_type toexpand; -// -// std::copy(make_ref_transform_iterator((*begin).children.begin(), get_value), +// +// std::copy(make_ref_transform_iterator((*begin).children.begin(), get_value), // make_ref_transform_iterator((*begin).children.end(), get_value), // std::inserter(toexpand, toexpand.end())); @@ -1854,19 +1866,19 @@ token_sequence_type directive; #else do { is_defined = ctx.is_defined_macro((*it).get_value()); // toexpand.begin(), toexpand.end()); - } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(), + } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(), found_directive, directive, is_defined)); #endif ctx.enter_if_block(is_defined); } /////////////////////////////////////////////////////////////////////////////// -// +// // on_ifndef(): handle #ifndef directives // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> -inline void +template <typename ContextT> +inline void pp_iterator_functor<ContextT>::on_ifndef( result_type const& found_directive, lexer_type const &it) // typename parse_tree_type::const_iterator const &it) @@ -1874,8 +1886,8 @@ pp_iterator_functor<ContextT>::on_ifndef( { // get_token_value<result_type, parse_node_type> get_value; // token_sequence_type toexpand; -// -// std::copy(make_ref_transform_iterator((*begin).children.begin(), get_value), +// +// std::copy(make_ref_transform_iterator((*begin).children.begin(), get_value), // make_ref_transform_iterator((*begin).children.end(), get_value), // std::inserter(toexpand, toexpand.end())); @@ -1890,48 +1902,48 @@ token_sequence_type directive; #else do { is_defined = ctx.is_defined_macro((*it).get_value()); // toexpand.begin(), toexpand.end()); - } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(), + } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(), found_directive, directive, is_defined)); #endif ctx.enter_if_block(!is_defined); } /////////////////////////////////////////////////////////////////////////////// -// +// // on_else(): handle #else directives // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> -inline void +template <typename ContextT> +inline void pp_iterator_functor<ContextT>::on_else() { if (!ctx.enter_else_block()) { // #else without matching #if - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_if, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_if, "#else", act_pos); } } /////////////////////////////////////////////////////////////////////////////// -// +// // on_endif(): handle #endif directives // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> -inline void +template <typename ContextT> +inline void pp_iterator_functor<ContextT>::on_endif() { if (!ctx.exit_if_block()) { // #endif without matching #if - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_if, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_if, "#endif", act_pos); } } /////////////////////////////////////////////////////////////////////////////// // replace all remaining (== undefined) identifiers with an integer literal '0' -template <typename ContextT> -inline void +template <typename ContextT> +inline void pp_iterator_functor<ContextT>::replace_undefined_identifiers( token_sequence_type &expanded) { @@ -1940,7 +1952,7 @@ pp_iterator_functor<ContextT>::replace_undefined_identifiers( exp_it != exp_end; ++exp_it) { using namespace boost::wave; - + token_id id = token_id(*exp_it); if (IS_CATEGORY(id, IdentifierTokenType) || IS_CATEGORY(id, KeywordTokenType)) @@ -1952,12 +1964,12 @@ pp_iterator_functor<ContextT>::replace_undefined_identifiers( } /////////////////////////////////////////////////////////////////////////////// -// +// // on_if(): handle #if directives // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> -inline void +template <typename ContextT> +inline void pp_iterator_functor<ContextT>::on_if( result_type const& found_directive, typename parse_tree_type::const_iterator const &begin, @@ -1967,7 +1979,7 @@ pp_iterator_functor<ContextT>::on_if( get_token_value<result_type, parse_node_type> get_value; token_sequence_type toexpand; - std::copy(make_ref_transform_iterator(begin, get_value), + std::copy(make_ref_transform_iterator(begin, get_value), make_ref_transform_iterator(end, get_value), std::inserter(toexpand, toexpand.end())); @@ -1990,7 +2002,7 @@ token_sequence_type expanded; { string_type outstr(boost::wave::util::impl::as_string(toexpand)); outstr += "(" + boost::wave::util::impl::as_string(expanded) + ")"; - BOOST_WAVE_DUMP_CONDITIONAL_EXPRESSIONS_OUT << "#if " << outstr + BOOST_WAVE_DUMP_CONDITIONAL_EXPRESSIONS_OUT << "#if " << outstr << std::endl; } #endif @@ -2010,8 +2022,8 @@ token_sequence_type expanded; ctx.get_hooks().evaluated_conditional_expression(toexpand, if_status); } while (false); #else - } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(), - found_directive, toexpand, if_status) + } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(), + found_directive, toexpand, if_status) && status == grammars::error_noerror); #endif @@ -2019,31 +2031,31 @@ token_sequence_type expanded; if (grammars::error_noerror != status) { // division or other error by zero occurred string_type expression = util::impl::as_string(expanded); - if (0 == expression.size()) + if (0 == expression.size()) expression = "<empty expression>"; if (grammars::error_division_by_zero & status) { - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, division_by_zero, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, division_by_zero, expression.c_str(), act_pos); } else if (grammars::error_integer_overflow & status) { - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, integer_overflow, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, integer_overflow, expression.c_str(), act_pos); } else if (grammars::error_character_overflow & status) { - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, character_literal_out_of_range, expression.c_str(), act_pos); } } } /////////////////////////////////////////////////////////////////////////////// -// +// // on_elif(): handle #elif directives // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> -inline void +template <typename ContextT> +inline void pp_iterator_functor<ContextT>::on_elif( result_type const& found_directive, typename parse_tree_type::const_iterator const &begin, @@ -2053,7 +2065,7 @@ pp_iterator_functor<ContextT>::on_elif( get_token_value<result_type, parse_node_type> get_value; token_sequence_type toexpand; - std::copy(make_ref_transform_iterator(begin, get_value), + std::copy(make_ref_transform_iterator(begin, get_value), make_ref_transform_iterator(end, get_value), std::inserter(toexpand, toexpand.end())); @@ -2063,7 +2075,7 @@ token_sequence_type toexpand; if (ctx.get_if_block_some_part_status()) { if (!ctx.enter_elif_block(false)) { // #else without matching #if - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_if, "#elif", act_pos); // fall through... } @@ -2072,7 +2084,7 @@ token_sequence_type toexpand; typename token_sequence_type::iterator begin2 = toexpand.begin(); impl::skip_to_eol(ctx, begin2, toexpand.end()); - return; // one of previous #if/#elif was true, so don't enter this #elif + return; // one of previous #if/#elif was true, so don't enter this #elif } // preprocess the given sequence into the provided list @@ -2082,7 +2094,7 @@ token_sequence_type expanded; do { expanded.clear(); - + typename token_sequence_type::iterator begin2 = toexpand.begin(); ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded); @@ -2112,14 +2124,14 @@ token_sequence_type expanded; ctx.get_hooks().evaluated_conditional_expression(toexpand, if_status); } while (false); #else - } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(), - found_directive, toexpand, if_status) + } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(), + found_directive, toexpand, if_status) && status == grammars::error_noerror); #endif - if (!ctx.enter_elif_block(if_status)) { + if (!ctx.enter_elif_block(if_status)) { // #elif without matching #if - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_if, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_if, "#elif", act_pos); return; } @@ -2127,48 +2139,48 @@ token_sequence_type expanded; if (grammars::error_noerror != status) { // division or other error by zero occurred string_type expression = util::impl::as_string(expanded); - if (0 == expression.size()) + if (0 == expression.size()) expression = "<empty expression>"; - + if (grammars::error_division_by_zero & status) { - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, division_by_zero, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, division_by_zero, expression.c_str(), act_pos); } else if (grammars::error_integer_overflow & status) { - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, integer_overflow, expression.c_str(), act_pos); } else if (grammars::error_character_overflow & status) { - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, character_literal_out_of_range, expression.c_str(), act_pos); } } } /////////////////////////////////////////////////////////////////////////////// -// +// // on_illformed(): handles the illegal directive // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> -inline void +template <typename ContextT> +inline void pp_iterator_functor<ContextT>::on_illformed( typename result_type::string_type s) { BOOST_ASSERT(ctx.get_if_block_status()); - + // some messages have more than one newline at the end typename string_type::size_type p = s.find_last_not_of('\n'); if (string_type::npos != p) s = s.substr(0, p+1); // throw the exception - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, ill_formed_directive, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, ill_formed_directive, s.c_str(), act_pos); } /////////////////////////////////////////////////////////////////////////////// -// +// // on_line(): handle #line directives // /////////////////////////////////////////////////////////////////////////////// @@ -2177,7 +2189,7 @@ namespace impl { template <typename IteratorT, typename StringT> bool retrieve_line_info (IteratorT first, IteratorT const &last, - unsigned int &line, StringT &file, + unsigned int &line, StringT &file, boost::wave::preprocess_exception::error_code& error) { using namespace boost::wave; @@ -2195,7 +2207,7 @@ namespace impl { error = preprocess_exception::bad_line_number; // extract file name (if it is given) - while (++first != last && IS_CATEGORY(*first, WhiteSpaceTokenType)) + while (++first != last && IS_CATEGORY(*first, WhiteSpaceTokenType)) /**/; // skip whitespace if (first != last) { @@ -2208,13 +2220,13 @@ namespace impl { if ('L' == file_lit[0]) { error = preprocess_exception::bad_line_filename; - return false; // shouldn't be a wide character string + return false; // shouldn't be a wide character string } file = file_lit.substr(1, file_lit.size()-2); // test if there is other junk on this line - while (++first != last && IS_CATEGORY(*first, WhiteSpaceTokenType)) + while (++first != last && IS_CATEGORY(*first, WhiteSpaceTokenType)) /**/; // skip whitespace } return first == last; @@ -2224,8 +2236,8 @@ namespace impl { } } -template <typename ContextT> -inline void +template <typename ContextT> +inline void pp_iterator_functor<ContextT>::on_line( typename parse_tree_type::const_iterator const &begin, typename parse_tree_type::const_iterator const &end) @@ -2233,13 +2245,13 @@ pp_iterator_functor<ContextT>::on_line( BOOST_ASSERT(ctx.get_if_block_status()); // Try to extract the line number and file name from the given token list -// directly. If that fails, preprocess the whole token sequence and try again +// directly. If that fails, preprocess the whole token sequence and try again // to extract this information. token_sequence_type expanded; get_token_value<result_type, parse_node_type> get_value; typedef typename ref_transform_iterator_generator< - get_token_value<result_type, parse_node_type>, + get_token_value<result_type, parse_node_type>, typename parse_tree_type::const_iterator >::type const_tree_iterator_t; @@ -2257,27 +2269,27 @@ token_sequence_type toexpand; if (!impl::retrieve_line_info(first, last, line, file_name, error)) { // preprocess the body of this #line message typename token_sequence_type::iterator begin2 = toexpand.begin(); - ctx.expand_whole_tokensequence(begin2, toexpand.end(), + ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded, false); error = preprocess_exception::no_error; - if (!impl::retrieve_line_info(expanded.begin(), expanded.end(), + if (!impl::retrieve_line_info(expanded.begin(), expanded.end(), line, file_name, error)) { typename ContextT::string_type msg( boost::wave::util::impl::as_string(expanded)); - BOOST_WAVE_THROW_VAR_CTX(ctx, preprocess_exception, error, + BOOST_WAVE_THROW_VAR_CTX(ctx, preprocess_exception, error, msg.c_str(), act_pos); return; } // call the corresponding pp hook function - ctx.get_hooks().found_line_directive(ctx.derived(), expanded, line, + ctx.get_hooks().found_line_directive(ctx.derived(), expanded, line, file_name.c_str()); } else { // call the corresponding pp hook function - ctx.get_hooks().found_line_directive(ctx.derived(), toexpand, line, + ctx.get_hooks().found_line_directive(ctx.derived(), toexpand, line, file_name.c_str()); } @@ -2292,13 +2304,13 @@ token_sequence_type toexpand; if (error != preprocess_exception::no_error) { typename ContextT::string_type msg( boost::wave::util::impl::as_string(expanded)); - BOOST_WAVE_THROW_VAR_CTX(ctx, preprocess_exception, error, + BOOST_WAVE_THROW_VAR_CTX(ctx, preprocess_exception, error, msg.c_str(), act_pos); return; } // set new line number/filename only if ok - if (!file_name.empty()) { // reuse current file name + if (!file_name.empty()) { // reuse current file name using boost::wave::util::impl::unescape_lit; act_pos.set_file(unescape_lit(file_name).c_str()); } @@ -2307,12 +2319,12 @@ token_sequence_type toexpand; } /////////////////////////////////////////////////////////////////////////////// -// +// // on_error(): handle #error directives // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> -inline void +template <typename ContextT> +inline void pp_iterator_functor<ContextT>::on_error( typename parse_tree_type::const_iterator const &begin, typename parse_tree_type::const_iterator const &end) @@ -2324,7 +2336,7 @@ token_sequence_type expanded; get_token_value<result_type, parse_node_type> get_value; typename ref_transform_iterator_generator< - get_token_value<result_type, parse_node_type>, + get_token_value<result_type, parse_node_type>, typename parse_tree_type::const_iterator >::type first = make_ref_transform_iterator(begin, get_value); @@ -2336,32 +2348,32 @@ token_sequence_type toexpand; std::inserter(toexpand, toexpand.end())); typename token_sequence_type::iterator begin2 = toexpand.begin(); - ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded, + ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded, false); if (!ctx.get_hooks().found_error_directive(ctx.derived(), toexpand)) #else // simply copy the body of this #error message to the issued diagnostic // message - std::copy(first, make_ref_transform_iterator(end, get_value), + std::copy(first, make_ref_transform_iterator(end, get_value), std::inserter(expanded, expanded.end())); if (!ctx.get_hooks().found_error_directive(ctx.derived(), expanded)) -#endif +#endif { // report the corresponding error BOOST_WAVE_STRINGTYPE msg(boost::wave::util::impl::as_string(expanded)); - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, error_directive, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, error_directive, msg.c_str(), act_pos); } } #if BOOST_WAVE_SUPPORT_WARNING_DIRECTIVE != 0 /////////////////////////////////////////////////////////////////////////////// -// +// // on_warning(): handle #warning directives // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> -inline void +template <typename ContextT> +inline void pp_iterator_functor<ContextT>::on_warning( typename parse_tree_type::const_iterator const &begin, typename parse_tree_type::const_iterator const &end) @@ -2373,7 +2385,7 @@ token_sequence_type expanded; get_token_value<result_type, parse_node_type> get_value; typename ref_transform_iterator_generator< - get_token_value<result_type, parse_node_type>, + get_token_value<result_type, parse_node_type>, typename parse_tree_type::const_iterator >::type first = make_ref_transform_iterator(begin, get_value); @@ -2385,31 +2397,31 @@ token_sequence_type toexpand; std::inserter(toexpand, toexpand.end())); typename token_sequence_type::iterator begin2 = toexpand.begin(); - ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded, + ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded, false); if (!ctx.get_hooks().found_warning_directive(ctx.derived(), toexpand)) #else // simply copy the body of this #warning message to the issued diagnostic // message - std::copy(first, make_ref_transform_iterator(end, get_value), + std::copy(first, make_ref_transform_iterator(end, get_value), std::inserter(expanded, expanded.end())); if (!ctx.get_hooks().found_warning_directive(ctx.derived(), expanded)) -#endif +#endif { // report the corresponding error BOOST_WAVE_STRINGTYPE msg(boost::wave::util::impl::as_string(expanded)); - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, warning_directive, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, warning_directive, msg.c_str(), act_pos); } } #endif // BOOST_WAVE_SUPPORT_WARNING_DIRECTIVE != 0 /////////////////////////////////////////////////////////////////////////////// -// +// // on_pragma(): handle #pragma directives // /////////////////////////////////////////////////////////////////////////////// -template <typename ContextT> +template <typename ContextT> inline bool pp_iterator_functor<ContextT>::on_pragma( typename parse_tree_type::const_iterator const &begin, @@ -2426,7 +2438,7 @@ token_sequence_type expanded; get_token_value<result_type, parse_node_type> get_value; typedef typename ref_transform_iterator_generator< - get_token_value<result_type, parse_node_type>, + get_token_value<result_type, parse_node_type>, typename parse_tree_type::const_iterator >::type const_tree_iterator_t; @@ -2436,13 +2448,13 @@ const_tree_iterator_t last = make_ref_transform_iterator(end, get_value); expanded.push_back(result_type(T_PP_PRAGMA, "#pragma", act_token.get_position())); expanded.push_back(result_type(T_SPACE, " ", act_token.get_position())); - while (++first != last && IS_CATEGORY(*first, WhiteSpaceTokenType)) + while (++first != last && IS_CATEGORY(*first, WhiteSpaceTokenType)) expanded.push_back(*first); // skip whitespace if (first != last) { - if (T_IDENTIFIER == token_id(*first) && - boost::wave::need_c99(ctx.get_language()) && - (*first).get_value() == "STDC") + if (T_IDENTIFIER == token_id(*first) && + boost::wave::need_c99(ctx.get_language()) && + (*first).get_value() == "STDC") { // do _not_ preprocess the token sequence std::copy(first, last, std::inserter(expanded, expanded.end())); @@ -2455,7 +2467,7 @@ const_tree_iterator_t last = make_ref_transform_iterator(end, get_value); std::copy(first, last, std::inserter(toexpand, toexpand.end())); typename token_sequence_type::iterator begin2 = toexpand.begin(); - ctx.expand_whole_tokensequence(begin2, toexpand.end(), + ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded, false); #else // do _not_ preprocess the token sequence @@ -2469,7 +2481,7 @@ const_tree_iterator_t last = make_ref_transform_iterator(end, get_value); BOOST_ASSERT(unput_queue.empty()); BOOST_ASSERT(pending_queue.empty()); -// try to interpret the expanded #pragma body +// try to interpret the expanded #pragma body token_sequence_type pending; if (interpret_pragma(expanded, pending)) { // if there is some replacement text, insert it into the pending queue @@ -2479,17 +2491,17 @@ const_tree_iterator_t last = make_ref_transform_iterator(end, get_value); } #if BOOST_WAVE_EMIT_PRAGMA_DIRECTIVES != 0 -// Move the resulting token sequence into the pending_queue, so it will be +// Move the resulting token sequence into the pending_queue, so it will be // returned to the caller. if (boost::wave::need_emit_pragma_directives(ctx.get_language())) { pending_queue.splice(pending_queue.begin(), expanded); return false; // return the whole #pragma directive } -#endif +#endif return true; // skip the #pragma at all } -template <typename ContextT> +template <typename ContextT> inline bool pp_iterator_functor<ContextT>::interpret_pragma( token_sequence_type const &pragma_body, token_sequence_type &result) @@ -2498,7 +2510,7 @@ pp_iterator_functor<ContextT>::interpret_pragma( typename token_sequence_type::const_iterator end = pragma_body.end(); typename token_sequence_type::const_iterator it = pragma_body.begin(); - for (++it; it != end && IS_CATEGORY(*it, WhiteSpaceTokenType); ++it) + for (++it; it != end && IS_CATEGORY(*it, WhiteSpaceTokenType); ++it) /**/; // skip whitespace if (it == end) // eof reached @@ -2512,16 +2524,16 @@ pp_iterator_functor<ContextT>::interpret_pragma( } // namespace impl /////////////////////////////////////////////////////////////////////////////// -// +// // pp_iterator // // The boost::wave::pp_iterator template is the iterator, through which // the resulting preprocessed input stream is accessible. -// +// /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> -class pp_iterator +class pp_iterator : public boost::spirit::classic::multi_pass< boost::wave::impl::pp_iterator_functor<ContextT>, boost::wave::util::functor_input @@ -2531,14 +2543,14 @@ public: typedef boost::wave::impl::pp_iterator_functor<ContextT> input_policy_type; private: - typedef + typedef boost::spirit::classic::multi_pass<input_policy_type, boost::wave::util::functor_input> base_type; typedef pp_iterator<ContextT> self_type; typedef boost::wave::util::functor_input functor_input_type; public: - pp_iterator() + pp_iterator() {} template <typename IteratorT> @@ -2548,9 +2560,9 @@ public: {} bool force_include(char const *path_, bool is_last) - { - bool result = this->get_functor().on_include_helper(path_, path_, - false, false); + { + bool result = this->get_functor().on_include_helper(path_, path_, + false, false); if (is_last) { this->functor_input_type:: template inner<input_policy_type>::advance_input(); diff --git a/boost/wave/util/cpp_macromap.hpp b/boost/wave/util/cpp_macromap.hpp index 8b155b83af..fb251ea105 100644 --- a/boost/wave/util/cpp_macromap.hpp +++ b/boost/wave/util/cpp_macromap.hpp @@ -2,10 +2,10 @@ Boost.Wave: A Standard compliant C++ preprocessor library Macro expansion engine - + http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ @@ -58,9 +58,9 @@ namespace boost { namespace wave { namespace util { /////////////////////////////////////////////////////////////////////////////// // // macromap -// -// This class holds all currently defined macros and on demand expands -// those macro definitions +// +// This class holds all currently defined macros and on demand expands +// those macro definitions // /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> @@ -74,16 +74,16 @@ class macromap { typedef typename ContextT::token_sequence_type definition_container_type; typedef std::vector<token_type> parameter_container_type; - typedef macro_definition<token_type, definition_container_type> + typedef macro_definition<token_type, definition_container_type> macro_definition_type; - typedef symbol_table<string_type, macro_definition_type> + typedef symbol_table<string_type, macro_definition_type> defined_macros_type; - typedef typename defined_macros_type::value_type::second_type + typedef typename defined_macros_type::value_type::second_type macro_ref_type; public: - macromap(ContextT &ctx_) - : current_macros(0), defined_macros(new defined_macros_type(1)), + macromap(ContextT &ctx_) + : current_macros(0), defined_macros(new defined_macros_type(1)), main_pos("", 0), ctx(ctx_), macro_uid(1) { current_macros = defined_macros.get(); @@ -91,14 +91,14 @@ public: ~macromap() {} // Add a new macro to the given macro scope - bool add_macro(token_type const &name, bool has_parameters, - parameter_container_type ¶meters, - definition_container_type &definition, bool is_predefined = false, + bool add_macro(token_type const &name, bool has_parameters, + parameter_container_type ¶meters, + definition_container_type &definition, bool is_predefined = false, defined_macros_type *scope = 0); // Tests, whether the given macro name is defined in the given macro scope - bool is_defined(string_type const &name, - typename defined_macros_type::iterator &it, + bool is_defined(string_type const &name, + typename defined_macros_type::iterator &it, defined_macros_type *scope = 0) const; // expects a token sequence as its parameters @@ -109,31 +109,31 @@ public: bool is_defined(string_type const &str) const; // Get the macro definition for the given macro scope - bool get_macro(string_type const &name, bool &has_parameters, - bool &is_predefined, position_type &pos, - parameter_container_type ¶meters, - definition_container_type &definition, + bool get_macro(string_type const &name, bool &has_parameters, + bool &is_predefined, position_type &pos, + parameter_container_type ¶meters, + definition_container_type &definition, defined_macros_type *scope = 0) const; // Remove a macro name from the given macro scope - bool remove_macro(string_type const &name, position_type const& pos, + bool remove_macro(string_type const &name, position_type const& pos, bool even_predefined = false); template <typename IteratorT, typename ContainerT> - token_type const &expand_tokensequence(IteratorT &first, - IteratorT const &last, ContainerT &pending, ContainerT &expanded, + token_type const &expand_tokensequence(IteratorT &first, + IteratorT const &last, ContainerT &pending, ContainerT &expanded, bool& seen_newline, bool expand_operator_defined); // Expand all macros inside the given token sequence template <typename IteratorT, typename ContainerT> - void expand_whole_tokensequence(ContainerT &expanded, - IteratorT &first, IteratorT const &last, + void expand_whole_tokensequence(ContainerT &expanded, + IteratorT &first, IteratorT const &last, bool expand_operator_defined); // Init the predefined macros (add them to the given scope) - void init_predefined_macros(char const *fname = "<Unknown>", + void init_predefined_macros(char const *fname = "<Unknown>", defined_macros_type *scope = 0, bool at_global_scope = true); - void predefine_macro(defined_macros_type *scope, string_type const &name, + void predefine_macro(defined_macros_type *scope, string_type const &name, token_type const &t); // Init the internal macro symbol namespace @@ -146,9 +146,9 @@ public: typedef typename defined_macros_type::name_iterator name_iterator; typedef typename defined_macros_type::const_name_iterator const_name_iterator; - name_iterator begin() + name_iterator begin() { return defined_macros_type::make_iterator(current_macros->begin()); } - name_iterator end() + name_iterator end() { return defined_macros_type::make_iterator(current_macros->end()); } const_name_iterator begin() const { return defined_macros_type::make_iterator(current_macros->begin()); } @@ -158,43 +158,43 @@ public: protected: // Helper functions for expanding all macros in token sequences template <typename IteratorT, typename ContainerT> - token_type const &expand_tokensequence_worker(ContainerT &pending, - unput_queue_iterator<IteratorT, token_type, ContainerT> &first, - unput_queue_iterator<IteratorT, token_type, ContainerT> const &last, + token_type const &expand_tokensequence_worker(ContainerT &pending, + unput_queue_iterator<IteratorT, token_type, ContainerT> &first, + unput_queue_iterator<IteratorT, token_type, ContainerT> const &last, bool& seen_newline, bool expand_operator_defined); // Collect all arguments supplied to a macro invocation #if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0 template <typename IteratorT, typename ContainerT, typename SizeT> typename std::vector<ContainerT>::size_type collect_arguments ( - token_type const curr_token, std::vector<ContainerT> &arguments, + token_type const curr_token, std::vector<ContainerT> &arguments, IteratorT &next, IteratorT const &end, SizeT const ¶meter_count, bool& seen_newline); #else template <typename IteratorT, typename ContainerT, typename SizeT> typename std::vector<ContainerT>::size_type collect_arguments ( - token_type const curr_token, std::vector<ContainerT> &arguments, - IteratorT &next, IteratorT &endparen, IteratorT const &end, + token_type const curr_token, std::vector<ContainerT> &arguments, + IteratorT &next, IteratorT &endparen, IteratorT const &end, SizeT const ¶meter_count, bool& seen_newline); #endif // Expand a single macro name template <typename IteratorT, typename ContainerT> - bool expand_macro(ContainerT &pending, token_type const &name, - typename defined_macros_type::iterator it, - IteratorT &first, IteratorT const &last, + bool expand_macro(ContainerT &pending, token_type const &name, + typename defined_macros_type::iterator it, + IteratorT &first, IteratorT const &last, bool& seen_newline, bool expand_operator_defined, defined_macros_type *scope = 0, ContainerT *queue_symbol = 0); // Expand a predefined macro (__LINE__, __FILE__ and __INCLUDE_LEVEL__) template <typename ContainerT> - bool expand_predefined_macro(token_type const &curr_token, + bool expand_predefined_macro(token_type const &curr_token, ContainerT &expanded); // Expand a single macro argument template <typename ContainerT> void expand_argument (typename std::vector<ContainerT>::size_type arg, - std::vector<ContainerT> &arguments, + std::vector<ContainerT> &arguments, std::vector<ContainerT> &expanded_args, bool expand_operator_defined, std::vector<bool> &has_expanded_args); @@ -202,13 +202,13 @@ protected: template <typename ContainerT> void expand_replacement_list( macro_definition_type const ¯odefinition, - std::vector<ContainerT> &arguments, + std::vector<ContainerT> &arguments, bool expand_operator_defined, ContainerT &expanded); // Rescans the replacement list for macro expansion template <typename IteratorT, typename ContainerT> - void rescan_replacement_list(token_type const &curr_token, - macro_definition_type ¯odef, ContainerT &replacement_list, + void rescan_replacement_list(token_type const &curr_token, + macro_definition_type ¯odef, ContainerT &replacement_list, ContainerT &expanded, bool expand_operator_defined, IteratorT &nfirst, IteratorT const &nlast); @@ -219,15 +219,15 @@ protected: // Resolve operator _Pragma or the #pragma directive template <typename IteratorT, typename ContainerT> - bool resolve_operator_pragma(IteratorT &first, + bool resolve_operator_pragma(IteratorT &first, IteratorT const &last, ContainerT &expanded, bool& seen_newline); -// Handle the concatenation operator '##' +// Handle the concatenation operator '##' template <typename ContainerT> bool concat_tokensequence(ContainerT &expanded); template <typename ContainerT> - bool is_valid_concat(string_type new_value, + bool is_valid_concat(string_type new_value, position_type const &pos, ContainerT &rescanned); #if BOOST_WAVE_SERIALIZATION != 0 @@ -248,7 +248,7 @@ private: { using namespace boost::serialization; if (version != (loaded_version & ~version_mask)) { - BOOST_WAVE_THROW(preprocess_exception, incompatible_config, + BOOST_WAVE_THROW(preprocess_exception, incompatible_config, "cpp_context state version", get_main_pos()); } ar & make_nvp("defined_macros", defined_macros); @@ -271,35 +271,35 @@ private: /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -// +// // add_macro(): adds a new macro to the macromap // /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> -inline bool -macromap<ContextT>::add_macro(token_type const &name, bool has_parameters, - parameter_container_type ¶meters, definition_container_type &definition, +inline bool +macromap<ContextT>::add_macro(token_type const &name, bool has_parameters, + parameter_container_type ¶meters, definition_container_type &definition, bool is_predefined, defined_macros_type *scope) { if (!is_predefined && impl::is_special_macroname (name.get_value())) { // exclude special macro names - BOOST_WAVE_THROW_NAME_CTX(ctx, macro_handling_exception, - illegal_redefinition, name.get_value().c_str(), main_pos, + BOOST_WAVE_THROW_NAME_CTX(ctx, macro_handling_exception, + illegal_redefinition, name.get_value().c_str(), main_pos, name.get_value().c_str()); return false; } - if (boost::wave::need_variadics(ctx.get_language()) && - "__VA_ARGS__" == name.get_value()) + if (boost::wave::need_variadics(ctx.get_language()) && + "__VA_ARGS__" == name.get_value()) { // can't use __VA_ARGS__ as a macro name - BOOST_WAVE_THROW_NAME_CTX(ctx, macro_handling_exception, - bad_define_statement_va_args, name.get_value().c_str(), main_pos, + BOOST_WAVE_THROW_NAME_CTX(ctx, macro_handling_exception, + bad_define_statement_va_args, name.get_value().c_str(), main_pos, name.get_value().c_str()); return false; } if (AltExtTokenType == (token_id(name) & ExtTokenOnlyMask)) { // exclude special operator names - BOOST_WAVE_THROW_NAME_CTX(ctx, macro_handling_exception, + BOOST_WAVE_THROW_NAME_CTX(ctx, macro_handling_exception, illegal_operator_redefinition, name.get_value().c_str(), main_pos, name.get_value().c_str()); return false; @@ -316,8 +316,8 @@ typename defined_macros_type::iterator it = current_scope->find(name.get_value() !impl::parameters_equal(macrodef->macroparameters, parameters) || !impl::definition_equals(macrodef->macrodefinition, definition)) { - BOOST_WAVE_THROW_NAME_CTX(ctx, macro_handling_exception, - macro_redefinition, name.get_value().c_str(), main_pos, + BOOST_WAVE_THROW_NAME_CTX(ctx, macro_handling_exception, + macro_redefinition, name.get_value().c_str(), main_pos, name.get_value().c_str()); } return false; @@ -327,20 +327,20 @@ typename defined_macros_type::iterator it = current_scope->find(name.get_value() if (has_parameters) { std::set<typename token_type::string_type> names; - typedef typename parameter_container_type::iterator + typedef typename parameter_container_type::iterator parameter_iterator_type; - typedef typename std::set<typename token_type::string_type>::iterator + typedef typename std::set<typename token_type::string_type>::iterator name_iterator_type; parameter_iterator_type end = parameters.end(); - for (parameter_iterator_type itp = parameters.begin(); itp != end; ++itp) + for (parameter_iterator_type itp = parameters.begin(); itp != end; ++itp) { name_iterator_type pit = names.find((*itp).get_value()); if (pit != names.end()) { // duplicate parameter name - BOOST_WAVE_THROW_NAME_CTX(ctx, macro_handling_exception, - duplicate_parameter_name, (*pit).c_str(), main_pos, + BOOST_WAVE_THROW_NAME_CTX(ctx, macro_handling_exception, + duplicate_parameter_name, (*pit).c_str(), main_pos, name.get_value().c_str()); return false; } @@ -349,19 +349,19 @@ typename defined_macros_type::iterator it = current_scope->find(name.get_value() } // insert a new macro node - std::pair<typename defined_macros_type::iterator, bool> p = + std::pair<typename defined_macros_type::iterator, bool> p = current_scope->insert( typename defined_macros_type::value_type( - name.get_value(), - macro_ref_type(new macro_definition_type(name, + name.get_value(), + macro_ref_type(new macro_definition_type(name, has_parameters, is_predefined, ++macro_uid) ) ) ); if (!p.second) { - BOOST_WAVE_THROW_NAME_CTX(ctx, macro_handling_exception, - macro_insertion_error, name.get_value().c_str(), main_pos, + BOOST_WAVE_THROW_NAME_CTX(ctx, macro_handling_exception, + macro_insertion_error, name.get_value().c_str(), main_pos, name.get_value().c_str()); return false; } @@ -372,26 +372,26 @@ typename defined_macros_type::iterator it = current_scope->find(name.get_value() // call the context supplied preprocessing hook #if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0 - ctx.get_hooks().defined_macro(name, has_parameters, - (*p.first).second->macroparameters, + ctx.get_hooks().defined_macro(name, has_parameters, + (*p.first).second->macroparameters, (*p.first).second->macrodefinition, is_predefined); #else - ctx.get_hooks().defined_macro(ctx.derived(), name, has_parameters, - (*p.first).second->macroparameters, + ctx.get_hooks().defined_macro(ctx.derived(), name, has_parameters, + (*p.first).second->macroparameters, (*p.first).second->macrodefinition, is_predefined); #endif return true; } /////////////////////////////////////////////////////////////////////////////// -// +// // is_defined(): returns, whether a given macro is already defined // /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> -inline bool +inline bool macromap<ContextT>::is_defined(typename token_type::string_type const &name, - typename defined_macros_type::iterator &it, + typename defined_macros_type::iterator &it, defined_macros_type *scope) const { if (0 == scope) scope = current_macros; @@ -403,27 +403,27 @@ macromap<ContextT>::is_defined(typename token_type::string_type const &name, if (name.size() < 8 || '_' != name[0] || '_' != name[1]) return false; // quick check failed - return name == "__LINE__" || name == "__FILE__" || + return name == "__LINE__" || name == "__FILE__" || name == "__INCLUDE_LEVEL__"; } template <typename ContextT> template <typename IteratorT> -inline bool -macromap<ContextT>::is_defined(IteratorT const &begin, +inline bool +macromap<ContextT>::is_defined(IteratorT const &begin, IteratorT const &end) const { // in normal mode the name under inspection should consist of an identifier // only token_id id = token_id(*begin); - if (T_IDENTIFIER != id && + if (T_IDENTIFIER != id && !IS_CATEGORY(id, KeywordTokenType) && !IS_EXTCATEGORY(id, OperatorTokenType|AltExtTokenType) && - !IS_CATEGORY(id, BoolLiteralTokenType)) + !IS_CATEGORY(id, BoolLiteralTokenType)) { std::string msg(impl::get_full_name(begin, end)); - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, invalid_macroname, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, invalid_macroname, msg.c_str(), main_pos); return false; } @@ -435,7 +435,7 @@ typename defined_macros_type::iterator cit; if (++it != end) { // there should be only one token as the inspected name std::string msg(impl::get_full_name(begin, end)); - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, invalid_macroname, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, invalid_macroname, msg.c_str(), main_pos); return false; } @@ -445,24 +445,24 @@ typename defined_macros_type::iterator cit; /////////////////////////////////////////////////////////////////////////////// // same as above, only takes an arbitrary string type as its parameter template <typename ContextT> -inline bool +inline bool macromap<ContextT>::is_defined(string_type const &str) const { typename defined_macros_type::iterator cit; - return is_defined(str, cit, 0); + return is_defined(str, cit, 0); } /////////////////////////////////////////////////////////////////////////////// -// +// // Get the macro definition for the given macro scope // /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> -inline bool -macromap<ContextT>::get_macro(string_type const &name, bool &has_parameters, - bool &is_predefined, position_type &pos, - parameter_container_type ¶meters, - definition_container_type &definition, +inline bool +macromap<ContextT>::get_macro(string_type const &name, bool &has_parameters, + bool &is_predefined, position_type &pos, + parameter_container_type ¶meters, + definition_container_type &definition, defined_macros_type *scope) const { typename defined_macros_type::iterator it; @@ -480,21 +480,21 @@ macro_definition_type ¯o_def = *(*it).second.get(); } /////////////////////////////////////////////////////////////////////////////// -// +// // remove_macro(): remove a macro from the macromap // /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> -inline bool -macromap<ContextT>::remove_macro(string_type const &name, +inline bool +macromap<ContextT>::remove_macro(string_type const &name, position_type const& pos, bool even_predefined) { typename defined_macros_type::iterator it = current_macros->find(name); - + if (it != current_macros->end()) { if ((*it).second->is_predefined) { if (!even_predefined || impl::is_special_macroname(name)) { - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_undefine_statement, name.c_str(), main_pos); return false; } @@ -512,32 +512,32 @@ macromap<ContextT>::remove_macro(string_type const &name, return true; } else if (impl::is_special_macroname(name)) { - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_undefine_statement, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_undefine_statement, name.c_str(), pos); } return false; // macro was not defined } /////////////////////////////////////////////////////////////////////////////// -// +// // expand_tokensequence // -// This function is a helper function which wraps the given iterator +// This function is a helper function which wraps the given iterator // range into corresponding unput_iterator's and calls the main workhorse // of the macro expansion engine (the function expand_tokensequence_worker) // -// This is the top level macro expansion function called from the +// This is the top level macro expansion function called from the // preprocessing iterator component only. // /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> template <typename IteratorT, typename ContainerT> inline typename ContextT::token_type const & -macromap<ContextT>::expand_tokensequence(IteratorT &first, - IteratorT const &last, ContainerT &pending, ContainerT &expanded, +macromap<ContextT>::expand_tokensequence(IteratorT &first, + IteratorT const &last, ContainerT &pending, ContainerT &expanded, bool& seen_newline, bool expand_operator_defined) { - typedef impl::gen_unput_queue_iterator<IteratorT, token_type, ContainerT> + typedef impl::gen_unput_queue_iterator<IteratorT, token_type, ContainerT> gen_type; typedef typename gen_type::return_type iterator_type; @@ -546,7 +546,7 @@ macromap<ContextT>::expand_tokensequence(IteratorT &first, on_exit::assign<IteratorT, iterator_type> on_exit(first, first_it); - return expand_tokensequence_worker(pending, first_it, last_it, + return expand_tokensequence_worker(pending, first_it, last_it, seen_newline, expand_operator_defined); } @@ -555,8 +555,8 @@ on_exit::assign<IteratorT, iterator_type> on_exit(first, first_it); // expand_tokensequence_worker // // This function is the main workhorse of the macro expansion engine. It -// expands as much tokens as needed to identify the next preprocessed -// token to return to the caller. +// expands as much tokens as needed to identify the next preprocessed +// token to return to the caller. // It returns the next preprocessed token. // // The iterator 'first' is adjusted accordingly. @@ -566,9 +566,9 @@ template <typename ContextT> template <typename IteratorT, typename ContainerT> inline typename ContextT::token_type const & macromap<ContextT>::expand_tokensequence_worker( - ContainerT &pending, - unput_queue_iterator<IteratorT, token_type, ContainerT> &first, - unput_queue_iterator<IteratorT, token_type, ContainerT> const &last, + ContainerT &pending, + unput_queue_iterator<IteratorT, token_type, ContainerT> &first, + unput_queue_iterator<IteratorT, token_type, ContainerT> const &last, bool& seen_newline, bool expand_operator_defined) { // if there exist pending tokens (tokens, which are already preprocessed), then @@ -579,7 +579,7 @@ macromap<ContextT>::expand_tokensequence_worker( return act_token = pending.front(); } -// analyze the next element of the given sequence, if it is an +// analyze the next element of the given sequence, if it is an // T_IDENTIFIER token, try to replace this as a macro etc. using namespace boost::wave; typedef unput_queue_iterator<IteratorT, token_type, ContainerT> iterator_type; @@ -599,23 +599,23 @@ macromap<ContextT>::expand_tokensequence_worker( if (T_IDENTIFIER == id || IS_CATEGORY(id, KeywordTokenType) || IS_EXTCATEGORY(id, OperatorTokenType|AltExtTokenType) || - IS_CATEGORY(id, BoolLiteralTokenType)) + IS_CATEGORY(id, BoolLiteralTokenType)) { // try to replace this identifier as a macro if (expand_operator_defined && (*first).get_value() == "defined") { // resolve operator defined() return resolve_defined(first, last, pending); } - else if (boost::wave::need_variadics(ctx.get_language()) && - (*first).get_value() == "_Pragma") + else if (boost::wave::need_variadics(ctx.get_language()) && + (*first).get_value() == "_Pragma") { // in C99 mode only: resolve the operator _Pragma token_type curr_token = *first; if (!resolve_operator_pragma(first, last, pending, seen_newline) || - pending.size() > 0) + pending.size() > 0) { - // unknown to us pragma or supplied replacement, return the + // unknown to us pragma or supplied replacement, return the // next token on_exit::pop_front<definition_container_type> pop_token(pending); @@ -623,7 +623,7 @@ macromap<ContextT>::expand_tokensequence_worker( } // the operator _Pragma() was eaten completely, continue - return act_token = token_type(T_PLACEHOLDER, "_", + return act_token = token_type(T_PLACEHOLDER, "_", curr_token.get_position()); } @@ -631,10 +631,10 @@ macromap<ContextT>::expand_tokensequence_worker( typename defined_macros_type::iterator it; if (is_defined(name_token.get_value(), it)) { - // the current token contains an identifier, which is currently + // the current token contains an identifier, which is currently // defined as a macro - if (expand_macro(pending, name_token, it, first, last, - seen_newline, expand_operator_defined)) + if (expand_macro(pending, name_token, it, first, last, + seen_newline, expand_operator_defined)) { // the tokens returned by expand_macro should be rescanned // beginning at the last token of the returned replacement list @@ -652,7 +652,7 @@ macromap<ContextT>::expand_tokensequence_worker( else if (!pending.empty()) { // return the first token from the pending queue on_exit::pop_front<definition_container_type> pop_queue (pending); - + return act_token = pending.front(); } else { @@ -661,13 +661,13 @@ macromap<ContextT>::expand_tokensequence_worker( } // return the next preprocessed token - return expand_tokensequence_worker(pending, first, last, + return expand_tokensequence_worker(pending, first, last, seen_newline, expand_operator_defined); } // else if (expand_operator_defined) { -// // in preprocessing conditionals undefined identifiers and keywords +// // in preprocessing conditionals undefined identifiers and keywords // // are to be replaced with '0' (see. C++ standard 16.1.4, [cpp.cond]) -// return act_token = +// return act_token = // token_type(T_INTLIT, "0", (*first++).get_position()); // } else { @@ -678,11 +678,11 @@ macromap<ContextT>::expand_tokensequence_worker( } else if (expand_operator_defined && IS_CATEGORY(*first, BoolLiteralTokenType)) { // expanding a constant expression inside #if/#elif, special handling - // of 'true' and 'false' + // of 'true' and 'false' - // all remaining identifiers and keywords, except for true and false, + // all remaining identifiers and keywords, except for true and false, // are replaced with the pp-number 0 (C++ standard 16.1.4, [cpp.cond]) - return act_token = token_type(T_INTLIT, T_TRUE != id ? "0" : "1", + return act_token = token_type(T_INTLIT, T_TRUE != id ? "0" : "1", (*first++).get_position()); } else { @@ -695,7 +695,7 @@ macromap<ContextT>::expand_tokensequence_worker( } /////////////////////////////////////////////////////////////////////////////// -// +// // collect_arguments(): collect the actual arguments of a macro invocation // // return the number of successfully detected non-empty arguments @@ -704,15 +704,15 @@ macromap<ContextT>::expand_tokensequence_worker( #if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0 template <typename ContextT> template <typename IteratorT, typename ContainerT, typename SizeT> -inline typename std::vector<ContainerT>::size_type -macromap<ContextT>::collect_arguments (token_type const curr_token, - std::vector<ContainerT> &arguments, IteratorT &next, +inline typename std::vector<ContainerT>::size_type +macromap<ContextT>::collect_arguments (token_type const curr_token, + std::vector<ContainerT> &arguments, IteratorT &next, IteratorT const &end, SizeT const ¶meter_count, bool& seen_newline) #else template <typename ContextT> template <typename IteratorT, typename ContainerT, typename SizeT> -inline typename std::vector<ContainerT>::size_type -macromap<ContextT>::collect_arguments (token_type const curr_token, +inline typename std::vector<ContainerT>::size_type +macromap<ContextT>::collect_arguments (token_type const curr_token, std::vector<ContainerT> &arguments, IteratorT &next, IteratorT &endparen, IteratorT const &end, SizeT const ¶meter_count, bool& seen_newline) #endif @@ -731,13 +731,13 @@ token_type startof_argument_list = *next; while (++next != end && nested_parenthesis_level) { token_id id = token_id(*next); - if (0 == parameter_count && + if (0 == parameter_count && !IS_CATEGORY((*next), WhiteSpaceTokenType) && id != T_NEWLINE && - id != T_RIGHTPAREN && id != T_LEFTPAREN) + id != T_RIGHTPAREN && id != T_LEFTPAREN) { // there shouldn't be any arguments - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, - too_many_macroarguments, curr_token.get_value().c_str(), + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + too_many_macroarguments, curr_token.get_value().c_str(), main_pos); return 0; } @@ -760,13 +760,13 @@ token_type startof_argument_list = *next; endparen = next; #endif if (parameter_count > 0) { - if (argument->empty() || - impl::is_whitespace_only(*argument)) + if (argument->empty() || + impl::is_whitespace_only(*argument)) { #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 if (boost::wave::need_variadics(ctx.get_language())) { // store a placemarker as the argument - argument->push_back(token_type(T_PLACEMARKER, "\xA7", + argument->push_back(token_type(T_PLACEMARKER, "\xA7", (*next).get_position())); ++count_arguments; } @@ -785,13 +785,13 @@ token_type startof_argument_list = *next; if (1 == nested_parenthesis_level) { // next parameter // trim_sequence(argument); - if (argument->empty() || - impl::is_whitespace_only(*argument)) + if (argument->empty() || + impl::is_whitespace_only(*argument)) { #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 if (boost::wave::need_variadics(ctx.get_language())) { // store a placemarker as the argument - argument->push_back(token_type(T_PLACEMARKER, "\xA7", + argument->push_back(token_type(T_PLACEMARKER, "\xA7", (*next).get_position())); ++count_arguments; } @@ -816,7 +816,7 @@ token_type startof_argument_list = *next; case T_SPACE: case T_SPACE2: case T_CCOMMENT: - if (!was_whitespace) + if (!was_whitespace) argument->push_back(token_type(T_SPACE, " ", (*next).get_position())); was_whitespace = true; break; // skip whitespace @@ -833,12 +833,12 @@ token_type startof_argument_list = *next; if (nested_parenthesis_level >= 1) { // missing ')': improperly terminated macro invocation - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, improperly_terminated_macro, "missing ')'", main_pos); return 0; } -// if no argument was expected and we didn't find any, than remove the empty +// if no argument was expected and we didn't find any, than remove the empty // element if (0 == parameter_count && 0 == count_arguments) { BOOST_ASSERT(1 == arguments.size()); @@ -848,20 +848,20 @@ token_type startof_argument_list = *next; } /////////////////////////////////////////////////////////////////////////////// -// +// // expand_whole_tokensequence // -// fully expands a given token sequence +// fully expands a given token sequence // /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> template <typename IteratorT, typename ContainerT> inline void -macromap<ContextT>::expand_whole_tokensequence(ContainerT &expanded, - IteratorT &first, IteratorT const &last, +macromap<ContextT>::expand_whole_tokensequence(ContainerT &expanded, + IteratorT &first, IteratorT const &last, bool expand_operator_defined) { - typedef impl::gen_unput_queue_iterator<IteratorT, token_type, ContainerT> + typedef impl::gen_unput_queue_iterator<IteratorT, token_type, ContainerT> gen_type; typedef typename gen_type::return_type iterator_type; @@ -875,7 +875,7 @@ macromap<ContextT>::expand_whole_tokensequence(ContainerT &expanded, while (!pending_queue.empty() || first_it != last_it) { expanded.push_back( - expand_tokensequence_worker(pending_queue, first_it, + expand_tokensequence_worker(pending_queue, first_it, last_it, seen_newline, expand_operator_defined) ); } @@ -885,23 +885,23 @@ macromap<ContextT>::expand_whole_tokensequence(ContainerT &expanded, } /////////////////////////////////////////////////////////////////////////////// -// +// // expand_argument // -// fully expands the given argument of a macro call +// fully expands the given argument of a macro call // /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> template <typename ContainerT> -inline void +inline void macromap<ContextT>::expand_argument ( - typename std::vector<ContainerT>::size_type arg, - std::vector<ContainerT> &arguments, std::vector<ContainerT> &expanded_args, + typename std::vector<ContainerT>::size_type arg, + std::vector<ContainerT> &arguments, std::vector<ContainerT> &expanded_args, bool expand_operator_defined, std::vector<bool> &has_expanded_args) { if (!has_expanded_args[arg]) { // expand the argument only once - typedef typename std::vector<ContainerT>::value_type::iterator + typedef typename std::vector<ContainerT>::value_type::iterator argument_iterator_type; argument_iterator_type begin_it = arguments[arg].begin(); @@ -915,10 +915,10 @@ macromap<ContextT>::expand_argument ( } /////////////////////////////////////////////////////////////////////////////// -// +// // expand_replacement_list // -// fully expands the replacement list of a given macro with the +// fully expands the replacement list of a given macro with the // actual arguments/expanded arguments // handles the '#' [cpp.stringize] and the '##' [cpp.concat] operator // @@ -928,11 +928,11 @@ template <typename ContainerT> inline void macromap<ContextT>::expand_replacement_list( macro_definition_type const ¯odef, - std::vector<ContainerT> &arguments, bool expand_operator_defined, + std::vector<ContainerT> &arguments, bool expand_operator_defined, ContainerT &expanded) { using namespace boost::wave; - typedef typename macro_definition_type::const_definition_iterator_t + typedef typename macro_definition_type::const_definition_iterator_t macro_definition_iter_t; std::vector<ContainerT> expanded_args(arguments.size()); @@ -947,7 +947,7 @@ bool adjacent_stringize = false; { bool use_replaced_arg = true; token_id base_id = BASE_TOKEN(token_id(*cit)); - + if (T_POUND_POUND == base_id) { // concatenation operator adjacent_concat = true; @@ -958,7 +958,7 @@ bool adjacent_stringize = false; adjacent_stringize = true; } else { - if (adjacent_stringize || adjacent_concat || + if (adjacent_stringize || adjacent_concat || T_POUND_POUND == impl::next_token<macro_definition_iter_t> ::peek(cit, cend)) { @@ -978,8 +978,8 @@ bool adjacent_stringize = false; BOOST_ASSERT(boost::wave::need_variadics(ctx.get_language())); i = token_id(*cit) - T_EXTPARAMETERBASE; is_ellipsis = true; - } - else + } + else #endif { i = token_id(*cit) - T_PARAMETERBASE; @@ -995,30 +995,30 @@ bool adjacent_stringize = false; BOOST_ASSERT(boost::wave::need_variadics(ctx.get_language())); // ensure all variadic arguments to be expanded - for (typename vector<ContainerT>::size_type arg = i; + for (typename vector<ContainerT>::size_type arg = i; arg < expanded_args.size(); ++arg) { - expand_argument(arg, arguments, expanded_args, + expand_argument(arg, arguments, expanded_args, expand_operator_defined, has_expanded_args); } impl::replace_ellipsis(expanded_args, i, expanded, pos); } - else + else #endif { // ensure argument i to be expanded - expand_argument(i, arguments, expanded_args, + expand_argument(i, arguments, expanded_args, expand_operator_defined, has_expanded_args); // replace argument ContainerT const &arg = expanded_args[i]; - - std::copy(arg.begin(), arg.end(), + + std::copy(arg.begin(), arg.end(), std::inserter(expanded, expanded.end())); } } - else if (adjacent_stringize && - !IS_CATEGORY(*cit, WhiteSpaceTokenType)) + else if (adjacent_stringize && + !IS_CATEGORY(*cit, WhiteSpaceTokenType)) { // stringize the current argument BOOST_ASSERT(!arguments[i].empty()); @@ -1030,14 +1030,14 @@ bool adjacent_stringize = false; if (is_ellipsis && boost::wave::need_variadics(ctx.get_language())) { impl::trim_sequence_left(arguments[i]); impl::trim_sequence_right(arguments.back()); - expanded.push_back(token_type(T_STRINGLIT, + expanded.push_back(token_type(T_STRINGLIT, impl::as_stringlit(arguments, i, pos), pos)); } - else -#endif + else +#endif { impl::trim_sequence(arguments[i]); - expanded.push_back(token_type(T_STRINGLIT, + expanded.push_back(token_type(T_STRINGLIT, impl::as_stringlit(arguments[i], pos), pos)); } adjacent_stringize = false; @@ -1057,9 +1057,9 @@ bool adjacent_stringize = false; #endif { ContainerT &arg = arguments[i]; - + impl::trim_sequence(arg); - std::copy(arg.begin(), arg.end(), + std::copy(arg.begin(), arg.end(), std::inserter(expanded, expanded.end())); } } @@ -1086,15 +1086,15 @@ bool adjacent_stringize = false; // // rescan_replacement_list // -// As the name implies, this function is used to rescan the replacement list +// As the name implies, this function is used to rescan the replacement list // after the first macro substitution phase. // /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> template <typename IteratorT, typename ContainerT> -inline void -macromap<ContextT>::rescan_replacement_list(token_type const &curr_token, - macro_definition_type ¯o_def, ContainerT &replacement_list, +inline void +macromap<ContextT>::rescan_replacement_list(token_type const &curr_token, + macro_definition_type ¯o_def, ContainerT &replacement_list, ContainerT &expanded, bool expand_operator_defined, IteratorT &nfirst, IteratorT const &nlast) { @@ -1126,8 +1126,8 @@ macromap<ContextT>::rescan_replacement_list(token_type const &curr_token, typename ContainerT::iterator begin_it = replacement_list.begin(); typename ContainerT::iterator end_it = replacement_list.end(); - expand_whole_tokensequence(expanded, begin_it, end_it, - expand_operator_defined); + expand_whole_tokensequence(expanded, begin_it, end_it, + expand_operator_defined); // trim replacement list, leave placeholder tokens untouched impl::trim_replacement_list(expanded); @@ -1141,7 +1141,7 @@ macromap<ContextT>::rescan_replacement_list(token_type const &curr_token, } /////////////////////////////////////////////////////////////////////////////// -// +// // expand_macro(): expands a defined macro // // This functions tries to expand the macro, to which points the 'first' @@ -1151,12 +1151,12 @@ macromap<ContextT>::rescan_replacement_list(token_type const &curr_token, /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> template <typename IteratorT, typename ContainerT> -inline bool -macromap<ContextT>::expand_macro(ContainerT &expanded, - token_type const &curr_token, typename defined_macros_type::iterator it, - IteratorT &first, IteratorT const &last, - bool& seen_newline, bool expand_operator_defined, - defined_macros_type *scope, ContainerT *queue_symbol) +inline bool +macromap<ContextT>::expand_macro(ContainerT &expanded, + token_type const &curr_token, typename defined_macros_type::iterator it, + IteratorT &first, IteratorT const &last, + bool& seen_newline, bool expand_operator_defined, + defined_macros_type *scope, ContainerT *queue_symbol) { using namespace boost::wave; @@ -1166,7 +1166,7 @@ macromap<ContextT>::expand_macro(ContainerT &expanded, IS_CATEGORY(token_id(curr_token), KeywordTokenType) || IS_EXTCATEGORY(token_id(curr_token), OperatorTokenType|AltExtTokenType) || IS_CATEGORY(token_id(curr_token), BoolLiteralTokenType)); - + if (it == scope->end()) { ++first; // advance @@ -1210,7 +1210,7 @@ macro_definition_type ¯o_def = *(*it).second.get(); ContainerT replacement_list; if (T_LEFTPAREN == impl::next_token<IteratorT>::peek(first, last)) { - // called as a function-like macro + // called as a function-like macro impl::skip_to_token(ctx, first, last, T_LEFTPAREN, seen_newline); #if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS == 0 @@ -1224,44 +1224,44 @@ ContainerT replacement_list; // collect the arguments std::vector<ContainerT> arguments; #if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0 - typename std::vector<ContainerT>::size_type count_args = - collect_arguments (curr_token, arguments, first, last, + typename std::vector<ContainerT>::size_type count_args = + collect_arguments (curr_token, arguments, first, last, macro_def.macroparameters.size(), seen_newline); #else - typename std::vector<ContainerT>::size_type count_args = - collect_arguments (curr_token, arguments, first, seqend, last, + typename std::vector<ContainerT>::size_type count_args = + collect_arguments (curr_token, arguments, first, seqend, last, macro_def.macroparameters.size(), seen_newline); #endif // verify the parameter count if (count_args < macro_def.macroparameters.size() || - arguments.size() < macro_def.macroparameters.size()) + arguments.size() < macro_def.macroparameters.size()) { if (count_args != arguments.size()) { // must been at least one empty argument in C++ mode - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, - empty_macroarguments, curr_token.get_value().c_str(), + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + empty_macroarguments, curr_token.get_value().c_str(), main_pos); } else { // too few macro arguments - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, - too_few_macroarguments, curr_token.get_value().c_str(), + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + too_few_macroarguments, curr_token.get_value().c_str(), main_pos); } return false; } if (count_args > macro_def.macroparameters.size() || - arguments.size() > macro_def.macroparameters.size()) + arguments.size() > macro_def.macroparameters.size()) { #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 - if (!macro_def.has_ellipsis) -#endif + if (!macro_def.has_ellipsis) +#endif { // too many macro arguments - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, - too_many_macroarguments, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + too_many_macroarguments, curr_token.get_value().c_str(), main_pos); return false; } @@ -1270,18 +1270,22 @@ ContainerT replacement_list; // inject tracing support #if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0 ctx.get_hooks().expanding_function_like_macro( - macro_def.macroname, macro_def.macroparameters, + macro_def.macroname, macro_def.macroparameters, macro_def.macrodefinition, curr_token, arguments); #else - if (ctx.get_hooks().expanding_function_like_macro(ctx.derived(), - macro_def.macroname, macro_def.macroparameters, + if (ctx.get_hooks().expanding_function_like_macro(ctx.derived(), + macro_def.macroname, macro_def.macroparameters, macro_def.macrodefinition, curr_token, arguments, seqstart, seqend)) { - // do not expand this macro, just copy the whole sequence +// // do not expand this macro, just copy the whole sequence +// expanded.push_back(curr_token); +// std::copy(seqstart, first, +// std::inserter(expanded, expanded.end())); + // do not expand macro, just copy macro name and parenthesis expanded.push_back(curr_token); - std::copy(seqstart, first, - std::inserter(expanded, expanded.end())); + expanded.push_back(*seqstart); + first = ++seqstart; return false; // no further preprocessing required } #endif @@ -1296,10 +1300,10 @@ ContainerT replacement_list; ctx.get_hooks().expanding_object_like_macro( macro_def.macroname, macro_def.macrodefinition, curr_token); #else - if (ctx.get_hooks().expanding_object_like_macro(ctx.derived(), + if (ctx.get_hooks().expanding_object_like_macro(ctx.derived(), macro_def.macroname, macro_def.macrodefinition, curr_token)) { - // do not expand this macro, just copy the whole sequence + // do not expand this macro, just copy the whole sequence expanded.push_back(curr_token); return false; // no further preprocessing required } @@ -1308,8 +1312,8 @@ ContainerT replacement_list; bool found = false; impl::find_concat_operator concat_tag(found); - std::remove_copy_if(macro_def.macrodefinition.begin(), - macro_def.macrodefinition.end(), + std::remove_copy_if(macro_def.macrodefinition.begin(), + macro_def.macrodefinition.end(), std::inserter(replacement_list, replacement_list.end()), concat_tag); @@ -1338,10 +1342,10 @@ ContainerT replacement_list; ctx.get_hooks().expanding_object_like_macro( macro_def.macroname, macro_def.macrodefinition, curr_token); #else - if (ctx.get_hooks().expanding_object_like_macro(ctx.derived(), + if (ctx.get_hooks().expanding_object_like_macro(ctx.derived(), macro_def.macroname, macro_def.macrodefinition, curr_token)) { - // do not expand this macro, just copy the whole sequence + // do not expand this macro, just copy the whole sequence expanded.push_back(curr_token); ++first; // skip macro name return false; // no further preprocessing required @@ -1351,15 +1355,15 @@ ContainerT replacement_list; bool found = false; impl::find_concat_operator concat_tag(found); - std::remove_copy_if(macro_def.macrodefinition.begin(), - macro_def.macrodefinition.end(), + std::remove_copy_if(macro_def.macrodefinition.begin(), + macro_def.macrodefinition.end(), std::inserter(replacement_list, replacement_list.end()), concat_tag); // handle concatenation operators if (found && !concat_tokensequence(replacement_list)) return false; - + ++first; // skip macro name } } @@ -1373,13 +1377,13 @@ ContainerT expanded_list; ctx.get_hooks().expanded_macro(ctx.derived(), replacement_list); #endif - rescan_replacement_list(curr_token, macro_def, replacement_list, + rescan_replacement_list(curr_token, macro_def, replacement_list, expanded_list, expand_operator_defined, first, last); #if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0 - ctx.get_hooks().rescanned_macro(expanded_list); + ctx.get_hooks().rescanned_macro(expanded_list); #else - ctx.get_hooks().rescanned_macro(ctx.derived(), expanded_list); + ctx.get_hooks().rescanned_macro(ctx.derived(), expanded_list); #endif expanded.splice(expanded.end(), expanded_list); return true; // rescan is required @@ -1387,25 +1391,25 @@ ContainerT expanded_list; /////////////////////////////////////////////////////////////////////////////// // -// If the token under inspection points to a certain predefined macro it will +// If the token under inspection points to a certain predefined macro it will // be expanded, otherwise false is returned. // (only __FILE__, __LINE__ and __INCLUDE_LEVEL__ macros are expanded here) // /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> template <typename ContainerT> -inline bool -macromap<ContextT>::expand_predefined_macro(token_type const &curr_token, +inline bool +macromap<ContextT>::expand_predefined_macro(token_type const &curr_token, ContainerT &expanded) { using namespace boost::wave; - + string_type const &value = curr_token.get_value(); if (value.size() < 8 || '_' != value[0] || '_' != value[1]) return false; // quick check failed - - if (value == "__LINE__") { + + if (value == "__LINE__") { // expand the __LINE__ macro char buffer[22]; // 21 bytes holds all NUL-terminated unsigned 64-bit numbers @@ -1417,13 +1421,13 @@ string_type const &value = curr_token.get_value(); else if (value == "__FILE__") { // expand the __FILE__ macro namespace fs = boost::filesystem; - + std::string file("\""); fs::path filename(wave::util::create_path(main_pos.get_file().c_str())); - + using boost::wave::util::impl::escape_lit; file += escape_lit(wave::util::native_file_string(filename)) + "\""; - expanded.push_back(token_type(T_STRINGLIT, file.c_str(), + expanded.push_back(token_type(T_STRINGLIT, file.c_str(), curr_token.get_position())); return true; } @@ -1441,29 +1445,29 @@ string_type const &value = curr_token.get_value(); /////////////////////////////////////////////////////////////////////////////// // -// resolve_defined(): resolve the operator defined() and replace it with the +// resolve_defined(): resolve the operator defined() and replace it with the // correct T_INTLIT token // /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> template <typename IteratorT, typename ContainerT> inline typename ContextT::token_type const & -macromap<ContextT>::resolve_defined(IteratorT &first, - IteratorT const &last, ContainerT &pending) +macromap<ContextT>::resolve_defined(IteratorT &first, + IteratorT const &last, ContainerT &pending) { using namespace boost::wave; using namespace boost::wave::grammars; ContainerT result; IteratorT start = first; -boost::spirit::classic::parse_info<IteratorT> hit = +boost::spirit::classic::parse_info<IteratorT> hit = defined_grammar_gen<typename ContextT::lexer_type>:: parse_operator_defined(start, last, result); - + if (!hit.hit) { string_type msg ("defined(): "); msg = msg + util::impl::as_string<string_type>(first, last); - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, ill_formed_expression, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, ill_formed_expression, msg.c_str(), main_pos); // insert a dummy token @@ -1473,11 +1477,11 @@ boost::spirit::classic::parse_info<IteratorT> hit = impl::assign_iterator<IteratorT>::do_(first, hit.stop); // insert a token, which reflects the outcome - pending.push_back(token_type(T_INTLIT, - is_defined(result.begin(), result.end()) ? "1" : "0", + pending.push_back(token_type(T_INTLIT, + is_defined(result.begin(), result.end()) ? "1" : "0", main_pos)); } - + on_exit::pop_front<definition_container_type> pop_front_token(pending); return act_token = pending.front(); @@ -1488,52 +1492,52 @@ on_exit::pop_front<definition_container_type> pop_front_token(pending); // resolve_operator_pragma(): resolve the operator _Pragma() and dispatch to // the associated action // -// This function returns true, if the pragma was correctly interpreted. +// This function returns true, if the pragma was correctly interpreted. // The iterator 'first' is positioned behind the closing ')'. -// This function returns false, if the _Pragma was not known, the +// This function returns false, if the _Pragma was not known, the // preprocessed token sequence is pushed back to the 'pending' sequence. // /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> template <typename IteratorT, typename ContainerT> inline bool -macromap<ContextT>::resolve_operator_pragma(IteratorT &first, - IteratorT const &last, ContainerT &pending, bool& seen_newline) +macromap<ContextT>::resolve_operator_pragma(IteratorT &first, + IteratorT const &last, ContainerT &pending, bool& seen_newline) { // isolate the parameter of the operator _Pragma token_type pragma_token = *first; - + if (!impl::skip_to_token(ctx, first, last, T_LEFTPAREN, seen_newline)) { // illformed operator _Pragma - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, ill_formed_expression, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, ill_formed_expression, "operator _Pragma()", pragma_token.get_position()); return false; } - + std::vector<ContainerT> arguments; #if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0 - typename std::vector<ContainerT>::size_type count_args = + typename std::vector<ContainerT>::size_type count_args = collect_arguments (pragma_token, arguments, first, last, 1, seen_newline); #else IteratorT endparen = first; - typename std::vector<ContainerT>::size_type count_args = - collect_arguments (pragma_token, arguments, first, endparen, last, 1, + typename std::vector<ContainerT>::size_type count_args = + collect_arguments (pragma_token, arguments, first, endparen, last, 1, seen_newline); #endif // verify the parameter count if (pragma_token.get_position().get_file().empty()) pragma_token.set_position(act_token.get_position()); - + if (count_args < 1 || arguments.size() < 1) { // too few macro arguments - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, too_few_macroarguments, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, too_few_macroarguments, pragma_token.get_value().c_str(), pragma_token.get_position()); return false; } if (count_args > 1 || arguments.size() > 1) { // too many macro arguments - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, too_many_macroarguments, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, too_many_macroarguments, pragma_token.get_value().c_str(), pragma_token.get_position()); return false; } @@ -1541,7 +1545,7 @@ macromap<ContextT>::resolve_operator_pragma(IteratorT &first, // preprocess the pragma token body typedef typename std::vector<ContainerT>::value_type::iterator argument_iterator_type; - + ContainerT expanded; argument_iterator_type begin_it = arguments[0].begin(); argument_iterator_type end_it = arguments[0].end(); @@ -1549,7 +1553,7 @@ macromap<ContextT>::resolve_operator_pragma(IteratorT &first, // un-escape the parameter of the operator _Pragma typedef typename token_type::string_type string_type; - + string_type pragma_cmd; typename ContainerT::const_iterator end_exp = expanded.end(); for (typename ContainerT::const_iterator it_exp = expanded.begin(); @@ -1559,24 +1563,24 @@ macromap<ContextT>::resolve_operator_pragma(IteratorT &first, break; if (IS_CATEGORY(*it_exp, WhiteSpaceTokenType)) continue; - + if (T_STRINGLIT != token_id(*it_exp)) { // ill formed operator _Pragma - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, - ill_formed_pragma_option, "_Pragma", + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + ill_formed_pragma_option, "_Pragma", pragma_token.get_position()); return false; } if (pragma_cmd.size() > 0) { - // there should be exactly one string literal (string literals are to - // be concatenated at translation phase 6, but _Pragma operators are + // there should be exactly one string literal (string literals are to + // be concatenated at translation phase 6, but _Pragma operators are // to be executed at translation phase 4) - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, - ill_formed_pragma_option, "_Pragma", + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + ill_formed_pragma_option, "_Pragma", pragma_token.get_position()); return false; } - + // remove the '\"' and concat all given string literal-values string_type token_str = (*it_exp).get_value(); pragma_cmd += token_str.substr(1, token_str.size() - 2); @@ -1585,23 +1589,23 @@ macromap<ContextT>::resolve_operator_pragma(IteratorT &first, // tokenize the pragma body typedef typename ContextT::lexer_type lexer_type; - + ContainerT pragma; std::string pragma_cmd_str(pragma_cmd_unesc.c_str()); - lexer_type it = lexer_type(pragma_cmd_str.begin(), pragma_cmd_str.end(), + lexer_type it = lexer_type(pragma_cmd_str.begin(), pragma_cmd_str.end(), pragma_token.get_position(), ctx.get_language()); lexer_type end = lexer_type(); - for (/**/; it != end; ++it) + for (/**/; it != end; ++it) pragma.push_back(*it); -// analyze the preprocessed token sequence and eventually dispatch to the +// analyze the preprocessed token sequence and eventually dispatch to the // associated action - if (interpret_pragma(ctx, pragma_token, pragma.begin(), pragma.end(), + if (interpret_pragma(ctx, pragma_token, pragma.begin(), pragma.end(), pending)) { return true; // successfully recognized a wave specific pragma } - + // unknown pragma token sequence, push it back and return to the caller pending.push_front(token_type(T_SPACE, " ", pragma_token.get_position())); pending.push_front(token_type(T_RIGHTPAREN, ")", pragma_token.get_position())); @@ -1614,16 +1618,16 @@ macromap<ContextT>::resolve_operator_pragma(IteratorT &first, /////////////////////////////////////////////////////////////////////////////// // -// Test, whether the result of a concat operator is well formed or not. +// Test, whether the result of a concat operator is well formed or not. // -// This is done by re-scanning (re-tokenizing) the resulting token sequence, +// This is done by re-scanning (re-tokenizing) the resulting token sequence, // which should give back exactly one token. // /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> template <typename ContainerT> inline bool -macromap<ContextT>::is_valid_concat(string_type new_value, +macromap<ContextT>::is_valid_concat(string_type new_value, position_type const &pos, ContainerT &rescanned) { // re-tokenize the newly generated string @@ -1631,17 +1635,17 @@ macromap<ContextT>::is_valid_concat(string_type new_value, std::string value_to_test(new_value.c_str()); - boost::wave::language_support lang = + boost::wave::language_support lang = boost::wave::enable_prefer_pp_numbers(ctx.get_language()); lang = boost::wave::enable_single_line(lang); - lexer_type it = lexer_type(value_to_test.begin(), value_to_test.end(), pos, + lexer_type it = lexer_type(value_to_test.begin(), value_to_test.end(), pos, lang); lexer_type end = lexer_type(); - for (/**/; it != end && T_EOF != token_id(*it); ++it) + for (/**/; it != end && T_EOF != token_id(*it); ++it) { // as of Wave V2.0.7 pasting of tokens is valid only if the resulting - // tokens are pp_tokens (as mandated by C++0x) + // tokens are pp_tokens (as mandated by C++11) if (!is_pp_token(*it)) return false; rescanned.push_back(*it); @@ -1650,7 +1654,7 @@ macromap<ContextT>::is_valid_concat(string_type new_value, #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 if (boost::wave::need_variadics(ctx.get_language())) return true; // in variadics mode token pasting is well defined -#endif +#endif // test if the newly generated token sequence contains more than 1 token return 1 == rescanned.size(); @@ -1663,8 +1667,8 @@ macromap<ContextT>::is_valid_concat(string_type new_value, // /////////////////////////////////////////////////////////////////////////////// template <typename Context> -inline void report_invalid_concatenation(Context& ctx, - typename Context::token_type const& prev, +inline void report_invalid_concatenation(Context& ctx, + typename Context::token_type const& prev, typename Context::token_type const& next, typename Context::position_type const& main_pos) { @@ -1680,7 +1684,7 @@ typename Context::string_type error_string("\""); template <typename ContextT> template <typename ContainerT> -inline bool +inline bool macromap<ContextT>::concat_tokensequence(ContainerT &expanded) { using namespace boost::wave; @@ -1688,7 +1692,7 @@ macromap<ContextT>::concat_tokensequence(ContainerT &expanded) iterator_type end = expanded.end(); iterator_type prev = end; - for (iterator_type it = expanded.begin(); it != end; /**/) + for (iterator_type it = expanded.begin(); it != end; /**/) { if (T_POUND_POUND == BASE_TOKEN(token_id(*it))) { iterator_type next = it; @@ -1696,7 +1700,7 @@ macromap<ContextT>::concat_tokensequence(ContainerT &expanded) ++next; if (prev == end || next == end) { // error, '##' should be in between two tokens - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, ill_formed_operator, "concat ('##')", main_pos); return false; } @@ -1707,12 +1711,12 @@ macromap<ContextT>::concat_tokensequence(ContainerT &expanded) ++next; if (next == end) { // error, '##' should be in between two tokens - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, ill_formed_operator, "concat ('##')", main_pos); return false; } } - + #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 if (boost::wave::need_variadics(ctx.get_language())) { if (T_PLACEMARKER == token_id(*next)) { @@ -1728,14 +1732,14 @@ macromap<ContextT>::concat_tokensequence(ContainerT &expanded) iterator_type first_to_delete = prev; *prev = *next; - expanded.erase(++first_to_delete, ++next); + expanded.erase(++first_to_delete, ++next); it = next; continue; } } #endif // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 - // test if the concat operator has to concatenate two unrelated + // test if the concat operator has to concatenate two unrelated // tokens i.e. the result yields more then one token string_type concat_result; ContainerT rescanned; @@ -1743,10 +1747,10 @@ macromap<ContextT>::concat_tokensequence(ContainerT &expanded) concat_result = ((*prev).get_value() + (*next).get_value()); // analyze the validity of the concatenation result - if (!is_valid_concat(concat_result, (*prev).get_position(), + if (!is_valid_concat(concat_result, (*prev).get_position(), rescanned) && - !IS_CATEGORY(*prev, WhiteSpaceTokenType) && - !IS_CATEGORY(*next, WhiteSpaceTokenType)) + !IS_CATEGORY(*prev, WhiteSpaceTokenType) && + !IS_CATEGORY(*next, WhiteSpaceTokenType)) { report_invalid_concatenation(ctx, *prev, *next, main_pos); return false; @@ -1755,12 +1759,12 @@ macromap<ContextT>::concat_tokensequence(ContainerT &expanded) #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 if (boost::wave::need_variadics(ctx.get_language())) { // remove the prev, '##' and the next tokens from the sequence - expanded.erase(prev, ++next); // remove not needed tokens + expanded.erase(prev, ++next); // remove not needed tokens // some stl implementations clear() the container if we erased all - // the elements, which orphans all iterators. we re-initialize these + // the elements, which orphans all iterators. we re-initialize these // here - if (expanded.empty()) + if (expanded.empty()) end = next = expanded.end(); // replace the old token (pointed to by *prev) with the re-tokenized @@ -1775,7 +1779,7 @@ macromap<ContextT>::concat_tokensequence(ContainerT &expanded) else #endif // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 { - // we leave the token_id unchanged, but unmark the token as + // we leave the token_id unchanged, but unmark the token as // disabled, if appropriate (*prev).set_value(concat_result); if (T_NONREPLACABLE_IDENTIFIER == token_id(*prev)) @@ -1784,7 +1788,7 @@ macromap<ContextT>::concat_tokensequence(ContainerT &expanded) // remove the '##' and the next tokens from the sequence iterator_type first_to_delete = prev; - expanded.erase(++first_to_delete, ++next); + expanded.erase(++first_to_delete, ++next); } it = next; continue; @@ -1806,14 +1810,14 @@ macromap<ContextT>::concat_tokensequence(ContainerT &expanded) /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> inline void -macromap<ContextT>::predefine_macro(defined_macros_type *scope, +macromap<ContextT>::predefine_macro(defined_macros_type *scope, string_type const &name, token_type const &t) { definition_container_type macrodefinition; std::vector<token_type> param; macrodefinition.push_back(t); - add_macro(token_type(T_IDENTIFIER, name, t.get_position()), + add_macro(token_type(T_IDENTIFIER, name, t.get_position()), false, param, macrodefinition, true, scope); } @@ -1823,8 +1827,8 @@ std::vector<token_type> param; // /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> -inline void -macromap<ContextT>::init_predefined_macros(char const *fname, +inline void +macromap<ContextT>::init_predefined_macros(char const *fname, defined_macros_type *scope, bool at_global_scope) { // if no scope is given, use the current one @@ -1842,25 +1846,25 @@ position_type pos("<built-in>"); token_type(m.token_id, m.value, pos)); } } - else -#endif + else +#endif { #if BOOST_WAVE_SUPPORT_CPP0X != 0 if (boost::wave::need_cpp0x(ctx.get_language())) { - // define C++0x specifics + // define C++11 specifics for (int i = 0; 0 != predef.static_data_cpp0x(i).name; ++i) { predefined_macros::static_macros const& m = predef.static_data_cpp0x(i); - predefine_macro(current_scope, m.name, + predefine_macro(current_scope, m.name, token_type(m.token_id, m.value, pos)); } } - else -#endif + else +#endif { // define C++ specifics for (int i = 0; 0 != predef.static_data_cpp(i).name; ++i) { predefined_macros::static_macros const& m = predef.static_data_cpp(i); - predefine_macro(current_scope, m.name, + predefine_macro(current_scope, m.name, token_type(m.token_id, m.value, pos)); } @@ -1870,18 +1874,18 @@ position_type pos("<built-in>"); predefine_macro(current_scope, "__WAVE_HAS_VARIADICS__", token_type(T_INTLIT, "1", pos)); } -#endif +#endif } } -// predefine the __BASE_FILE__ macro which contains the main file name - namespace fs = boost::filesystem; +// predefine the __BASE_FILE__ macro which contains the main file name + namespace fs = boost::filesystem; if (string_type(fname) != "<Unknown>") { fs::path filename(create_path(fname)); using boost::wave::util::impl::escape_lit; predefine_macro(current_scope, "__BASE_FILE__", - token_type(T_STRINGLIT, string_type("\"") + + token_type(T_STRINGLIT, string_type("\"") + escape_lit(native_file_string(filename)).c_str() + "\"", pos)); base_name = fname; } @@ -1890,7 +1894,7 @@ position_type pos("<built-in>"); using boost::wave::util::impl::escape_lit; predefine_macro(current_scope, "__BASE_FILE__", - token_type(T_STRINGLIT, string_type("\"") + + token_type(T_STRINGLIT, string_type("\"") + escape_lit(native_file_string(filename)).c_str() + "\"", pos)); } @@ -1908,7 +1912,7 @@ position_type pos("<built-in>"); // /////////////////////////////////////////////////////////////////////////////// template <typename ContextT> -inline void +inline void macromap<ContextT>::reset_macromap() { current_macros->clear(); diff --git a/boost/wave/util/cpp_macromap_predef.hpp b/boost/wave/util/cpp_macromap_predef.hpp index 0725a36306..74ba2ad7b1 100644 --- a/boost/wave/util/cpp_macromap_predef.hpp +++ b/boost/wave/util/cpp_macromap_predef.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ @@ -224,7 +224,7 @@ namespace util { } #if BOOST_WAVE_SUPPORT_CPP0X != 0 - // C++0x mode + // C++11 mode static_macros const& static_data_cpp0x(std::size_t i) const { static static_macros data[] = { diff --git a/boost/wave/util/cpp_macromap_utils.hpp b/boost/wave/util/cpp_macromap_utils.hpp index 84b5b03de6..36b187801d 100644 --- a/boost/wave/util/cpp_macromap_utils.hpp +++ b/boost/wave/util/cpp_macromap_utils.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/util/file_position.hpp b/boost/wave/util/file_position.hpp index 87f6f77375..66c5d7814d 100644 --- a/boost/wave/util/file_position.hpp +++ b/boost/wave/util/file_position.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/util/filesystem_compatibility.hpp b/boost/wave/util/filesystem_compatibility.hpp index 5bd924af72..157c6418c0 100644 --- a/boost/wave/util/filesystem_compatibility.hpp +++ b/boost/wave/util/filesystem_compatibility.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ @@ -25,12 +25,12 @@ namespace boost { namespace wave { namespace util // interface wrappers for older Boost versions inline boost::filesystem::path initial_path() { - return boost::filesystem::initial_path(); + return boost::filesystem::initial_path(); } inline boost::filesystem::path current_path() { - return boost::filesystem::current_path(); + return boost::filesystem::current_path(); } template <typename String> @@ -43,18 +43,18 @@ namespace boost { namespace wave { namespace util #endif } - inline std::string leaf(boost::filesystem::path const& p) - { + inline std::string leaf(boost::filesystem::path const& p) + { #if BOOST_FILESYSTEM_VERSION >= 3 - return p.leaf().string(); + return p.leaf().string(); #else - return p.leaf(); + return p.leaf(); #endif } - inline boost::filesystem::path branch_path(boost::filesystem::path const& p) - { - return p.branch_path(); + inline boost::filesystem::path branch_path(boost::filesystem::path const& p) + { + return p.branch_path(); } inline boost::filesystem::path normalize(boost::filesystem::path& p) @@ -62,12 +62,12 @@ namespace boost { namespace wave { namespace util return p.normalize(); } - inline std::string native_file_string(boost::filesystem::path const& p) - { + inline std::string native_file_string(boost::filesystem::path const& p) + { #if BOOST_FILESYSTEM_VERSION >= 3 - return p.string(); + return p.string(); #else - return p.native_file_string(); + return p.native_file_string(); #endif } @@ -75,7 +75,11 @@ namespace boost { namespace wave { namespace util boost::filesystem::path const& p) { #if BOOST_FILESYSTEM_VERSION >= 3 +#if BOOST_VERSION >= 105000 + return boost::filesystem::complete(p, initial_path()); +#else return boost::filesystem3::complete(p, initial_path()); +#endif #else return boost::filesystem::complete(p, initial_path()); #endif @@ -85,7 +89,11 @@ namespace boost { namespace wave { namespace util boost::filesystem::path const& p, boost::filesystem::path const& base) { #if BOOST_FILESYSTEM_VERSION >= 3 +#if BOOST_VERSION >= 105000 + return boost::filesystem::complete(p, base); +#else return boost::filesystem3::complete(p, base); +#endif #else return boost::filesystem::complete(p, base); #endif @@ -95,18 +103,26 @@ namespace boost { namespace wave { namespace util // interface wrappers if deprecated functions do not exist inline boost::filesystem::path initial_path() - { + { #if BOOST_FILESYSTEM_VERSION >= 3 +#if BOOST_VERSION >= 105000 + return boost::filesystem::detail::initial_path(); +#else return boost::filesystem3::detail::initial_path(); +#endif #else return boost::filesystem::initial_path<boost::filesystem::path>(); #endif } inline boost::filesystem::path current_path() - { + { #if BOOST_FILESYSTEM_VERSION >= 3 +#if BOOST_VERSION >= 105000 + return boost::filesystem::current_path(); +#else return boost::filesystem3::current_path(); +#endif #else return boost::filesystem::current_path<boost::filesystem::path>(); #endif @@ -118,18 +134,18 @@ namespace boost { namespace wave { namespace util return boost::filesystem::path(p); } - inline std::string leaf(boost::filesystem::path const& p) - { + inline std::string leaf(boost::filesystem::path const& p) + { #if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION >= 3 return p.filename().string(); #else - return p.filename(); + return p.filename(); #endif } - inline boost::filesystem::path branch_path(boost::filesystem::path const& p) - { - return p.parent_path(); + inline boost::filesystem::path branch_path(boost::filesystem::path const& p) + { + return p.parent_path(); } inline boost::filesystem::path normalize(boost::filesystem::path& p) @@ -137,12 +153,12 @@ namespace boost { namespace wave { namespace util return p; // function doesn't exist anymore } - inline std::string native_file_string(boost::filesystem::path const& p) - { + inline std::string native_file_string(boost::filesystem::path const& p) + { #if BOOST_VERSION >= 104600 - return p.string(); + return p.string(); #else - return p.file_string(); + return p.file_string(); #endif } @@ -167,6 +183,13 @@ namespace boost { namespace wave { namespace util } #endif + // starting withBoost V1.50 create_directories throws if given an empty path + inline bool create_directories(boost::filesystem::path const& p) + { + if (p.string().empty()) + return true; + return boost::filesystem::create_directories(p); + } }}} #endif diff --git a/boost/wave/util/functor_input.hpp b/boost/wave/util/functor_input.hpp index d30a090a1a..6cd75828fb 100644 --- a/boost/wave/util/functor_input.hpp +++ b/boost/wave/util/functor_input.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/util/insert_whitespace_detection.hpp b/boost/wave/util/insert_whitespace_detection.hpp index 8485e9c1d1..e5726965f7 100644 --- a/boost/wave/util/insert_whitespace_detection.hpp +++ b/boost/wave/util/insert_whitespace_detection.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/util/interpret_pragma.hpp b/boost/wave/util/interpret_pragma.hpp index e787040b1a..e5b9127366 100644 --- a/boost/wave/util/interpret_pragma.hpp +++ b/boost/wave/util/interpret_pragma.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/util/iteration_context.hpp b/boost/wave/util/iteration_context.hpp index 8673f46639..1ea027c88d 100644 --- a/boost/wave/util/iteration_context.hpp +++ b/boost/wave/util/iteration_context.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ @@ -30,17 +30,17 @@ namespace util { /////////////////////////////////////////////////////////////////////////////// template <typename IterationContextT> -class iteration_context_stack +class iteration_context_stack { typedef std::stack<IterationContextT> base_type; - + public: typedef typename base_type::size_type size_type; - + iteration_context_stack() : max_include_nesting_depth(BOOST_WAVE_MAX_INCLUDE_LEVEL_DEPTH) {} - + void set_max_include_nesting_depth(size_type new_depth) { max_include_nesting_depth = new_depth; } size_type get_max_include_nesting_depth() const @@ -49,22 +49,22 @@ public: typename base_type::size_type size() const { return iter_ctx.size(); } typename base_type::value_type &top() { return iter_ctx.top(); } void pop() { iter_ctx.pop(); } - + template <typename Context, typename PositionT> - void push(Context& ctx, PositionT const &pos, + void push(Context& ctx, PositionT const &pos, typename base_type::value_type const &val) - { + { if (iter_ctx.size() == max_include_nesting_depth) { char buffer[22]; // 21 bytes holds all NUL-terminated unsigned 64-bit numbers using namespace std; // for some systems sprintf is in namespace std sprintf(buffer, "%d", (int)max_include_nesting_depth); - BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, + BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, include_nesting_too_deep, buffer, pos); } - iter_ctx.push(val); + iter_ctx.push(val); } - + private: size_type max_include_nesting_depth; base_type iter_ctx; diff --git a/boost/wave/util/macro_definition.hpp b/boost/wave/util/macro_definition.hpp index 16be858704..f488ac3a2a 100644 --- a/boost/wave/util/macro_definition.hpp +++ b/boost/wave/util/macro_definition.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/util/macro_helpers.hpp b/boost/wave/util/macro_helpers.hpp index 4d156638dd..a33e8d02f9 100644 --- a/boost/wave/util/macro_helpers.hpp +++ b/boost/wave/util/macro_helpers.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/util/pattern_parser.hpp b/boost/wave/util/pattern_parser.hpp index 876726fe4e..a36b980fbc 100644 --- a/boost/wave/util/pattern_parser.hpp +++ b/boost/wave/util/pattern_parser.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/util/symbol_table.hpp b/boost/wave/util/symbol_table.hpp index 0eda557fba..312b0a2f19 100644 --- a/boost/wave/util/symbol_table.hpp +++ b/boost/wave/util/symbol_table.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/util/time_conversion_helper.hpp b/boost/wave/util/time_conversion_helper.hpp index a477607b95..2918dde359 100644 --- a/boost/wave/util/time_conversion_helper.hpp +++ b/boost/wave/util/time_conversion_helper.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/util/transform_iterator.hpp b/boost/wave/util/transform_iterator.hpp index 7477bfedbd..c60dbdaf4a 100644 --- a/boost/wave/util/transform_iterator.hpp +++ b/boost/wave/util/transform_iterator.hpp @@ -3,7 +3,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/util/unput_queue_iterator.hpp b/boost/wave/util/unput_queue_iterator.hpp index 7fc060153b..6d1ce1dc32 100644 --- a/boost/wave/util/unput_queue_iterator.hpp +++ b/boost/wave/util/unput_queue_iterator.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/wave_config.hpp b/boost/wave/wave_config.hpp index fa537a6891..ec712ef16d 100644 --- a/boost/wave/wave_config.hpp +++ b/boost/wave/wave_config.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ @@ -83,9 +83,9 @@ #endif /////////////////////////////////////////////////////////////////////////////// -// Decide, whether to support C++0x +// Decide, whether to support C++11 // -// To implement C++0x keywords and preprocessor semantics define the following +// To implement C++11 keywords and preprocessor semantics define the following // to something not equal to zero. // #if !defined(BOOST_WAVE_SUPPORT_CPP0X) diff --git a/boost/wave/wave_config_constant.hpp b/boost/wave/wave_config_constant.hpp index 68bdf74c42..45f83a2abc 100644 --- a/boost/wave/wave_config_constant.hpp +++ b/boost/wave/wave_config_constant.hpp @@ -4,7 +4,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ diff --git a/boost/wave/wave_version.hpp b/boost/wave/wave_version.hpp index 3512e0da10..7b143ca76c 100644 --- a/boost/wave/wave_version.hpp +++ b/boost/wave/wave_version.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ - Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ @@ -16,11 +16,11 @@ // BOOST_WAVE_VERSION & 0x0000FF is the sub-minor version // BOOST_WAVE_VERSION & 0x00FF00 is the minor version // BOOST_WAVE_VERSION & 0xFF0000 is the major version -#define BOOST_WAVE_VERSION 0x020300 +#define BOOST_WAVE_VERSION 0x020302 // The following defines contain the same information as above #define BOOST_WAVE_VERSION_MAJOR 2 #define BOOST_WAVE_VERSION_MINOR 3 -#define BOOST_WAVE_VERSION_SUBMINOR 0 +#define BOOST_WAVE_VERSION_SUBMINOR 2 #endif // !defined(WAVE_VERSION_H_9D79ABDB_AC54_4C0A_89B1_F70A2DCFE21E_INCLUDED) diff --git a/boost/wave/whitespace_handling.hpp b/boost/wave/whitespace_handling.hpp index be9725fd8d..c81a67c67e 100644 --- a/boost/wave/whitespace_handling.hpp +++ b/boost/wave/whitespace_handling.hpp @@ -5,7 +5,7 @@ http://www.boost.org/ Copyright (c) 2003 Paul Mensonides - Copyright (c) 2001-2011 Hartmut Kaiser. + Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ @@ -67,7 +67,7 @@ namespace util { #if BOOST_WAVE_SUPPORT_CPP0X != 0 /////////////////////////////////////////////////////////////////////////// - // This function returns the number of newlines in the given C++0x style + // This function returns the number of newlines in the given C++11 style // raw string template <typename TokenT> int rawstring_count_newlines(TokenT const& token) |