Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56842 - in branches/release: boost/spirit/home boost/spirit/home/karma/char boost/spirit/home/lex/lexer/lexertl boost/spirit/home/qi/char boost/spirit/home/qi/nonterminal boost/spirit/home/qi/numeric/detail boost/spirit/home/support boost/spirit/home/support/detail boost/spirit/include boost/spirit/repository/home/qi/nonterminal libs/spirit/test/karma libs/spirit/test/lex libs/spirit/test/qi
From: hartmut.kaiser_at_[hidden]
Date: 2009-10-14 15:14:39


Author: hkaiser
Date: 2009-10-14 15:14:36 EDT (Wed, 14 Oct 2009)
New Revision: 56842
URL: http://svn.boost.org/trac/boost/changeset/56842

Log:
Spirit: merging fixes related to VC7.1 from trunk
Removed:
   branches/release/boost/spirit/home/support/safe_bool.hpp
   branches/release/boost/spirit/include/support_safe_bool.hpp
Properties modified:
   branches/release/boost/spirit/home/qi/nonterminal/rule.hpp (props changed)
   branches/release/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp (props changed)
   branches/release/boost/spirit/home/support/attributes.hpp (props changed)
   branches/release/boost/spirit/repository/home/qi/nonterminal/subrule.hpp (props changed)
   branches/release/libs/spirit/test/qi/optional.cpp (props changed)
Text files modified:
   branches/release/boost/spirit/home/karma/char/char.hpp | 4 +-
   branches/release/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp | 16 ++++----
   branches/release/boost/spirit/home/lex/lexer/lexertl/lexer.hpp | 11 +++--
   branches/release/boost/spirit/home/lex/lexer/lexertl/static_lexer.hpp | 12 +++---
   branches/release/boost/spirit/home/lex/lexer/lexertl/token.hpp | 25 +++++++++----
   branches/release/boost/spirit/home/qi/char/char.hpp | 8 ++--
   branches/release/boost/spirit/home/support.hpp | 1
   branches/release/boost/spirit/home/support/detail/what_function.hpp | 2
   branches/release/boost/spirit/home/support/meta_compiler.hpp | 72 ++++++++++++++++++++++++++++++++++++++++
   branches/release/libs/spirit/test/karma/bool.cpp | 13 +++---
   branches/release/libs/spirit/test/lex/regression001.cpp | 2
   11 files changed, 123 insertions(+), 43 deletions(-)

Modified: branches/release/boost/spirit/home/karma/char/char.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/char/char.hpp (original)
+++ branches/release/boost/spirit/home/karma/char/char.hpp 2009-10-14 15:14:36 EDT (Wed, 14 Oct 2009)
@@ -228,8 +228,8 @@
         info what(Context& /*context*/) const
         {
             info result("char-range", char_encoding::toucs4(from));
- boost::get<std::string&>(result.value) += '-';
- boost::get<std::string&>(result.value) += to_utf8(char_encoding::toucs4(to));
+ boost::get<std::string>(result.value) += '-';
+ boost::get<std::string>(result.value) += to_utf8(char_encoding::toucs4(to));
             return result;
         }
 

Modified: branches/release/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp 2009-10-14 15:14:36 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: branches/release/boost/spirit/home/lex/lexer/lexertl/lexer.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/lexer.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexertl/lexer.hpp 2009-10-14 15:14:36 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_ ? &dummy::true_ : 0; }
 
         typedef typename boost::detail::iterator_traits<Iterator>::value_type
             char_type;

Modified: branches/release/boost/spirit/home/lex/lexer/lexertl/static_lexer.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/static_lexer.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexertl/static_lexer.hpp 2009-10-14 15:14:36 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: branches/release/boost/spirit/home/lex/lexer/lexertl/token.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/token.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexertl/token.hpp 2009-10-14 15:14:36 EDT (Wed, 14 Oct 2009)
@@ -10,8 +10,9 @@
 #pragma once
 #endif
 
+#include <boost/config.hpp>
+#include <boost/detail/workaround.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 +151,24 @@
 
         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_WORKAROUND(BOOST_MSVC, <= 1400)
+ private:
+ struct dummy { void true_() {}; };
+ typedef void (dummy::*safe_bool)();
+
+ public:
+ operator safe_bool() const { return is_valid() ? &dummy::true_ : 0; }
+#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();
     }
 
 }}}}

