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

Modified Files:
        expr.hpp proto_typeof.hpp ref.hpp traits.hpp 
Added Files:
        deep_copy.hpp 
Log Message:
all expr types have nested ::id, add deep_copy() for storing all nodes by 
value, and BOOST_PROTO_AUTO(var, expr) as a shortcut for BOOST_AUTO(var, 
proto::deep_copy(expr))

--- NEW FILE: deep_copy.hpp ---
///////////////////////////////////////////////////////////////////////////////
/// \file deep_copy.hpp
/// Replace all nodes stored by reference by nodes stored by value.
//
//  Copyright 2004 Eric Niebler. Distributed under the Boost
//  Software License, Version 1.0. (See accompanying file
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_PP_IS_ITERATING

    #ifndef BOOST_PROTO_DEEP_COPY_HPP_EAN_11_21_2006
    #define BOOST_PROTO_DEEP_COPY_HPP_EAN_11_21_2006

    #include <boost/preprocessor/cat.hpp>
    #include <boost/preprocessor/enum.hpp>
    #include <boost/preprocessor/iterate.hpp>
    #include <boost/xpressive/proto/proto_fwd.hpp>
    #include <boost/xpressive/proto/expr.hpp>

    namespace boost { namespace proto
    {
        namespace detail
        {
            template<typename Expr, typename Tag = typename Expr::tag_type, 
long Arity = Expr::arity::value>
            struct deep_copy_impl;

            template<typename Expr>
            struct deep_copy_impl<Expr, terminal_tag, 1>
            {
                static typename Expr::expr_type const &
                call(Expr const &expr)
                {
                    return expr.cast();
                }
            };
        }

        namespace meta
        {
            template<typename Expr>
            struct deep_copy
            {
                typedef typename Expr::id type;
            };
        }

        template<typename Expr>
        typename Expr::id deep_copy(Expr const &expr)
        {
            return detail::deep_copy_impl<Expr>::call(expr);
        }

        namespace detail
        {
        #define BOOST_PROTO_DEFINE_DEEP_COPY(z, n, data)\
            proto::deep_copy(BOOST_PP_CAT(expr.cast().arg, n).cast())

        #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PROTO_MAX_ARITY, 
<boost/xpressive/proto/deep_copy.hpp>))

        #include BOOST_PP_ITERATE()

        #undef BOOST_PP_ITERATION_PARAMS_1
        #undef BOOST_PROTO_DEFINE_DEEP_COPY
        }

    }}

    #endif // BOOST_PROTO_COMPILER_DEEP_COPY_HPP_EAN_11_21_2006

#else

    #define N BOOST_PP_ITERATION()

            template<typename Expr, typename Tag>
            struct deep_copy_impl<Expr, Tag, N>
            {
                static typename Expr::id
                call(Expr const &expr)
                {
                    typename Expr::id that = {
                        BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_DEEP_COPY, ~)
                    };
                    return that;
                }
            };

    #undef N

#endif

Index: expr.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/expr.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- expr.hpp    20 Nov 2006 03:41:06 -0000      1.1
+++ expr.hpp    21 Nov 2006 17:28:15 -0000      1.2
@@ -45,6 +45,10 @@
         proto::as_expr_ref(BOOST_PP_CAT(a,n))\
         /**/
 
+    #define BOOST_PP_ITERATION_PARAMS_1 (4, (1, 1, 
<boost/xpressive/proto/expr.hpp>, 0))
+    #include BOOST_PP_ITERATE()
+    #undef BOOST_PP_ITERATION_PARAMS_1
+
     #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
@@ -67,15 +71,22 @@
 
     #endif
 
-    #endif // BOOST_PROTO_BASIC_EXPR_HPP_EAN_04_01_2005
+    #endif // BOOST_PROTO_EXPR_HPP_EAN_04_01_2005
 
-#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == 1
+#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() < 2
 
