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

Modified Files:
        context.hpp fusion.hpp ref.hpp 
Log Message:
misc clean-up

Index: context.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/context.hpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- context.hpp 26 Mar 2007 20:28:54 -0000      1.13
+++ context.hpp 27 Mar 2007 06:38:16 -0000      1.14
@@ -65,42 +65,6 @@
         template<typename T>
         char (&check_reference(T const &))[2];
 
-        template<typename T>
-        struct as_param
-          : add_reference<typename add_const<T>::type>
-        {};
-
-        template<typename T, typename U = T>
-        struct result_of_fixup
-          : mpl::if_<is_function<T>, T *, U>
-        {};
-
-        template<typename T, typename U>
-        struct result_of_fixup<T &, U>
-          : result_of_fixup<T, T>
-        {};
-
-        template<typename T, typename U>
-        struct result_of_fixup<T *, U>
-          : result_of_fixup<T, U>
-        {};
-
-        template<typename T, typename U>
-        struct result_of_fixup<T const, U>
-          : result_of_fixup<T, U>
-        {};
-
-        //// Tests for result_of_fixup
-        //struct bar {};
-        //BOOST_MPL_ASSERT((is_same<bar,        result_of_fixup<bar>::type>));
-        //BOOST_MPL_ASSERT((is_same<bar const,  result_of_fixup<bar 
const>::type>));
-        //BOOST_MPL_ASSERT((is_same<bar,        result_of_fixup<bar 
&>::type>));
-        //BOOST_MPL_ASSERT((is_same<bar const,  result_of_fixup<bar const 
&>::type>));
-        //BOOST_MPL_ASSERT((is_same<void(*)(),  
result_of_fixup<void(*)()>::type>));
-        //BOOST_MPL_ASSERT((is_same<void(*)(),  result_of_fixup<void(* 
const)()>::type>));
-        //BOOST_MPL_ASSERT((is_same<void(*)(),  result_of_fixup<void(* const 
&)()>::type>));
-        //BOOST_MPL_ASSERT((is_same<void(*)(),  
result_of_fixup<void(&)()>::type>));
-
         template<typename A0, typename A1>
         struct comma_result
         {
@@ -125,33 +89,11 @@
         {
             typedef void type;
         };
-
-        template<typename Context>
-        struct eval_transform
-        {
-            eval_transform(Context &ctx)
-              : ctx_(ctx)
-            {}
-
-            template<typename Arg>
-            struct result
-            {
-                typedef typename Context::template eval<typename 
remove_cv_ref<Arg>::type>::result_type type;
-            };
-
-            template<typename Arg>
-            typename result<Arg>::type operator()(Arg &arg) const
-            {
-                return arg.eval(ctx_);
-            }
-
-            Context &ctx_;
-        };
     }
 
     /// INTERNAL ONLY
     ///
-#define BOOST_PROTO_TYPEOF_2(Expr, Type)\
+#define BOOST_PROTO_TYPEOF(Expr, Type)\
     BOOST_PROTO_DECLTYPE_NESTED_TYPEDEF_TPL(BOOST_PP_CAT(nested_, Type), 
(Expr))\
     typedef typename BOOST_PP_CAT(nested_, Type)::type Type;\
     /**/
@@ -161,13 +103,13 @@
 
     /// INTERNAL ONLY
     ///
