Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62372 - in trunk/boost/proto: . detail transform
From: eric_at_[hidden]
Date: 2010-06-01 18:13:34


Author: eric_niebler
Date: 2010-06-01 18:13:33 EDT (Tue, 01 Jun 2010)
New Revision: 62372
URL: http://svn.boost.org/trac/boost/changeset/62372

Log:
use generators directly instead of relying on the domain to inherit from them, which seems a dubious design
Text files modified:
   trunk/boost/proto/deep_copy.hpp | 12 +++---
   trunk/boost/proto/detail/expr0.hpp | 1
   trunk/boost/proto/extends.hpp | 26 +++++++++------
   trunk/boost/proto/generate.hpp | 6 +++
   trunk/boost/proto/make_expr.hpp | 10 +++--
   trunk/boost/proto/operators.hpp | 64 +++++++++++++++++++++++++++------------
   trunk/boost/proto/traits.hpp | 26 ++++++++++-----
   trunk/boost/proto/transform/pass_through.hpp | 6 +-
   8 files changed, 98 insertions(+), 53 deletions(-)

Modified: trunk/boost/proto/deep_copy.hpp
==============================================================================
--- trunk/boost/proto/deep_copy.hpp (original)
+++ trunk/boost/proto/deep_copy.hpp 2010-06-01 18:13:33 EDT (Tue, 01 Jun 2010)
@@ -41,13 +41,13 @@
                 actual_terminal_type;
 
                 typedef typename terminal<actual_terminal_type>::type expr_type;
- typedef typename Expr::proto_domain proto_domain;
- typedef typename proto_domain::template result<proto_domain(expr_type)>::type result_type;
+ typedef typename Expr::proto_generator proto_generator;
+ typedef typename proto_generator::template result<proto_generator(expr_type)>::type result_type;
 
                 template<typename Expr2, typename S, typename D>
                 result_type operator()(Expr2 const &e, S const &, D const &) const
                 {
- return typename Expr::proto_domain()(expr_type::make(e.proto_base().child0));
+ return proto_generator()(expr_type::make(e.proto_base().child0));
                 }
             };
         }
@@ -198,8 +198,8 @@
>
                 expr_type;
 
- typedef typename Expr::proto_domain proto_domain;
- typedef typename proto_domain::template result<proto_domain(expr_type)>::type result_type;
+ typedef typename Expr::proto_generator proto_generator;
+ typedef typename proto_generator::template result<proto_generator(expr_type)>::type result_type;
 
                 template<typename Expr2, typename S, typename D>
                 result_type operator()(Expr2 const &e, S const &, D const &) const
@@ -208,7 +208,7 @@
                         BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_DEEP_COPY_FUN, ~)
                     };
 
- return typename Expr::proto_domain()(that);
+ return proto_generator()(that);
                 }
             };
 

Modified: trunk/boost/proto/detail/expr0.hpp
==============================================================================
--- trunk/boost/proto/detail/expr0.hpp (original)
+++ trunk/boost/proto/detail/expr0.hpp 2010-06-01 18:13:33 EDT (Tue, 01 Jun 2010)
@@ -57,6 +57,7 @@
         typedef BOOST_PP_CAT(list, BOOST_PP_ITERATION())<BOOST_PP_ENUM_PARAMS(ARG_COUNT, Arg)> proto_args;
         #endif
         typedef default_domain proto_domain;
+ typedef default_generator proto_generator;
         typedef proto::tag::proto_expr fusion_tag;
         typedef expr proto_derived_expr;
         typedef void proto_is_expr_; /**< INTERNAL ONLY */

Modified: trunk/boost/proto/extends.hpp
==============================================================================
--- trunk/boost/proto/extends.hpp (original)
+++ trunk/boost/proto/extends.hpp 2010-06-01 18:13:33 EDT (Tue, 01 Jun 2010)
@@ -75,7 +75,7 @@
     #define BOOST_PROTO_DEFINE_FUN_OP_IMPL_(Z, N, DATA, Const) \
         BOOST_PP_IF(N, BOOST_PROTO_TEMPLATE_YES_, BOOST_PROTO_TEMPLATE_NO_)(Z, N) \
         typename boost::tr1_result_of< \