+    #if BOOST_PP_ITERATION_FLAGS() == 0
+        template<typename Args>
+        struct expr<terminal_tag, Args, 1>
+        {
+            typedef terminal_tag tag_type;
+    #else
         template<typename Tag, typename Args>
         struct expr<Tag, Args, BOOST_PP_ITERATION() >
         {
-            typedef expr expr_type;
             typedef Tag tag_type;
+    #endif
+            typedef expr expr_type;
             typedef Args args_type;
             typedef mpl::long_<BOOST_PP_ITERATION()> arity;
             typedef proto_expr_tag fusion_tag;
@@ -84,6 +95,14 @@
             BOOST_PP_REPEAT(BOOST_PP_ITERATION(), BOOST_PROTO_ARG, _)
             BOOST_PP_REPEAT_FROM_TO(BOOST_PP_ITERATION(), 
BOOST_PROTO_MAX_ARITY, BOOST_PROTO_VOID, _)
 
+            typedef expr
+    #if BOOST_PP_ITERATION_FLAGS() == 1
+                <tag_type, BOOST_PP_CAT(args, BOOST_PP_ITERATION()) <
+                    BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), typename 
Args::arg, ::expr_type::id BOOST_PP_INTERCEPT)
+                > >
+    #endif
+            id;
+
             expr const &cast() const
             {
                 return *this;

Index: proto_typeof.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/proto_typeof.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- proto_typeof.hpp    20 Nov 2006 03:41:07 -0000      1.6
+++ proto_typeof.hpp    21 Nov 2006 17:28:15 -0000      1.7
@@ -18,6 +18,7 @@
 #include <boost/config.hpp>
 #include <boost/typeof/typeof.hpp>
 #include <boost/xpressive/proto/proto_fwd.hpp>
+#include <boost/xpressive/proto/deep_copy.hpp>
 
 #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
 
@@ -72,4 +73,36 @@
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::ref, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::expr, (typename)(typename)(long))
 
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::args1, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::args2, 2)
+// can't use PP metaprogramming here because all typeof registrations
+// must be on separate lines.
+#if BOOST_PROTO_MAX_ARITY >= 3
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::args3, 3)
+#endif
+#if BOOST_PROTO_MAX_ARITY >= 4
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::args4, 4)
+#endif
+#if BOOST_PROTO_MAX_ARITY >= 5
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::args5, 5)
+#endif
+#if BOOST_PROTO_MAX_ARITY >= 6
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::args6, 6)
+#endif
+#if BOOST_PROTO_MAX_ARITY >= 7
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::args7, 7)
+#endif
+#if BOOST_PROTO_MAX_ARITY >= 8
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::args8, 8)
+#endif
+#if BOOST_PROTO_MAX_ARITY >= 9
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::args9, 9)
+#endif
+#if BOOST_PROTO_MAX_ARITY >= 10
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::args10, 10)
+#endif
+
+#define BOOST_PROTO_AUTO(Var, Expr) BOOST_AUTO(Var, 
boost::proto::deep_copy(Expr))
+#define BOOST_PROTO_AUTO_TPL(Var, Expr) BOOST_AUTO_TPL(Var, 
boost::proto::deep_copy(Expr))
+
 #endif

Index: ref.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/ref.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ref.hpp     10 Nov 2006 04:09:38 -0000      1.7
+++ ref.hpp     21 Nov 2006 17:28:15 -0000      1.8
@@ -25,6 +25,7 @@
         typedef typename Expr::tag_type tag_type;
         typedef typename Expr::args_type args_type;
         typedef typename Expr::arity arity;
+        typedef typename Expr::id id;
         typedef proto_ref_tag fusion_tag;
         typedef void is_boost_proto_ref_;
         typedef void is_boost_proto_expr_;

Index: traits.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/traits.hpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- traits.hpp  20 Nov 2006 03:41:07 -0000      1.16
+++ traits.hpp  21 Nov 2006 17:28:15 -0000      1.17
@@ -1,8 +1,8 @@
 ///////////////////////////////////////////////////////////////////////////////
 /// \file traits.hpp
-/// Contains definitions for arg_type\<\>, left_type\<\>,
-/// right_type\<\>, tag_type\<\>, and the helper functions arg(), left(),
-/// and right().
+/// Contains definitions for arg\<\>, arg_c\<\>, left\<\>,
+/// right\<\>, tag\<\>, and the helper functions arg(), arg_c(),
+/// left() and right().
 //
 //  Copyright 2004 Eric Niebler. Distributed under the Boost
 //  Software License, Version 1.0. (See accompanying file
@@ -213,24 +213,13 @@
             // id
             template<typename Expr>
             struct id
-              : id<typename Expr::expr_type>
-            {};
-
-            template<typename Args>
-            struct id<expr<terminal_tag, Args, 1> >
             {
-                typedef expr<terminal_tag, Args, 1> type;
+                typedef typename Expr::expr_type::id type;
             };
 
-        #define BOOST_PROTO_ARG_ID(z, N, data)\
-            typename id<typename data::BOOST_PP_CAT(BOOST_PP_CAT(arg, N), 
_type)::expr_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_ID
         }
 
         namespace op
@@ -447,15 +436,6 @@
             {
                 typedef expr<function_tag, BOOST_PP_CAT(args, 
N)<BOOST_PP_ENUM_PARAMS(N, A)> > type;
             };
-
-            template<typename Tag, typename Args>
-            struct id<expr<Tag, Args, N> >
-            {
-                typedef expr<Tag, Args, N> raw_expr_;
-                typedef expr<Tag, BOOST_PP_CAT(args, N)<
-                    BOOST_PP_ENUM(N, BOOST_PROTO_ARG_ID, raw_expr_)
-                > > 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