|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72164 - in branches/release: . boost boost/wave boost/wave/grammars libs libs/wave libs/wave/samples/cpp_tokens libs/wave/samples/list_includes libs/wave/samples/real_positions libs/wave/src tools tools/wave
From: hartmut.kaiser_at_[hidden]
Date: 2011-05-25 15:27:26
Author: hkaiser
Date: 2011-05-25 15:27:24 EDT (Wed, 25 May 2011)
New Revision: 72164
URL: http://svn.boost.org/trac/boost/changeset/72164
Log:
Wave: merging from trunk
Properties modified:
branches/release/ (props changed)
branches/release/boost/ (props changed)
branches/release/boost/wave/ (props changed)
branches/release/libs/ (props changed)
branches/release/libs/wave/ (props changed)
branches/release/tools/ (props changed)
branches/release/tools/wave/ (props changed)
Text files modified:
branches/release/boost/wave/grammars/cpp_chlit_grammar.hpp | 12 +++---
branches/release/boost/wave/grammars/cpp_expression_grammar.hpp | 22 ++++++++++-
branches/release/boost/wave/grammars/cpp_literal_grammar_gen.hpp | 4 +-
branches/release/boost/wave/wave_config.hpp | 16 ++++++++
branches/release/boost/wave/wave_version.hpp | 4 +-
branches/release/libs/wave/ChangeLog | 1
branches/release/libs/wave/samples/cpp_tokens/instantiate_cpp_literalgrs.cpp | 6 ++
branches/release/libs/wave/samples/list_includes/instantiate_cpp_literalgrs.cpp | 6 ++
branches/release/libs/wave/samples/real_positions/instantiate_cpp_literalgrs.cpp | 6 ++
branches/release/libs/wave/src/instantiate_cpp_literalgrs.cpp | 6 ++
branches/release/tools/wave/cpp.cpp | 76 ++++++++++++++++++++--------------------
branches/release/tools/wave/trace_macro_expansion.hpp | 12 +++--
12 files changed, 112 insertions(+), 59 deletions(-)
Modified: branches/release/boost/wave/grammars/cpp_chlit_grammar.hpp
==============================================================================
--- branches/release/boost/wave/grammars/cpp_chlit_grammar.hpp (original)
+++ branches/release/boost/wave/grammars/cpp_chlit_grammar.hpp 2011-05-25 15:27:24 EDT (Wed, 25 May 2011)
@@ -298,15 +298,15 @@
#define BOOST_WAVE_CHLITGRAMMAR_GEN_INLINE inline
#endif
-template <typename TokenT>
+template <typename IntegralResult, typename TokenT>
BOOST_WAVE_CHLITGRAMMAR_GEN_INLINE
-unsigned int
-chlit_grammar_gen<TokenT>::evaluate(TokenT const &token, value_error &status)
+IntegralResult
+chlit_grammar_gen<IntegralResult, TokenT>::evaluate(TokenT const &token, value_error &status)
{
using namespace boost::spirit::classic;
chlit_grammar g;
-boost::uint32_t result = 0;
+IntegralResult result = 0;
typename TokenT::string_type const &token_val = token.get_value();
parse_info<typename TokenT::string_type::const_iterator> hit =
parse(token_val.begin(), token_val.end(), g[spirit_assign_actor(result)]);
@@ -320,7 +320,7 @@
if ('L' == token_val[0]) {
// recognized wide character
if (g.overflow ||
- result > (unsigned long)(std::numeric_limits<wchar_t>::max)())
+ result > (IntegralResult)(std::numeric_limits<wchar_t>::max)())
{
// out of range
status = error_character_overflow;
@@ -329,7 +329,7 @@
else {
// recognized narrow ('normal') character
if (g.overflow ||
- result > (unsigned long)(std::numeric_limits<unsigned char>::max)())
+ result > (IntegralResult)(std::numeric_limits<unsigned char>::max)())
{
// out of range
status = error_character_overflow;
Modified: branches/release/boost/wave/grammars/cpp_expression_grammar.hpp
==============================================================================
--- branches/release/boost/wave/grammars/cpp_expression_grammar.hpp (original)
+++ branches/release/boost/wave/grammars/cpp_expression_grammar.hpp 2011-05-25 15:27:24 EDT (Wed, 25 May 2011)
@@ -105,7 +105,7 @@
///////////////////////////////////////////////////////////////////////////////
//
-// convert the given token value (character literal) to a unsigned int
+// Convert the given token value (character literal) to a unsigned int
//
///////////////////////////////////////////////////////////////////////////////
struct convert_chlit {
@@ -122,7 +122,25 @@
{
typedef boost::wave::grammars::closures::closure_value return_type;
value_error status = error_noerror;
- unsigned int value = chlit_grammar_gen<TokenT>::evaluate(token, status);
+
+ // If the literal is a wchar_t and wchar_t is represented by a
+ // signed integral type, then the created value will be signed as
+ // well, otherwise we assume unsigned values.
+#if BOOST_WAVE_WCHAR_T_SIGNEDNESS == BOOST_WAVE_WCHAR_T_AUTOSELECT
+ if ('L' == token.get_value()[0] && std::numeric_limits<wchar_t>::is_signed)
+ {
+ int value = chlit_grammar_gen<int, TokenT>::evaluate(token, status);
+ return return_type(value, status);
+ }
+#elif BOOST_WAVE_WCHAR_T_SIGNEDNESS == BOOST_WAVE_WCHAR_T_FORCE_SIGNED
+ if ('L' == token.get_value()[0])
+ {
+ int value = chlit_grammar_gen<int, TokenT>::evaluate(token, status);
+ return return_type(value, status);
+ }
+#endif
+
+ unsigned int value = chlit_grammar_gen<unsigned int, TokenT>::evaluate(token, status);
return return_type(value, status);
}
};
Modified: branches/release/boost/wave/grammars/cpp_literal_grammar_gen.hpp
==============================================================================
--- branches/release/boost/wave/grammars/cpp_literal_grammar_gen.hpp (original)
+++ branches/release/boost/wave/grammars/cpp_literal_grammar_gen.hpp 2011-05-25 15:27:24 EDT (Wed, 25 May 2011)
@@ -54,10 +54,10 @@
// to safe compilation time.
//
///////////////////////////////////////////////////////////////////////////////
-template <typename TokenT>
+template <typename IntegralResult, typename TokenT>
struct BOOST_WAVE_DECL chlit_grammar_gen {
- static unsigned int evaluate(TokenT const &tok, value_error& status);
+ static IntegralResult evaluate(TokenT const &tok, value_error& status);
};
///////////////////////////////////////////////////////////////////////////////
Modified: branches/release/boost/wave/wave_config.hpp
==============================================================================
--- branches/release/boost/wave/wave_config.hpp (original)
+++ branches/release/boost/wave/wave_config.hpp 2011-05-25 15:27:24 EDT (Wed, 25 May 2011)
@@ -403,6 +403,22 @@
}}
///////////////////////////////////////////////////////////////////////////////
+// On some platforms Wave will not be able to properly detect whether wchar_t
+// is representing a signed or unsigned integral data type. Use the
+// configuration constants below to force wchar_t being signed or unsigned, as
+// appropriate.
+//
+// The default is to use std::numeric_limits<wchar_t>::is_signed.
+
+#define BOOST_WAVE_WCHAR_T_AUTOSELECT 1
+#define BOOST_WAVE_WCHAR_T_FORCE_SIGNED 2
+#define BOOST_WAVE_WCHAR_T_FORCE_UNSIGNED 3
+
+#if !defined(BOOST_WAVE_WCHAR_T_SIGNEDNESS)
+#define BOOST_WAVE_WCHAR_T_SIGNEDNESS BOOST_WAVE_WCHAR_T_AUTOSELECT
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
// Wave needs at least 4 parameters for phoenix actors
#if !defined(PHOENIX_LIMIT)
#define PHOENIX_LIMIT 6
Modified: branches/release/boost/wave/wave_version.hpp
==============================================================================
--- branches/release/boost/wave/wave_version.hpp (original)
+++ branches/release/boost/wave/wave_version.hpp 2011-05-25 15:27:24 EDT (Wed, 25 May 2011)
@@ -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 0x020200
+#define BOOST_WAVE_VERSION 0x020300
// The following defines contain the same information as above
#define BOOST_WAVE_VERSION_MAJOR 2
-#define BOOST_WAVE_VERSION_MINOR 2
+#define BOOST_WAVE_VERSION_MINOR 3
#define BOOST_WAVE_VERSION_SUBMINOR 0
#endif // !defined(WAVE_VERSION_H_9D79ABDB_AC54_4C0A_89B1_F70A2DCFE21E_INCLUDED)
Modified: branches/release/libs/wave/ChangeLog
==============================================================================
--- branches/release/libs/wave/ChangeLog (original)
+++ branches/release/libs/wave/ChangeLog 2011-05-25 15:27:24 EDT (Wed, 25 May 2011)
@@ -36,6 +36,7 @@
cause unexpected results if the suppressed macro would influence #ifdef's
later on.
- Fixed problem #5554: wave slex parser eof without eol skips the last line.
+ interactive mode.
Boost V1.46.0
- V2.2.0
Modified: branches/release/libs/wave/samples/cpp_tokens/instantiate_cpp_literalgrs.cpp
==============================================================================
--- branches/release/libs/wave/samples/cpp_tokens/instantiate_cpp_literalgrs.cpp (original)
+++ branches/release/libs/wave/samples/cpp_tokens/instantiate_cpp_literalgrs.cpp 2011-05-25 15:27:24 EDT (Wed, 25 May 2011)
@@ -37,7 +37,11 @@
typedef boost::wave::cpplexer::slex_token<> token_type;
template struct boost::wave::grammars::intlit_grammar_gen<token_type>;
-template struct boost::wave::grammars::chlit_grammar_gen<token_type>;
+#if BOOST_WAVE_WCHAR_T_SIGNEDNESS == BOOST_WAVE_WCHAR_T_AUTOSELECT || \
+ BOOST_WAVE_WCHAR_T_SIGNEDNESS == BOOST_WAVE_WCHAR_T_FORCE_SIGNED
+template struct boost::wave::grammars::chlit_grammar_gen<int, token_type>;
+#endif
+template struct boost::wave::grammars::chlit_grammar_gen<unsigned int, token_type>;
#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
Modified: branches/release/libs/wave/samples/list_includes/instantiate_cpp_literalgrs.cpp
==============================================================================
--- branches/release/libs/wave/samples/list_includes/instantiate_cpp_literalgrs.cpp (original)
+++ branches/release/libs/wave/samples/list_includes/instantiate_cpp_literalgrs.cpp 2011-05-25 15:27:24 EDT (Wed, 25 May 2011)
@@ -37,7 +37,11 @@
typedef boost::wave::cpplexer::lex_token<> token_type;
template struct boost::wave::grammars::intlit_grammar_gen<token_type>;
-template struct boost::wave::grammars::chlit_grammar_gen<token_type>;
+#if BOOST_WAVE_WCHAR_T_SIGNEDNESS == BOOST_WAVE_WCHAR_T_AUTOSELECT || \
+ BOOST_WAVE_WCHAR_T_SIGNEDNESS == BOOST_WAVE_WCHAR_T_FORCE_SIGNED
+template struct boost::wave::grammars::chlit_grammar_gen<int, token_type>;
+#endif
+template struct boost::wave::grammars::chlit_grammar_gen<unsigned int, token_type>;
#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
Modified: branches/release/libs/wave/samples/real_positions/instantiate_cpp_literalgrs.cpp
==============================================================================
--- branches/release/libs/wave/samples/real_positions/instantiate_cpp_literalgrs.cpp (original)
+++ branches/release/libs/wave/samples/real_positions/instantiate_cpp_literalgrs.cpp 2011-05-25 15:27:24 EDT (Wed, 25 May 2011)
@@ -36,7 +36,11 @@
typedef lex_token<> token_type;
template struct boost::wave::grammars::intlit_grammar_gen<token_type>;
-template struct boost::wave::grammars::chlit_grammar_gen<token_type>;
+#if BOOST_WAVE_WCHAR_T_SIGNEDNESS == BOOST_WAVE_WCHAR_T_AUTOSELECT || \
+ BOOST_WAVE_WCHAR_T_SIGNEDNESS == BOOST_WAVE_WCHAR_T_FORCE_SIGNED
+template struct boost::wave::grammars::chlit_grammar_gen<int, token_type>;
+#endif
+template struct boost::wave::grammars::chlit_grammar_gen<unsigned int, token_type>;
#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
Modified: branches/release/libs/wave/src/instantiate_cpp_literalgrs.cpp
==============================================================================
--- branches/release/libs/wave/src/instantiate_cpp_literalgrs.cpp (original)
+++ branches/release/libs/wave/src/instantiate_cpp_literalgrs.cpp 2011-05-25 15:27:24 EDT (Wed, 25 May 2011)
@@ -41,7 +41,11 @@
// no need to change anything below
template struct boost::wave::grammars::intlit_grammar_gen<token_type>;
-template struct boost::wave::grammars::chlit_grammar_gen<token_type>;
+#if BOOST_WAVE_WCHAR_T_SIGNEDNESS == BOOST_WAVE_WCHAR_T_AUTOSELECT || \
+ BOOST_WAVE_WCHAR_T_SIGNEDNESS == BOOST_WAVE_WCHAR_T_FORCE_SIGNED
+template struct boost::wave::grammars::chlit_grammar_gen<int, token_type>;
+#endif
+template struct boost::wave::grammars::chlit_grammar_gen<unsigned int, token_type>;
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
Modified: branches/release/tools/wave/cpp.cpp
==============================================================================
--- branches/release/tools/wave/cpp.cpp (original)
+++ branches/release/tools/wave/cpp.cpp 2011-05-25 15:27:24 EDT (Wed, 25 May 2011)
@@ -143,10 +143,10 @@
"LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)",
0
};
-
+
for (int i = 0; 0 != copyright[i]; ++i)
cout << copyright[i] << endl;
-
+
return 0; // exit app
}
@@ -216,7 +216,7 @@
else {
// store this path as an user path
p->paths.push_back(t);
- }
+ }
}
};
@@ -236,7 +236,7 @@
}
return false;
}
-
+
vector<std::string> options;
std::string line;
@@ -245,7 +245,7 @@
std::string::size_type pos = line.find_first_not_of(" \t");
if (pos == std::string::npos)
continue;
-
+
// skip comment lines
if ('#' != line[pos]) {
// strip leading and trailing whitespace
@@ -281,7 +281,7 @@
}
return file;
}
-
+
///////////////////////////////////////////////////////////////////////////////
}
@@ -311,7 +311,7 @@
: print_time(false), outstrm(outstrm_)
{
}
-
+
~auto_stop_watch()
{
if (print_time) {
@@ -320,7 +320,7 @@
<< std::endl;
}
}
-
+
void set_print_time(bool print_time_)
{
print_time = print_time_;
@@ -350,7 +350,7 @@
"end-of-file while writing to the stream\n";
}
return result;
- }
+ }
///////////////////////////////////////////////////////////////////////////
// Retrieve the position of a macro definition
@@ -364,7 +364,7 @@
bool is_predefined = false;
std::vector<typename Context::token_type> parameters;
typename Context::token_sequence_type definition;
-
+
return ctx.get_macro_definition(name, has_parameters, is_predefined,
pos, parameters, definition);
}
@@ -422,7 +422,7 @@
return result;
}
-
+
///////////////////////////////////////////////////////////////////////////
// Read one logical line of text
inline bool
@@ -560,13 +560,13 @@
for (name_iterator it = ctx.macro_names_begin(); it != end; ++it)
{
typedef std::vector<context_type::token_type> parameters_type;
-
+
bool has_pars = false;
bool predef = false;
context_type::position_type pos;
parameters_type pars;
context_type::token_sequence_type def;
-
+
if (ctx.get_macro_definition(*it, has_pars, predef, pos, pars, def))
{
macronames_out << (predef ? "-P" : "-D") << *it;
@@ -666,7 +666,7 @@
std::istreambuf_iterator<char>());
#endif
}
-
+
// The preprocessing of the input stream is done on the fly behind the
// scenes during iteration over the context_type::iterator_type stream.
std::ofstream output;
@@ -871,13 +871,13 @@
ctx.get_language(), false));
}
#endif
-
+
// enable preserving comments mode
if (preserve_comments) {
ctx.set_language(
boost::wave::enable_preserve_comments(ctx.get_language()));
}
-
+
// control the generation of #line directives
if (vm.count("line")) {
int lineopt = vm["line"].as<int>();
@@ -910,7 +910,7 @@
// add include directories to the system include search paths
if (vm.count("sysinclude")) {
vector<std::string> syspaths = vm["sysinclude"].as<vector<std::string> >();
-
+
vector<std::string>::const_iterator end = syspaths.end();
for (vector<std::string>::const_iterator cit = syspaths.begin();
cit != end; ++cit)
@@ -918,7 +918,7 @@
ctx.add_sysinclude_path(cmd_line_utils::trim_quotes(*cit).c_str());
}
}
-
+
// add include directories to the include search paths
if (vm.count("include")) {
cmd_line_utils::include_paths const &ip =
@@ -934,7 +934,7 @@
// if -I- was given on the command line, this has to be propagated
if (ip.seen_separator)
ctx.set_sysinclude_delimiter();
-
+
// add system include directories to the include path
vector<std::string>::const_iterator sysend = ip.syspaths.end();
for (vector<std::string>::const_iterator syscit = ip.syspaths.begin();
@@ -943,7 +943,7 @@
ctx.add_sysinclude_path(cmd_line_utils::trim_quotes(*syscit).c_str());
}
}
-
+
// add additional defined macros
if (vm.count("define")) {
vector<std::string> const ¯os = vm["define"].as<vector<std::string> >();
@@ -980,7 +980,7 @@
}
#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS == 0
- // suppress expansion of, specified macros
+ // suppress expansion of specified macros
if (vm.count("noexpand")) {
vector<std::string> const &noexpandmacros =
vm["noexpand"].as<vector<std::string> >();
@@ -1003,7 +1003,7 @@
}
ctx.set_max_include_nesting_depth(max_depth);
}
-
+
// open the output file
if (vm.count("output")) {
// try to open the file, where to put the preprocessed output
@@ -1049,17 +1049,17 @@
// we assume the session to be interactive if input is stdin and output is
// stdout and the output is not inhibited
bool is_interactive = input_is_stdin && !output.is_open() && allow_output;
-
+
if (is_interactive) {
// if interactive we don't warn for missing endif's etc.
ctx.set_language(
- boost::wave::enable_single_line(ctx.get_language()));
+ boost::wave::enable_single_line(ctx.get_language()), false);
}
-
+
// analyze the input file
context_type::iterator_type first = ctx.begin();
context_type::iterator_type last = ctx.end();
-
+
// preprocess the required include files
if (vm.count("forceinclude")) {
// add the filenames to force as include files in _reverse_ order
@@ -1093,7 +1093,7 @@
do {
// loop over all generated tokens outputting the generated text
bool finished = false;
-
+
if (input_is_stdin) {
if (is_interactive)
cout << ">>> "; // prompt if is interactive
@@ -1104,16 +1104,16 @@
break; // end of input reached
first = ctx.begin(instring.begin(), instring.end());
}
-
+
bool need_to_advanve = false;
-
+
do {
try {
if (need_to_advanve) {
++first;
need_to_advanve = false;
}
-
+
while (first != last) {
// store the last known good token position
current_position = (*first).get_position();
@@ -1131,7 +1131,7 @@
else
cout << (*first).get_value();
}
-
+
// advance to the next token
++first;
}
@@ -1215,12 +1215,12 @@
<< " using a different configuration (see wave_config.hpp)."
<< endl;
}
-
+
// analyze the command line options and arguments
try {
// declare the options allowed on the command line only
po::options_description desc_cmdline ("Options allowed on the command line only");
-
+
desc_cmdline.add_options()
("help,h", "print out program usage (this message)")
("version,v", "print the version number")
@@ -1257,7 +1257,7 @@
("nesting,n", po::value<int>(),
"specify a new maximal include nesting depth")
;
-
+
po::options_description desc_ext ("Extended options (allowed everywhere)");
desc_ext.add_options()
@@ -1309,21 +1309,21 @@
"or 'wave.state' [-] (interactive mode only)")
#endif
;
-
+
// combine the options for the different usage schemes
po::options_description desc_overall_cmdline;
po::options_description desc_overall_cfgfile;
desc_overall_cmdline.add(desc_cmdline).add(desc_generic).add(desc_ext);
desc_overall_cfgfile.add(desc_generic).add(desc_ext);
-
+
// parse command line and store results
using namespace boost::program_options::command_line_style;
po::parsed_options opts(po::parse_command_line(argc, argv,
desc_overall_cmdline, unix_style, cmd_line_utils::at_option_parser));
po::variables_map vm;
-
+
po::store(opts, vm);
po::notify(vm);
@@ -1389,7 +1389,7 @@
cout << desc_help << endl;
return 1;
}
-
+
if (vm.count("version")) {
cout << get_version() << endl;
return 0;
Modified: branches/release/tools/wave/trace_macro_expansion.hpp
==============================================================================
--- branches/release/tools/wave/trace_macro_expansion.hpp (original)
+++ branches/release/tools/wave/trace_macro_expansion.hpp 2011-05-25 15:27:24 EDT (Wed, 25 May 2011)
@@ -17,6 +17,7 @@
#include <ostream>
#include <string>
#include <stack>
+#include <set>
#include <boost/assert.hpp>
#include <boost/config.hpp>
@@ -161,8 +162,6 @@
default_outfile(default_outfile_),
emit_relative_filenames(false)
{
- using namespace std; // some systems have time in namespace std
- time(&started_at);
}
~trace_macro_expansion()
{
@@ -1046,11 +1045,14 @@
// ensure all directories for this file do exist
fs::create_directories(boost::wave::util::branch_path(fpath));
- // figure out, whether the file to open was last accessed by us
+ // figure out, whether the file has been written to by us, if yes, we
+ // append any output to this file, otherwise we overwrite it
std::ios::openmode mode = std::ios::out;
- if (fs::exists(fpath) && fs::last_write_time(fpath) >= started_at)
+ if (fs::exists(fpath) && written_by_us.find(fpath) != written_by_us.end())
mode = (std::ios::openmode)(std::ios::out | std::ios::app);
+ written_by_us.insert(fpath);
+
// close the current file
if (outputstrm.is_open())
outputstrm.close();
@@ -1460,7 +1462,7 @@
boost::filesystem::path current_outfile; // name of the current output file
stop_watch elapsed_time; // trace timings
- std::time_t started_at; // time, this process was started at
+ std::set<boost::filesystem::path> written_by_us; // all files we have written to
typedef std::pair<bool, boost::filesystem::path> output_option_type;
std::stack<output_option_type> output_options; // output option stack
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk