|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54903 - in trunk/boost/spirit/home/support: . iterators iterators/detail
From: hartmut.kaiser_at_[hidden]
Date: 2009-07-11 23:24:01
Author: hkaiser
Date: 2009-07-11 23:24:00 EDT (Sat, 11 Jul 2009)
New Revision: 54903
URL: http://svn.boost.org/trac/boost/changeset/54903
Log:
Spirit: fixing default multi_pass
Text files modified:
trunk/boost/spirit/home/support/common_terminals.hpp | 1 -
trunk/boost/spirit/home/support/iterators/detail/input_iterator_policy.hpp | 34 +++++++++++++++-------------------
trunk/boost/spirit/home/support/iterators/detail/lex_input_policy.hpp | 12 +++---------
trunk/boost/spirit/home/support/iterators/multi_pass.hpp | 11 +++++++++--
trunk/boost/spirit/home/support/iterators/multi_pass_fwd.hpp | 20 ++++++++++++++++++--
5 files changed, 45 insertions(+), 33 deletions(-)
Modified: trunk/boost/spirit/home/support/common_terminals.hpp
==============================================================================
--- trunk/boost/spirit/home/support/common_terminals.hpp (original)
+++ trunk/boost/spirit/home/support/common_terminals.hpp 2009-07-11 23:24:00 EDT (Sat, 11 Jul 2009)
@@ -24,7 +24,6 @@
// Our basic terminals
BOOST_SPIRIT_DEFINE_TERMINALS(
( verbatim )
- ( none )
( lexeme )
( omit )
( raw )
Modified: trunk/boost/spirit/home/support/iterators/detail/input_iterator_policy.hpp
==============================================================================
--- trunk/boost/spirit/home/support/iterators/detail/input_iterator_policy.hpp (original)
+++ trunk/boost/spirit/home/support/iterators/detail/input_iterator_policy.hpp 2009-07-11 23:24:00 EDT (Sat, 11 Jul 2009)
@@ -17,9 +17,9 @@
namespace input_iterator_is_valid_test_
{
template <typename Token>
- inline bool token_is_valid(Token const&)
+ inline bool token_is_valid(Token const& c)
{
- return true;
+ return c ? true : false;
}
}
@@ -33,7 +33,7 @@
{
///////////////////////////////////////////////////////////////////////
template <typename T>
- class unique : public detail::default_input_policy
+ class unique // : public detail::default_input_policy
{
private:
typedef
@@ -57,29 +57,26 @@
protected:
unique() {}
- explicit unique(T x) : input(x) {}
+ explicit unique(T x) {}
- void swap(unique& x)
- {
- spirit::detail::swap(input, x.input);
- }
+ void swap(unique&) {}
public:
template <typename MultiPass>
- static void advance_input(MultiPass& mp, value_type& t)
+ static void destroy(MultiPass&) {}
+
+ template <typename MultiPass>
+ static value_type& advance_input(MultiPass& mp, value_type& t)
{
- // if mp.shared is NULL then this instance of the multi_pass
- // represents a end iterator, so no advance functionality is
- // needed
- if (0 != mp.shared())
- t = *++mp.input;
+ return t = *mp.shared()->input_++;
}
// test, whether we reached the end of the underlying stream
template <typename MultiPass>
static bool input_at_eof(MultiPass const& mp, value_type const&)
{
- return mp.input == T();
+ static T const end_iter;
+ return mp.shared()->input_ == end_iter;
}
template <typename MultiPass>
@@ -89,17 +86,16 @@
return token_is_valid(t);
}
- protected:
- T input;
+ // no unique data elements
};
///////////////////////////////////////////////////////////////////////
template <typename T>
struct shared
{
- explicit shared(T) {}
+ explicit shared(T const& input) : input_(input) {}
- // no shared data elements
+ T input_;
};
};
Modified: trunk/boost/spirit/home/support/iterators/detail/lex_input_policy.hpp
==============================================================================
--- trunk/boost/spirit/home/support/iterators/detail/lex_input_policy.hpp (original)
+++ trunk/boost/spirit/home/support/iterators/detail/lex_input_policy.hpp 2009-07-11 23:24:00 EDT (Sat, 11 Jul 2009)
@@ -37,16 +37,10 @@
public:
template <typename MultiPass>
- static void advance_input(MultiPass& mp, value_type& t)
+ static value_type& advance_input(MultiPass& mp, value_type& t)
{
- // if mp.shared is NULL then this instance of the multi_pass
- // represents a end iterator, so no advance functionality is
- // needed
- if (0 != mp.shared())
- {
- extern int yylex();
- t = yylex();
- }
+ extern int yylex();
+ return t = yylex();
}
// test, whether we reached the end of the underlying stream
Modified: trunk/boost/spirit/home/support/iterators/multi_pass.hpp
==============================================================================
--- trunk/boost/spirit/home/support/iterators/multi_pass.hpp (original)
+++ trunk/boost/spirit/home/support/iterators/multi_pass.hpp 2009-07-11 23:24:00 EDT (Sat, 11 Jul 2009)
@@ -64,7 +64,7 @@
// the base class). This is fully intended behavior as some policies
// rely on the fact that their shared part is initialized before their
// unique part. Please ignore the warnings, these are harmless.
- explicit multi_pass(T input)
+ explicit multi_pass(T const& input)
: member_base(new shared_data_type(input)), policies_base_type(input) {}
multi_pass(multi_pass const& x)
@@ -192,11 +192,18 @@
///////////////////////////////////////////////////////////////////////////
template <typename Policies, typename T>
inline multi_pass<T, Policies>
- make_multi_pass(T i)
+ make_multi_pass(T const& i)
{
return multi_pass<T, Policies>(i);
}
+ template <typename T>
+ inline multi_pass<T>
+ make_default_multi_pass(T const& i)
+ {
+ return multi_pass<T>(i);
+ }
+
template <typename T, typename Policies>
inline void
swap(multi_pass<T, Policies> &x, multi_pass<T, Policies> &y)
Modified: trunk/boost/spirit/home/support/iterators/multi_pass_fwd.hpp
==============================================================================
--- trunk/boost/spirit/home/support/iterators/multi_pass_fwd.hpp (original)
+++ trunk/boost/spirit/home/support/iterators/multi_pass_fwd.hpp 2009-07-11 23:24:00 EDT (Sat, 11 Jul 2009)
@@ -30,11 +30,27 @@
struct no_check;
// storage policies
- struct std_deque;
+ struct split_std_deque;
template<std::size_t N> struct fixed_size_queue;
+
+ // policy combiner
+#if defined(BOOST_SPIRIT_DEBUG)
+ template<typename Ownership = ref_counted
+ , typename Checking = buf_id_check
+ , typename Input = input_iterator
+ , typename Storage = split_std_deque>
+ struct default_policy;
+#else
+ template<typename Ownership = ref_counted
+ , typename Checking = no_check
+ , typename Input = input_iterator
+ , typename Storage = split_std_deque>
+ struct default_policy;
+#endif
}
- template <typename T, typename Policies>
+ template <typename T
+ , typename Policies = iterator_policies::default_policy<> >
class multi_pass;
template <typename T, typename Policies>
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