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

Modified Files:
        domain.hpp make_expr.hpp proto_fwd.hpp 
Log Message:
make_expr and friends play nice with domains and generate<>

Index: domain.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/domain.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- domain.hpp  14 Feb 2007 08:03:06 -0000      1.1
+++ domain.hpp  25 May 2007 00:53:40 -0000      1.2
@@ -11,6 +11,7 @@
 #define BOOST_PROTO_DOMAIN_HPP_EAN_02_13_2007
 
 #include <boost/xpressive/proto/detail/prefix.hpp>
+#include <boost/mpl/bool.hpp>
 #include <boost/xpressive/proto/proto_fwd.hpp>
 #include <boost/xpressive/proto/detail/suffix.hpp>
 
@@ -21,8 +22,22 @@
     struct domain
     {
         typedef Grammar grammar;
+
+        /// INTERNAL ONLY
+        ///
+        typedef void boost_proto_is_domain_;
     };
 
+    template<typename T, typename EnableIf>
+    struct is_domain
+      : mpl::false_
+    {};
+
+    template<typename T>
+    struct is_domain<T, typename T::boost_proto_is_domain_>
+      : mpl::true_
+    {};
+
 }}
 
 #endif

Index: make_expr.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/make_expr.hpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- make_expr.hpp       24 May 2007 23:25:40 -0000      1.13
+++ make_expr.hpp       25 May 2007 00:53:40 -0000      1.14
@@ -27,6 +27,8 @@
     #include <boost/type_traits/remove_reference.hpp>
     #include <boost/xpressive/proto/proto_fwd.hpp>
     #include <boost/xpressive/proto/traits.hpp>
+    #include <boost/xpressive/proto/domain.hpp>
+    #include <boost/xpressive/proto/generate.hpp>
     #include <boost/fusion/sequence/intrinsic/at.hpp>
     #include <boost/fusion/sequence/intrinsic/value_at.hpp>
     #include <boost/fusion/sequence/intrinsic/size.hpp>