-#define BOOST_PROTO_UNARY_OP_RESULT_2(Op, Tag)\
+#define BOOST_PROTO_UNARY_OP_RESULT(Op, Tag)\
     template<typename Expr, typename Context>\
     struct default_eval<Expr, Context, Tag>\
     {\
         static Expr const &sexpr;\
         static Context &sctx;\
-        BOOST_PROTO_TYPEOF_2(Op proto::arg_c<0>(sexpr).eval(sctx), 
result_type)\
+        BOOST_PROTO_TYPEOF(Op proto::arg_c<0>(sexpr).eval(sctx), result_type)\
         result_type operator()(Expr const &expr, Context &ctx) const\
         {\
             return Op proto::arg_c<0>(expr).eval(ctx);\
@@ -177,13 +119,13 @@
 
     /// INTERNAL ONLY
     ///
-#define BOOST_PROTO_BINARY_OP_RESULT_2(Op, Tag)\
+#define BOOST_PROTO_BINARY_OP_RESULT(Op, Tag)\
     template<typename Expr, typename Context>\
     struct default_eval<Expr, Context, Tag>\
     {\
         static Expr const &sexpr;\
         static Context &sctx;\
-        BOOST_PROTO_TYPEOF_2(proto::arg_c<0>(sexpr).eval(sctx) Op 
proto::arg_c<1>(sexpr).eval(sctx), result_type)\
+        BOOST_PROTO_TYPEOF(proto::arg_c<0>(sexpr).eval(sctx) Op 
proto::arg_c<1>(sexpr).eval(sctx), result_type)\
         result_type operator()(Expr const &expr, Context &ctx) const\
         {\
             return proto::arg_c<0>(expr).eval(ctx) Op 
proto::arg_c<1>(expr).eval(ctx);\
@@ -191,46 +133,46 @@
     };\
     /**/
 
-    BOOST_PROTO_UNARY_OP_RESULT_2(+, proto::tag::unary_plus)
-    BOOST_PROTO_UNARY_OP_RESULT_2(-, proto::tag::unary_minus)
-    BOOST_PROTO_UNARY_OP_RESULT_2(*, proto::tag::unary_star)
-    BOOST_PROTO_UNARY_OP_RESULT_2(~, proto::tag::complement)
-    BOOST_PROTO_UNARY_OP_RESULT_2(&, proto::tag::address_of)
-    BOOST_PROTO_UNARY_OP_RESULT_2(!, proto::tag::logical_not)
-    BOOST_PROTO_UNARY_OP_RESULT_2(++, proto::tag::pre_inc)
-    BOOST_PROTO_UNARY_OP_RESULT_2(--, proto::tag::pre_dec)
+    BOOST_PROTO_UNARY_OP_RESULT(+, proto::tag::unary_plus)
+    BOOST_PROTO_UNARY_OP_RESULT(-, proto::tag::unary_minus)
+    BOOST_PROTO_UNARY_OP_RESULT(*, proto::tag::unary_star)
+    BOOST_PROTO_UNARY_OP_RESULT(~, proto::tag::complement)
+    BOOST_PROTO_UNARY_OP_RESULT(&, proto::tag::address_of)
+    BOOST_PROTO_UNARY_OP_RESULT(!, proto::tag::logical_not)
+    BOOST_PROTO_UNARY_OP_RESULT(++, proto::tag::pre_inc)
+    BOOST_PROTO_UNARY_OP_RESULT(--, proto::tag::pre_dec)
 
-    BOOST_PROTO_BINARY_OP_RESULT_2(<<, proto::tag::left_shift)
-    BOOST_PROTO_BINARY_OP_RESULT_2(>>, proto::tag::right_shift)
-    BOOST_PROTO_BINARY_OP_RESULT_2(*, proto::tag::multiply)
-    BOOST_PROTO_BINARY_OP_RESULT_2(/, proto::tag::divide)
-    BOOST_PROTO_BINARY_OP_RESULT_2(%, proto::tag::modulus)
-    BOOST_PROTO_BINARY_OP_RESULT_2(+, proto::tag::add)
-    BOOST_PROTO_BINARY_OP_RESULT_2(-, proto::tag::subtract)
-    BOOST_PROTO_BINARY_OP_RESULT_2(<, proto::tag::less)
-    BOOST_PROTO_BINARY_OP_RESULT_2(>, proto::tag::greater)
-    BOOST_PROTO_BINARY_OP_RESULT_2(<=, proto::tag::less_equal)
-    BOOST_PROTO_BINARY_OP_RESULT_2(>=, proto::tag::greater_equal)
-    BOOST_PROTO_BINARY_OP_RESULT_2(==, proto::tag::equal)
-    BOOST_PROTO_BINARY_OP_RESULT_2(!=, proto::tag::not_equal)
-    BOOST_PROTO_BINARY_OP_RESULT_2(||, proto::tag::logical_or)
-    BOOST_PROTO_BINARY_OP_RESULT_2(&&, proto::tag::logical_and)
-    BOOST_PROTO_BINARY_OP_RESULT_2(&, proto::tag::bitwise_and)
-    BOOST_PROTO_BINARY_OP_RESULT_2(|, proto::tag::bitwise_or)
-    BOOST_PROTO_BINARY_OP_RESULT_2(^, proto::tag::bitwise_xor)
-    BOOST_PROTO_BINARY_OP_RESULT_2(->*, proto::tag::mem_ptr)
-    BOOST_PROTO_BINARY_OP_RESULT_2(=, proto::tag::assign)
+    BOOST_PROTO_BINARY_OP_RESULT(<<, proto::tag::left_shift)
+    BOOST_PROTO_BINARY_OP_RESULT(>>, proto::tag::right_shift)
+    BOOST_PROTO_BINARY_OP_RESULT(*, proto::tag::multiply)
+    BOOST_PROTO_BINARY_OP_RESULT(/, proto::tag::divide)
+    BOOST_PROTO_BINARY_OP_RESULT(%, proto::tag::modulus)
+    BOOST_PROTO_BINARY_OP_RESULT(+, proto::tag::add)
+    BOOST_PROTO_BINARY_OP_RESULT(-, proto::tag::subtract)
+    BOOST_PROTO_BINARY_OP_RESULT(<, proto::tag::less)
+    BOOST_PROTO_BINARY_OP_RESULT(>, proto::tag::greater)
+    BOOST_PROTO_BINARY_OP_RESULT(<=, proto::tag::less_equal)
+    BOOST_PROTO_BINARY_OP_RESULT(>=, proto::tag::greater_equal)
+    BOOST_PROTO_BINARY_OP_RESULT(==, proto::tag::equal)
+    BOOST_PROTO_BINARY_OP_RESULT(!=, proto::tag::not_equal)
+    BOOST_PROTO_BINARY_OP_RESULT(||, proto::tag::logical_or)
+    BOOST_PROTO_BINARY_OP_RESULT(&&, proto::tag::logical_and)
+    BOOST_PROTO_BINARY_OP_RESULT(&, proto::tag::bitwise_and)
+    BOOST_PROTO_BINARY_OP_RESULT(|, proto::tag::bitwise_or)
+    BOOST_PROTO_BINARY_OP_RESULT(^, proto::tag::bitwise_xor)
+    BOOST_PROTO_BINARY_OP_RESULT(->*, proto::tag::mem_ptr)
+    BOOST_PROTO_BINARY_OP_RESULT(=, proto::tag::assign)
 
-    BOOST_PROTO_BINARY_OP_RESULT_2(<<=, proto::tag::left_shift_assign)
-    BOOST_PROTO_BINARY_OP_RESULT_2(>>=, proto::tag::right_shift_assign)
-    BOOST_PROTO_BINARY_OP_RESULT_2(*=, proto::tag::multiply_assign)
-    BOOST_PROTO_BINARY_OP_RESULT_2(/=, proto::tag::divide_assign)
-    BOOST_PROTO_BINARY_OP_RESULT_2(%=, proto::tag::modulus_assign)
-    BOOST_PROTO_BINARY_OP_RESULT_2(+=, proto::tag::add_assign)
-    BOOST_PROTO_BINARY_OP_RESULT_2(-=, proto::tag::subtract_assign)
-    BOOST_PROTO_BINARY_OP_RESULT_2(&=, proto::tag::bitwise_and_assign)
-    BOOST_PROTO_BINARY_OP_RESULT_2(|=, proto::tag::bitwise_or_assign)
-    BOOST_PROTO_BINARY_OP_RESULT_2(^=, proto::tag::bitwise_xor_assign)
+    BOOST_PROTO_BINARY_OP_RESULT(<<=, proto::tag::left_shift_assign)
+    BOOST_PROTO_BINARY_OP_RESULT(>>=, proto::tag::right_shift_assign)
+    BOOST_PROTO_BINARY_OP_RESULT(*=, proto::tag::multiply_assign)
+    BOOST_PROTO_BINARY_OP_RESULT(/=, proto::tag::divide_assign)
+    BOOST_PROTO_BINARY_OP_RESULT(%=, proto::tag::modulus_assign)
+    BOOST_PROTO_BINARY_OP_RESULT(+=, proto::tag::add_assign)
+    BOOST_PROTO_BINARY_OP_RESULT(-=, proto::tag::subtract_assign)
+    BOOST_PROTO_BINARY_OP_RESULT(&=, proto::tag::bitwise_and_assign)
+    BOOST_PROTO_BINARY_OP_RESULT(|=, proto::tag::bitwise_or_assign)
+    BOOST_PROTO_BINARY_OP_RESULT(^=, proto::tag::bitwise_xor_assign)
 
     template<typename Expr, typename Context>
     struct default_eval<Expr, Context, proto::tag::terminal>
@@ -262,7 +204,7 @@
     {
         static Expr const &sexpr;
         static Context &sctx;
-        BOOST_PROTO_TYPEOF_2(proto::arg_c<0>(sexpr).eval(sctx) ++, result_type)
+        BOOST_PROTO_TYPEOF(proto::arg_c<0>(sexpr).eval(sctx) ++, result_type)
         result_type operator()(Expr const &expr, Context &ctx) const
         {
             return proto::arg_c<0>(expr).eval(ctx) ++;
@@ -275,7 +217,7 @@
     {
         static Expr const &sexpr;
         static Context &sctx;
-        BOOST_PROTO_TYPEOF_2(proto::arg_c<0>(sexpr).eval(sctx) --, result_type)
+        BOOST_PROTO_TYPEOF(proto::arg_c<0>(sexpr).eval(sctx) --, result_type)
         result_type operator()(Expr const &expr, Context &ctx) const
         {
             return proto::arg_c<0>(expr).eval(ctx) --;
@@ -288,7 +230,7 @@
     {
         static Expr const &sexpr;
         static Context &sctx;
-        
BOOST_PROTO_TYPEOF_2(proto::arg_c<0>(sexpr).eval(sctx)[proto::arg_c<1>(sexpr).eval(sctx)],
 result_type)
+        
BOOST_PROTO_TYPEOF(proto::arg_c<0>(sexpr).eval(sctx)[proto::arg_c<1>(sexpr).eval(sctx)],
 result_type)
         result_type operator()(Expr const &expr, Context &ctx) const
         {
             return 
proto::arg_c<0>(expr).eval(ctx)[proto::arg_c<1>(expr).eval(ctx)];
@@ -305,27 +247,23 @@
               , Context
             >::type
         function_type;
+
         typedef
-            typename fusion::result_of::invoke<
-                function_type
-              , fusion::transform_view<
-                    typename fusion::result_of::pop_front<ref<Expr const> 
>::type const
-                  , detail::eval_transform<Context>
-                >
-            >::type
+            fusion::transform_view<
+                typename fusion::result_of::pop_front<children<Expr const> 
>::type const
+              , eval_fun<Context>
+            >
+        arguments_type;
+
+        typedef
+            typename fusion::result_of::invoke<function_type, 
arguments_type>::type
         result_type;
+
         result_type operator()(Expr const &expr, Context &ctx) const
         {
-            ref<Expr const> ref_expr = {expr};
             return fusion::invoke<function_type>(
                 proto::arg_c<0>(expr).eval(ctx)
-              , fusion::transform_view<
-                    typename fusion::result_of::pop_front<ref<Expr const> 
>::type const
-                  , detail::eval_transform<Context>
-                >(
-                    fusion::pop_front(ref_expr)
-                  , detail::eval_transform<Context>(ctx)
-                )
+              , arguments_type(fusion::pop_front(proto::children_of(expr)), 
eval_fun<Context>(ctx))
             );
         }
     };
@@ -342,27 +280,31 @@
 
     /// callable_context
     ///
-    template<typename Derived>
+    template<typename Context>
     struct callable_context
     {
         template<typename Expr>
         struct eval
         {
             typedef typename fusion::result_of::invoke<
-                Derived &
-              , typename fusion::result_of::push_front<proto::ref<Expr const>, 
typename Expr::tag_type>::type const
+                Context &
+              , typename fusion::result_of::push_front<children<Expr const>, 
typename Expr::tag_type>::type const
             >::type result_type;
 
-            result_type operator()(Expr const &expr, Derived &ctx)
+            result_type operator()(Expr const &expr, Context &context)
             {
-                proto::ref<Expr const> ref = {expr};
-                return fusion::invoke<Derived &>(ctx, fusion::push_front(ref, 
typename Expr::tag_type()));
+                return fusion::invoke<Context &>(
+                    context
+                  , fusion::push_front(proto::children_of(expr), typename 
Expr::tag_type())
+                );
             }
 
-            result_type operator()(Expr const &expr, Derived const &ctx)
+            result_type operator()(Expr const &expr, Context const &context)
             {
-                proto::ref<Expr const> ref = {expr};
-                return fusion::invoke<Derived const &>(ctx, 
fusion::push_front(ref, typename Expr::tag_type()));
+                return fusion::invoke<Context const &>(
+                    context
+                  , fusion::push_front(proto::children_of(expr), typename 
Expr::tag_type())
+                );
             }
         };
     };

Index: fusion.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/fusion.hpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- fusion.hpp  26 Mar 2007 06:06:25 -0000      1.22
+++ fusion.hpp  27 Mar 2007 06:38:16 -0000      1.23
@@ -33,24 +33,69 @@
 #include <boost/fusion/sequence/view/ext_/segmented_iterator.hpp>
 #include <boost/xpressive/proto/detail/suffix.hpp>
 
-namespace boost { namespace proto { namespace detail
+namespace boost { namespace proto
 {
-    template<typename Expr, int Pos>
-    struct ref_iterator
-      : fusion::iterator_base<ref_iterator<Expr, Pos> >
+    namespace detail
     {
-        typedef Expr expr_type;
-        typedef mpl::long_<Pos> index;
-        typedef fusion::forward_traversal_tag category;
-        typedef proto_ref_iterator_tag fusion_tag;
+        template<typename Expr, int Pos>
+        struct ref_iterator
+          : fusion::iterator_base<ref_iterator<Expr, Pos> >
+        {
+            typedef Expr expr_type;
+            typedef mpl::long_<Pos> index;
+            typedef fusion::forward_traversal_tag category;
+            typedef proto_ref_iterator_tag fusion_tag;
 
-        ref_iterator(Expr const &expr)
-          : expr_(expr)
+            ref_iterator(Expr const &expr)
+              : expr_(expr)
+            {}
+
+            Expr expr_;
+        };
+    }
+
+    template<typename Expr>
+    struct children
+      : proto::ref<Expr>
+    {
+        children(Expr &expr)
+          : proto::ref<Expr>(proto::ref<Expr>::make(expr))
         {}
+    };
 
-        Expr expr_;
+    template<typename Expr>
+    children<Expr> children_of(Expr &expr)
+    {
+        return children<Expr>(expr);
+    }
+
+    template<typename Context>
+    struct eval_fun
+    {
+        eval_fun(Context &ctx)
+          : ctx_(ctx)
+        {}
+
+        template<typename Arg>
+        struct result
+        {
+            typedef 
+                typename Context::template eval<
+                    typename detail::remove_cv_ref<Arg>::type
+                >::result_type
+            type;
+        };
+
+        template<typename Arg>
+        typename result<Arg>::type operator()(Arg &arg) const
+        {
+            return arg.eval(ctx_);
+        }
+
+    private:
+        Context &ctx_;
     };
-}}}
+}}
 
 namespace boost { namespace fusion
 {

Index: ref.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/ref.hpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- ref.hpp     15 Feb 2007 18:38:04 -0000      1.24
+++ ref.hpp     27 Mar 2007 06:38:16 -0000      1.25
@@ -47,6 +47,12 @@
             return this->expr.cast();
         }
 
+        static ref<Expr> make(Expr &expr)
+        {
+            ref<Expr> that = {expr};
+            return that;
+        }
+
         Expr &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