Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66749 - in sandbox/SOC/2010/phoenix3: boost/phoenix boost/phoenix/statement libs/phoenix/test libs/phoenix/test/statement
From: thom.heller_at_[hidden]
Date: 2010-11-25 07:00:23


Author: theller
Date: 2010-11-25 07:00:18 EST (Thu, 25 Nov 2010)
New Revision: 66749
URL: http://svn.boost.org/trac/boost/changeset/66749

Log:
finished refactoring of loop statements
Text files modified:
   sandbox/SOC/2010/phoenix3/boost/phoenix/statement.hpp | 6 ++--
   sandbox/SOC/2010/phoenix3/boost/phoenix/statement/do_while.hpp | 34 ++++++++++++++++++-------------
   sandbox/SOC/2010/phoenix3/boost/phoenix/statement/for.hpp | 43 +++++++++++++++++++++------------------
   sandbox/SOC/2010/phoenix3/boost/phoenix/statement/while.hpp | 33 +++++++++++++++++-------------
   sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile | 4 +-
   sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/loops_tests.cpp | 11 ++-------
   6 files changed, 70 insertions(+), 61 deletions(-)

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 07:00:18 EST (Thu, 25 Nov 2010)
@@ -8,13 +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/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>
+#include <boost/phoenix/statement/while.hpp>
 
 #endif

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/statement/do_while.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/statement/do_while.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/statement/do_while.hpp 2010-11-25 07:00:18 EST (Thu, 25 Nov 2010)
@@ -8,20 +8,18 @@
 #ifndef PHOENIX_STATEMENT_DO_WHILE_HPP
 #define PHOENIX_STATEMENT_DO_WHILE_HPP
 