@@ -62,53 +64,81 @@
     {
         namespace result_of
         {
-            template<typename Tag, typename Sequence, std::size_t Size>
+            template<typename Tag, typename Domain, typename Sequence, 
std::size_t Size>
             struct unpack_expr_detail
             {};
 
-            template<typename Sequence>
-            struct unpack_expr_detail<tag::terminal, Sequence, 1u>
+            template<typename Domain, typename Sequence>
+            struct unpack_expr_detail<tag::terminal, Domain, Sequence, 1u>
             {
                 typedef expr<
                     tag::terminal
                   , args1<typename fusion::result_of::value_at_c<Sequence, 
0>::type>
-                > type;
+                > expr_type;
+
+                typedef typename generate<Domain, expr_type>::type type;
 
                 static type const call(Sequence const &sequence)
                 {
-                    type that = {fusion::at_c<0>(sequence)};
-                    return that;
+                    expr_type that = {fusion::at_c<0>(sequence)};
+                    return generate<Domain, expr_type>::make(that);
                 }
             };
 
-            template<typename Tag, typename Sequence>
-            struct unpack_expr
-              : unpack_expr_detail<Tag, Sequence, 
fusion::result_of::size<Sequence>::type::value>
+            template<
+                typename Tag
+              , typename Domain
+                BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(BOOST_PROTO_MAX_ARITY, 
typename A, = void BOOST_PP_INTERCEPT)
+              , typename _ = void
+            >
+            struct make_expr_detail
             {};
 
-        #define BOOST_PP_ITERATION_PARAMS_1                                    
                     \
-            (4, (1, BOOST_PROTO_MAX_ARITY, 
<boost/xpressive/proto/make_expr.hpp>, 1))               \
-            /**/
-
-        #include BOOST_PP_ITERATE()
-
-            template<typename A>
-            struct make_expr<tag::terminal, A>
+            template<typename Domain, typename A>
+            struct make_expr_detail<tag::terminal, Domain, A>
             {
                 typedef typename add_reference<A>::type reference;
-                typedef expr<tag::terminal, args1<reference> > type;
+                typedef expr<tag::terminal, args1<reference> > expr_type;
+                typedef typename generate<Domain, expr_type>::type type;
 
                 static type const call(reference a)
                 {
-                    type that = {a};
-                    return that;
+                    expr_type that = {a};
+                    return generate<Domain, expr_type>::make(that);
                 }
             };
+
+        #define BOOST_PP_ITERATION_PARAMS_1                                    
                     \
+            (4, (1, BOOST_PROTO_MAX_ARITY, 
<boost/xpressive/proto/make_expr.hpp>, 1))               \
+            /**/
+
+        #include BOOST_PP_ITERATE()
+
+            template<typename Tag, typename Sequence, typename, typename>
+            struct unpack_expr
+              : unpack_expr_detail<Tag, default_domain, Sequence, 
fusion::result_of::size<Sequence>::type::value>
+            {};
+
+            template<typename Tag, typename Domain, typename Sequence>
+            struct unpack_expr<Tag, Domain, Sequence, typename 
Domain::boost_proto_is_domain_>
+              : unpack_expr_detail<Tag, Domain, Sequence, 
fusion::result_of::size<Sequence>::type::value>
+            {};
+
+            template<typename Tag 
BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, typename A), typename, 
typename>
+            struct make_expr
+              : make_expr_detail<Tag, default_domain 
BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A) >
+            {};
+
+            template<typename Tag, typename Domain 
BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, typename A) >
+            struct make_expr<Tag, Domain 
BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A), typename 
Domain::boost_proto_is_domain_>
+              : make_expr_detail<Tag, Domain 
BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A) >
+            {};
+
         }
 
         namespace functional
         {
-            template<typename Tag>
+            template<typename Tag, typename Domain>
             struct make_expr
             {
                 template<typename Sig>
@@ -122,8 +152,8 @@
         #include BOOST_PP_ITERATE()
             };
 
-            template<>
-            struct make_expr<tag::terminal>
+            template<typename Domain>
+            struct make_expr<tag::terminal, Domain>
             {
                 template<typename Sig>
                 struct result
@@ -131,23 +161,23 @@
 
                 template<typename This, typename A>
                 struct result<This(A)>
-                  : result_of::make_expr<tag::terminal, A>
+                  : result_of::make_expr<tag::terminal, Domain, A>
                 {};
 
                 template<typename A>
-                typename result_of::make_expr<tag::terminal, A &>::type 
operator ()(A &a) const
+                typename result_of::make_expr<tag::terminal, Domain, A 
&>::type operator ()(A &a) const
                 {
-                    return result_of::make_expr<tag::terminal, A &>::call(a);
+                    return result_of::make_expr<tag::terminal, Domain, A 
&>::call(a);
                 }
 
                 template<typename A>
-                typename result_of::make_expr<tag::terminal, A const &>::type 
operator ()(A const &a) const
+                typename result_of::make_expr<tag::terminal, Domain, A const 
&>::type operator ()(A const &a) const
                 {
-                    return result_of::make_expr<tag::terminal, A const 
&>::call(a);
+                    return result_of::make_expr<tag::terminal, Domain, A const 
&>::call(a);
                 }
             };
 
-            template<typename Tag>
+            template<typename Tag, typename Domain>
             struct unpack_expr
             {
                 template<typename Sig>
@@ -156,36 +186,36 @@
 
                 template<typename This, typename Sequence>
                 struct result<This(Sequence)>
-                  : result_of::unpack_expr<Tag, typename 
detail::remove_cv_ref<Sequence>::type>
+                  : result_of::unpack_expr<Tag, Domain, typename 
detail::remove_cv_ref<Sequence>::type>
                 {};
 
                 template<typename Sequence>
-                typename result_of::unpack_expr<Tag, Sequence>::type
+                typename result_of::unpack_expr<Tag, Domain, Sequence>::type
                 operator ()(Sequence const &sequence) const
                 {
-                    return result_of::unpack_expr<Tag, 
Sequence>::call(sequence);
+                    return result_of::unpack_expr<Tag, Domain, 
Sequence>::call(sequence);
                 }
             };
 
-            template<typename Tag>
+            template<typename Tag, typename Domain>
             struct unfused_expr_fun
             {
                 template<typename Sequence>
                 struct result
-                  : result_of::unpack_expr<Tag, Sequence>
+                  : result_of::unpack_expr<Tag, Domain, Sequence>
                 {};
 
                 template<typename Sequence>
-                typename proto::result_of::unpack_expr<Tag, Sequence>::type
+                typename proto::result_of::unpack_expr<Tag, Domain, 
Sequence>::type
                 operator ()(Sequence const &sequence) const
                 {
-                    return result_of::unpack_expr<Tag, 
Sequence>::call(sequence);
+                    return result_of::unpack_expr<Tag, Domain, 
Sequence>::call(sequence);
                 }
             };
 
-            template<typename Tag>
+            template<typename Tag, typename Domain>
             struct unfused_expr
-              : fusion::unfused_generic<unfused_expr_fun<Tag> >
+              : fusion::unfused_generic<unfused_expr_fun<Tag, Domain> >
             {};
         }
 
