Skip to content

Commit

Permalink
Changed in the Wave library all throw's to boost::throw_exception().
Browse files Browse the repository at this point in the history
[SVN r31950]
  • Loading branch information
hkaiser committed Dec 8, 2005
1 parent c14a346 commit bb62cff
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 23 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ CHANGELOG
- Added the --autooutput (-E) option to the Wave driver applet which redirects
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.

Mon Dec 5 22:05:22 CST 2005
Boost V1.33.1
Expand Down
11 changes: 7 additions & 4 deletions include/boost/wave/cpp_exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/throw_exception.hpp>

#include <boost/wave/wave_config.hpp>

Expand All @@ -38,8 +39,9 @@
if ((msg)[0] != 0) stream << ": " << (msg); \
stream << std::ends; \
std::string throwmsg = stream.str(); stream.freeze(false); \
throw cls(throwmsg.c_str(), cls::code, (act_pos).get_line(), \
(act_pos).get_column(), (act_pos).get_file().c_str()); \
boost::throw_exception(cls(throwmsg.c_str(), cls::code, \
(act_pos).get_line(), (act_pos).get_column(), \
(act_pos).get_file().c_str())); \
} \
/**/
#else
Expand All @@ -52,8 +54,9 @@
<< cls::error_text(cls::code); \
if ((msg)[0] != 0) stream << ": " << (msg); \
stream << std::ends; \
throw cls(stream.str().c_str(), cls::code, (act_pos).get_line(), \
(act_pos).get_column(), (act_pos).get_file().c_str()); \
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
12 changes: 8 additions & 4 deletions include/boost/wave/cpplexer/cpplexer_exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/throw_exception.hpp>

#include <boost/wave/wave_config.hpp>

// this must occur after all of the includes and before any code appears
Expand All @@ -34,10 +36,11 @@
std::strstream stream; \
stream << cls::severity_text(cls::code) << ": " \
<< cls::error_text(cls::code); \
if (msg[0] != 0) stream << ": " << msg; \
if ((msg)[0] != 0) stream << ": " << (msg); \
stream << std::ends; \
std::string throwmsg = stream.str(); stream.freeze(false); \
throw cls(throwmsg.c_str(), cls::code, line, column, name); \
boost::throw_exception(cls(throwmsg.c_str(), cls::code, line, column, \
name)); \
} \
/**/
#else
Expand All @@ -48,9 +51,10 @@
std::stringstream stream; \
stream << cls::severity_text(cls::code) << ": " \
<< cls::error_text(cls::code); \
if (msg[0] != 0) stream << ": " << msg; \
if ((msg)[0] != 0) stream << ": " << (msg); \
stream << std::ends; \
throw cls(stream.str().c_str(), cls::code, line, column, name); \
boost::throw_exception(cls(stream.str().c_str(), cls::code, line, column, \
name)); \
} \
/**/
#endif // BOOST_NO_STRINGSTREAM
Expand Down
3 changes: 2 additions & 1 deletion include/boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ lexer<IteratorT, PositionT>::report_error(Scanner const *s, char const *msg, ...

BOOST_WAVE_LEXER_THROW(lexing_exception, generic_lexing_error, buffer,
s->line, s->column, s->file_name);
BOOST_UNREACHABLE_RETURN(0);
// BOOST_UNREACHABLE_RETURN(0);
return 0;
}

