Update of /cvsroot/boost/boost/boost/xpressive/proto
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv2545/proto

Modified Files:
        expr.hpp matches.hpp proto_fwd.hpp traits.hpp 
Log Message:
add an .eval() member function to the expr<> struct

Index: expr.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/expr.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- expr.hpp    1 Dec 2006 05:46:06 -0000       1.5
+++ expr.hpp    8 Dec 2006 22:24:24 -0000       1.6
@@ -24,9 +24,9 @@
     #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
     #include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
 
-    #include <boost/config.hpp>
-    #include <boost/detail/workaround.hpp>
+    #include <boost/utility/result_of.hpp>
     #include <boost/xpressive/proto/proto_fwd.hpp>
+    #include <boost/xpressive/proto/ref.hpp>
     #include <boost/xpressive/proto/args.hpp>
     #include <boost/xpressive/proto/traits.hpp>
 
@@ -45,6 +45,14 @@
         proto::as_expr_ref(BOOST_PP_CAT(a,n))\
         /**/
 
+    #define BOOST_PROTO_UNREF_ARG_TYPE(z, n, data)\
+        typename proto::meta::unref<typename Args::BOOST_PP_CAT(arg, n)>::type\
+        /**/
+
+    #define BOOST_PROTO_UNREF_ARG(z, n, data)\
+        proto::unref(this->BOOST_PP_CAT(arg, n))\
+        /**/
+
     #define BOOST_PP_ITERATION_PARAMS_1 (4, (1, BOOST_PROTO_MAX_ARITY, 
<boost/xpressive/proto/expr.hpp>, 1))
     #include BOOST_PP_ITERATE()
     #undef BOOST_PP_ITERATION_PARAMS_1
@@ -52,14 +60,13 @@
     #undef BOOST_PROTO_ARG
     #undef BOOST_PROTO_VOID
     #undef BOOST_PROTO_AS_OP
+    #undef BOOST_PROTO_UNREF_ARG_TYPE
+    #undef BOOST_PROTO_UNREF_ARG
     }}
 
     #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400))
     namespace boost
     {
-        template<typename T>
-        struct result_of;
-
     #define BOOST_PP_ITERATION_PARAMS_1 (4, (0, BOOST_PROTO_MAX_ARITY, 
<boost/xpressive/proto/expr.hpp>, 2))
     #include BOOST_PP_ITERATE()
     #undef BOOST_PP_ITERATION_PARAMS_1
@@ -81,27 +88,41 @@
             typedef proto_expr_tag fusion_tag;
             typedef void is_boost_proto_expr_;
 
-            BOOST_PP_REPEAT(BOOST_PP_ITERATION(), BOOST_PROTO_ARG, _)
-            BOOST_PP_REPEAT_FROM_TO(BOOST_PP_ITERATION(), 
BOOST_PROTO_MAX_ARITY, BOOST_PROTO_VOID, _)
+            BOOST_PP_REPEAT(BOOST_PP_ITERATION(), BOOST_PROTO_ARG, ~)
+            BOOST_PP_REPEAT_FROM_TO(BOOST_PP_ITERATION(), 
BOOST_PROTO_MAX_ARITY, BOOST_PROTO_VOID, ~)
 
             expr const &cast() const
             {
                 return *this;
             }
 
+            template<typename Fun>
+            typename boost::result_of<Fun(Tag 
BOOST_PP_ENUM_TRAILING(BOOST_PP_ITERATION(), BOOST_PROTO_UNREF_ARG_TYPE, 
~))>::type
+            eval(Fun &fun) const
+            {
+                return fun(Tag() BOOST_PP_ENUM_TRAILING(BOOST_PP_ITERATION(), 
BOOST_PROTO_UNREF_ARG, ~));
+            }
+
+            template<typename Fun>
+            typename boost::result_of<Fun const(Tag 
BOOST_PP_ENUM_TRAILING(BOOST_PP_ITERATION(), BOOST_PROTO_UNREF_ARG_TYPE, 
~))>::type
+            eval(Fun const &fun) const
+            {
+                return fun(Tag(), BOOST_PP_ENUM(BOOST_PP_ITERATION(), 
BOOST_PROTO_UNREF_ARG, ~));
+            }
+
             template<typename A>
