Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58117 - in trunk/boost/spirit/home: karma karma/auto karma/detail qi/auto qi/detail support/auto
From: hartmut.kaiser_at_[hidden]
Date: 2009-12-03 11:57:17


Author: hkaiser
Date: 2009-12-03 11:57:16 EST (Thu, 03 Dec 2009)
New Revision: 58117
URL: http://svn.boost.org/trac/boost/changeset/58117

Log:
Spirit: simplified auto facilities
Text files modified:
   trunk/boost/spirit/home/karma/auto/create_generator.hpp | 8 -
   trunk/boost/spirit/home/karma/auto/meta_create.hpp | 135 ++++++++++++++-------------------------
   trunk/boost/spirit/home/karma/detail/generate_auto.hpp | 2
   trunk/boost/spirit/home/karma/generate.hpp | 4
   trunk/boost/spirit/home/qi/auto/create_parser.hpp | 8 -
   trunk/boost/spirit/home/qi/auto/meta_create.hpp | 103 +++++++++--------------------
   trunk/boost/spirit/home/qi/detail/parse_auto.hpp | 2
   trunk/boost/spirit/home/support/auto/meta_create.hpp | 44 +++++--------
   8 files changed, 107 insertions(+), 199 deletions(-)

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-12-03 11:57:16 EST (Thu, 03 Dec 2009)
@@ -11,16 +11,13 @@
 #endif
 
 #include <boost/spirit/home/karma/auto/meta_create.hpp>
