|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r58057 - in trunk/boost/spirit/home: karma/auto qi/auto support/auto
From: hartmut.kaiser_at_[hidden]
Date: 2009-11-30 09:24:14
Author: hkaiser
Date: 2009-11-30 09:24:13 EST (Mon, 30 Nov 2009)
New Revision: 58057
URL: http://svn.boost.org/trac/boost/changeset/58057
Log:
Spirit: tweaking auto_
Text files modified:
trunk/boost/spirit/home/karma/auto/auto.hpp | 14 +------
trunk/boost/spirit/home/karma/auto/create_generator.hpp | 15 +++----
trunk/boost/spirit/home/karma/auto/meta_create.hpp | 28 ++++++-------
trunk/boost/spirit/home/qi/auto/auto.hpp | 14 +------
trunk/boost/spirit/home/qi/auto/create_parser.hpp | 15 +++----
trunk/boost/spirit/home/qi/auto/meta_create.hpp | 30 +++++++--------
trunk/boost/spirit/home/support/auto/meta_create.hpp | 77 +++++++++++++++++++++------------------
7 files changed, 84 insertions(+), 109 deletions(-)
Modified: trunk/boost/spirit/home/karma/auto/auto.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/auto/auto.hpp (original)
+++ trunk/boost/spirit/home/karma/auto/auto.hpp 2009-11-30 09:24:13 EST (Mon, 30 Nov 2009)
@@ -54,16 +54,6 @@
auto_generator(Modifiers const& modifiers)
: modifiers_(modifiers) {}
- template <
- typename OutputIterator, typename Context, typename Delimiter
- , typename Attribute, typename Expr>
- bool generate_auto(OutputIterator& sink, Context& context
- , Delimiter const& d, Attribute const& attr, Expr const& expr) const
- {
- return compile<karma::domain>(expr, modifiers_)
- .generate(sink, context, d, attr);
- }
-
// auto_generator has an attached attribute
template <
typename OutputIterator, typename Context, typename Delimiter
@@ -71,8 +61,8 @@
bool generate(OutputIterator& sink, Context& context
, Delimiter const& d, Attribute const& attr) const
{
- return generate_auto(sink, context, d, attr
- , create_generator<Attribute>());
+ return compile<karma::domain>(create_generator<Attribute>(), modifiers_)
+ .generate(sink, context, d, attr);
}
// this auto_generator has no attribute attached, it needs to have been
Modified: trunk/boost/spirit/home/karma/auto/create_generator.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/auto/create_generator.hpp (original)
+++ trunk/boost/spirit/home/karma/auto/create_generator.hpp 2009-11-30 09:24:13 EST (Mon, 30 Nov 2009)
@@ -18,24 +18,21 @@
///////////////////////////////////////////////////////////////////////////
template <typename T>
struct create_generator
- {
- typedef spirit::meta_create<karma::domain, T> creator_type;
-
- typedef typename proto::result_of::deep_copy<
- typename creator_type::type
- >::type type;
- };
+ : proto::result_of::deep_copy<
+ typename spirit::traits::meta_create<karma::domain, T>::type
+ > {};
}}}
namespace boost { namespace spirit { namespace karma
{
///////////////////////////////////////////////////////////////////////////
+ // Main API function for generator creation from data type
template <typename T>
typename result_of::create_generator<T>::type
create_generator()
{
- typedef typename result_of::create_generator<T>::creator_type creator_type;
- return proto::deep_copy(creator_type::call());
+ return proto::deep_copy(
+ spirit::traits::meta_create<karma::domain, T>::call());
}
}}}
Modified: trunk/boost/spirit/home/karma/auto/meta_create.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/auto/meta_create.hpp (original)
+++ trunk/boost/spirit/home/karma/auto/meta_create.hpp 2009-11-30 09:24:13 EST (Mon, 30 Nov 2009)
@@ -41,7 +41,7 @@
}
};
- typedef spirit::detail::make_unary_proto_expr<
+ typedef make_unary_proto_expr<
typename Container::value_type, proto::tag::dereference
, make_dereference, karma::domain
> make_proto_expr;
@@ -132,7 +132,7 @@
, mpl::vector<>, mpl::push_back<mpl::_, mpl::_>
>::type sequence_type;
- typedef spirit::detail::make_nary_proto_expr<
+ typedef make_nary_proto_expr<
sequence_type, proto::tag::shift_left, make_shift_left, karma::domain
> make_proto_expr;
@@ -188,7 +188,7 @@
}
};
- typedef spirit::detail::make_unary_proto_expr<
+ typedef make_unary_proto_expr<
T, proto::tag::negate, make_negate, karma::domain
> make_proto_expr;
@@ -214,7 +214,7 @@
}
};
- typedef spirit::detail::make_nary_proto_expr<
+ typedef make_nary_proto_expr<
typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types
, proto::tag::bitwise_or, make_bitwise_or, karma::domain
> make_proto_expr;
@@ -329,20 +329,18 @@
}}}
///////////////////////////////////////////////////////////////////////////////
-namespace boost { namespace spirit
+namespace boost { namespace spirit { namespace traits
{
+ ///////////////////////////////////////////////////////////////////////////
+ // main customization point for create_generator
+ template <typename T, typename Enable = void>
+ struct create_generator : karma::meta_create<T> {};
+
+ ///////////////////////////////////////////////////////////////////////////
// dispatch this to the karma related specializations
template <typename T>
struct meta_create<karma::domain, T>
- {
- typedef typename spirit::detail::remove_const_ref<T>::type data_type;
- typedef typename karma::meta_create<data_type>::type type;
-
- static type call()
- {
- return karma::meta_create<data_type>::call();
- }
- };
-}}
+ : create_generator<typename spirit::detail::remove_const_ref<T>::type> {};
+}}}
#endif
Modified: trunk/boost/spirit/home/qi/auto/auto.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/auto/auto.hpp (original)
+++ trunk/boost/spirit/home/qi/auto/auto.hpp 2009-11-30 09:24:13 EST (Mon, 30 Nov 2009)
@@ -52,22 +52,12 @@
: modifiers_(modifiers) {}
template <typename Iterator, typename Context, typename Skipper
- , typename Attribute, typename Expr>
- bool parse_auto(Iterator& first, Iterator const& last
- , Context& context, Skipper const& skipper, Attribute& attr
- , Expr const& expr) const
- {
- return compile<qi::domain>(expr, modifiers_)
- .parse(first, last, context, skipper, attr);
- }
-
- template <typename Iterator, typename Context, typename Skipper
, typename Attribute>
bool parse(Iterator& first, Iterator const& last
, Context& context, Skipper const& skipper, Attribute& attr) const
{
- return parse_auto(first, last, context, skipper, attr
- , create_parser<Attribute>());
+ return compile<qi::domain>(create_parser<Attribute>(), modifiers_)
+ .parse(first, last, context, skipper, attr);
}
template <typename Context>
Modified: trunk/boost/spirit/home/qi/auto/create_parser.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/auto/create_parser.hpp (original)
+++ trunk/boost/spirit/home/qi/auto/create_parser.hpp 2009-11-30 09:24:13 EST (Mon, 30 Nov 2009)
@@ -18,24 +18,21 @@
///////////////////////////////////////////////////////////////////////////
template <typename T>
struct create_parser
- {
- typedef spirit::meta_create<qi::domain, T> creator_type;
-
- typedef typename proto::result_of::deep_copy<
- typename creator_type::type
- >::type type;
- };
+ : proto::result_of::deep_copy<
+ typename spirit::traits::meta_create<qi::domain, T>::type
+ > {};
}}}
namespace boost { namespace spirit { namespace qi
{
///////////////////////////////////////////////////////////////////////////
+ // Main API function for parser creation from data type
template <typename T>
typename result_of::create_parser<T>::type
create_parser()
{
- typedef typename result_of::create_parser<T>::creator_type creator_type;
- return proto::deep_copy(creator_type::call());
+ return proto::deep_copy(
+ spirit::traits::meta_create<qi::domain, T>::call());
}
}}}
Modified: trunk/boost/spirit/home/qi/auto/meta_create.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/auto/meta_create.hpp (original)
+++ trunk/boost/spirit/home/qi/auto/meta_create.hpp 2009-11-30 09:24:13 EST (Mon, 30 Nov 2009)
@@ -41,7 +41,7 @@
}
};
- typedef spirit::detail::make_unary_proto_expr<
+ typedef make_unary_proto_expr<
typename Container::value_type, proto::tag::dereference
, make_dereference, qi::domain
> make_proto_expr;
@@ -74,7 +74,7 @@
, mpl::vector<>, mpl::push_back<mpl::_, mpl::_>
>::type sequence_type;
- typedef spirit::detail::make_nary_proto_expr<
+ typedef make_nary_proto_expr<
sequence_type, proto::tag::shift_right, make_shift_right, qi::domain
> make_proto_expr;
@@ -119,7 +119,7 @@
}
};
- typedef spirit::detail::make_unary_proto_expr<
+ typedef make_unary_proto_expr<
T, proto::tag::negate, make_negate, qi::domain
> make_proto_expr;
@@ -145,7 +145,7 @@
}
};
- typedef spirit::detail::make_nary_proto_expr<
+ typedef make_nary_proto_expr<
typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types
, proto::tag::bitwise_or, make_bitwise_or, qi::domain
> make_proto_expr;
@@ -260,20 +260,18 @@
}}}
///////////////////////////////////////////////////////////////////////////////
-namespace boost { namespace spirit
+namespace boost { namespace spirit { namespace traits
{
+ ///////////////////////////////////////////////////////////////////////////
+ // main customization point for create_parser
+ template <typename T, typename Enable = void>
+ struct create_parser : qi::meta_create<T> {};
+
+ ///////////////////////////////////////////////////////////////////////////
// dispatch this to the qi related specializations
template <typename T>
- struct meta_create<qi::domain, T>
- {
- typedef typename spirit::detail::remove_const_ref<T>::type data_type;
- typedef typename qi::meta_create<data_type>::type type;
-
- static type call()
- {
- return qi::meta_create<data_type>::call();
- }
- };
-}}
+ struct meta_create<qi::domain, T>
+ : create_parser<typename spirit::detail::remove_const_ref<T>::type> {};
+}}}
#endif
Modified: trunk/boost/spirit/home/support/auto/meta_create.hpp
==============================================================================
--- trunk/boost/spirit/home/support/auto/meta_create.hpp (original)
+++ trunk/boost/spirit/home/support/auto/meta_create.hpp 2009-11-30 09:24:13 EST (Mon, 30 Nov 2009)
@@ -20,13 +20,16 @@
#include <boost/type_traits/remove_reference.hpp>
#include <boost/fusion/include/fold.hpp>
-namespace boost { namespace spirit
+namespace boost { namespace spirit { namespace traits
{
///////////////////////////////////////////////////////////////////////////
- template <typename Domain, typename Type, typename Char = char
- , typename Enable = void>
+ // This is the main dispatching point for meta_create to the correct domain
+ template <typename Domain, typename T, typename Enable = void>
struct meta_create;
+}}}
+namespace boost { namespace spirit
+{
///////////////////////////////////////////////////////////////////////////
namespace detail
{
@@ -39,24 +42,6 @@
: remove_const<typename remove_reference<T>::type> {};
///////////////////////////////////////////////////////////////////////
- template <typename T, typename OpTag, typename F, typename Domain>
- struct make_unary_proto_expr
- {
- typedef spirit::meta_create<Domain, T> subject_type;
-
- typedef proto::expr<
- OpTag, proto::list1<
- typename add_const_ref<typename subject_type::type>::type
- >, 1
- > type;
-
- static type call()
- {
- return F::template call<type>(subject_type::call());
- }
- };
-
- ///////////////////////////////////////////////////////////////////////
template <typename OpTag, typename F, typename Domain>
struct nary_proto_expr_function
{
@@ -67,7 +52,7 @@
struct result<nary_proto_expr_function(T1, T2)>
{
typedef typename
- spirit::meta_create<Domain, T2>::type
+ spirit::traits::meta_create<Domain, T2>::type
right_type;
typedef typename mpl::if_<
@@ -86,7 +71,7 @@
typename result<nary_proto_expr_function(unused_type const&, T)>::type
operator()(unused_type const&, T) const
{
- typedef spirit::meta_create<Domain, T> type;
+ typedef spirit::traits::meta_create<Domain, T> type;
return type::call();
}
@@ -95,7 +80,7 @@
operator()(T1 const& t1, T2) const
{
// we variants to the alternative operator
- typedef spirit::meta_create<Domain, T2>
+ typedef spirit::traits::meta_create<Domain, T2>
right_type;
typedef typename result<nary_proto_expr_function(T1, T2)>::type
return_type;
@@ -103,22 +88,42 @@
return F::template call<return_type>(t1, right_type::call());
}
};
+ }
- template <typename Sequence, typename OpTag, typename F, typename Domain>
- struct make_nary_proto_expr
+ ///////////////////////////////////////////////////////////////////////
+ template <typename T, typename OpTag, typename F, typename Domain>
+ struct make_unary_proto_expr
+ {
+ typedef spirit::traits::meta_create<Domain, T> subject_type;
+
+ typedef proto::expr<
+ OpTag, proto::list1<
+ typename detail::add_const_ref<typename subject_type::type>::type
+ >, 1
+ > type;
+
+ static type call()
{
- typedef nary_proto_expr_function<OpTag, F, Domain> make_proto_expr;
+ return F::template call<type>(subject_type::call());
+ }
+ };
- typedef typename fusion::result_of::fold<
- Sequence, unused_type, make_proto_expr
- >::type type;
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Sequence, typename OpTag, typename F, typename Domain>
+ struct make_nary_proto_expr
+ {
+ typedef detail::nary_proto_expr_function<OpTag, F, Domain>
+ make_proto_expr;
- static type call()
- {
- return fusion::fold(Sequence(), unused, make_proto_expr());
- }
- };
- }
+ typedef typename fusion::result_of::fold<
+ Sequence, unused_type, make_proto_expr
+ >::type type;
+
+ static type call()
+ {
+ return fusion::fold(Sequence(), unused, make_proto_expr());
+ }
+ };
}}
#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