-#include <boost/phoenix/core/compose.hpp>
+#include <boost/phoenix/core/expression.hpp>
 
 namespace boost { namespace phoenix
 {
- namespace result_of
- {
- template <typename Env, typename Cond, typename Do>
- struct do_while
- {
- typedef void type;
- };
- }
+ PHOENIX_DEFINE_EXPRESSION(
+ do_while
+ , (meta_grammar) // Cond
+ (meta_grammar) // Do
+ )
 
     struct do_while_eval
+ : proto::callable
     {
         typedef void result_type;
 
@@ -34,9 +32,17 @@
             while (eval(cond, env));
         }
     };
-
- template <typename Cond, typename Do>
- struct make_do_while : compose<do_while_eval, Cond, Do> {};
+
+ template <typename Dummy>
+ struct default_actions::when<rule::do_while, Dummy>
+ : proto::call<
+ do_while_eval(
+ _env
+ , proto::_child_c<0> // Cond
+ , proto::_child_c<1> // Do
+ )
+ >
+ {};
 
     template <typename Do>
     struct do_while_gen
@@ -45,10 +51,10 @@
             : do_(do_) {}
 
         template <typename Cond>
- typename make_do_while<Cond, Do>::type const
+ typename expression::do_while<Cond, Do>::type const
         while_(Cond const& cond) const
         {
- return make_do_while<Cond, Do>()(cond, do_);
+ return expression::do_while<Cond, Do>::make(cond, do_);
         }
 
         Do const& do_;

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/statement/for.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/statement/for.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/statement/for.hpp 2010-11-25 07:00:18 EST (Thu, 25 Nov 2010)
@@ -8,24 +8,17 @@
 #ifndef PHOENIX_STATEMENT_FOR_HPP
 #define PHOENIX_STATEMENT_FOR_HPP
 
-#include <boost/phoenix/core/compose.hpp>
+#include <boost/phoenix/core/expression.hpp>
 
 namespace boost { namespace phoenix
 {
- namespace result_of
- {
- template <
- typename Env
- , typename Init
- , typename Cond
- , typename Step
- , typename Do>
- struct for_
- {
- typedef void type;
- };
-
- }
+ PHOENIX_DEFINE_EXPRESSION(
+ for_
+ , (meta_grammar) // Cond
+ (meta_grammar) // Init
+ (meta_grammar) // Step
+ (meta_grammar) // Do
+ )
 
     struct for_eval
     {
@@ -50,9 +43,19 @@
         }
     };
     
- template <typename Init, typename Cond, typename Step, typename Do>
- struct make_for : compose<for_eval, Init, Cond, Step, Do> {};
-
+ template <typename Dummy>
+ struct default_actions::when<rule::for_, Dummy>
+ : proto::call<
+ for_eval(
+ _env
+ , proto::_child_c<0> // Cond
+ , proto::_child_c<1> // Init
+ , proto::_child_c<2> // Step
+ , proto::_child_c<3> // Do
+ )
+ >
+ {};
+
     template <typename Init, typename Cond, typename Step>
     struct for_gen
     {
@@ -60,10 +63,10 @@
             : init(init), cond(cond), step(step) {}
 
         template <typename Do>
- typename make_for<Init, Cond, Step, Do>::type const
+ typename expression::for_<Init, Cond, Step, Do>::type const
         operator[](Do const& do_) const
         {
- return make_for<Init, Cond, Step, Do>()(init, cond, step, do_);
+ return expression::for_<Init, Cond, Step, Do>::make(init, cond, step, do_);
         }
 
         Init const& init;

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/statement/while.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/statement/while.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/statement/while.hpp 2010-11-25 07:00:18 EST (Thu, 25 Nov 2010)
@@ -8,18 +8,15 @@
 #ifndef PHOENIX_STATEMENT_WHILE_HPP
 #define PHOENIX_STATEMENT_WHILE_HPP
 
-#include <boost/phoenix/core/compose.hpp>
+#include <boost/phoenix/core/expression.hpp>
 
 namespace boost { namespace phoenix
 {
- namespace result_of
- {
- template <typename Env, typename Cond, typename Do>
- struct while_
- {
- typedef void type;
- };
- }
+ PHOENIX_DEFINE_EXPRESSION(
+ while_
+ , (meta_grammar) // Cond
+ (meta_grammar) // Do
+ )
 
     struct while_eval
     {
@@ -35,9 +32,17 @@
             }
         }
     };
-
- template <typename Cond, typename Do>
- struct make_while : compose<while_eval, Cond, Do> {};
+
+ template <typename Dummy>
+ struct default_actions::when<rule::while_, Dummy>
+ : proto::call<
+ while_eval(
+ _env
+ , proto::_child_c<0> // Cond
+ , proto::_child_c<1> // Do
+ )
+ >
+ {};
 
     template <typename Cond>
     struct while_gen
@@ -45,10 +50,10 @@
         while_gen(Cond const& cond) : cond(cond) {}
 
         template <typename Do>
- typename make_while<Cond, Do>::type const
+ typename expression::while_<Cond, Do>::type const
         operator[](Do const& do_) const
         {
- return make_while<Cond, Do>()(cond, do_);
+ return expression::while_<Cond, Do>::make(cond, do_);
         }
 
         Cond const& cond;

Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile 2010-11-25 07:00:18 EST (Thu, 25 Nov 2010)
@@ -51,8 +51,8 @@
     ;
     
 test-suite phoenix_statement :
-# [ run statement/if_tests.cpp ]
-# [ run statement/loops_tests.cpp ]
+ [ run statement/if_tests.cpp ]
+ [ run statement/loops_tests.cpp ]
 # [ run statement/switch_tests.cpp ]
 # [ run statement/exceptions.cpp ]
     ;

Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/loops_tests.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/loops_tests.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/loops_tests.cpp 2010-11-25 07:00:18 EST (Thu, 25 Nov 2010)
@@ -17,10 +17,8 @@
 {
     using boost::phoenix::arg_names::arg1;
     using boost::phoenix::do_;
- using boost::phoenix::for_;
     using boost::phoenix::ref;
     using boost::phoenix::val;
- using boost::phoenix::while_;
 
     using std::cout;
     using std::endl;
@@ -40,8 +38,7 @@
                 cout << arg1 << ", ",
                 ++ref(x)
             ],
- cout << ref("\n")
- //cout << val("\n")
+ cout << val("\n")
         )
     );
 
@@ -58,8 +55,7 @@
                 ++ref(x)
             ]
             .while_(arg1--),
- cout << ref("\n")
- //cout << val("\n")
+ cout << val("\n")
         )
     );
 
@@ -76,8 +72,7 @@
                 cout << arg1 << ", ",
                 ++ref(x)
             ],
- cout << ref("\n")
- //cout << val("\n")
+ cout << val("\n")
         )
     );
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk