|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56834 - in trunk/boost/spirit/home: lex/lexer/lexertl support
From: hartmut.kaiser_at_[hidden]
Date: 2009-10-14 12:57:44
Author: hkaiser
Date: 2009-10-14 12:57:43 EDT (Wed, 14 Oct 2009)
New Revision: 56834
URL: http://svn.boost.org/trac/boost/changeset/56834
Log:
Spirit: fixing some VC7.1 specific issues
Removed:
trunk/boost/spirit/home/support/safe_bool.hpp
Text files modified:
trunk/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp | 16 ++++++++--------
trunk/boost/spirit/home/lex/lexer/lexertl/lexer.hpp | 11 ++++++-----
trunk/boost/spirit/home/lex/lexer/lexertl/static_lexer.hpp | 12 ++++++------
trunk/boost/spirit/home/lex/lexer/lexertl/token.hpp | 25 +++++++++++++++++--------
4 files changed, 37 insertions(+), 27 deletions(-)
Modified: trunk/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp 2009-10-14 12:57:43 EDT (Wed, 14 Oct 2009)
@@ -51,10 +51,10 @@
// initialize the shared data
template <typename IterData>
- data (IterData const& data, Iterator& first, Iterator const& last)
+ data (IterData const& data_, Iterator& first, Iterator const& last)
: first_(first), last_(last)
- , state_machine_(data.state_machine_)
- , rules_(data.rules_) {}
+ , state_machine_(data_.state_machine_)
+ , rules_(data_.rules_) {}
// The following functions are used by the implementation of the
// placeholder '_state'.
@@ -183,8 +183,8 @@
// initialize the shared data
template <typename IterData>
- data (IterData const& data, Iterator& first, Iterator const& last)
- : base_type(data, first, last)
+ data (IterData const& data_, Iterator& first, Iterator const& last)
+ : base_type(data_, first, last)
, state_(0) {}
// The following functions are used by the implementation of the
@@ -255,9 +255,9 @@
, Iterator, data, std::size_t> wrap_action_type;
template <typename IterData>
- data (IterData const& data, Iterator& first, Iterator const& last)
- : base_type(data, first, last)
- , actions_(data.actions_), hold_()
+ data (IterData const& data_, Iterator& first, Iterator const& last)
+ : base_type(data_, first, last)
+ , actions_(data_.actions_), hold_()
, value_(iterator_range<Iterator>(first, last))
, has_hold_(false), has_value_(false) {}
Modified: trunk/boost/spirit/home/lex/lexer/lexertl/lexer.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/lexertl/lexer.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/lexertl/lexer.hpp 2009-10-14 12:57:43 EDT (Wed, 14 Oct 2009)
@@ -12,7 +12,6 @@
#include <iosfwd>
-#include <boost/spirit/home/support/safe_bool.hpp>
#include <boost/spirit/home/support/detail/lexer/generator.hpp>
#include <boost/spirit/home/support/detail/lexer/rules.hpp>
#include <boost/spirit/home/support/detail/lexer/consts.hpp>
@@ -145,11 +144,13 @@
, typename Functor = functor<Token, lexertl::detail::data, Iterator> >
class lexer
{
+ private:
+ struct dummy { void true_() {}; };
+ typedef void (dummy::*safe_bool)();
+
public:
- operator typename safe_bool<lexer>::result_type() const
- {
- return safe_bool<lexer>()(initialized_dfa_);
- }
+ operator safe_bool () const
+ { return !initialized_dfa_ ? 0 : &dummy::true_; }
typedef typename boost::detail::iterator_traits<Iterator>::value_type
char_type;
Modified: trunk/boost/spirit/home/lex/lexer/lexertl/static_lexer.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/lexertl/static_lexer.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/lexertl/static_lexer.hpp 2009-10-14 12:57:43 EDT (Wed, 14 Oct 2009)
@@ -10,7 +10,6 @@
#pragma once
#endif
-#include <boost/spirit/home/support/safe_bool.hpp>
#include <boost/spirit/home/lex/lexer/lexertl/token.hpp>
#include <boost/spirit/home/lex/lexer/lexertl/functor.hpp>
#include <boost/spirit/home/lex/lexer/lexertl/static_functor_data.hpp>
@@ -112,12 +111,13 @@
, typename Functor = functor<Token, detail::static_data, Iterator> >
class static_lexer
{
+ private:
+ struct dummy { void true_() {}; };
+ typedef void (dummy::*safe_bool)();
+
public:
- // operator_bool() is needed for the safe_bool base class
- operator typename safe_bool<static_lexer>::result_type() const
- {
- return safe_bool<static_lexer>()(true); // object is always valid
- }
+ // object is always valid
+ operator safe_bool() const { return &dummy::true_; }
typedef typename boost::detail::iterator_traits<Iterator>::value_type
char_type;
Modified: trunk/boost/spirit/home/lex/lexer/lexertl/token.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/lexertl/token.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/lexertl/token.hpp 2009-10-14 12:57:43 EDT (Wed, 14 Oct 2009)
@@ -10,8 +10,8 @@
#pragma once
#endif
+#include <boost/config.hpp>
#include <boost/spirit/home/qi/detail/assign_to.hpp>
-#include <boost/spirit/home/support/safe_bool.hpp>
#include <boost/spirit/home/support/attributes.hpp>
#include <boost/spirit/home/support/argument.hpp>
#include <boost/spirit/home/support/detail/lexer/generator.hpp>
@@ -150,16 +150,25 @@
std::size_t state() const { return 0; } // always '0' (INITIAL state)
+ bool is_valid() const
+ {
+ return 0 != id_ && id_type(boost::lexer::npos) != id_;
+ }
+
#if defined(BOOST_SPIRIT_DEBUG)
std::pair<Iterator, Iterator> matched_;
#endif
- // operator_bool() is needed for the safe_bool base class
- operator typename safe_bool<token>::result_type() const
- {
- return safe_bool<token>()(
- 0 != id_ && id_type(boost::lexer::npos) != id_);
- }
+// works only starting MSVC V8
+#if BOOST_MSVC >= 1500
+ private:
+ struct dummy { void true_() {}; };
+ typedef void (dummy::*safe_bool)();
+
+ public:
+ operator safe_bool () const
+ { return !is_valid() ? 0 : &dummy::true_; }
+#endif
protected:
id_type id_; // token id, 0 if nothing has been matched
@@ -354,7 +363,7 @@
inline bool
token_is_valid(token<Iterator, AttributeTypes, HasState> const& t)
{
- return t ? true : false;
+ return t.is_valid();
}
}}}}
Deleted: trunk/boost/spirit/home/support/safe_bool.hpp
==============================================================================
--- trunk/boost/spirit/home/support/safe_bool.hpp 2009-10-14 12:57:43 EDT (Wed, 14 Oct 2009)
+++ (empty file)
@@ -1,31 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2009 Joel de Guzman
- Copyright (c) 2001-2009 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_SAFE_BOOL_HPP)
-#define BOOST_SPIRIT_SAFE_BOOL_HPP
-
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
-namespace boost { namespace spirit
-{
- template<class Tag>
- class safe_bool
- {
- public:
- typedef void (safe_bool::*result_type)();
- result_type operator()(bool b) { return b ? &safe_bool::true_ : 0; }
-
- private:
- void true_() {}
- };
-
-}}
-
-#endif
-
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