-            expr<tag::assign, args2<ref<expr>, typename 
meta::as_expr_ref<A>::type> > const
+            expr<tag::assign, args2<ref<expr>, typename 
proto::meta::as_expr_ref<A>::type> > const
             operator =(A const &a) const
             {
-                expr<tag::assign, args2<ref<expr>, typename 
meta::as_expr_ref<A>::type> > that = {{*this}, proto::as_expr_ref(a)};
+                expr<tag::assign, args2<ref<expr>, typename 
proto::meta::as_expr_ref<A>::type> > that = {{*this}, proto::as_expr_ref(a)};
                 return that;
             }
 
             template<typename A>
-            expr<tag::subscript, args2<ref<expr>, typename 
meta::as_expr_ref<A>::type> > const
+            expr<tag::subscript, args2<ref<expr>, typename 
proto::meta::as_expr_ref<A>::type> > const
             operator [](A const &a) const
             {
-                expr<tag::subscript, args2<ref<expr>, typename 
meta::as_expr_ref<A>::type> > that = {{*this}, proto::as_expr_ref(a)};
+                expr<tag::subscript, args2<ref<expr>, typename 
proto::meta::as_expr_ref<A>::type> > that = {{*this}, proto::as_expr_ref(a)};
                 return that;
             }
 
@@ -133,14 +154,14 @@
         template<typename This BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
         struct result<This(BOOST_PP_ENUM_PARAMS(N, A))>
         {
-            typedef expr<tag::function, BOOST_PP_CAT(args, 
BOOST_PP_INC(N))<ref<expr> BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, typename 
meta::as_expr_ref<A, >::type BOOST_PP_INTERCEPT)> > type;
+            typedef expr<tag::function, BOOST_PP_CAT(args, 
BOOST_PP_INC(N))<ref<expr> BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, typename 
proto::meta::as_expr_ref<A, >::type BOOST_PP_INTERCEPT)> > type;
         };
 
         template<BOOST_PP_ENUM_PARAMS(N, typename A)>
-        expr<tag::function, BOOST_PP_CAT(args, BOOST_PP_INC(N))<ref<expr> 
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, typename meta::as_expr_ref<A, >::type 
BOOST_PP_INTERCEPT)> > const
+        expr<tag::function, BOOST_PP_CAT(args, BOOST_PP_INC(N))<ref<expr> 
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, typename proto::meta::as_expr_ref<A, 
>::type BOOST_PP_INTERCEPT)> > const
         operator ()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const &a)) const
         {
-            expr<tag::function, BOOST_PP_CAT(args, BOOST_PP_INC(N))<ref<expr> 
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, typename meta::as_expr_ref<A, >::type 
BOOST_PP_INTERCEPT)> > that = {{*this} BOOST_PP_ENUM_TRAILING(N, 
BOOST_PROTO_AS_OP, _)};
+            expr<tag::function, BOOST_PP_CAT(args, BOOST_PP_INC(N))<ref<expr> 
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, typename proto::meta::as_expr_ref<A, 
>::type BOOST_PP_INTERCEPT)> > that = {{*this} BOOST_PP_ENUM_TRAILING(N, 
BOOST_PROTO_AS_OP, _)};
             return that;
         }
 

Index: matches.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/matches.hpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- matches.hpp 2 Dec 2006 23:56:33 -0000       1.17
+++ matches.hpp 8 Dec 2006 22:24:24 -0000       1.18
@@ -124,12 +124,6 @@
               : mpl::false_
             {};
 
-        #define BOOST_PROTO_MATCHES_N_FUN(z, n, data)\
-            matches_impl<\
-                typename Args1::BOOST_PP_CAT(arg, n)::expr_type\
-              , typename deref<typename Args2::BOOST_PP_CAT(arg, n)>::type\
-            >
-
             template<typename Expr>
             struct matches_impl< Expr, mpl::_ >
               : mpl::true_
@@ -151,11 +145,23 @@
                 >
             {};
 
+        #define BOOST_PROTO_MATCHES_N_FUN(z, n, data)\
+            matches_impl<\
+                typename Args1::BOOST_PP_CAT(arg, n)::expr_type\
+              , typename deref<typename Args2::BOOST_PP_CAT(arg, n)>::type\
+            >
+
         #define BOOST_PROTO_DEFINE_MATCHES(z, n, data)\