Modified: branches/release/boost/spirit/home/qi/char/char.hpp
==============================================================================
--- branches/release/boost/spirit/home/qi/char/char.hpp (original)
+++ branches/release/boost/spirit/home/qi/char/char.hpp 2009-10-14 15:14:36 EDT (Wed, 14 Oct 2009)
@@ -202,8 +202,8 @@
         info what(Context& /*context*/) const
         {
             info result("char-range", char_encoding::toucs4(from));
- boost::get<std::string&>(result.value) += '-';
- boost::get<std::string&>(result.value) += to_utf8(char_encoding::toucs4(to));
+ boost::get<std::string>(result.value) += '-';
+ boost::get<std::string>(result.value) += to_utf8(char_encoding::toucs4(to));
             return result;
         }
 
@@ -240,8 +240,8 @@
         info what(Context& /*context*/) const
         {
             info result("no-case-char-range", char_encoding::toucs4(from_lo));
- boost::get<std::string&>(result.value) += '-';
- boost::get<std::string&>(result.value) += to_utf8(char_encoding::toucs4(to_lo));
+ boost::get<std::string>(result.value) += '-';
+ boost::get<std::string>(result.value) += to_utf8(char_encoding::toucs4(to_lo));
             return result;
         }
 

Modified: branches/release/boost/spirit/home/support.hpp
==============================================================================
--- branches/release/boost/spirit/home/support.hpp (original)
+++ branches/release/boost/spirit/home/support.hpp 2009-10-14 15:14:36 EDT (Wed, 14 Oct 2009)
@@ -24,7 +24,6 @@
 #include<boost/spirit/home/support/make_component.hpp>
 #include<boost/spirit/home/support/meta_compiler.hpp>
 #include<boost/spirit/home/support/modify.hpp>
-#include<boost/spirit/home/support/safe_bool.hpp>
 #include<boost/spirit/home/support/sequence_base_id.hpp>
 #include<boost/spirit/home/support/string_traits.hpp>
 #include<boost/spirit/home/support/terminal.hpp>

Modified: branches/release/boost/spirit/home/support/detail/what_function.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/detail/what_function.hpp (original)
+++ branches/release/boost/spirit/home/support/detail/what_function.hpp 2009-10-14 15:14:36 EDT (Wed, 14 Oct 2009)
@@ -28,7 +28,7 @@
         template <typename Component>
         void operator()(Component const& component) const
         {
- get<std::list<info>&>(what.value).push_back(component.what(context));
+ get<std::list<info> >(what.value).push_back(component.what(context));
         }
 
         info& what;

Modified: branches/release/boost/spirit/home/support/meta_compiler.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/meta_compiler.hpp (original)
+++ branches/release/boost/spirit/home/support/meta_compiler.hpp 2009-10-14 15:14:36 EDT (Wed, 14 Oct 2009)
@@ -12,6 +12,8 @@
 #pragma once
 #endif
 
+#include <boost/config.hpp>
+#include <boost/detail/workaround.hpp>
 #include <boost/proto/proto.hpp>
 #include <boost/spirit/home/support/make_component.hpp>
 #include <boost/spirit/home/support/modify.hpp>
@@ -54,6 +56,9 @@
             !use_operator<Domain, proto::tag::subscript>::value
         ), error_proto_tag_subscript_cannot_be_used, ());
 
+#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
+ // this is the non-broken part for compilers properly supporting
+ // partial template specialization (VC7.1 does not)
         struct cases
         {
             template <typename Tag, typename Enable = void>
@@ -113,6 +118,73 @@
>
             {};
         };