@@ -196,18 +226,38 @@
     #include BOOST_PP_ITERATE()
 
         template<typename Tag, typename Sequence>
-        typename result_of::unpack_expr<Tag, Sequence>::type const
+        typename lazy_disable_if<
+            is_domain<Sequence>
+          , result_of::unpack_expr<Tag, Sequence>
+        >::type const
         unpack_expr(Sequence const &sequence)
         {
             return result_of::unpack_expr<Tag, Sequence>::call(sequence);
         }
 
+        template<typename Tag, typename Domain, typename Sequence>
+        typename result_of::unpack_expr<Tag, Domain, Sequence>::type const
+        unpack_expr(Sequence const &sequence)
+        {
+            return result_of::unpack_expr<Tag, Domain, 
Sequence>::call(sequence);
+        }
+
         template<typename Tag, typename A0>
-        typename result_of::make_expr<Tag, A0>::type const
+        typename lazy_disable_if<
+            is_domain<A0>
+          , result_of::make_expr<Tag, A0>
+        >::type const
         make_expr(A0 &a0 BOOST_PROTO_DISABLE_IF_IS_CONST(A0))
         {
             return result_of::make_expr<Tag, A0>::call(a0);
         }
+
+        template<typename Tag, typename Domain, typename A0>
+        typename result_of::make_expr<Tag, Domain, A0>::type const
+        make_expr(A0 &a0 BOOST_PROTO_DISABLE_IF_IS_CONST(A0))
+        {
+            return result_of::make_expr<Tag, Domain, A0>::call(a0);
+        }
     }}
 
     #undef BOOST_PROTO_AS_ARG_TYPE
@@ -221,37 +271,41 @@
 
     #define N BOOST_PP_ITERATION()
 
