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

Modified Files:
        expr.hpp extends.hpp operators.hpp proto.hpp proto_fwd.hpp 
Added Files:
        domain.hpp generate.hpp 
Log Message:
add domain<> for associating a grammar with a domain, and use the domain's 
grammart to control the operator overloading; add is_allowed for extra ability 
to control operator overloading (eg., in the default domain

--- NEW FILE: domain.hpp ---
///////////////////////////////////////////////////////////////////////////////
/// \file domain.hpp
/// Contains definition of domain\<\> class template, for defining domains
/// with a grammar for controlling operator overloading.
//
//  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_PROTO_DOMAIN_HPP_EAN_02_13_2007
#define BOOST_PROTO_DOMAIN_HPP_EAN_02_13_2007

#include <boost/xpressive/proto/detail/prefix.hpp>
#include <boost/xpressive/proto/proto_fwd.hpp>
#include <boost/xpressive/proto/detail/suffix.hpp>

namespace boost { namespace proto
{

    template<typename Grammar>
    struct domain
    {
        typedef Grammar grammar;
    };

}}

#endif

--- NEW FILE: generate.hpp ---
///////////////////////////////////////////////////////////////////////////////
/// \file generate.hpp
/// Contains definition of generate\<\> class template, which end users can 
/// specialize for generating domain-specific expression wrappers.
//
//  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_PROTO_GENERATE_HPP_EAN_02_13_2007
#define BOOST_PROTO_GENERATE_HPP_EAN_02_13_2007

#include <boost/xpressive/proto/detail/prefix.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/xpressive/proto/proto_fwd.hpp>
#include <boost/xpressive/proto/matches.hpp>
#include <boost/xpressive/proto/detail/suffix.hpp>

namespace boost { namespace proto
{

    template<typename Domain, typename Expr>
    struct generate
    {
        typedef Expr type;

        static Expr const &make(Expr const &expr)
        {
            return expr;
        }
    };

    template<typename Domain, typename Expr, typename EnableIf>
    struct is_allowed
      : matches<Expr, typename Domain::grammar>
    {};

    namespace detail
    {
        struct empty
        {};

        template<typename Domain, typename Expr>
        struct generate_if
          : mpl::if_<
                is_allowed<Domain, Expr>
              , generate<Domain, Expr>
              , detail::empty
            >::type
        {};

    }

}}

#endif

Index: expr.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/expr.hpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- expr.hpp    13 Feb 2007 21:57:21 -0000      1.22
+++ expr.hpp    14 Feb 2007 08:03:06 -0000      1.23
@@ -79,7 +79,7 @@
             typedef Tag tag_type;
             typedef expr type;
             typedef Args args_type;
-            typedef void domain;
+            typedef default_domain domain;
             typedef mpl::long_<BOOST_PP_ITERATION()> arity;
             typedef proto_expr_tag fusion_tag;
             typedef void is_boost_proto_expr_;
@@ -184,7 +184,7 @@
 
         template<typename This BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
         struct result<This(BOOST_PP_ENUM_PARAMS(N, A))>
-            : result_of::BOOST_PP_CAT(funop, N)<expr 
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, typename remove_reference<A, >::type 
BOOST_PP_INTERCEPT)>
+          : result_of::BOOST_PP_CAT(funop, N)<expr 
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, typename remove_reference<A, >::type 
BOOST_PP_INTERCEPT)>
         {};
 
         template<BOOST_PP_ENUM_PARAMS(N, typename A)>

Index: extends.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/extends.hpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- extends.hpp 13 Feb 2007 21:57:21 -0000      1.20
+++ extends.hpp 14 Feb 2007 08:03:06 -0000      1.21
@@ -21,6 +21,7 @@
 #include <boost/xpressive/proto/traits.hpp>
 #include <boost/xpressive/proto/expr.hpp>
 #include <boost/xpressive/proto/args.hpp>
+#include <boost/xpressive/proto/generate.hpp>
 #include <boost/xpressive/proto/detail/suffix.hpp>
 
 namespace boost { namespace proto
@@ -97,9 +98,7 @@
             typedef typename generate<Domain, expr<tag::function, 
args1<ref<Derived const> > > >::type type;
         };
 