-            matches_impl<typename Expr::expr_type, typename 
deref<BOOST_PP_CAT(G, n)>::type>
+            matches_impl<\
+                typename Expr::expr_type\
+              , typename deref<BOOST_PP_CAT(G, n)>::type\
+            >
 
         #define BOOST_PROTO_DEFINE_TERMINAL_MATCHES(z, n, data)\
-            terminal_matches< BOOST_PP_CAT(Expr, n), BOOST_PP_CAT(Grammar, n) >
+            terminal_matches<\
+                BOOST_PP_CAT(Expr, n)\
+              , BOOST_PP_CAT(Grammar, n)\
+            >
 
         #define BOOST_PP_ITERATION_PARAMS_1 (3, (2, BOOST_PROTO_MAX_ARITY, 
<boost/xpressive/proto/matches.hpp>))
 

Index: proto_fwd.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/proto_fwd.hpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- proto_fwd.hpp       1 Dec 2006 05:46:06 -0000       1.33
+++ proto_fwd.hpp       8 Dec 2006 22:24:24 -0000       1.34
@@ -279,6 +279,9 @@
         template<typename T, bool IsExpr = is_expr<T>::value>
         struct unref;
 
+        template<typename Expr, typename Fun, long Arity = Expr::arity::value>
+        struct eval;
+
         // Specific expression generators, for convenience
         template<typename T> struct unary_plus;
         template<typename T> struct unary_minus;

Index: traits.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/traits.hpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- traits.hpp  1 Dec 2006 05:46:06 -0000       1.20
+++ traits.hpp  8 Dec 2006 22:24:24 -0000       1.21
@@ -18,6 +18,7 @@
     #include <boost/mpl/bool.hpp>
     #include <boost/call_traits.hpp>
     #include <boost/static_assert.hpp>
+    #include <boost/utility/result_of.hpp>
     #include <boost/xpressive/proto/proto_fwd.hpp>
     #include <boost/xpressive/proto/ref.hpp>
     #include <boost/xpressive/proto/args.hpp>
@@ -25,6 +26,7 @@
     #include <boost/preprocessor/iteration/iterate.hpp>
     #include <boost/preprocessor/repetition/enum.hpp>
     #include <boost/preprocessor/repetition/enum_params.hpp>
+    #include <boost/preprocessor/repetition/enum_trailing.hpp>
     #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
     #include <boost/preprocessor/facilities/intercept.hpp>
     #include <boost/preprocessor/arithmetic/sub.hpp>
@@ -217,9 +219,17 @@
               : deep_copy<Expr>
             {};
 
+        #define BOOST_PROTO_ARG_N_TYPE(z, n, data)\
+            typename proto::meta::unref<\
+                typename Expr::BOOST_PP_CAT(BOOST_PP_CAT(arg, n), _type)\
+            >::type\
+            /**/
+
         #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PROTO_MAX_ARITY, 
<boost/xpressive/proto/traits.hpp>))
         #include BOOST_PP_ITERATE()
         #undef BOOST_PP_ITERATION_PARAMS_1
+
+        #undef BOOST_PROTO_ARG_N_TYPE
         }
 
         namespace op
@@ -432,10 +442,17 @@
             template<BOOST_PP_ENUM_PARAMS(N, typename A)>
             struct function<
                 BOOST_PP_ENUM_PARAMS(N, A) 
-                
BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void 
BOOST_PP_INTERCEPT), void >
+                
BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void 
BOOST_PP_INTERCEPT), void
+            >
             {
                 typedef expr<proto::tag::function, BOOST_PP_CAT(args, 
N)<BOOST_PP_ENUM_PARAMS(N, A)> > type;
             };
+
+            template<typename Expr, typename Fun>
+            struct eval<Expr, Fun, N>
+              : boost::result_of<Fun(typename Expr::tag_type 
BOOST_PP_ENUM_TRAILING(N, BOOST_PROTO_ARG_N_TYPE, ~))>
+            {
+            };
         #endif
 
             template<typename Expr>


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to