Skip to content

Commit

Permalink
Added config support for Wave #pragma command directives.
Browse files Browse the repository at this point in the history
[SVN r31980]
  • Loading branch information
hkaiser committed Dec 11, 2005
1 parent bb62cff commit cd419d7
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 127 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ CHANGELOG
the generated output to a file named after the input file changing the file
extension to '.i'.
- Changed all throw's to boost::throw_exception.
- Added the possibility to config the command keyword for the wave specific
#pragma directives. It is now possible to define a string literal via
BOOST_WAVE_PRAGMA_COMMAND, which will be recognized and all corresponding
#pragma's are fdispatched to the interpret_pragma() preprocessing hook.
The default value for BOOST_WAVE_PRAGMA_COMMAND is "wave" to ensure complete
backward compatibility.

Mon Dec 5 22:05:22 CST 2005
Boost V1.33.1
Expand Down
4 changes: 2 additions & 2 deletions doc/acknowledgements.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</blockquote>
<p> Special thanks also to people who gave feedback and valuable comments, particularly members of Boost and Spirit mailing lists. This includes all those who participated in the Boost review:
<blockquote>
<p><strong>Tom Brinkman</strong> (who volunteered to be the review managaer), <strong>David Abrahams</strong>, <strong>Beman Dewes</strong>, <strong>Reece Dunn</strong>, <strong>Larry Evans</strong>, <strong>Doug Gregor</strong>, <strong>Joel de Guzman</strong>, <strong>Baptiste Lepilleur</strong>, <strong>Andy Little</strong>, <strong>Paul Mensonides</strong>, <strong>Dan Nuffer</strong>, <strong>Andreas Pokorny</strong>, <strong>Vladimir Prus</strong>, <strong>Gennadiy Rozental</strong>, <strong>Michiel Salters</strong>, <strong>Jonathan Turkanis</strong>, <strong>Chris Uzdavinis</strong>, <strong>Pavel Vozenilek</strong>, <strong>Michael Walter</strong></p>
<p><strong>Tom Brinkman</strong> (who volunteered to be the review manager), <strong>David Abrahams</strong>, <strong>Beman Dewes</strong>, <strong>Reece Dunn</strong>, <strong>Larry Evans</strong>, <strong>Doug Gregor</strong>, <strong>Joel de Guzman</strong>, <strong>Baptiste Lepilleur</strong>, <strong>Andy Little</strong>, <strong>Paul Mensonides</strong>, <strong>Dan Nuffer</strong>, <strong>Andreas Pokorny</strong>, <strong>Vladimir Prus</strong>, <strong>Gennadiy Rozental</strong>, <strong>Michiel Salters</strong>, <strong>Jonathan Turkanis</strong>, <strong>Chris Uzdavinis</strong>, <strong>Pavel Vozenilek</strong>, <strong>Michael Walter</strong></p>
</blockquote>
<p>The <tt>Wave</tt> library uses the following <tt>Boost</tt> <a href="references.html#boost">[8]</a>
libraries:</p>
Expand Down Expand Up @@ -85,7 +85,7 @@
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
</font> </p>
<span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
<!-- #BeginDate format:fcAm1m -->Saturday, December 10, 2005 18:02<!-- #EndDate -->
</span>
</body>
</html>
8 changes: 7 additions & 1 deletion doc/compiletime_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@
strict C99/C++ basic source character set. If it is not defined or defined
to zero, the lexers recognize the <span class="string">'$'</span> character as part of identifiers.</p></td>
</tr>
<tr>
<td class="table_cells"><code>BOOST_WAVE_PRAGMA_KEYWORD</code></td>
<td class="table_cells"><p>If this is defined to a string literal it will be used as the pragma keyword recogniyed by the library as specific Wave pragma's. This constant defaults to <span class="literal">&quot;wave&quot;</span>, i.e. the library recognizes all <span class="preprocessor">#pragma wave option [(argument)]</span> directives and dispatches the handling to the interpret_pragma() preprocessing hook function (see: <a href="class_reference_ctxpolicy.html">Preprocessing Hooks</a>). The arguments part of the pragma is optional.<br>
</p>
</td>
</tr>
</table>
<P dir="ltr"><b><a name="using_custom_lexer"></a>Using a different token type or lexer type in conjunction with Wave </b></P>
<P dir="ltr">It is possible to use the <tt>Wave</tt> library while using your own token and/or lexer types. This may be achieved by providing your lexer type as the second template parameter while instantiating the <tt>boost::wave::context&lt;&gt;</tt> object. The token type used by the library is derived from the <tt>token_type</tt> typedef to be provided by the lexer type. If you want to provide your own token type only, you may use the <tt>boost::wave::lex_iterator&lt;&gt;</tt> type contained with the library. This type needs to be parametrized with the token type to use. </P>
Expand Down Expand Up @@ -203,7 +209,7 @@
<font size="2">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) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Saturday, November 19, 2005 11:17<!-- #EndDate -->
<!-- #BeginDate format:fcAm1m -->Saturday, December 10, 2005 14:59<!-- #EndDate -->
</span></p>
</body>
</html>
18 changes: 9 additions & 9 deletions doc/supported_pragmas.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<td width="30"><a href="macro_expansion_process.html"><img src="theme/r_arr.gif" border="0"></a></td>
</tr>
</table>
<p>The Wave preprocessor library supports a couple of specific <tt>#pragma</tt>
<p>The Wave preprocessor library supports specific <tt>#pragma</tt>
directives, which may be used to control some of the library features. All directives
described here are usable as conventional <tt>#pragma</tt> directives and as
<tt>operator&nbsp;_Pragma</tt> (if variadics are enabled). So for instance the
Expand All @@ -33,10 +33,10 @@
<p>and </p>
<pre> _Pragma(&quot;wave trace(enable)&quot;)</pre>
<p>All <tt>Wave</tt> specific pragma's must have the general form <tt>'wave option[(value)]'</tt>,
where <tt>'wave'</tt> is the specific keyword, <tt>'option'</tt> is the concrete
where <tt>'wave'</tt> is the specific keyword (which may be configured through the <tt>BOOST_WAVE_PRAGMA_KEYWORD</tt> compile time constant, see <a href="compiletime_config.html">here</a> for more information), <tt>'option'</tt> is the concrete
pragma functionality to trigger and <tt>'value'</tt> is an optional value to
be supplied to the <tt>'option'</tt> functionality. The following table lists
all possible pragma functions supported by the <tt>Wave</tt> library. For all recognised pragmas of this general form the interpret_pragma hook function from inside the context_policies are call, so that the user of the library is responsible for </p>
all possible pragma functions supported by the <tt>Wave</tt> library. For all recognised pragmas of this general form the interpret_pragma hook function from inside the <a href="class_reference_ctxpolicy.html">preprocessing_hooks</a> policy are called, so that the user of the library is responsible for the correct interpretation of these pragma's. </p>
<table width="77%" border="0" align="center">
<tr>
<td colspan="4"> <p class="table_title">Supported pragma's</p></td>
Expand Down Expand Up @@ -92,20 +92,20 @@
<td class="table_cells"><p>Wave driver</p></td>
</tr>
</table>
<p>All pragma's not listed here but flagged as <tt>'wave'</tt> are reported as
<p>All pragma's not listed here but flagged as <tt>'wave'</tt> are currently reported as
errors. The handling of all remaining pragma's depends on the compilation constant
<code><tt>WAVE_RETURN_PRAGMA_DIRECTIVES</tt></code>, which allows to specify,
<code><tt>BOOST_WAVE_RETURN_PRAGMA_DIRECTIVES</tt></code>, which allows to specify,
if those pragmas are left unchanged in the output stream or not. Please note,
that the operator _Pragma variant is always subject to full preprocessing, before
the pragma itself is evaluated. The #pragma variant is subject to preprocessing
only, if the <code><tt>WAVE_PREPROCESS_PRAGMA_BODY</tt></code> compilation constant
only, if the <code><tt>BOOST_WAVE_PREPROCESS_PRAGMA_BODY</tt></code> compilation constant
was specified during compilation. For more information about the possible compilation
constants look <a href="compiletime_config.html">here</a>.</p>
<p>Additionally the Wave preprocessor supports the <tt>#pragma once</tt> directive,
which specifies that the file, in which the pragma resides, will be included
(opened) only once by the compiler in a build. This may be used to optimize
the preprocessing of larger compilation units, which include a lot of files. Note though, that the #pragma once directive is supported only, if the compile time constant <tt>WAVE_SUPPORT_PRAGMA_ONCE</tt> was given during compilation of the library</span>.</p>
<p>It is fairly easy to implement your own <tt>#pragma wave ... </tt> directives. All you have to do is to implement your own <tt>interpret_pragma</tt> function (see <a href="class_reference_ctxpolicy.html#interpret_pragma">here</a>) which should the handle additional directives. For an example of how to do it, you may have a look at the Wave driver application, which implements the <tt>#pragma wave timer()</tt> directive with the help of a supplied <tt>interpret_pragma</tt> function. </p>
the preprocessing of larger compilation units, which include a lot of files. Note though, that the #pragma once directive is supported only, if the compile time constant <tt>BOOST_WAVE_SUPPORT_PRAGMA_ONCE</tt> was given during compilation of the library</span>.</p>
<p>It is fairly easy to implement your own <tt>#pragma wave ... </tt> directives. All you have to do is to implement your own <tt>interpret_pragma</tt> function (see <a href="class_reference_ctxpolicy.html#interpret_pragma">here</a>) which should handle the additional directives. For an example of how to do it, you may have a look at the Wave driver application, which implements all of the pragma's listed above (for instance the the <tt>#pragma wave timer()</tt> directive) with the help of a supplied <tt>interpret_pragma</tt> function. </p>
<table border="0">
<tr>
<td width="10"></td>
Expand All @@ -120,7 +120,7 @@
<font size="2">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) </font> </p>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated:
<!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate -->
<!-- #BeginDate format:fcAm1m -->Saturday, December 10, 2005 15:04<!-- #EndDate -->
</span>
</p>
<p>&nbsp;</p>
Expand Down
3 changes: 1 addition & 2 deletions include/boost/wave/cpp_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,7 @@ class context {
bool interpret_pragma(ContainerT &pending, token_type const &option,
ContainerT const &values, token_type const &act_token)
{
return hooks.interpret_pragma(*this, pending, option, values,
act_token);
return hooks.interpret_pragma(*this, pending, option, values, act_token);
}

private:
Expand Down
38 changes: 19 additions & 19 deletions include/boost/wave/cpp_exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,31 @@
#include <strstream>
#define BOOST_WAVE_THROW(cls, code, msg, act_pos) \
{ \
using namespace boost::wave; \
std::strstream stream; \
stream << cls::severity_text(cls::code) << ": " \
<< cls::error_text(cls::code); \
if ((msg)[0] != 0) stream << ": " << (msg); \
stream << std::ends; \
std::string throwmsg = stream.str(); stream.freeze(false); \
boost::throw_exception(cls(throwmsg.c_str(), cls::code, \
(act_pos).get_line(), (act_pos).get_column(), \
(act_pos).get_file().c_str())); \
using namespace boost::wave; \
std::strstream stream; \
stream << cls::severity_text(cls::code) << ": " \
<< cls::error_text(cls::code); \
if ((msg)[0] != 0) stream << ": " << (msg); \
stream << std::ends; \
std::string throwmsg = stream.str(); stream.freeze(false); \
boost::throw_exception(cls(throwmsg.c_str(), cls::code, \
(act_pos).get_line(), (act_pos).get_column(), \
(act_pos).get_file().c_str())); \
} \
/**/
#else
#include <sstream>
#define BOOST_WAVE_THROW(cls, code, msg, act_pos) \
{ \
using namespace boost::wave; \
std::stringstream stream; \
stream << cls::severity_text(cls::code) << ": " \
<< cls::error_text(cls::code); \
if ((msg)[0] != 0) stream << ": " << (msg); \
stream << std::ends; \
boost::throw_exception(cls(stream.str().c_str(), cls::code, \
(act_pos).get_line(), (act_pos).get_column(), \
(act_pos).get_file().c_str())); \
using namespace boost::wave; \
std::stringstream stream; \
stream << cls::severity_text(cls::code) << ": " \
<< cls::error_text(cls::code); \
if ((msg)[0] != 0) stream << ": " << (msg); \
stream << std::ends; \
boost::throw_exception(cls(stream.str().c_str(), cls::code, \
(act_pos).get_line(), (act_pos).get_column(), \
(act_pos).get_file().c_str())); \
} \
/**/
#endif // BOOST_NO_STRINGSTREAM
Expand Down
10 changes: 6 additions & 4 deletions include/boost/wave/preprocessing_hooks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,17 @@ struct default_preprocessing_hooks {

///////////////////////////////////////////////////////////////////////////
//
// The function 'interpret_pragma' is called, whenever a #pragma wave
// directive is found, which isn't known to the core Wave library.
// The function 'interpret_pragma' is called, whenever a #pragma command
// directive is found which isn't known to the core Wave library, where
// command is the value defined as the BOOST_WAVE_PRAGMA_KEYWORD constant
// which defaults to "wave".
//
// The parameter 'ctx' is a reference to the context object used for
// instantiating the preprocessing iterators by the user.
//
// 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
// #pragma wave() directive.
// #pragma directive.
//
// The parameter 'option' contains the name of the interpreted pragma.
//
Expand All @@ -186,7 +188,7 @@ struct default_preprocessing_hooks {
{
return false;
}

///////////////////////////////////////////////////////////////////////////
//
// The function 'defined_macro' is called, whenever a macro was defined
Expand Down
2 changes: 1 addition & 1 deletion include/boost/wave/util/cpp_macromap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ macromap<ContextT>::concat_tokensequence(ContainerT &expanded)
// Here we have to work around a conflict between the Standards
// requirement, that the preprocessor has to act upon so called
// pp-tokens and the fact, that Wave acts upon C++ tokens. So we have
// eventually to combine the current token with the next tokens
// sometimes to combine the current token with the next tokens
// if these are of type T_IDENTIFIER or T_INTLIT following without any
// interventing whitespace.
// Please note though, that this hack unfortunately doesn't fix all
Expand Down
2 changes: 1 addition & 1 deletion include/boost/wave/util/insert_whitespace_detection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class insert_whitespace_detection
bool must_insert(boost::wave::token_id current, StringT const &value)
{
using namespace boost::wave;
switch (current) {
switch (static_cast<unsigned int>(current)) {
case T_NONREPLACABLE_IDENTIFIER:
case T_IDENTIFIER:
return impl::handle_identifier(prev, beforeprev, value);
Expand Down
Loading

0 comments on commit cd419d7

Please sign in to comment.