|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r59538 - in trunk/boost/wave: . util
From: hartmut.kaiser_at_[hidden]
Date: 2010-02-06 18:24:07
Author: hkaiser
Date: 2010-02-06 18:24:06 EST (Sat, 06 Feb 2010)
New Revision: 59538
URL: http://svn.boost.org/trac/boost/changeset/59538
Log:
Wave: added found_unknown_directive preprocessing hook, bumped version number
Text files modified:
trunk/boost/wave/preprocessing_hooks.hpp | 31 +++++++++++++++++++++++++++++++
trunk/boost/wave/util/cpp_iterator.hpp | 25 +++++++++++++++++++++++--
trunk/boost/wave/wave_version.hpp | 4 ++--
3 files changed, 56 insertions(+), 4 deletions(-)
Modified: trunk/boost/wave/preprocessing_hooks.hpp
==============================================================================
--- trunk/boost/wave/preprocessing_hooks.hpp (original)
+++ trunk/boost/wave/preprocessing_hooks.hpp 2010-02-06 18:24:06 EST (Sat, 06 Feb 2010)
@@ -477,6 +477,37 @@
///////////////////////////////////////////////////////////////////////////
//
+ // The function 'found_unknown_directive' is called, whenever an unknown
+ // preprocessor directive was encountered.
+ //
+ // The parameter 'ctx' is a reference to the context object used for
+ // instantiating the preprocessing iterators by the user.
+ //
+ // The parameter 'directive' is a reference to the token holding the
+ // preprocessing directive.
+ //
+ // The parameter 'line' holds the entire source line containing the
+ // unknown directive.
+ //
+ // The parameter 'pending' may be used to push tokens back into the input
+ // stream, which are to be used as the replacement text for the whole
+ // line containing the unknown directive.
+ //
+ // The return value defines, whether the given expression has been
+ // properly interpreted by the hook function or not. If this function
+ // returns 'false', the library will raise an 'ill_formed_directive'
+ // preprocess_exception. Otherwise the tokens pushed back into 'pending'
+ // are passed on to the user program.
+ //
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename ContextT, typename ContainerT>
+ bool
+ found_unknown_directive(ContextT const& ctx, ContainerT const& line,
+ ContainerT& pending)
+ { return false; } // by default we never interpret unknown directives
+
+ ///////////////////////////////////////////////////////////////////////////
+ //
// The function 'evaluated_conditional_expression' is called, whenever a
// conditional preprocessing expression was evaluated (the expression
// given to a #if, #elif, #ifdef or #ifndef directive)
Modified: trunk/boost/wave/util/cpp_iterator.hpp
==============================================================================
--- trunk/boost/wave/util/cpp_iterator.hpp (original)
+++ trunk/boost/wave/util/cpp_iterator.hpp 2010-02-06 18:24:06 EST (Sat, 06 Feb 2010)
@@ -1255,7 +1255,28 @@
}
else if (ctx.get_if_block_status()) {
// report invalid pp directive
- on_illformed((*it).get_value());
+ impl::skip_to_eol(ctx, it, iter_ctx->last);
+ seen_newline = true;
+
+ string_type str(boost::wave::util::impl::as_string<string_type>(
+ iter_ctx->first, it));
+
+ token_sequence_type faulty_line;
+
+ for (/**/; iter_ctx->first != it; ++iter_ctx->first)
+ faulty_line.push_back(*iter_ctx->first);
+
+ token_sequence_type pending;
+ if (ctx.get_hooks().found_unknown_directive(ctx, faulty_line, pending))
+ {
+ // if there is some replacement text, insert it into the pending queue
+ if (!pending.empty())
+ pending_queue.splice(pending_queue.begin(), pending);
+ return true;
+ }
+
+ // default behavior is to throw an exception
+ on_illformed(str);
}
}
@@ -2399,7 +2420,7 @@
token_sequence_type pending;
if (interpret_pragma(expanded, pending)) {
// if there is some replacement text, insert it into the pending queue
- if (pending.size() > 0)
+ if (!pending.empty())
pending_queue.splice(pending_queue.begin(), pending);
return true; // this #pragma was successfully recognized
}
Modified: trunk/boost/wave/wave_version.hpp
==============================================================================
--- trunk/boost/wave/wave_version.hpp (original)
+++ trunk/boost/wave/wave_version.hpp 2010-02-06 18:24:06 EST (Sat, 06 Feb 2010)
@@ -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 0x020004
+#define BOOST_WAVE_VERSION 0x020005
// The following defines contain the same information as above
#define BOOST_WAVE_VERSION_MAJOR 2
#define BOOST_WAVE_VERSION_MINOR 0
-#define BOOST_WAVE_VERSION_SUBMINOR 4
+#define BOOST_WAVE_VERSION_SUBMINOR 5
#endif // !defined(WAVE_VERSION_H_9D79ABDB_AC54_4C0A_89B1_F70A2DCFE21E_INCLUDED)
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