-        // BUGBUG Derived is incomplete here!
-        //typename generate<Domain, expr<tag::function, args1<ref<Derived 
const> > >, void >::type const
-        expr<tag::function, args1<ref<Derived const> > > const
+        typename generate<Domain, expr<tag::function, args1<ref<Derived const> 
> > >::type const
         operator ()() const
         {
             expr<tag::function, args1<ref<Derived const> > > that = 
{{this->derived()}};

Index: operators.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/operators.hpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- operators.hpp       13 Feb 2007 21:57:21 -0000      1.25
+++ operators.hpp       14 Feb 2007 08:03:06 -0000      1.26
@@ -18,20 +18,11 @@
 #include <boost/xpressive/proto/proto_fwd.hpp>
 #include <boost/xpressive/proto/tags.hpp>
 #include <boost/xpressive/proto/expr.hpp>
+#include <boost/xpressive/proto/generate.hpp>
 #include <boost/xpressive/proto/detail/suffix.hpp>
 
 namespace boost { namespace proto
 {
-    template<typename Domain, typename Expr, typename EnableIf>
-    struct generate
-    {
-        typedef Expr type;
-        static Expr const &make(Expr const &expr)
-        {
-            return expr;
-        }
-    };
-
     namespace detail
     {
         template<typename Tag, typename Left, typename Right, typename Enable1 
= void, typename Enable2 = void>
@@ -40,7 +31,7 @@
 
         template<typename Tag, typename Left, typename Right>
         struct as_expr_if2<Tag, Left, Right, typename 
Left::is_boost_proto_expr_, void>
-          : generate<
+          : generate_if<
                 typename Left::domain
               , expr<
                     Tag
@@ -54,9 +45,8 @@
             typedef expr<tag::terminal, args1<Right &> > term_type;
             typedef expr<Tag, args2<ref<Left>, typename generate<typename 
Left::domain, term_type>::type> > expr_type;
 
-            template<typename Left2>
-            static typename generate<typename Left2::domain, expr_type>::type
-            make(Left2 &left, Right &right)
+            static typename generate<typename Left::domain, expr_type>::type
+            make(Left &left, Right &right)
             {
                 term_type term = {right};
                 expr_type that = {{left}, generate<typename Left::domain, 
term_type>::make(term)};
@@ -66,7 +56,7 @@
 
         template<typename Tag, typename Left, typename Right>
         struct as_expr_if2<Tag, Left, Right, void, typename 
Right::is_boost_proto_expr_>
-          : generate<
+          : generate_if<
                 typename Right::domain
               , expr<
                     Tag
@@ -80,9 +70,8 @@
             typedef expr<tag::terminal, args1<Left &> > term_type;
             typedef expr<Tag, args2<typename generate<typename Right::domain, 
term_type>::type, ref<Right> > > expr_type;
 
-            template<typename Right2>
-            static typename generate<typename Right2::domain, expr_type>::type
-            make(Left &left, Right2 &right)
+            static typename generate<typename Right::domain, expr_type>::type
+            make(Left &left, Right &right)
             {
                 term_type term = {left};
                 expr_type that = {generate<typename Right::domain, 
term_type>::make(term), {right}};
@@ -97,7 +86,7 @@
 
         template<typename Tag, typename Left, typename Right>
         struct as_expr_if<Tag, Left, Right, typename 
Left::is_boost_proto_expr_, typename Right::is_boost_proto_expr_>
-          : generate<
+          : generate_if<
                 typename Left::domain
               , expr<Tag, args2<ref<Left>, ref<Right> > >
             >
@@ -105,9 +94,8 @@
             typedef expr<Tag, args2<ref<Left>, ref<Right> > > expr_type;
             BOOST_MPL_ASSERT((is_same<typename Left::domain, typename 
Right::domain>));
 
-            template<typename Left2>
-            static typename generate<typename Left2::domain, expr_type>::type
-            make(Left2 &left, Right &right)
+            static typename generate<typename Left::domain, expr_type>::type
+            make(Left &left, Right &right)
             {
                 expr_type that = {{left}, {right}};
                 return generate<typename Left::domain, expr_type>::make(that);
@@ -117,18 +105,20 @@
 
 #define BOOST_PROTO_UNARY_OP(op, tag)\
     template<typename Arg>\
-    inline typename generate<typename Arg::domain, expr<tag, 
args1<ref<typename Arg::boost_proto_expr_type_> > > >::type const\
+    inline typename detail::generate_if<typename Arg::domain, expr<tag, 
args1<ref<typename Arg::boost_proto_expr_type_> > > >::type const\
     operator op(Arg &arg)\
     {\
-        expr<tag, args1<ref<typename Arg::boost_proto_expr_type_> > > that = 
{{arg}};\
-        return generate<typename Arg::domain, expr<tag, args1<ref<typename 
Arg::boost_proto_expr_type_> > > >::make(that);\
+        typedef expr<tag, args1<ref<typename Arg::boost_proto_expr_type_> > > 
that_type;\
+        that_type that = {{arg}};\
+        return generate<typename Arg::domain, that_type>::make(that);\
     }\
     template<typename Arg>\
-    inline typename generate<typename Arg::domain, expr<tag, 
args1<ref<typename Arg::boost_proto_expr_type_ const> > > >::type const\
+    inline typename detail::generate_if<typename Arg::domain, expr<tag, 
args1<ref<typename Arg::boost_proto_expr_type_ const> > > >::type const\
     operator op(Arg const &arg)\
     {\
-        expr<tag, args1<ref<typename Arg::boost_proto_expr_type_ const> > > 
that = {{arg}};\
-        return generate<typename Arg::domain, expr<tag, args1<ref<typename 
Arg::boost_proto_expr_type_ const> > > >::make(that);\
+        typedef expr<tag, args1<ref<typename Arg::boost_proto_expr_type_ 
const> > > that_type;\
+        that_type that = {{arg}};\
+        return generate<typename Arg::domain, that_type>::make(that);\
     }\
     /**/
 
@@ -200,41 +190,45 @@
     BOOST_PROTO_BINARY_OP(|=, tag::bitwise_or_assign)
     BOOST_PROTO_BINARY_OP(^=, tag::bitwise_xor_assign)
 
+#undef BOOST_PROTO_UNARY_OP
+#undef BOOST_PROTO_BINARY_OP
+
     template<typename Arg>
-    inline typename generate<typename Arg::domain, expr<tag::post_inc, 
args1<ref<typename Arg::boost_proto_expr_type_> > > >::type const
+    inline typename detail::generate_if<typename Arg::domain, 
expr<tag::post_inc, args1<ref<typename Arg::boost_proto_expr_type_> > > >::type 
const
     operator ++(Arg &arg, int)
     {
-        expr<tag::post_inc, args1<ref<typename Arg::boost_proto_expr_type_> > 
> that = {{arg}};
-        return generate<typename Arg::domain, expr<tag::post_inc, 
args1<ref<typename Arg::boost_proto_expr_type_> > > >::make(that);
+        typedef expr<tag::post_inc, args1<ref<typename 
Arg::boost_proto_expr_type_> > > that_type;
+        that_type that = {{arg}};
+        return generate<typename Arg::domain, that_type>::make(that);
     }
 
     template<typename Arg>
-    inline typename generate<typename Arg::domain, expr<tag::post_inc, 
args1<ref<typename Arg::boost_proto_expr_type_ const> > > >::type const
+    inline typename detail::generate_if<typename Arg::domain, 
expr<tag::post_inc, args1<ref<typename Arg::boost_proto_expr_type_ const> > > 
>::type const
     operator ++(Arg const &arg, int)
     {
-        expr<tag::post_inc, args1<ref<typename Arg::boost_proto_expr_type_ 
const> > > that = {{arg}};
-        return generate<typename Arg::domain, expr<tag::post_inc, 
args1<ref<typename Arg::boost_proto_expr_type_ const> > > >::make(that);
+        typedef expr<tag::post_inc, args1<ref<typename 
Arg::boost_proto_expr_type_ const> > > that_type;
+        that_type that = {{arg}};
+        return generate<typename Arg::domain, that_type>::make(that);
     }
 
     template<typename Arg>
-    inline typename generate<typename Arg::domain, expr<tag::post_dec, 
args1<ref<typename Arg::boost_proto_expr_type_> > > >::type const
+    inline typename detail::generate_if<typename Arg::domain, 
expr<tag::post_dec, args1<ref<typename Arg::boost_proto_expr_type_> > > >::type 
const
     operator --(Arg &arg, int)
     {
-        expr<tag::post_dec, args1<ref<typename Arg::boost_proto_expr_type_> > 
> that = {{arg}};
-        return generate<typename Arg::domain, expr<tag::post_dec, 
args1<ref<typename Arg::boost_proto_expr_type_> > > >::make(that);
+        typedef expr<tag::post_dec, args1<ref<typename 
Arg::boost_proto_expr_type_> > > that_type;
+        that_type that = {{arg}};
+        return generate<typename Arg::domain, that_type>::make(that);
     }
 
     template<typename Arg>
-    inline typename generate<typename Arg::domain, expr<tag::post_dec, 
args1<ref<typename Arg::boost_proto_expr_type_ const> > > >::type const
+    inline typename detail::generate_if<typename Arg::domain, 
expr<tag::post_dec, args1<ref<typename Arg::boost_proto_expr_type_ const> > > 
>::type const
     operator --(Arg const &arg, int)
     {
-        expr<tag::post_dec, args1<ref<typename Arg::boost_proto_expr_type_ 
const> > > that = {{arg}};
-        return generate<typename Arg::domain, expr<tag::post_dec, 
args1<ref<typename Arg::boost_proto_expr_type_ const> > > >::make(that);
+        typedef expr<tag::post_dec, args1<ref<typename 
Arg::boost_proto_expr_type_ const> > > that_type;
+        that_type that = {{arg}};
+        return generate<typename Arg::domain, that_type>::make(that);
     }
 
-#undef BOOST_PROTO_UNARY_OP
-#undef BOOST_PROTO_BINARY_OP
-
 }}
 
 #endif

Index: proto.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/proto.hpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- proto.hpp   13 Jan 2007 18:09:21 -0000      1.15
+++ proto.hpp   14 Feb 2007 08:03:06 -0000      1.16
@@ -16,10 +16,12 @@
 #include <boost/xpressive/proto/tags.hpp>
 #include <boost/xpressive/proto/expr.hpp>
 #include <boost/xpressive/proto/traits.hpp>
+#include <boost/xpressive/proto/domain.hpp>
 #include <boost/xpressive/proto/compile.hpp>
 #include <boost/xpressive/proto/matches.hpp>
 #include <boost/xpressive/proto/extends.hpp>
 #include <boost/xpressive/proto/literal.hpp>
+#include <boost/xpressive/proto/generate.hpp>
 #include <boost/xpressive/proto/operators.hpp>
 #include <boost/xpressive/proto/deep_copy.hpp>
 #include <boost/xpressive/proto/detail/suffix.hpp>

Index: proto_fwd.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/proto_fwd.hpp,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- proto_fwd.hpp       13 Feb 2007 21:57:21 -0000      1.51
+++ proto_fwd.hpp       14 Feb 2007 08:03:07 -0000      1.52
@@ -235,13 +235,20 @@
     struct proto_ref_tag;
     struct proto_ref_iterator_tag;
 
-    template<typename Expr, typename Derived, typename Domain = void>
+    struct _;
+
+    template<typename Grammar = proto::_>
+    struct domain;
+
+    typedef domain<> default_domain;
+
+    template<typename Expr, typename Derived, typename Domain = default_domain>
     struct extends;
 
     template<typename Derived = void>
     struct context;
 
-    template<typename T, typename Domain = void>
+    template<typename T, typename Domain = default_domain>
     struct literal;
 
     template<typename T, typename EnableIf = void>
@@ -357,9 +364,12 @@
     template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PROTO_MAX_ARITY, 
typename A, void), typename Dummy = void>
     struct function;
 
-    template<typename Domain, typename Expr, typename EnableIf = void>
+    template<typename Domain, typename Expr>
     struct generate;
 
+    template<typename Domain, typename Expr, typename EnableIf = void>
+    struct is_allowed;
+
     namespace op
     {
         struct compile;
@@ -460,8 +470,6 @@
     template<typename Grammar>
     struct has_pass_through_transform;
 
-    struct _;
-
     template<typename Grammar>
     struct vararg;
 


-------------------------------------------------------------------------
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