-#include <boost/proto/deep_copy.hpp>
 
 namespace boost { namespace spirit { namespace result_of
 {
     ///////////////////////////////////////////////////////////////////////////
     template <typename T>
     struct create_generator
- : proto::result_of::deep_copy<
- typename spirit::traits::meta_create<karma::domain, T>::type
- > {};
+ : spirit::traits::meta_create<karma::domain, T> {};
 }}}
 
 namespace boost { namespace spirit { namespace karma
@@ -31,8 +28,7 @@
     typename result_of::create_generator<T>::type
     create_generator()
     {
- return proto::deep_copy(
- spirit::traits::meta_create<karma::domain, T>::call());
+ return 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-12-03 11:57:16 EST (Thu, 03 Dec 2009)
@@ -33,19 +33,9 @@
     template <typename Container>
     struct meta_create_container
     {
- struct make_dereference
- {
- template <typename RT, typename T_>
- static RT call(T_ const& t)
- {
- // we map STL containers to the Kleene star
- return *t;
- }
- };
-
         typedef make_unary_proto_expr<
- typename Container::value_type, proto::tag::dereference
- , make_dereference, karma::domain
+ typename Container::value_type
+ , proto::tag::dereference, karma::domain
> make_proto_expr;
 
         typedef typename make_proto_expr::type type;
@@ -61,57 +51,57 @@
     template <typename String>
     struct meta_create_string
     {
- typedef spirit::standard::string_type const& type;
- static type call() { return spirit::standard::string; }
+ typedef spirit::standard::string_type type;
+ static type const& call() { return spirit::standard::string; }
     };
 
     template <>
     struct meta_create_string<wchar_t*>
     {
- typedef spirit::standard_wide::string_type const& type;
- static type call() { return spirit::standard_wide::string; }
+ typedef spirit::standard_wide::string_type type;
+ static type const& call() { return spirit::standard_wide::string; }
     };
 
     template <>
     struct meta_create_string<wchar_t const*>
     {
- typedef spirit::standard_wide::string_type const& type;
- static type call() { return spirit::standard_wide::string; }
+ typedef spirit::standard_wide::string_type type;
+ static type const& call() { return spirit::standard_wide::string; }
     };
 
     template <int N>
     struct meta_create_string<wchar_t[N]>
     {
- typedef spirit::standard_wide::string_type const& type;
- static type call() { return spirit::standard_wide::string; }
+ typedef spirit::standard_wide::string_type type;
+ static type const& call() { return spirit::standard_wide::string; }
     };
 
     template <int N>
     struct meta_create_string<wchar_t const[N]>
     {
- typedef spirit::standard_wide::string_type const& type;
- static type call() { return spirit::standard_wide::string; }
+ typedef spirit::standard_wide::string_type type;
+ static type const& call() { return spirit::standard_wide::string; }
     };
 
     template <int N>
     struct meta_create_string<wchar_t(&)[N]>
     {
- typedef spirit::standard_wide::string_type const& type;
- static type call() { return spirit::standard_wide::string; }
+ typedef spirit::standard_wide::string_type type;
+ static type const& call() { return spirit::standard_wide::string; }
     };
 
     template <int N>
     struct meta_create_string<wchar_t const(&)[N]>
     {
- typedef spirit::standard_wide::string_type const& type;
- static type call() { return spirit::standard_wide::string; }
+ typedef spirit::standard_wide::string_type type;
+ static type const& call() { return spirit::standard_wide::string; }
     };
 
     template <typename Traits, typename Allocator>
     struct meta_create_string<std::basic_string<wchar_t, Traits, Allocator> >
     {
- typedef spirit::standard_wide::string_type const& type;
- static type call() { return spirit::standard_wide::string; }
+ typedef spirit::standard_wide::string_type type;
+ static type const& call() { return spirit::standard_wide::string; }
     };
 
     ///////////////////////////////////////////////////////////////////////////
@@ -119,15 +109,6 @@
     template <typename Sequence>
     struct meta_create_sequence
     {
- struct make_shift_left
- {
- template <typename RT, typename T1, typename T2>
- static RT call(T1 const& t1, T2 const& t2)
- {
- return t1 << t2;
- }
- };
-
         // create a mpl sequence from the given fusion sequence
         typedef typename mpl::fold<
             typename fusion::result_of::as_vector<Sequence>::type
@@ -135,7 +116,7 @@
>::type sequence_type;
 
         typedef make_nary_proto_expr<
- sequence_type, proto::tag::shift_left, make_shift_left, karma::domain
+ sequence_type, proto::tag::shift_left, karma::domain
> make_proto_expr;
 
         typedef typename make_proto_expr::type type;
@@ -185,17 +166,8 @@
     template <typename T>
     struct meta_create<boost::optional<T> >
     {
- struct make_negate
- {
- template <typename RT, typename T_>
- static RT call(T_ const& t)
- {
- return -t;
- }
- };
-
         typedef make_unary_proto_expr<
- T, proto::tag::negate, make_negate, karma::domain
+ T, proto::tag::negate, karma::domain
> make_proto_expr;
 
         typedef typename make_proto_expr::type type;
@@ -211,18 +183,9 @@
     template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
     struct meta_create<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
     {
- struct make_bitwise_or
- {
- template <typename RT, typename T1_, typename T2_>
- static RT call(T1_ const& t1, T2_ const& t2)
- {
- return t1 | t2;
- }
- };
-
         typedef make_nary_proto_expr<
             typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types
- , proto::tag::bitwise_or, make_bitwise_or, karma::domain
+ , proto::tag::bitwise_or, karma::domain
> make_proto_expr;
 
         typedef typename make_proto_expr::type type;
@@ -240,76 +203,76 @@
     template <>
     struct meta_create<char>
     {
- typedef spirit::standard::char_type const& type;
- static type call() { return spirit::standard::char_; }
+ typedef spirit::standard::char_type type;
+ static type const& call() { return spirit::standard::char_; }
     };
     template <>
     struct meta_create<wchar_t>
     {
- typedef spirit::standard_wide::char_type const& type;
- static type call() { return spirit::standard_wide::char_; }
+ typedef spirit::standard_wide::char_type type;
+ static type const& call() { return spirit::standard_wide::char_; }
     };
 
     // boolean generator
     template <>
     struct meta_create<bool>
     {
- typedef spirit::bool__type const& type;
- static type call() { return spirit::bool_; }
+ typedef spirit::bool__type type;
+ static type const& call() { return spirit::bool_; }
     };
 
     // integral generators
     template <>
     struct meta_create<int>
     {
- typedef spirit::int__type const& type;
- static type call() { return spirit::int_; }
+ typedef spirit::int__type type;
+ static type const& call() { return spirit::int_; }
     };
     template <>
     struct meta_create<short>
     {
- typedef spirit::short__type const& type;
- static type call() { return spirit::short_; }
+ typedef spirit::short__type type;
+ static type const& call() { return spirit::short_; }
     };
     template <>
     struct meta_create<long>
     {
- typedef spirit::long__type const& type;
- static type call() { return spirit::long_; }
+ typedef spirit::long__type type;
+ static type const& call() { return spirit::long_; }
     };
     template <>
     struct meta_create<unsigned int>
     {
- typedef spirit::uint__type const& type;
- static type call() { return spirit::uint_; }
+ typedef spirit::uint__type type;
+ static type const& call() { return spirit::uint_; }
     };
 #if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
     template <>
     struct meta_create<unsigned short>
     {
- typedef spirit::ushort__type const& type;
- static type call() { return spirit::ushort_; }
+ typedef spirit::ushort__type type;
+ static type const& call() { return spirit::ushort_; }
     };
 #endif
     template <>
     struct meta_create<unsigned long>
     {
- typedef spirit::ulong__type const& type;
- static type call() { return spirit::ulong_; }
+ typedef spirit::ulong__type type;
+ static type const& call() { return spirit::ulong_; }
     };
 
 #ifdef BOOST_HAS_LONG_LONG
     template <>
     struct meta_create<boost::long_long_type>
     {
- typedef spirit::long_long_type const& type;
- static type call() { return spirit::long_long; }
+ typedef spirit::long_long_type type;
+ static type const& call() { return spirit::long_long; }
     };
     template <>
     struct meta_create<boost::ulong_long_type>
     {
- typedef spirit::ulong_long_type const& type;
- static type call() { return spirit::ulong_long; }
+ typedef spirit::ulong_long_type type;
+ static type const& call() { return spirit::ulong_long; }
     };
 #endif
 
@@ -317,20 +280,20 @@
     template <>
     struct meta_create<float>
     {
- typedef spirit::float__type const& type;
- static type call() { return spirit::float_; }
+ typedef spirit::float__type type;
+ static type const& call() { return spirit::float_; }
     };
     template <>
     struct meta_create<double>
     {
- typedef spirit::double__type const& type;
- static type call() { return spirit::double_; }
+ typedef spirit::double__type type;
+ static type const& call() { return spirit::double_; }
     };
     template <>
     struct meta_create<long double>
     {
- typedef spirit::long_double_type const& type;
- static type call() { return spirit::long_double; }
+ typedef spirit::long_double_type type;
+ static type const& call() { return spirit::long_double; }
     };
 }}}
 

Modified: trunk/boost/spirit/home/karma/detail/generate_auto.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/detail/generate_auto.hpp (original)
+++ trunk/boost/spirit/home/karma/detail/generate_auto.hpp 2009-12-03 11:57:16 EST (Thu, 03 Dec 2009)
@@ -10,7 +10,7 @@
 #pragma once
 #endif
 
-#include <boost/spirit/home/karma/detail/generate.hpp>
+#include <boost/spirit/home/karma/generate.hpp>
 #include <boost/spirit/home/karma/auto/create_generator.hpp>
 #include <boost/utility/enable_if.hpp>
 

Modified: trunk/boost/spirit/home/karma/generate.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/generate.hpp (original)
+++ trunk/boost/spirit/home/karma/generate.hpp 2009-12-03 11:57:16 EST (Thu, 03 Dec 2009)
@@ -128,7 +128,7 @@
         detail::output_iterator<OutputIterator
           , mpl::int_<properties::value | delimiter_properties::value>
> sink(target_sink);
- return generate_delimited(sink, expr, delimiter, pre_delimit, attr);
+ return karma::generate_delimited(sink, expr, delimiter, pre_delimit, attr);
     }
 
     ///////////////////////////////////////////////////////////////////////////
@@ -141,7 +141,7 @@
       , Delimiter const& delimiter
       , Attribute const& attr)
     {
- return generate_delimited(sink, expr, delimiter
+ return karma::generate_delimited(sink, expr, delimiter
           , delimit_flag::dont_predelimit, attr);
     }
 

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-12-03 11:57:16 EST (Thu, 03 Dec 2009)
@@ -11,16 +11,13 @@
 #endif
 
 #include <boost/spirit/home/qi/auto/meta_create.hpp>
-#include <boost/proto/deep_copy.hpp>
 
 namespace boost { namespace spirit { namespace result_of
 {
     ///////////////////////////////////////////////////////////////////////////
     template <typename T>
     struct create_parser
- : proto::result_of::deep_copy<
- typename spirit::traits::meta_create<qi::domain, T>::type
- > {};
+ : spirit::traits::meta_create<qi::domain, T> {};
 }}}
 
 namespace boost { namespace spirit { namespace qi
@@ -31,8 +28,7 @@
     typename result_of::create_parser<T>::type
     create_parser()
     {
- return proto::deep_copy(
- spirit::traits::meta_create<qi::domain, T>::call());
+ return 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-12-03 11:57:16 EST (Thu, 03 Dec 2009)
@@ -33,19 +33,9 @@
     template <typename Container>
     struct meta_create_container
     {
- struct make_dereference
- {
- template <typename RT, typename T_>
- static RT call(T_ const& t)
- {
- // we map STL containers to the Kleene star
- return *t;
- }
- };
-
         typedef make_unary_proto_expr<
- typename Container::value_type, proto::tag::dereference
- , make_dereference, qi::domain
+ typename Container::value_type
+ , proto::tag::dereference, qi::domain
> make_proto_expr;
 
         typedef typename make_proto_expr::type type;
@@ -61,15 +51,6 @@
     template <typename Sequence>
     struct meta_create_sequence
     {
- struct make_shift_right
- {
- template <typename RT, typename T1, typename T2>
- static RT call(T1 const& t1, T2 const& t2)
- {
- return t1 >> t2;
- }
- };
-
         // create a mpl sequence from the given fusion sequence
         typedef typename mpl::fold<
             typename fusion::result_of::as_vector<Sequence>::type
@@ -77,7 +58,7 @@
>::type sequence_type;
 
         typedef make_nary_proto_expr<
- sequence_type, proto::tag::shift_right, make_shift_right, qi::domain
+ sequence_type, proto::tag::shift_right, qi::domain
> make_proto_expr;
 
         typedef typename make_proto_expr::type type;
@@ -117,17 +98,8 @@
     template <typename T>
     struct meta_create<boost::optional<T> >
     {
- struct make_negate
- {
- template <typename RT, typename T_>
- static RT call(T_ const& t)
- {
- return -t;
- }
- };
-
         typedef make_unary_proto_expr<
- T, proto::tag::negate, make_negate, qi::domain
+ T, proto::tag::negate, qi::domain
> make_proto_expr;
 
         typedef typename make_proto_expr::type type;
@@ -143,18 +115,9 @@
     template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
     struct meta_create<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
     {
- struct make_bitwise_or
- {
- template <typename RT, typename T1_, typename T2_>
- static RT call(T1_ const& t1, T2_ const& t2)
- {
- return t1 | t2;
- }
- };
-
         typedef make_nary_proto_expr<
             typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types
- , proto::tag::bitwise_or, make_bitwise_or, qi::domain
+ , proto::tag::bitwise_or, qi::domain
> make_proto_expr;
 
         typedef typename make_proto_expr::type type;
@@ -172,76 +135,76 @@
     template <>
     struct meta_create<char>
     {
- typedef spirit::standard::char_type const& type;
- static type call() { return spirit::standard::char_; }
+ typedef spirit::standard::char_type type;
+ static type const& call() { return spirit::standard::char_; }
     };
     template <>
     struct meta_create<wchar_t>
     {
- typedef spirit::standard_wide::char_type const& type;
- static type call() { return spirit::standard_wide::char_; }
+ typedef spirit::standard_wide::char_type type;
+ static type const& call() { return spirit::standard_wide::char_; }
     };
 
     // boolean generator
     template <>
     struct meta_create<bool>
     {
- typedef spirit::bool__type const& type;
- static type call() { return spirit::bool_; }
+ typedef spirit::bool__type type;
+ static type const& call() { return spirit::bool_; }
     };
 
     // integral generators
     template <>
     struct meta_create<int>
     {
- typedef spirit::int__type const& type;
- static type call() { return spirit::int_; }
+ typedef spirit::int__type type;
+ static type const& call() { return spirit::int_; }
     };
     template <>
     struct meta_create<short>
     {
- typedef spirit::short__type const& type;
- static type call() { return spirit::short_; }
+ typedef spirit::short__type type;
+ static type const& call() { return spirit::short_; }
     };
     template <>
     struct meta_create<long>
     {
- typedef spirit::long__type const& type;
- static type call() { return spirit::long_; }
+ typedef spirit::long__type type;
+ static type const& call() { return spirit::long_; }
     };
     template <>
     struct meta_create<unsigned int>
     {
- typedef spirit::uint__type const& type;
- static type call() { return spirit::uint_; }
+ typedef spirit::uint__type type;
+ static type const& call() { return spirit::uint_; }
     };
 #if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
     template <>
     struct meta_create<unsigned short>
     {
- typedef spirit::ushort__type const& type;
- static type call() { return spirit::ushort_; }
+ typedef spirit::ushort__type type;
+ static type const& call() { return spirit::ushort_; }
     };
 #endif
     template <>
     struct meta_create<unsigned long>
     {
- typedef spirit::ulong__type const& type;
- static type call() { return spirit::ulong_; }
+ typedef spirit::ulong__type type;
+ static type const& call() { return spirit::ulong_; }
     };
 
 #ifdef BOOST_HAS_LONG_LONG
     template <>
     struct meta_create<boost::long_long_type>
     {
- typedef spirit::long_long_type const& type;
- static type call() { return spirit::long_long; }
+ typedef spirit::long_long_type type;
+ static type const& call() { return spirit::long_long; }
     };
     template <>
     struct meta_create<boost::ulong_long_type>
     {
- typedef spirit::ulong_long_type const& type;
- static type call() { return spirit::ulong_long; }
+ typedef spirit::ulong_long_type type;
+ static type const& call() { return spirit::ulong_long; }
     };
 #endif
 
@@ -249,20 +212,20 @@
     template <>
     struct meta_create<float>
     {
- typedef spirit::float__type const& type;
- static type call() { return spirit::float_; }
+ typedef spirit::float__type type;
+ static type const& call() { return spirit::float_; }
     };
     template <>
     struct meta_create<double>
     {
- typedef spirit::double__type const& type;
- static type call() { return spirit::double_; }
+ typedef spirit::double__type type;
+ static type const& call() { return spirit::double_; }
     };
     template <>
     struct meta_create<long double>
     {
- typedef spirit::long_double_type const& type;
- static type call() { return spirit::long_double; }
+ typedef spirit::long_double_type type;
+ static type const& call() { return spirit::long_double; }
     };
 }}}
 

Modified: trunk/boost/spirit/home/qi/detail/parse_auto.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/detail/parse_auto.hpp (original)
+++ trunk/boost/spirit/home/qi/detail/parse_auto.hpp 2009-12-03 11:57:16 EST (Thu, 03 Dec 2009)
@@ -11,7 +11,7 @@
 #pragma once
 #endif
 
-#include <boost/spirit/home/qi/detail/parse.hpp>
+#include <boost/spirit/home/qi/parse.hpp>
 #include <boost/spirit/home/qi/auto/create_parser.hpp>
 #include <boost/utility/enable_if.hpp>
 #include <boost/mpl/not.hpp>

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-12-03 11:57:16 EST (Thu, 03 Dec 2009)
@@ -48,7 +48,7 @@
           : remove_const<typename remove_reference<T>::type> {};
 
         ///////////////////////////////////////////////////////////////////////
- template <typename OpTag, typename F, typename Domain>
+ template <typename OpTag, typename Domain>
         struct nary_proto_expr_function
         {
             template <typename T>
@@ -57,19 +57,15 @@
             template <typename T1, typename T2>
             struct result<nary_proto_expr_function(T1, T2)>
             {
+ typedef typename remove_const_ref<T1>::type left_type;
                 typedef typename
                     spirit::traits::meta_create<Domain, T2>::type
                 right_type;
 
- typedef typename mpl::if_<
- traits::not_is_unused<typename remove_const_ref<T1>::type>
- , proto::expr<
- OpTag, proto::list2<
- typename add_const_ref<T1>::type
- , typename add_const_ref<right_type>::type
- >, 2
- >
- , right_type
+ typedef typename mpl::eval_if<
+ traits::not_is_unused<left_type>
+ , proto::result_of::make_expr<OpTag, left_type, right_type>
+ , mpl::identity<right_type>
>::type type;
             };
 
@@ -77,8 +73,8 @@
             typename result<nary_proto_expr_function(unused_type const&, T)>::type
             operator()(unused_type const&, T) const
             {
- typedef spirit::traits::meta_create<Domain, T> type;
- return type::call();
+ typedef spirit::traits::meta_create<Domain, T> right_type;
+ return right_type::call();
             }
 
             template <typename T1, typename T2>
@@ -86,39 +82,33 @@
             operator()(T1 const& t1, T2) const
             {
                 // we variants to the alternative operator
- typedef spirit::traits::meta_create<Domain, T2>
- right_type;
- typedef typename result<nary_proto_expr_function(T1, T2)>::type
- return_type;
-
- return F::template call<return_type>(t1, right_type::call());
+ typedef spirit::traits::meta_create<Domain, T2> right_type;
+ return proto::make_expr<OpTag>(t1, right_type::call());
             }
         };
     }
 
     ///////////////////////////////////////////////////////////////////////
- template <typename T, typename OpTag, typename F, typename Domain>
+ template <typename T, typename OpTag, 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;
+ typedef typename proto::result_of::make_expr<
+ OpTag, typename subject_type::type
+ >::type type;
 
         static type call()
         {
- return F::template call<type>(subject_type::call());
+ return proto::make_expr<OpTag>(subject_type::call());
         }
     };
 
     ///////////////////////////////////////////////////////////////////////////
- template <typename Sequence, typename OpTag, typename F, typename Domain>
+ template <typename Sequence, typename OpTag, typename Domain>
     struct make_nary_proto_expr
     {
- typedef detail::nary_proto_expr_function<OpTag, F, Domain>
+ typedef detail::nary_proto_expr_function<OpTag, Domain>
             make_proto_expr;
 
         typedef typename fusion::result_of::fold<


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