-        template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
-        struct make_expr<Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, A)>
+        template<typename Tag, typename Domain 
BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+        struct make_expr_detail<Tag, Domain BOOST_PP_ENUM_TRAILING_PARAMS(N, 
A) >
         {
             typedef expr<
                 Tag
               , BOOST_PP_CAT(args, N)<BOOST_PP_ENUM(N, 
BOOST_PROTO_AS_ARG_TYPE, A) >
-            > type;
+            > expr_type;
+
+            typedef typename generate<Domain, expr_type>::type type;
 
             static type const call(BOOST_PP_ENUM_BINARY_PARAMS(N, A, &a))
             {
-                type that = {
+                expr_type that = {
                     BOOST_PP_ENUM(N, BOOST_PROTO_AS_ARG, a)
                 };
-                return that;
+                return generate<Domain, expr_type>::make(that);
             }
         };
 
-        template<typename Tag, typename Sequence>
-        struct unpack_expr_detail<Tag, Sequence, N>
+        template<typename Tag, typename Domain, typename Sequence>
+        struct unpack_expr_detail<Tag, Domain, Sequence, N>
         {
             typedef expr<
                 Tag
               , BOOST_PP_CAT(args, N)<BOOST_PP_ENUM(N, BOOST_PROTO_AT_TYPE, 
Sequence const) >
-            > type;
+            > expr_type;
+
+            typedef typename generate<Domain, expr_type>::type type;
 
             static type const call(Sequence const &sequence)
             {
-                type that = {
+                expr_type that = {
                     BOOST_PP_ENUM(N, BOOST_PROTO_AT, sequence)
                 };
-                return that;
+                return generate<Domain, expr_type>::make(that);
             }
         };
 
@@ -265,6 +319,7 @@
         struct result<This(BOOST_PP_ENUM_PARAMS(N, A))>
           : result_of::make_expr<
                 Tag
+              , Domain
                 BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
                     N
                   , typename remove_reference<A
@@ -274,10 +329,10 @@
         {};
 
         template<BOOST_PP_ENUM_PARAMS(N, typename A)>
-        typename result_of::make_expr<Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, 
const A)>::type const
+        typename result_of::make_expr<Tag, Domain 
BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)>::type const
         operator ()(BOOST_PP_ENUM_BINARY_PARAMS(N, const A, &a)) const
         {
-            return result_of::make_expr<Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, 
const A)>::call(
+            return result_of::make_expr<Tag, Domain 
BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)>::call(
                 BOOST_PP_ENUM_PARAMS(N, a)
             );
         }
@@ -289,7 +344,10 @@
     #define N BOOST_PP_ITERATION()
 
         template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
-        typename result_of::make_expr<Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, 
const A)>::type const
+        typename lazy_disable_if<
+            is_domain<A0>
+          , result_of::make_expr<Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)>
+        >::type const
         make_expr(BOOST_PP_ENUM_BINARY_PARAMS(N, const A, &a))
         {
             return result_of::make_expr<Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, 
const A)>::call(
@@ -297,6 +355,15 @@
             );
         }
 
+        template<typename Tag, typename Domain 
BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+        typename result_of::make_expr<Tag, Domain 
BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)>::type const
+        make_expr(BOOST_PP_ENUM_BINARY_PARAMS(N, const A, &a))
+        {
+            return result_of::make_expr<Tag, Domain 
BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)>::call(
+                BOOST_PP_ENUM_PARAMS(N, a)
+            );
+        }
+
     #undef N
 
 #endif // BOOST_PP_IS_ITERATING

Index: proto_fwd.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/proto_fwd.hpp,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- proto_fwd.hpp       24 May 2007 23:25:40 -0000      1.64
+++ proto_fwd.hpp       25 May 2007 00:53:40 -0000      1.65
@@ -215,6 +215,9 @@
     template<typename T, typename EnableIf = void>
     struct is_expr;
 
+    template<typename T, typename EnableIf = void>
+    struct is_domain;
+
     namespace result_of
     {
         template<typename T, typename EnableIf = void>
@@ -254,11 +257,12 @@
               , typename A
               , = void BOOST_PP_INTERCEPT
             )
-          , typename _ = void
+          , typename _1 = void
+          , typename _2 = void
         >
         struct make_expr;
 
-        template<typename Tag, typename Sequence>
+        template<typename Tag, typename DomainOrSequence, typename 
SequenceOrVoid = void, typename _ = void>
         struct unpack_expr;
     }
 
@@ -358,16 +362,16 @@
         template<long N>
         struct arg_c;
 
-        template<typename Tag>
+        template<typename Tag, typename Domain = default_domain>
         struct make_expr;
 
-        template<typename Tag>
+        template<typename Tag, typename Domain = default_domain>
         struct unpack_expr;
 
-        template<typename Tag>
+        template<typename Tag, typename Domain = default_domain>
         struct unfused_expr_fun;
 
-        template<typename Tag>
+        template<typename Tag, typename Domain = default_domain>
         struct unfused_expr;
     }
 


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to