+#else
+ // this part actually constitutes invalid C++ code, but it allows us to
+ // convince VC7.1 to do what we want
+ struct cases
+ {
+ template <typename Tag, typename Enable = void>
+ struct case_
+ : proto::not_<proto::_>
+ {};
+
+ ///////////////////////////////////////////////////////////////////
+ // terminals
+ ///////////////////////////////////////////////////////////////////
+ template <>
+ struct case_<proto::tag::terminal>
+ : proto::when<
+ proto::if_<use_terminal<Domain, proto::_value>()>,
+ detail::make_terminal<Domain>
+ >
+ {};
+
+ template <typename Tag>
+ struct case_<Tag>
+ : proto::or_<
+ ///////////////////////////////////////////////////////////////////
+ // binary operators
+ ///////////////////////////////////////////////////////////////////
+ proto::when<proto::binary_expr<
+ typename enable_if<use_operator<Domain, Tag>, Tag>::type
+ , meta_grammar, meta_grammar>
+ , detail::make_binary<Domain, Tag, meta_grammar>
+ >,
+ ///////////////////////////////////////////////////////////////////
+ // unary operators
+ ///////////////////////////////////////////////////////////////////
+ proto::when<proto::unary_expr<
+ typename enable_if<use_operator<Domain, Tag>, Tag>::type
+ , meta_grammar>
+ , detail::make_unary<Domain, Tag, meta_grammar>
+ >
+ >
+ {};
+
+ template <>
+ struct case_<proto::tag::subscript>
+ : proto::or_<
+ ///////////////////////////////////////////////////////////////////
+ // directives
+ ///////////////////////////////////////////////////////////////////
+ proto::when<proto::binary_expr<proto::tag::subscript
+ , proto::and_<
+ proto::terminal<proto::_>
+ , proto::if_<use_directive<Domain, proto::_value >()> >
+ , meta_grammar>,
+ detail::make_directive<Domain, meta_grammar>
+ >,
+ ///////////////////////////////////////////////////////////////////
+ // semantic actions
+ ///////////////////////////////////////////////////////////////////
+ proto::when<proto::binary_expr<proto::tag::subscript
+ , meta_grammar, proto::_>,
+ detail::make_action<Domain, meta_grammar>
+ >
+ >
+ {};
+ };
+#endif
 
         struct meta_grammar
           : proto::switch_<cases>

Deleted: branches/release/boost/spirit/home/support/safe_bool.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/safe_bool.hpp 2009-10-14 15:14:36 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
-

Deleted: branches/release/boost/spirit/include/support_safe_bool.hpp
==============================================================================
--- branches/release/boost/spirit/include/support_safe_bool.hpp 2009-10-14 15:14:36 EDT (Wed, 14 Oct 2009)
+++ (empty file)
@@ -1,18 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2009 Joel de Guzman
- Copyright (c) 2001-2009 Hartmut Kaiser
- http://spirit.sourceforge.net/
-
- 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)
-=============================================================================*/
-#ifndef BOOST_SPIRIT_INCLUDE_SUPPORT_SAFE_BOOL
-#define BOOST_SPIRIT_INCLUDE_SUPPORT_SAFE_BOOL
-
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
-#include <boost/spirit/home/support/safe_bool.hpp>
-
-#endif

Modified: branches/release/libs/spirit/test/karma/bool.cpp
==============================================================================
--- branches/release/libs/spirit/test/karma/bool.cpp (original)
+++ branches/release/libs/spirit/test/karma/bool.cpp 2009-10-14 15:14:36 EDT (Wed, 14 Oct 2009)
@@ -13,8 +13,6 @@
 #include <boost/spirit/include/karma_numeric.hpp>
 #include <boost/spirit/include/karma_directive.hpp>
 
-#include <boost/spirit/home/support/safe_bool.hpp>
-
 #include <boost/spirit/include/phoenix_core.hpp>
 #include <boost/spirit/include/phoenix_operator.hpp>
 #include <boost/spirit/include/phoenix_statement.hpp>
@@ -46,11 +44,12 @@
     bool b;
 
     // we need to provide (safe) convertibility to bool
- typedef boost::spirit::safe_bool<test_bool_data> safe_bool_type;
- operator safe_bool_type::result_type() const
- {
- return safe_bool_type()(b);
- }
+private:
+ struct dummy { void true_() {}; };
+ typedef void (dummy::*safe_bool)();
+
+public:
+ operator safe_bool () const { return b ? &dummy::true_ : 0; }
 };
 
 struct test_bool_policy : boost::spirit::karma::bool_policies<>

Modified: branches/release/libs/spirit/test/lex/regression001.cpp
==============================================================================
--- branches/release/libs/spirit/test/lex/regression001.cpp (original)
+++ branches/release/libs/spirit/test/lex/regression001.cpp 2009-10-14 15:14:36 EDT (Wed, 14 Oct 2009)
@@ -56,7 +56,7 @@
     base_iterator last = &first[str.size()];
 
     for(lexer_type::iterator_type i = position_helper_lexer.begin(first, last);
- i != position_helper_lexer.end() && *i; i++ )
+ i != position_helper_lexer.end() && (*i).is_valid(); i++ )
     {
     }
     return boost::report_errors();


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