///////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion include/boost/wave/grammars/cpp_expression_grammar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ expression_grammar_gen<TokenT>::evaluate(
catch (wave::preprocess_exception const& e) {
// expression is illformed
if (if_block_status) {
throw e;
boost::throw_exception(e);
}
else {
// as the if_block_status is false no errors will be reported
Expand Down
10 changes: 6 additions & 4 deletions include/boost/wave/util/flex_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class StoragePolicy

#include <boost/config.hpp>
#include <boost/assert.hpp>
#include <boost/throw_exception.hpp>

#include <boost/iterator/reverse_iterator.hpp>

#include <memory>
Expand Down Expand Up @@ -197,7 +199,7 @@ template <class T> class mallocator
{
using namespace std;
void* p = malloc(n * sizeof(T));
if (!p) throw bad_alloc();
if (!p) boost::throw_exception(std::bad_alloc());
return static_cast<pointer>(p);
}

Expand Down Expand Up @@ -312,7 +314,7 @@ class SimpleStringStorage
// has one one character in there
pData_ = static_cast<Data*>(
malloc(sizeof(Data) + capacity * sizeof(E)));
if (!pData_) throw std::bad_alloc();
if (!pData_) boost::throw_exception(std::bad_alloc());
pData_->pEnd_ = pData_->buffer_ + size;
pData_->pEndOfMem_ = pData_->buffer_ + capacity;
}
Expand Down Expand Up @@ -411,7 +413,7 @@ class SimpleStringStorage

void* p = realloc(pData_,
sizeof(Data) + res_arg * sizeof(E));
if (!p) throw std::bad_alloc();
if (!p) boost::throw_exception(std::bad_alloc());

if (p != pData_)
{
Expand Down Expand Up @@ -1387,7 +1389,7 @@ class flex_string : private Storage
#if defined(THROW_ON_ENFORCE)
template <typename Exception>
static void Enforce(bool condition, Exception*, const char* msg)
{ if (!condition) throw Exception(msg); }
{ if (!condition) boost::throw_exception(Exception(msg)); }
#else
template <typename Exception>
static inline void Enforce(bool condition, Exception*, const char* msg)
Expand Down
18 changes: 10 additions & 8 deletions samples/cpp_tokens/slex/lexer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
#define BOOST_SPIRIT_LEXER_HPP

///////////////////////////////////////////////////////////////////////////////
#include <boost/throw_exception.hpp>

#include <boost/spirit/core.hpp>
#include <boost/spirit/symbols/symbols.hpp>
#include <boost/spirit/utility/chset.hpp>
Expand Down Expand Up @@ -1720,7 +1722,7 @@ class make_string
// empty string not allowed
if (*scan.first == '"')
{
throw bad_regex();
boost::throw_exception(bad_regex());
}

const escape_char_parser<lex_escapes, char_t> lex_escape_ch =
Expand Down Expand Up @@ -1784,7 +1786,7 @@ class make_rep1
unsigned int count;
uint_p[assign(count)].parse(scan);
if (count == 0)
throw bad_regex();
boost::throw_exception(bad_regex());

node* top_node = m_stack.top();
m_stack.pop();
Expand Down Expand Up @@ -1820,7 +1822,7 @@ class make_rep2
unsigned int count;
uint_p[assign(count)].parse(scan);
if (count == 0)
throw bad_regex();
boost::throw_exception(bad_regex());

node* top_node = m_stack.top();
m_stack.pop();
Expand Down Expand Up @@ -1858,13 +1860,13 @@ class make_rep3
unsigned int count1, count2;
uint_p[assign(count1)].parse(scan);
if (count1 == 0)
throw bad_regex();
boost::throw_exception(bad_regex());

++scan.first; // skip over ','

uint_p[assign(count2)].parse(scan);
if (count2 <= count1)
throw bad_regex();
boost::throw_exception(bad_regex());

node* top_node = m_stack.top();
m_stack.pop();
Expand Down Expand Up @@ -2409,19 +2411,19 @@ parse_regexes(const RegexListT& regex_list, GrammarT& g)
{
// parse the expressions into a tree
if (regex_list.begin() == regex_list.end())
throw bad_regex();
boost::throw_exception(bad_regex());

typename RegexListT::const_iterator ri = regex_list.begin();
std::auto_ptr<node> tree(lexerimpl::parse(g, (*ri).str));
if (tree.get() == 0)
throw bad_regex();
boost::throw_exception(bad_regex());

++ri;
for (/**/; ri != regex_list.end(); ++ri)
{
std::auto_ptr<node> next_tree(lexerimpl::parse(g, (*ri).str));
if (next_tree.get() == 0)
throw bad_regex();
boost::throw_exception(bad_regex());
std::auto_ptr<node> newnode(new or_node(tree.release(), next_tree.release()));
tree = newnode;
}
Expand Down
1 change: 1 addition & 0 deletions samples/waveidl/idllexer/idl_re2c_lexer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ lexer<IteratorT, PositionT>::report_error(scanner_t const *s, char const* msg, .

BOOST_WAVE_LEXER_THROW(boost::wave::cpplexer::lexing_exception,
generic_lexing_error, buffer, s->line, -1, s->file_name);
return 0;
}

///////////////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 2 additions & 1 deletion test/testwave/testwave_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

// include boost
#include <boost/config.hpp>
#include <boost/throw_exception.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/detail/workaround.hpp>
Expand Down Expand Up @@ -714,7 +715,7 @@ namespace {
// CW 8.3 has problems with the v.as<T>() below
T const* r = boost::any_cast<T>(&v.value());
if (!r)
throw boost::bad_any_cast();
boost::throw_exception(boost::bad_any_cast());
return *r;
#else
return v.as<T>();
Expand Down

0 comments on commit bb62cff

Please sign in to comment.