|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56591 - in trunk/boost/spirit/home: karma/auxiliary karma/detail lex/lexer qi/auxiliary qi/detail qi/nonterminal support
From: hartmut.kaiser_at_[hidden]
Date: 2009-10-05 07:45:59
Author: hkaiser
Date: 2009-10-05 07:45:58 EDT (Mon, 05 Oct 2009)
New Revision: 56591
URL: http://svn.boost.org/trac/boost/changeset/56591
Log:
Spirit: finalizing transform_attribute for rules, renamed is_not_unused to not_is_unused
Text files modified:
trunk/boost/spirit/home/karma/auxiliary/attr_cast.hpp | 11 ++++++---
trunk/boost/spirit/home/karma/detail/output_iterator.hpp | 2
trunk/boost/spirit/home/karma/detail/pass_container.hpp | 2
trunk/boost/spirit/home/lex/lexer/token_def.hpp | 2
trunk/boost/spirit/home/qi/auxiliary/attr_cast.hpp | 14 +++++-------
trunk/boost/spirit/home/qi/detail/pass_container.hpp | 2
trunk/boost/spirit/home/qi/nonterminal/rule.hpp | 18 +++++++++-------
trunk/boost/spirit/home/support/attributes.hpp | 43 ++++++++++++++++++++++++---------------
trunk/boost/spirit/home/support/unused.hpp | 4 +-
9 files changed, 55 insertions(+), 43 deletions(-)
Modified: trunk/boost/spirit/home/karma/auxiliary/attr_cast.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/auxiliary/attr_cast.hpp (original)
+++ trunk/boost/spirit/home/karma/auxiliary/attr_cast.hpp 2009-10-05 07:45:58 EDT (Mon, 05 Oct 2009)
@@ -74,7 +74,7 @@
typedef mpl::int_<subject_type::properties::value> properties;
typedef typename mpl::eval_if<
- traits::is_not_unused<Transformed>
+ traits::not_is_unused<Transformed>
, mpl::identity<Transformed>
, traits::attribute_of<subject_type> >::type
transformed_attribute_type;
@@ -93,7 +93,7 @@
// deal with the passed attribute inside the parse function.
template <typename Context, typename Unused>
struct attribute
- : mpl::if_<traits::is_not_unused<Exposed>, Exposed
+ : mpl::if_<traits::not_is_unused<Exposed>, Exposed
, transformed_attribute_type>
{};
@@ -102,8 +102,11 @@
bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
, Attribute const& attr) const
{
- return compile<karma::domain>(subject).generate(sink, ctx, d
- , traits::pre_transform<transformed_attribute_type>(attr));
+ typedef typename traits::result_of::transform<
+ Attribute const, transformed_attribute_type> transform;
+
+ return compile<karma::domain>(subject).generate(
+ sink, ctx, d, transform::pre(attr));
}
template <typename Context>
Modified: trunk/boost/spirit/home/karma/detail/output_iterator.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/detail/output_iterator.hpp (original)
+++ trunk/boost/spirit/home/karma/detail/output_iterator.hpp 2009-10-05 07:45:58 EDT (Mon, 05 Oct 2009)
@@ -371,7 +371,7 @@
{
// get the most derived type of this class
typedef typename mpl::if_<
- traits::is_not_unused<Derived>, Derived
+ traits::not_is_unused<Derived>, Derived
, output_iterator<OutputIterator, Properties, Derived>
>::type most_derived_type;
Modified: trunk/boost/spirit/home/karma/detail/pass_container.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/detail/pass_container.hpp (original)
+++ trunk/boost/spirit/home/karma/detail/pass_container.hpp 2009-10-05 07:45:58 EDT (Mon, 05 Oct 2009)
@@ -134,7 +134,7 @@
// of the current element (component). If this is has no attribute
// we shouldn't use an element of the container but unused_type
// instead
- typedef traits::is_not_unused<
+ typedef traits::not_is_unused<
typename traits::attribute_of<Component, context_type>::type
> predicate;
Modified: trunk/boost/spirit/home/lex/lexer/token_def.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/token_def.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/token_def.hpp 2009-10-05 07:45:58 EDT (Mon, 05 Oct 2009)
@@ -69,7 +69,7 @@
// or unused_type (if omit has been specified).
typedef typename Iterator::base_iterator_type iterator_type;
typedef typename mpl::if_<
- traits::is_not_unused<Attribute>
+ traits::not_is_unused<Attribute>
, typename mpl::if_<
is_same<Attribute, lex::omit>, unused_type, Attribute
>::type
Modified: trunk/boost/spirit/home/qi/auxiliary/attr_cast.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/auxiliary/attr_cast.hpp (original)
+++ trunk/boost/spirit/home/qi/auxiliary/attr_cast.hpp 2009-10-05 07:45:58 EDT (Mon, 05 Oct 2009)
@@ -75,7 +75,7 @@
subject_type;
typedef typename mpl::eval_if<
- traits::is_not_unused<Transformed>
+ traits::not_is_unused<Transformed>
, mpl::identity<Transformed>
, traits::attribute_of<subject_type> >::type
transformed_attribute_type;
@@ -94,7 +94,7 @@
// deal with the passed attribute inside the parse function.
template <typename Context, typename Iterator>
struct attribute
- : mpl::if_<traits::is_not_unused<Exposed>, Exposed
+ : mpl::if_<traits::not_is_unused<Exposed>, Exposed
, transformed_attribute_type>
{};
@@ -108,17 +108,15 @@
// otherwise we assume the exposed attribute type to be the actual
// attribute type as passed by the user.
typedef typename mpl::if_<
- traits::is_not_unused<Exposed>, Exposed, Attribute>::type
+ traits::not_is_unused<Exposed>, Exposed, Attribute>::type
exposed_attribute_type;
// do down-stream transformation, provides attribute for embedded
// parser
- typedef typename traits::result_of::pre_transform<
- exposed_attribute_type, transformed_attribute_type>::type
- attribute_type;
+ typedef typename traits::result_of::transform<
+ exposed_attribute_type, transformed_attribute_type> transform;
- attribute_type attr_ =
- traits::pre_transform<transformed_attribute_type>(attr);
+ typename transform::type attr_ = transform::pre(attr);
if (!compile<qi::domain>(subject).
parse(first, last, context, skipper, attr_))
Modified: trunk/boost/spirit/home/qi/detail/pass_container.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/detail/pass_container.hpp (original)
+++ trunk/boost/spirit/home/qi/detail/pass_container.hpp 2009-10-05 07:45:58 EDT (Mon, 05 Oct 2009)
@@ -121,7 +121,7 @@
// we need to dispatch again depending on the type of the attribute
// of the current element (component). If this is has no attribute
// we shouldn't push an element into the container.
- typedef traits::is_not_unused<
+ typedef traits::not_is_unused<
typename traits::attribute_of<
Component, context_type, iterator_type
>::type
Modified: trunk/boost/spirit/home/qi/nonterminal/rule.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/nonterminal/rule.hpp (original)
+++ trunk/boost/spirit/home/qi/nonterminal/rule.hpp 2009-10-05 07:45:58 EDT (Mon, 05 Oct 2009)
@@ -218,10 +218,11 @@
// do down-stream transformation, provides attribute for
// rhs parser
- typename traits::result_of::pre_transform<
- typename make_attribute::type, attr_type
- >::type attr_ =
- traits::pre_transform<attr_type>(make_attribute::call(attr));
+ typedef typename traits::result_of::transform<
+ typename make_attribute::type, attr_type> transform;
+
+ typename transform::type attr_ =
+ transform::pre(make_attribute::call(attr));
// If you are seeing a compilation error here, you are probably
// trying to use a rule or a grammar which has inherited
@@ -257,10 +258,11 @@
// do down-stream transformation, provides attribute for
// rhs parser
- typename traits::result_of::pre_transform<
- typename make_attribute::type, attr_type
- >::type attr_ =
- traits::pre_transform<attr_type>(make_attribute::call(attr));
+ typedef typename traits::result_of::transform<
+ typename make_attribute::type, attr_type> transform;
+
+ typename transform::type attr_ =
+ transform::pre(make_attribute::call(attr));
// If you are seeing a compilation error here, you are probably
// trying to use a rule or a grammar which has inherited
Modified: trunk/boost/spirit/home/support/attributes.hpp
==============================================================================
--- trunk/boost/spirit/home/support/attributes.hpp (original)
+++ trunk/boost/spirit/home/support/attributes.hpp 2009-10-05 07:45:58 EDT (Mon, 05 Oct 2009)
@@ -76,7 +76,7 @@
{
template <typename Component>
struct apply
- : is_not_unused<typename
+ : not_is_unused<typename
attribute_of<Component, Context, Iterator>::type>
{};
};
@@ -169,7 +169,7 @@
// (filter all unused attributes from the list)
template <typename Sequence>
struct filter_unused_attributes
- : fusion::result_of::filter_if<Sequence, is_not_unused<mpl::_> >
+ : fusion::result_of::filter_if<Sequence, not_is_unused<mpl::_> >
{};
///////////////////////////////////////////////////////////////////////////
@@ -322,8 +322,13 @@
struct transform_attribute
{
typedef Transformed type;
+
static Transformed pre(Exposed& val) { return Transformed(val); }
+ static Transformed pre(Exposed const& val) { return Transformed(val); }
+ // By default post transform only if types are convertible,
+ // otherwise we assume no post transform is required (i.e. the user
+ // utilizes nview et.al.).
static void post(Exposed&, Transformed const&, mpl::false_)
{
}
@@ -332,22 +337,18 @@
assign_to(attr, val);
}
- // By default do post transform only if types are convertible,
- // otherwise we assume no post transform is required (i.e. the user
- // utilizes nview et.al.).
static void post(Exposed& val, Transformed const& attr)
{
post(val, attr, is_convertible<Transformed, Exposed>());
}
};
- // The default is not to do any transformation
- template <typename Attribute>
- struct transform_attribute<Attribute, Attribute>
+ template <typename Exposed, typename Transformed>
+ struct transform_attribute<Exposed const, Transformed>
{
- typedef Attribute& type;
- static Attribute& pre(Attribute& val) { return val; }
- static void post(Attribute&, Attribute const&) {}
+ typedef Transformed type;
+ static Transformed pre(Exposed const& val) { return Transformed(val); }
+ // Karma only, no post() required
};
template <typename Attribute>
@@ -355,7 +356,7 @@
{
typedef Attribute const& type;
static Attribute const& pre(Attribute const& val) { return val; }
- static void post(Attribute const&, Attribute const&) {}
+ // Karma only, no post() required
};
// reference types need special handling
@@ -366,8 +367,11 @@
template <typename Attribute>
struct transform_attribute<Attribute&, Attribute>
- : transform_attribute<Attribute, Attribute>
- {};
+ {
+ typedef Attribute& type;
+ static Attribute& pre(Attribute& val) { return val; }
+ static void post(Attribute&, Attribute const&) {}
+ };
template <typename Attribute>
struct transform_attribute<Attribute const&, Attribute>
@@ -394,6 +398,11 @@
{};
template <typename Attribute>
+ struct transform_attribute<unused_type const, Attribute>
+ : transform_attribute<unused_type, unused_type>
+ {};
+
+ template <typename Attribute>
struct transform_attribute<Attribute, unused_type>
: transform_attribute<unused_type, unused_type>
{};
@@ -406,20 +415,20 @@
namespace result_of
{
template <typename Exposed, typename Transformed>
- struct pre_transform
+ struct transform
: traits::transform_attribute<Exposed, Transformed>
{};
}
template <typename Transformed, typename Exposed>
- typename traits::result_of::pre_transform<Exposed, Transformed>::type
+ typename traits::result_of::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 traits::result_of::transform<Exposed const, Transformed>::type
pre_transform(Exposed const& attr)
{
return transform_attribute<Exposed const, Transformed>::pre(attr);
Modified: trunk/boost/spirit/home/support/unused.hpp
==============================================================================
--- trunk/boost/spirit/home/support/unused.hpp (original)
+++ trunk/boost/spirit/home/support/unused.hpp 2009-10-05 07:45:58 EDT (Mon, 05 Oct 2009)
@@ -55,8 +55,8 @@
namespace traits
{
// We use this test to detect if the argument is not an unused_type
- template <typename T> struct is_not_unused : mpl::true_ {};
- template <> struct is_not_unused<unused_type> : mpl::false_ {};
+ template <typename T> struct not_is_unused : mpl::true_ {};
+ template <> struct not_is_unused<unused_type> : mpl::false_ {};
}
}}
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