- proto_domain( \
+ proto_generator( \
                 typename boost::proto::result_of::BOOST_PP_CAT(funop, N)< \
                     proto_derived_expr Const() \
                   , proto_domain \
@@ -90,7 +90,7 @@
               , proto_domain \
                 BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, const A) \
> funop; \
- return proto_domain()( \
+ return proto_generator()( \
                 funop::call( \
                     *static_cast<proto_derived_expr Const() *>(this) \
                     BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, a) \
@@ -104,7 +104,7 @@
     #define BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(Const) \
         template<typename... A> \
         typename boost::tr1_result_of< \
- proto_domain( \
+ proto_generator( \
                 typename boost::proto::result_of::funop< \
                     proto_derived_expr Const()(A const &...) \
                   , proto_derived_expr \
@@ -119,7 +119,7 @@
               , proto_derived_expr \
               , proto_domain \
> funop; \
- return proto_domain()( \
+ return proto_generator()( \
                 funop::call( \
                     *static_cast<proto_derived_expr Const() *>(this) \
                   , a... \
@@ -196,12 +196,13 @@
     #define BOOST_PROTO_BASIC_EXTENDS(Expr, Derived, Domain) \
         BOOST_PROTO_BASIC_EXTENDS_(Expr, Derived, Domain) \
         typedef void proto_is_aggregate_; \
+ typedef Domain::proto_generator proto_generator; \
         /**< INTERNAL ONLY */
 
     #define BOOST_PROTO_EXTENDS_COPY_ASSIGN_IMPL_(This, Const, Typename) \
         BOOST_PROTO_DISABLE_MSVC_C4522 \
         Typename() boost::tr1_result_of< \
- Typename() This::proto_domain( \
+ Typename() This::proto_generator( \
                 boost::proto::expr< \
                     boost::proto::tag::assign \
                   , boost::proto::list2< \
@@ -226,7 +227,7 @@
                 *this \
               , a \
             }; \
- return Typename() This::proto_domain()(that); \
+ return Typename() This::proto_generator()(that); \
         } \
         /**/
 
@@ -248,7 +249,7 @@
     #define BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(ThisConst, ThatConst) \
         template<typename A> \
         typename boost::tr1_result_of< \
- proto_domain( \
+ proto_generator( \
                 boost::proto::expr< \
                     boost::proto::tag::assign \
                   , boost::proto::list2< \
@@ -273,7 +274,7 @@
                 *static_cast<proto_derived_expr ThisConst() *>(this) \
               , boost::proto::as_child<proto_domain>(a) \
             }; \
- return proto_domain()(that); \
+ return proto_generator()(that); \
         } \
         /**/
 
@@ -312,7 +313,7 @@
     #define BOOST_PROTO_EXTENDS_SUBSCRIPT_IMPL_(ThisConst, ThatConst) \
         template<typename A> \
         typename boost::tr1_result_of< \
- proto_domain( \
+ proto_generator( \
                 boost::proto::expr< \
                     boost::proto::tag::subscript \
                   , boost::proto::list2< \
@@ -337,7 +338,7 @@
                 *static_cast<proto_derived_expr ThisConst() *>(this) \
               , boost::proto::as_child<proto_domain>(a) \
             }; \
- return proto_domain()(that); \
+ return proto_generator()(that); \
         } \
         /**/
 
@@ -364,7 +365,7 @@
         { \
             typedef \
                 typename boost::tr1_result_of< \
- proto_domain( \
+ proto_generator( \
                         typename boost::proto::result_of::funop< \
                             Sig \
                           , proto_derived_expr \
@@ -497,6 +498,7 @@
 
             typedef extends proto_extends;
             BOOST_PROTO_BASIC_EXTENDS_(Expr, Derived, Domain)
+ typedef typename Domain::proto_generator proto_generator;
             BOOST_PROTO_EXTENDS_ASSIGN_CONST_()
             BOOST_PROTO_EXTENDS_SUBSCRIPT_CONST()
 
@@ -541,6 +543,7 @@
 
             typedef extends proto_extends;
             BOOST_PROTO_BASIC_EXTENDS_(Expr, Derived, Domain)
+ typedef typename Domain::proto_generator proto_generator;
             BOOST_PROTO_EXTENDS_ASSIGN_()
             BOOST_PROTO_EXTENDS_SUBSCRIPT()
 
@@ -577,6 +580,7 @@
                 expr<tag::member, list2<This &, expr<tag::terminal, term<Fun> > const &>, 2>
             proto_base_expr;
             typedef Domain proto_domain;
+ typedef typename Domain::proto_generator proto_generator;
             typedef virtual_member<This, Fun, Domain> proto_derived_expr;
             typedef typename proto_base_expr::proto_tag proto_tag;
             typedef typename proto_base_expr::proto_args proto_args;

Modified: trunk/boost/proto/generate.hpp
==============================================================================
--- trunk/boost/proto/generate.hpp (original)
+++ trunk/boost/proto/generate.hpp 2010-06-01 18:13:33 EDT (Tue, 01 Jun 2010)
@@ -349,6 +349,12 @@
         {
             typedef Expr type;
         };
+
+ template<typename Expr>
+ struct result_of<proto::default_generator(Expr)>
+ {
+ typedef Expr type;
+ };
     }
 
     #endif // BOOST_PROTO_GENERATE_HPP_EAN_02_13_2007

Modified: trunk/boost/proto/make_expr.hpp
==============================================================================
--- trunk/boost/proto/make_expr.hpp (original)
+++ trunk/boost/proto/make_expr.hpp 2010-06-01 18:13:33 EDT (Tue, 01 Jun 2010)
@@ -868,14 +868,15 @@
               , N
> expr_type;
 
- typedef typename Domain::template result<Domain(expr_type)>::type result_type;
+ typedef typename Domain::proto_generator proto_generator;
+ typedef typename proto_generator::template result<proto_generator(expr_type)>::type result_type;
 
             result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, typename add_reference<A, >::type a)) const
             {
                 expr_type const that = {
                     BOOST_PP_ENUM(N, BOOST_PROTO_AS_CHILD, (A, a, Domain))
                 };
- return Domain()(that);
+ return proto_generator()(that);
             }
         };
 
@@ -902,7 +903,8 @@
               , N
> expr_type;
 
- typedef typename Domain::template result<Domain(expr_type)>::type type;
+ typedef typename Domain::proto_generator proto_generator;
+ typedef typename proto_generator::template result<proto_generator(expr_type)>::type type;
 
             static type const call(Sequence const &sequence)
             {
@@ -910,7 +912,7 @@
                 expr_type const that = {
                     BOOST_PP_ENUM(N, BOOST_PROTO_FUSION_AS_CHILD_AT, ~)
                 };
- return Domain()(that);
+ return proto_generator()(that);
             }
         };
 

Modified: trunk/boost/proto/operators.hpp
==============================================================================
--- trunk/boost/proto/operators.hpp (original)
+++ trunk/boost/proto/operators.hpp 2010-06-01 18:13:33 EDT (Tue, 01 Jun 2010)
@@ -31,7 +31,7 @@
         struct generate_if
           : lazy_enable_if_c<
                 matches<Expr, typename Domain::proto_grammar>::value
- , typename Domain::template result<Domain(Expr)>
+ , typename Domain::proto_generator::template result<typename Domain::proto_generator(Expr)>
>
         {};
 
@@ -46,8 +46,8 @@
         struct generate_if_left
           : lazy_enable_if_c<
                 matches<proto::expr<Tag, proto::list2<Left &, Right>, 2>, typename Domain::proto_grammar>::value
- , typename Domain::template result<Domain(
- proto::expr<Tag, proto::list2<Left &, typename Domain::template result<Domain(Right)>::type>, 2>
+ , typename Domain::proto_generator::template result<typename Domain::proto_generator(
+ proto::expr<Tag, proto::list2<Left &, typename Domain::proto_generator::template result<Domain(Right)>::type>, 2>
                 )>
>
         {};
@@ -63,8 +63,8 @@
         struct generate_if_right
           : lazy_enable_if_c<
                 matches<proto::expr<Tag, proto::list2<Left, Right &>, 2>, typename Domain::proto_grammar>::value
- , typename Domain::template result<Domain(
- proto::expr<Tag, proto::list2<typename Domain::template result<Domain(Left)>::type, Right &>, 2>
+ , typename Domain::proto_generator::template result<typename Domain::proto_generator(
+ proto::expr<Tag, proto::list2<typename Domain::proto_generator::template result<Domain(Left)>::type, Right &>, 2>
                 )>
>
         {};
@@ -90,15 +90,24 @@
>
         {
             typedef proto::expr<tag::terminal, term<Right &>, 0> term_type;
- typedef typename Left::proto_domain proto_domain;
- typedef proto::expr<Tag, list2<Left &, typename proto_domain::template result<proto_domain(term_type)>::type>, 2> expr_type;
+ typedef typename Left::proto_generator proto_generator;
+ typedef
+ proto::expr<
+ Tag
+ , list2<
+ Left &
+ , typename proto_generator::template result<proto_generator(term_type)>::type
+ >
+ , 2
+ >
+ expr_type;
 
- static typename proto_domain::template result<proto_domain(expr_type)>::type
+ static typename proto_generator::template result<proto_generator(expr_type)>::type
             make(Left &left, Right &right)
             {
                 term_type const term = {right};
- expr_type const that = {left, proto_domain()(term)};
- return proto_domain()(that);
+ expr_type const that = {left, proto_generator()(term)};
+ return proto_generator()(that);
             }
         };
 
@@ -112,15 +121,24 @@
>
         {
             typedef proto::expr<tag::terminal, term<Left &>, 0> term_type;
- typedef typename Right::proto_domain proto_domain;
- typedef proto::expr<Tag, list2<typename proto_domain::template result<proto_domain(term_type)>::type, Right &>, 2> expr_type;
+ typedef typename Right::proto_generator proto_generator;
+ typedef
+ proto::expr<
+ Tag
+ , list2<
+ typename proto_generator::template result<proto_generator(term_type)>::type
+ , Right &
+ >
+ , 2
+ >
+ expr_type;
 
- static typename proto_domain::template result<proto_domain(expr_type)>::type
+ static typename proto_generator::template result<proto_generator(expr_type)>::type
             make(Left &left, Right &right)
             {
                 term_type const term = {left};
- expr_type const that = {proto_domain()(term), right};
- return proto_domain()(that);
+ expr_type const that = {proto_generator()(term), right};
+ return proto_generator()(that);
             }
         };
 
@@ -137,13 +155,19 @@
>
         {
             typedef proto::expr<Tag, list2<Left &, Right &>, 2> expr_type;
- typedef typename common_domain2<typename Left::proto_domain, typename Right::proto_domain>::type proto_domain;
+ typedef
+ typename common_domain2<
+ typename Left::proto_domain
+ , typename Right::proto_domain
+ >::type
+ proto_domain;
+ typedef typename proto_domain::proto_generator proto_generator;
 
- static typename proto_domain::template result<proto_domain(expr_type)>::type
+ static typename proto_generator::template result<proto_generator(expr_type)>::type
             make(Left &left, Right &right)
             {
                 expr_type const that = {left, right};
- return proto_domain()(that);
+ return proto_generator()(that);
             }
         };
 
@@ -229,7 +253,7 @@
     { \
         typedef proto::expr<TAG, list1<Arg &>, 1> that_type; \
         that_type const that = {arg}; \
- return typename Arg::proto_domain()(that); \
+ return typename Arg::proto_generator()(that); \
     } \
     template<typename Arg> \
     typename detail::generate_if< \
@@ -241,7 +265,7 @@
     { \
         typedef proto::expr<TAG, list1<Arg const &>, 1> that_type; \
         that_type const that = {arg}; \
- return typename Arg::proto_domain()(that); \
+ return typename Arg::proto_generator()(that); \
     } \
     /**/
 

Modified: trunk/boost/proto/traits.hpp
==============================================================================
--- trunk/boost/proto/traits.hpp (original)
+++ trunk/boost/proto/traits.hpp 2010-06-01 18:13:33 EDT (Tue, 01 Jun 2010)
@@ -256,7 +256,8 @@
>::type
                 arg0_;
                 typedef proto::expr<proto::tag::terminal, term<arg0_>, 0> expr_;
- typedef typename Domain::template result<Domain(expr_)>::type type;
+ typedef typename Domain::proto_generator proto_generator;
+ typedef typename proto_generator::template result<Domain(expr_)>::type type;
                 typedef type const reference;
 
                 /// INTERNAL ONLY
@@ -264,7 +265,7 @@
                 template<typename T2>
                 static reference call(T2 &t)
                 {
- return Domain()(expr_::make(t));
+ return proto_generator()(expr_::make(t));
                 }
             };
 
@@ -289,7 +290,8 @@
>
             {
                 typedef typename T::proto_derived_expr expr_; // removes the const
- typedef typename Domain::template result<Domain(expr_)>::type type;
+ typedef typename Domain::proto_generator proto_generator;
+ typedef typename proto_generator::template result<proto_generator(expr_)>::type type;
                 typedef type const reference;
 
                 /// INTERNAL ONLY
@@ -297,7 +299,7 @@
                 template<typename T2>
                 static reference call(T2 &t)
                 {
- return Domain()(t);
+ return proto_generator()(t);
                 }
             };
 
@@ -344,14 +346,15 @@
             struct as_child
             {
                 typedef proto::expr<proto::tag::terminal, term<T &>, 0> expr_;
- typedef typename Domain::template result<Domain(expr_)>::type type;
+ typedef typename Domain::proto_generator proto_generator;
+ typedef typename proto_generator::template result<proto_generator(expr_)>::type type;
 
                 /// INTERNAL ONLY
                 ///
                 template<typename T2>
                 static type call(T2 &t)
                 {
- return Domain()(expr_::make(t));
+ return proto_generator()(expr_::make(t));
                 }
             };
 
@@ -375,14 +378,19 @@
               #endif
>
             {
+ typedef typename Domain::proto_generator proto_generator;
                 // BUGBUG should be able to hold this guy by reference, no?
                 #if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || \
                     BOOST_WORKAROUND(BOOST_INTEL, BOOST_TESTED_AT(1010))
                 // These compilers don't strip top-level cv qualifiers
                 // on arguments in function types
- typedef typename Domain::template result<Domain(typename T::proto_derived_expr)>::type type;
+ typedef
+ typename proto_generator::template result<
+ proto_generator(typename T::proto_derived_expr)
+ >::type
+ type;
                 #else
- typedef typename Domain::template result<Domain(T)>::type type;
+ typedef typename proto_generator::template result<proto_generator(T)>::type type;
                 #endif
 
                 /// INTERNAL ONLY
@@ -390,7 +398,7 @@
                 template<typename T2>
                 static type call(T2 &t)
                 {
- return Domain()(t);
+ return proto_generator()(t);
                 }
             };
 

Modified: trunk/boost/proto/transform/pass_through.hpp
==============================================================================
--- trunk/boost/proto/transform/pass_through.hpp (original)
+++ trunk/boost/proto/transform/pass_through.hpp 2010-06-01 18:13:33 EDT (Tue, 01 Jun 2010)
@@ -175,8 +175,8 @@
                   , N
> expr_type;
 
- typedef typename unref_expr::proto_domain proto_domain;
- typedef typename boost::tr1_result_of<proto_domain(expr_type)>::type result_type;
+ typedef typename unref_expr::proto_generator proto_generator;
+ typedef typename boost::tr1_result_of<proto_generator(expr_type)>::type result_type;
 
                 result_type const operator ()(
                     typename pass_through_impl::expr_param e
@@ -193,7 +193,7 @@
                     // built with VC8.
                     &that;
                     #endif
- return proto_domain()(that);
+ return proto_generator()(that);
                 }
             };
 


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