$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r66747 - in sandbox/SOC/2010/phoenix3: boost/phoenix boost/phoenix/core boost/phoenix/statement libs/phoenix/test/boost_bind_compatibility libs/phoenix/test/statement
From: thom.heller_at_[hidden]
Date: 2010-11-25 06:46:52
Author: theller
Date: 2010-11-25 06:46:49 EST (Thu, 25 Nov 2010)
New Revision: 66747
URL: http://svn.boost.org/trac/boost/changeset/66747
Log:
finished refactoring of if statement
Added:
   sandbox/SOC/2010/phoenix3/boost/phoenix/statement/sequence.hpp   (contents, props changed)
Text files modified: 
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/expression.hpp                                   |     2                                         
   sandbox/SOC/2010/phoenix3/boost/phoenix/statement.hpp                                         |    13 +++--                                   
   sandbox/SOC/2010/phoenix3/boost/phoenix/statement/if.hpp                                      |    93 +++++++++++++++++++++++++++------------ 
   sandbox/SOC/2010/phoenix3/libs/phoenix/test/boost_bind_compatibility/bind_stdcall_mf_test.cpp |     4 +                                       
   sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/if_tests.cpp                            |     2                                         
   5 files changed, 76 insertions(+), 38 deletions(-)
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/expression.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/expression.hpp	(original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/expression.hpp	2010-11-25 06:46:49 EST (Thu, 25 Nov 2010)
@@ -220,7 +220,7 @@
         
         static type make(PHOENIX_A_a)
         {
-            type e = {proto::make_expr<Tag, default_domain_with_basic_expr>(PHOENIX_a)};
+            actor<base_type> const e = {proto::make_expr<Tag, default_domain_with_basic_expr>(PHOENIX_a)};
             return e;
         }
 
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/statement.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/statement.hpp	(original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/statement.hpp	2010-11-25 06:46:49 EST (Thu, 25 Nov 2010)
@@ -8,12 +8,13 @@
 #define PHOENIX_STATEMENT_HPP
 
 #include <boost/phoenix/version.hpp>
-#include <boost/phoenix/statement/do_while.hpp>
-#include <boost/phoenix/statement/for.hpp>
+//#include <boost/phoenix/statement/do_while.hpp>
+//#include <boost/phoenix/statement/for.hpp>
 #include <boost/phoenix/statement/if.hpp>
-#include <boost/phoenix/statement/switch.hpp>
-#include <boost/phoenix/statement/throw.hpp>
-#include <boost/phoenix/statement/try_catch.hpp>
-#include <boost/phoenix/statement/while.hpp>
+#include <boost/phoenix/statement/sequence.hpp>
+//#include <boost/phoenix/statement/switch.hpp>
+//#include <boost/phoenix/statement/throw.hpp>
+//#include <boost/phoenix/statement/try_catch.hpp>
+//#include <boost/phoenix/statement/while.hpp>
 
 #endif
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/statement/if.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/statement/if.hpp	(original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/statement/if.hpp	2010-11-25 06:46:49 EST (Thu, 25 Nov 2010)
@@ -9,10 +9,11 @@
 #define PHOENIX_STATEMENT_IF_HPP
 
 #include <boost/config.hpp>
+#include <boost/phoenix/core/expression.hpp>
 #include <boost/phoenix/core/actor.hpp>
-#include <boost/phoenix/core/compose.hpp>
+//#include <boost/phoenix/core/compose.hpp>
 
-#include <boost/phoenix/support/element_at.hpp>
+//#include <boost/phoenix/support/element_at.hpp>
 
 #ifdef BOOST_MSVC
 #pragma warning(push)
@@ -25,13 +26,41 @@
     // If-Else statements
     ////////////////////////////////////////////////////////////////////////////
     
-    // Function for evaluating lambdas like: if_( foo )[ bar ].else_[ baz ]
+    template <typename> struct if_actor;
+    
+    PHOENIX_DEFINE_EXPRESSION_EXT(
+        if_actor
+      , if_
+      , (meta_grammar) // Cond
+        (meta_grammar) // Then
+    )
+    
+    PHOENIX_DEFINE_EXPRESSION(
+        if_else_
+      , (meta_grammar) // Cond
+        (meta_grammar) // Then
+        (meta_grammar) // Else
+    )
+    
+    // Function for evaluating lambdas like:
+    // if_( foo )[ bar ]
+    // and
+    // if_( foo )[ bar ].else_[ baz ]
     struct if_else_eval
+        : proto::callable
     {
         typedef void result_type;
         
+        template<typename Env, typename Cond, typename Then>
+        result_type
+        operator()(Env & env, Cond const & cond, Then const & then) const
+        {
+            if( eval( cond, env ) )
+                eval( then, env );
+        }
+        
         template<typename Env, typename Cond, typename Then, typename Else>
-        void
+        result_type
         operator()(
               Env & env
             , Cond const & cond
@@ -44,23 +73,30 @@
                 eval( else_, env );
         }
     };
+    
+    template <typename Dummy>
+    struct default_actions::when<rule::if_, Dummy>
+        : proto::call<
+            if_else_eval(
+                _env
+              , proto::_child_c<0> // Cond
+              , proto::_child_c<1> // Then
+            )
+          >
+    {};
+    
+    template <typename Dummy>
+    struct default_actions::when<rule::if_else_, Dummy>
+        : proto::call<
+            if_else_eval(
+                _env
+              , proto::_child_c<0> // Cond
+              , proto::_child_c<1> // Then
+              , proto::_child_c<2> // Else
+            )
+          >
+    {};
 
-    template <typename Cond, typename Then, typename Else>
-    struct make_if_else_s : compose<if_else_eval, Cond, Then, Else> {};
-
-    // Function for evaluating lambdas like: if_( foo )[ bar ]
-    struct if_eval
-    {
-        typedef void result_type;
-        
-        template<typename Env, typename Cond, typename Then>
-        void
-        operator()(Env & env, Cond const & cond, Then const & then) const
-        {
-            if( eval( cond, env ) )
-                eval( then, env );
-        }
-    };
 
     // Generator for .else_[ expr ] branch.
     template<typename Cond, typename Then>
@@ -71,10 +107,10 @@
             , then( then ) {}
 
         template<typename Else>
-        typename make_if_else_s<Cond, Then, Else>::type const
+        typename expression::if_else_<Cond, Then, Else>::type const
         operator[](Else const & else_) const
         {
-            return make_if_else_s<Cond, Then, Else>()(cond, then, else_);
+            return expression::if_else_<Cond, Then, Else>::make(cond, then, else_);
         }
 
         Cond const & cond;
@@ -90,18 +126,15 @@
 
         if_actor(base_type const & base)
             : base_type( base )
-            , else_(element_at_c<0>(*this), element_at_c<1>(*this))
+            , else_(proto::child_c<0>(*this), proto::child_c<1>(*this))
         {}
 
-        typedef typename result_of::element_value_at_c<Expr, 0>::type cond_type;
-        typedef typename result_of::element_value_at_c<Expr, 1>::type then_type;
+        typedef typename proto::result_of::child_c<Expr, 0>::type cond_type;
+        typedef typename proto::result_of::child_c<Expr, 1>::type then_type;
 
         else_gen<cond_type, then_type> else_;
     };
 
-    template <typename Cond, typename Then>
-    struct make_if : compose_ex<if_eval, if_actor, Cond, Then> {};
-
     // Generator for if( cond )[ then ] branch.
     template<typename Cond>
     struct if_gen
@@ -110,10 +143,10 @@
             : cond( cond ) {}
 
         template<typename Then>
-        typename make_if<Cond, Then>::type const
+        typename expression::if_<Cond, Then>::type const
         operator[](Then const & then) const
         {
-            return make_if<Cond, Then>()(cond, then);
+            return expression::if_<Cond, Then>::make(cond, then);
         }
 
         Cond const & cond;
Added: sandbox/SOC/2010/phoenix3/boost/phoenix/statement/sequence.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/statement/sequence.hpp	2010-11-25 06:46:49 EST (Thu, 25 Nov 2010)
@@ -0,0 +1,36 @@
+/*==============================================================================
+    Copyright (c) 2001-2010 Joel de Guzman
+    Copyright (c) 2010 Eric Niebler
+    Copyright (c) 2010 Thomas Heller
+
+    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 PHOENIX_STATEMENT_SEQUENCE_HPP
+#define PHOENIX_STATEMENT_SEQUENCE_HPP
+
+#include <boost/config.hpp>
+#include <boost/phoenix/core/expression.hpp>
+#include <boost/phoenix/core/actor.hpp>
+
+namespace boost { namespace phoenix
+{
+	namespace rule
+	{
+		struct sequence
+		  : proto::binary_expr<
+		    proto::tag::comma
+		  , meta_grammar
+		  , meta_grammar>
+		{};
+	}
+
+	template <typename Dummy>
+	struct meta_grammar::case_<proto::tag::comma, Dummy>
+		: proto::when<rule::sequence, proto::external_transform>
+	{};
+
+}}
+
+#endif
Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/boost_bind_compatibility/bind_stdcall_mf_test.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/boost_bind_compatibility/bind_stdcall_mf_test.cpp	(original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/boost_bind_compatibility/bind_stdcall_mf_test.cpp	2010-11-25 06:46:49 EST (Thu, 25 Nov 2010)
@@ -75,7 +75,10 @@
     X x;
 
     // 0
+    
+    std::cout << typeid(typename boost::result_of<X::f0()>::type).name() << "\n";
 
+    /*
     bind(&X::f0, &x)();
     bind(&X::f0, ref(x))();
 
@@ -156,6 +159,7 @@
     bind(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)();
 
     BOOST_TEST( x.hash == 23558 );
+    */
 }
 
 int main()
Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/if_tests.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/if_tests.cpp	(original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/if_tests.cpp	2010-11-25 06:46:49 EST (Thu, 25 Nov 2010)
@@ -8,9 +8,9 @@
 #include <vector>
 #include <algorithm>
 #include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
 #include <boost/phoenix/statement.hpp>
 #include <boost/phoenix/operator.hpp>
-#include <boost/phoenix/core.hpp>
 
 int
 main()