|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56800 - in branches/release/boost/spirit/home: karma/detail qi/detail qi/operator support
From: hartmut.kaiser_at_[hidden]
Date: 2009-10-13 15:59:39
Author: hkaiser
Date: 2009-10-13 15:59:38 EDT (Tue, 13 Oct 2009)
New Revision: 56800
URL: http://svn.boost.org/trac/boost/changeset/56800
Log:
Spirit: merging pending changes from trunk
Text files modified:
branches/release/boost/spirit/home/karma/detail/extract_from.hpp | 47 ++++++-----
branches/release/boost/spirit/home/karma/detail/pass_container.hpp | 11 +-
branches/release/boost/spirit/home/qi/detail/assign_to.hpp | 10 --
branches/release/boost/spirit/home/qi/operator/optional.hpp | 2
branches/release/boost/spirit/home/support/attributes.hpp | 21 ++--
branches/release/boost/spirit/home/support/attributes_fwd.hpp | 25 ++++++
branches/release/boost/spirit/home/support/container.hpp | 154 ++++++++++++++++++++-------------------
branches/release/boost/spirit/home/support/context.hpp | 2
8 files changed, 146 insertions(+), 126 deletions(-)
Modified: branches/release/boost/spirit/home/karma/detail/extract_from.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/detail/extract_from.hpp (original)
+++ branches/release/boost/spirit/home/karma/detail/extract_from.hpp 2009-10-13 15:59:38 EDT (Tue, 13 Oct 2009)
@@ -18,6 +18,7 @@
#include <boost/ref.hpp>
#include <boost/optional.hpp>
+///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace traits
{
///////////////////////////////////////////////////////////////////////////
@@ -70,39 +71,39 @@
};
///////////////////////////////////////////////////////////////////////////
- namespace result_of
- {
- template <typename Attribute>
- struct extract_from
- : traits::extract_from_attribute<Attribute>
- {};
-
- template <>
- struct extract_from<unused_type>
- {
- typedef unused_type type;
- };
-
- template <>
- struct extract_from<unused_type const>
- {
- typedef unused_type type;
- };
- }
-
- ///////////////////////////////////////////////////////////////////////////
template <typename Attribute>
- typename extract_from_attribute<Attribute>::type
+ typename spirit::result_of::extract_from<Attribute>::type
extract_from(Attribute const& attr)
{
return extract_from_attribute<Attribute>::call(attr);
};
- inline unused_type extract_from(unused_type)
+ unused_type extract_from(unused_type)
{
return unused;
};
}}}
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace result_of
+{
+ template <typename Attribute>
+ struct extract_from
+ : traits::extract_from_attribute<Attribute>
+ {};
+
+ template <>
+ struct extract_from<unused_type>
+ {
+ typedef unused_type type;
+ };
+
+ template <>
+ struct extract_from<unused_type const>
+ {
+ typedef unused_type type;
+ };
+}}}
+
#endif
Modified: branches/release/boost/spirit/home/karma/detail/pass_container.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/detail/pass_container.hpp (original)
+++ branches/release/boost/spirit/home/karma/detail/pass_container.hpp 2009-10-13 15:59:38 EDT (Tue, 13 Oct 2009)
@@ -25,9 +25,9 @@
namespace boost { namespace spirit { namespace karma { namespace detail
{
- // has_same_elements: utility to check if the RHS attribute
+ // has_same_elements: utility to check if the LHS attribute
// is an STL container and that its value_type is convertible
- // to the LHS.
+ // to the RHS.
template <typename RHS, typename LHSAttribute
, bool IsContainer = traits::is_container<LHSAttribute>::value>
@@ -77,8 +77,7 @@
// get the next value to generate from container
typename traits::container_iterator<Attr>::type end =
traits::end(attr);
- if (!traits::compare(iter, end) &&
- !f(component, traits::deref(iter)))
+ if (!traits::compare(iter, end) && !f(component, traits::deref(iter)))
{
// needs to return false as long as everything is ok
traits::next(iter);
@@ -147,7 +146,9 @@
template <typename Component>
bool dispatch_main(Component const& component, mpl::true_) const
{
- bool result = f(component, make_iterator_range(iter, traits::end(attr)));
+ typename traits::container_iterator<Attr>::type end =
+ traits::end(attr);
+ bool result = f(component, make_iterator_range(iter, end));
if (result)
iter = traits::end(attr); // adjust current iter to the end
return result;
Modified: branches/release/boost/spirit/home/qi/detail/assign_to.hpp
==============================================================================
--- branches/release/boost/spirit/home/qi/detail/assign_to.hpp (original)
+++ branches/release/boost/spirit/home/qi/detail/assign_to.hpp 2009-10-13 15:59:38 EDT (Tue, 13 Oct 2009)
@@ -73,16 +73,6 @@
}
};
- template <typename Attribute, typename T>
- struct assign_to_attribute_from_value<reference_wrapper<Attribute>, T>
- {
- static void
- call(T const& val, reference_wrapper<Attribute> attr)
- {
- attr = val;
- }
- };
-
template <typename T, typename Attribute>
inline void
assign_to(T const& val, Attribute& attr)
Modified: branches/release/boost/spirit/home/qi/operator/optional.hpp
==============================================================================
--- branches/release/boost/spirit/home/qi/operator/optional.hpp (original)
+++ branches/release/boost/spirit/home/qi/operator/optional.hpp 2009-10-13 15:59:38 EDT (Tue, 13 Oct 2009)
@@ -61,7 +61,7 @@
, Attribute& attr) const
{
// create a local value if Attribute is not unused_type
- typename traits::result_of::optional_value<Attribute>::type val;
+ typename spirit::result_of::optional_value<Attribute>::type val;
if (subject.parse(first, last, context, skipper, val))
{
Modified: branches/release/boost/spirit/home/support/attributes.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/attributes.hpp (original)
+++ branches/release/boost/spirit/home/support/attributes.hpp 2009-10-13 15:59:38 EDT (Tue, 13 Oct 2009)
@@ -34,6 +34,7 @@
#include <vector>
#include <utility>
+///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace traits
{
///////////////////////////////////////////////////////////////////////////
@@ -422,23 +423,15 @@
{};
///////////////////////////////////////////////////////////////////////////
- namespace result_of
- {
- template <typename Exposed, typename Transformed>
- struct pre_transform
- : traits::transform_attribute<Exposed, Transformed>
- {};
- }
-
template <typename Transformed, typename Exposed>
- typename traits::result_of::pre_transform<Exposed, Transformed>::type
+ typename spirit::result_of::pre_transform<Exposed, Transformed>::type
pre_transform(Exposed& attr)
{
return transform_attribute<Exposed, Transformed>::pre(attr);
}
template <typename Transformed, typename Exposed>
- typename traits::result_of::pre_transform<Exposed const, Transformed>::type
+ typename spirit::result_of::pre_transform<Exposed const, Transformed>::type
pre_transform(Exposed const& attr)
{
return transform_attribute<Exposed const, Transformed>::pre(attr);
@@ -678,7 +671,15 @@
inline void clear(unused_type)
{
}
+}}}
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace result_of
+{
+ template <typename Exposed, typename Transformed>
+ struct pre_transform
+ : traits::transform_attribute<Exposed, Transformed>
+ {};
}}}
#endif
Modified: branches/release/boost/spirit/home/support/attributes_fwd.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/attributes_fwd.hpp (original)
+++ branches/release/boost/spirit/home/support/attributes_fwd.hpp 2009-10-13 15:59:38 EDT (Tue, 13 Oct 2009)
@@ -87,7 +87,32 @@
template <typename Iterator, typename Enable = void>
struct compare_iterators;
+}}}
+
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace result_of
+{
+ // forward declaration only
+ template <typename Attribute>
+ struct extract_from;
+
+ template <typename Exposed, typename Transformed>
+ struct pre_transform;
+
+ template <typename T>
+ struct optional_value;
+
+ template <typename Container>
+ struct begin;
+
+ template <typename Container>
+ struct end;
+
+ template <typename Iterator>
+ struct next;
+ template <typename Iterator>
+ struct deref;
}}}
#endif
Modified: branches/release/boost/spirit/home/support/container.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/container.hpp (original)
+++ branches/release/boost/spirit/home/support/container.hpp 2009-10-13 15:59:38 EDT (Tue, 13 Oct 2009)
@@ -49,6 +49,11 @@
{};
template <typename T>
+ struct is_container<T&>
+ : is_container<T>
+ {};
+
+ template <typename T>
struct is_container<optional<T> >
: is_container<T>
{};
@@ -65,40 +70,6 @@
#undef BOOST_SPIRIT_IS_CONTAINER
- namespace result_of
- {
- ///////////////////////////////////////////////////////////////////////
- template <typename T>
- struct optional_value
- {
- typedef T type;
- };
-
- template <typename T>
- struct optional_value<optional<T> >
- {
- typedef T type;
- };
-
- template <typename T>
- struct optional_value<optional<T> const>
- {
- typedef T const type;
- };
-
- template <>
- struct optional_value<unused_type>
- {
- typedef unused_type type;
- };
-
- template <>
- struct optional_value<unused_type const>
- {
- typedef unused_type type;
- };
- }
-
///////////////////////////////////////////////////////////////////////////
namespace detail
{
@@ -130,6 +101,11 @@
{};
//]
+ template <typename T>
+ struct container_value<T&>
+ : container_value<T>
+ {};
+
// this will be instantiated if the optional holds a container
template <typename T>
struct container_value<optional<T> >
@@ -177,6 +153,11 @@
};
template <typename Container>
+ struct container_iterator<Container&>
+ : container_iterator<Container>
+ {};
+
+ template <typename Container>
struct container_iterator<Container const>
{
typedef typename Container::const_iterator type;
@@ -353,23 +334,14 @@
template <typename Container, typename Enable/* = void*/>
struct begin_container
{
- typedef typename container_iterator<Container>::type type;
- static type call(Container& c)
+ static typename container_iterator<Container>::type call(Container& c)
{
return c.begin();
}
};
- namespace result_of
- {
template <typename Container>
- struct begin
- : traits::container_iterator<Container>
- {};
- }
-
- template <typename Container>
- typename begin_container<Container>::type
+ typename spirit::result_of::begin<Container>::type
begin(Container& c)
{
return begin_container<Container>::call(c);
@@ -385,23 +357,14 @@
template <typename Container, typename Enable/* = void*/>
struct end_container
{
- typedef typename container_iterator<Container>::type type;
- static type call(Container& c)
+ static typename container_iterator<Container>::type call(Container& c)
{
return c.end();
}
};
- namespace result_of
- {
- template <typename Container>
- struct end
- : traits::container_iterator<Container>
- {};
- }
-
template <typename Container>
- inline typename end_container<Container>::type
+ inline typename spirit::result_of::end<Container>::type
end(Container& c)
{
return end_container<Container>::call(c);
@@ -424,14 +387,6 @@
}
};
- namespace result_of
- {
- template <typename Iterator>
- struct deref
- : traits::deref_iterator<Iterator>
- {};
- }
-
template <typename Iterator>
typename deref_iterator<Iterator>::type
deref(Iterator& it)
@@ -449,24 +404,14 @@
template <typename Iterator, typename Enable/* = void*/>
struct next_iterator
{
- typedef Iterator type;
- static type call(Iterator& it)
+ static Iterator call(Iterator& it)
{
return ++it;
}
};
- namespace result_of
- {
- template <typename Iterator>
- struct next
- {
- typedef Iterator type;
- };
- }
-
template <typename Iterator>
- typename next_iterator<Iterator>::type
+ typename spirit::result_of::next<Iterator>::type
next(Iterator& it)
{
return next_iterator<Iterator>::call(it);
@@ -498,6 +443,63 @@
{
return false;
}
+}}}
+
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace result_of
+{
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename T>
+ struct optional_value
+ {
+ typedef T type;
+ };
+
+ template <typename T>
+ struct optional_value<optional<T> >
+ {
+ typedef T type;
+ };
+
+ template <typename T>
+ struct optional_value<optional<T> const>
+ {
+ typedef T const type;
+ };
+
+ template <>
+ struct optional_value<unused_type>
+ {
+ typedef unused_type type;
+ };
+
+ template <>
+ struct optional_value<unused_type const>
+ {
+ typedef unused_type type;
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Container>
+ struct begin
+ : traits::container_iterator<Container>
+ {};
+
+ template <typename Container>
+ struct end
+ : traits::container_iterator<Container>
+ {};
+
+ template <typename Iterator>
+ struct next
+ {
+ typedef Iterator type;
+ };
+
+ template <typename Iterator>
+ struct deref
+ : traits::deref_iterator<Iterator>
+ {};
}}}
Modified: branches/release/boost/spirit/home/support/context.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/context.hpp (original)
+++ branches/release/boost/spirit/home/support/context.hpp 2009-10-13 15:59:38 EDT (Tue, 13 Oct 2009)
@@ -170,7 +170,7 @@
phoenix::actor<attribute<1> > const _r1 = attribute<1>();
phoenix::actor<attribute<2> > const _r2 = attribute<2>();
- // Bring in the rest of the attributes (_4 .. _N+1), using PP
+ // Bring in the rest of the attributes (_r4 .. _rN+1), using PP
BOOST_PP_REPEAT_FROM_TO(
3, SPIRIT_ATTRIBUTES_LIMIT, SPIRIT_DECLARE_ATTRIBUTE, _)
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