Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67864 - in sandbox/SOC/2010/phoenix3: boost/phoenix/core boost/phoenix/scope boost/phoenix/statement libs/phoenix/test/scope
From: thom.heller_at_[hidden]
Date: 2011-01-09 10:07:52


Author: theller
Date: 2011-01-09 10:07:48 EST (Sun, 09 Jan 2011)
New Revision: 67864
URL: http://svn.boost.org/trac/boost/changeset/67864

Log:
code clean up take 2
Text files modified:
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor.hpp | 2
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/environment.hpp | 1
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/is_nullary.hpp | 145 +++++++++++++++++++++------------------
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp | 6 -
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope/lambda.hpp | 68 ++++++++----------
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope/let.hpp | 36 ++++-----
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_variable.hpp | 35 ++++-----
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope/scoped_environment.hpp | 2
   sandbox/SOC/2010/phoenix3/boost/phoenix/statement/switch.hpp | 19 ++--
   sandbox/SOC/2010/phoenix3/boost/phoenix/statement/try_catch.hpp | 10 +-
   sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/let_tests.cpp | 35 --------
   11 files changed, 164 insertions(+), 195 deletions(-)

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor.hpp 2011-01-09 10:07:48 EST (Sun, 09 Jan 2011)
@@ -61,7 +61,7 @@
             typedef
                 // avoid calling result_of::actor when this is false
                 typename mpl::eval_if<
- typename is_nullary<Expr>::type
+ typename result_of::is_nullary<Expr>::type
                   , boost::result_of<
                         evaluator(
                             Expr const &

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/environment.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/environment.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/environment.hpp 2011-01-09 10:07:48 EST (Sun, 09 Jan 2011)
@@ -12,6 +12,7 @@
 #include <boost/fusion/container/vector.hpp>
 #include <boost/fusion/support/is_sequence.hpp>
 #include <boost/phoenix/support/iterate.hpp>
+#include <boost/proto/proto.hpp>
 #include <boost/proto/functional/fusion/at.hpp>
 #include <boost/utility/enable_if.hpp>
 #include <boost/utility/result_of.hpp>

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/is_nullary.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/is_nullary.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/is_nullary.hpp 2011-01-09 10:07:48 EST (Sun, 09 Jan 2011)
@@ -11,84 +11,95 @@
 
 #include <boost/proto/proto.hpp>
 #include <boost/phoenix/core/environment.hpp>
+#include <boost/phoenix/core/is_actor.hpp>
 #include <boost/phoenix/core/meta_grammar.hpp>
 #include <boost/phoenix/core/terminal.hpp>
 
 namespace boost { namespace phoenix
 {
- template <typename Expr>
- struct is_nullary;
-
- namespace detail
- {
- struct is_nullary_
- {
- template <typename Rule, typename Dummy = void>
- struct when
- : proto::fold<
- proto::_
- , mpl::true_()
- , mpl::and_<
- proto::_state
- , evaluator(proto::_, _env)
- >()
- >
- {};
- };
-
- template <typename Dummy>
- struct is_nullary_::when<rule::argument, Dummy>
- : proto::make<mpl::false_()>
- {};
-
- template <typename Dummy>
- struct is_nullary_::when<rule::custom_terminal, Dummy>
- : proto::lazy<
- is_nullary<custom_terminal<proto::_value> >(
- proto::_
- , _env
- )
+ namespace result_of
+ {
+ template <typename Expr, typename Enable = void>
+ struct is_nullary;
+ }
+
+ struct is_nullary
+ {
+ template <typename Rule, typename Dummy = void>
+ struct when
+ : proto::fold<
+ proto::_
+ , mpl::true_()
+ , mpl::and_<
+ proto::_state
+ , evaluator(proto::_, _env)
+ >()
>
- {};
-
- template <typename Dummy>
- struct is_nullary_::when<rule::terminal, Dummy>
- : proto::make<mpl::true_()>
- {};
- }
-
- template <typename Expr>
- struct is_nullary
- : boost::result_of<
- evaluator(
- Expr const&
- , fusion::vector2<
- mpl::true_
- , detail::is_nullary_
- >&
+ {};
+ };
+
+ template <typename Dummy>
+ struct is_nullary::when<rule::argument, Dummy>
+ : proto::make<mpl::false_()>
+ {};
+
+ template <typename Dummy>
+ struct is_nullary::when<rule::custom_terminal, Dummy>
+ : proto::lazy<
+ result_of::is_nullary<custom_terminal<proto::_value> >(
+ proto::_
+ , _env
             )
>
- {};
-
- template <typename T>
- struct is_nullary<custom_terminal<T> >
- : proto::make<mpl::true_()>
     {};
-
- template <typename T>
- struct is_nullary<T & >
- : is_nullary<T>
- {};
-
- template <typename T>
- struct is_nullary<T const & >
- : is_nullary<T>
+
+ template <typename Dummy>
+ struct is_nullary::when<rule::terminal, Dummy>
+ : proto::make<mpl::true_()>
     {};
 
- template <typename T>
- struct is_nullary<T const >
- : is_nullary<T>
- {};
+ namespace result_of
+ {
+ template <typename Expr, typename Enable>
+ struct is_nullary
+ {
+ typedef
+ typename boost::phoenix::evaluator::impl<
+ Expr const &
+ , fusion::vector2<
+ mpl::true_
+ , boost::phoenix::is_nullary
+ >
+ , int
+ >::result_type
+ type;
+ };
+
+ template <typename T>
+ struct is_nullary<T & >
+ : is_nullary<T>
+ {};
+
+ template <typename T>
+ struct is_nullary<T const & >
+ : is_nullary<T>
+ {};
+
+ template <typename T>
+ struct is_nullary<T const >
+ : is_nullary<T>
+ {};
+
+ template <typename T>
+ struct is_nullary<custom_terminal<T>, typename disable_if<is_actor<T> >::type>
+ : proto::make<mpl::true_()>
+ {};
+
+ template <typename T>
+ struct is_nullary<custom_terminal<T>, typename enable_if<is_actor<T> >::type>
+ : proto::call<evaluator(proto::_value)>
+ {};
+ }
 
 }}
 

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp 2011-01-09 10:07:48 EST (Sun, 09 Jan 2011)
@@ -73,12 +73,6 @@
             return eval(expr, env);
         }
     };
-
- template <typename T>
- struct is_nullary<custom_terminal<actor<T> > >
- : proto::call<evaluator(proto::_value)>
- {};
-
 }}
 
 #endif

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/lambda.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/scope/lambda.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/lambda.hpp 2011-01-09 10:07:48 EST (Sun, 09 Jan 2011)
@@ -12,6 +12,7 @@
 #include <boost/phoenix/core/limits.hpp>
 #include <boost/mpl/int.hpp>
 #include <boost/phoenix/core/actor.hpp>
+#include <boost/phoenix/core/unpack.hpp>
 #include <boost/phoenix/scope/local_variable.hpp>
 
 namespace boost { namespace phoenix
@@ -177,26 +178,23 @@
>
     {};
 
- namespace detail
- {
- template <typename Dummy>
- struct is_nullary_::when<rule::lambda, Dummy>
- : proto::when<
- expression::lambda<
- proto::terminal<proto::_>
- , rule::local_var_def_list
- , meta_grammar
- >
- , evaluator(
- proto::_child_c<2>
- , fusion::vector2<
- mpl::true_
- , scope_is_nullary_actions
- >()
- )
+ template <typename Dummy>
+ struct is_nullary::when<rule::lambda, Dummy>
+ : proto::when<
+ expression::lambda<
+ proto::terminal<proto::_>
+ , rule::local_var_def_list
+ , meta_grammar
>
- {};
- }
+ , evaluator(
+ proto::_child_c<2>
+ , fusion::vector2<
+ mpl::true_
+ , detail::scope_is_nullary_actions
+ >()
+ )
+ >
+ {};
 
     namespace tag
     {
@@ -229,26 +227,22 @@
         {};
     }
 
- namespace detail
- {
- template <typename Dummy>
- struct is_nullary_::when<rule::lambda_actor, Dummy>
- : proto::or_<
- proto::when<
- expression::lambda_actor<meta_grammar>
- , mpl::true_()
- >
- , proto::when<
- expression::lambda_actor<
- rule::local_var_def_list
- , meta_grammar
- >
- , evaluator(proto::_child_c<1>, _env)
+ template <typename Dummy>
+ struct is_nullary::when<rule::lambda_actor, Dummy>
+ : proto::or_<
+ proto::when<
+ expression::lambda_actor<meta_grammar>
+ , mpl::true_()
+ >
+ , proto::when<
+ expression::lambda_actor<
+ rule::local_var_def_list
+ , meta_grammar
>
+ , evaluator(proto::_child_c<1>, _env)
>
- {};
- }
-
+ >
+ {};
 
     template <typename Dummy>
     struct meta_grammar::case_<tag::lambda_actor, Dummy>

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/let.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/scope/let.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/let.hpp 2011-01-09 10:07:48 EST (Sun, 09 Jan 2011)
@@ -23,25 +23,6 @@
         (meta_grammar)
     )
 
- namespace detail
- {
- template <typename Dummy>
- struct is_nullary_::when<rule::let, Dummy>
- : proto::make<
- mpl::and_<
- detail::local_var_def_is_nullary(proto::_child_c<0>, _env)
- , evaluator(
- proto::_child_c<1>
- , fusion::vector2<
- mpl::true_
- , scope_is_nullary_actions
- >()
- )
- >()
- >
- {};
- }
-
     struct let_eval
     {
         template <typename Sig>
@@ -186,6 +167,23 @@
     };
 
     let_local_gen const let = {};
+
+ template <typename Dummy>
+ struct is_nullary::when<rule::let, Dummy>
+ : proto::make<
+ mpl::and_<
+ detail::local_var_def_is_nullary(proto::_child_c<0>, _env)
+ , evaluator(
+ proto::_child_c<1>
+ , fusion::vector2<
+ mpl::true_
+ , detail::scope_is_nullary_actions
+ >()
+ )
+ >()
+ >
+ {};
+
 }}
 
 #endif

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_variable.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_variable.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_variable.hpp 2011-01-09 10:07:48 EST (Sun, 09 Jan 2011)
@@ -10,6 +10,8 @@
 
 #include <boost/phoenix/core/actor.hpp>
 #include <boost/phoenix/core/expression.hpp>
+#include <boost/phoenix/core/reference.hpp>
+#include <boost/phoenix/core/value.hpp>
 #include <boost/phoenix/scope/scoped_environment.hpp>
 #include <boost/phoenix/statement/sequence.hpp>
 
@@ -176,31 +178,31 @@
>
     {};
 
+ template <typename Dummy>
+ struct is_nullary::when<rule::local_variable, Dummy>
+ : proto::make<mpl::false_()>/*proto::if_<
+ is_scoped_environment<functional::args(_env)>()
+ , mpl::true_()
+ , mpl::false_()
+ >*/
+ {};
+
     namespace detail
     {
- template <typename Dummy>
- struct is_nullary_::when<rule::local_variable, Dummy>
- : proto::if_<
- is_scoped_environment<functional::args(_env)>()
- , mpl::true_()
- , mpl::false_()
- >
- {};
-
         struct local_var_def_is_nullary
             : proto::or_<
                 proto::when<
                     proto::comma<
- local_var_def_is_nullary
+ detail::local_var_def_is_nullary
                       , rule::local_var_def
>
                   , mpl::and_<
- local_var_def_is_nullary(proto::_left, proto::_state)
+ detail::local_var_def_is_nullary(proto::_left, proto::_state)
                       , evaluator(
                             proto::_right(proto::_right)
                           , fusion::vector2<
                                 mpl::true_
- , detail::is_nullary_
+ , boost::phoenix::is_nullary
>()
                         )
>()
@@ -211,21 +213,17 @@
                         proto::_child_c<1>
                       , fusion::vector2<
                             mpl::true_
- , detail::is_nullary_
+ , boost::phoenix::is_nullary
>()
                     )
>
>
         {};
- }
-
- namespace detail
- {
         
         struct scope_is_nullary_actions
         {
             template <typename Rule, typename Dummy = void>
- struct when : is_nullary_::when<Rule, Dummy>
+ struct when : boost::phoenix::is_nullary::when<Rule, Dummy>
             {};
         };
 
@@ -273,7 +271,6 @@
                   , proto::if_<
                         proto::matches<proto::_left, proto::_data>()
                       , evaluator(proto::_right, proto::_state)
- //, int()
                       , detail::local_var_not_found()
>
>

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/scoped_environment.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/scope/scoped_environment.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/scoped_environment.hpp 2011-01-09 10:07:48 EST (Sun, 09 Jan 2011)
@@ -16,6 +16,8 @@
 #include <boost/fusion/sequence/intrinsic/value_at.hpp>
 #include <boost/fusion/sequence/intrinsic/at.hpp>
 #include <boost/phoenix/core/limits.hpp>
+#include <boost/phoenix/core/environment.hpp>
+#include <boost/utility/result_of.hpp>
 
 namespace boost { namespace phoenix
 {

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/statement/switch.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/statement/switch.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/statement/switch.hpp 2011-01-09 10:07:48 EST (Sun, 09 Jan 2011)
@@ -97,15 +97,6 @@
>
         {};
 
- template <typename Dummy>
- struct is_nullary_::when<rule::switch_, Dummy>
- : proto::make<
- mpl::and_<
- evaluator(proto::_child_c<0>, _env)
- , switch_case_is_nullary(proto::_child_c<1>, _env)
- >()
- >
- {};
         struct switch_case_grammar
             : proto::or_<
                 proto::when<
@@ -153,6 +144,16 @@
             {};
     }
 
+ template <typename Dummy>
+ struct is_nullary::when<rule::switch_, Dummy>
+ : proto::make<
+ mpl::and_<
+ evaluator(proto::_child_c<0>, _env)
+ , detail::switch_case_is_nullary(proto::_child_c<1>, _env)
+ >()
+ >
+ {};
+
     struct switch_eval
     {
         typedef void result_type;

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/statement/try_catch.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/statement/try_catch.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/statement/try_catch.hpp 2011-01-09 10:07:48 EST (Sun, 09 Jan 2011)
@@ -139,11 +139,6 @@
>
         {};
 
- template <typename Dummy>
- struct is_nullary_::when<rule::try_catch, Dummy>
- : proto::call<try_catch_is_nullary(proto::_, int(), _env)>
- {};
-
         template <
             typename TryCatch
           , typename Exception
@@ -226,6 +221,11 @@
         #include <boost/phoenix/statement/detail/catch_push_back.hpp>
     }
 
+ template <typename Dummy>
+ struct is_nullary::when<rule::try_catch, Dummy>
+ : proto::call<detail::try_catch_is_nullary(proto::_, int(), _env)>
+ {};
+
     template <typename TryCatch, typename Exception>
     struct catch_gen
     {

Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/let_tests.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/let_tests.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/let_tests.cpp 2011-01-09 10:07:48 EST (Sun, 09 Jan 2011)
@@ -11,47 +11,18 @@
 
 #define PHOENIX_LIMIT 6
 #include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/tuple.hpp>
 #include <boost/phoenix/core.hpp>
 #include <boost/phoenix/operator.hpp>
 #include <boost/phoenix/function.hpp>
 #include <boost/phoenix/fusion.hpp>
 #include <boost/phoenix/scope.hpp>
-#include <boost/fusion/tuple.hpp>
 
 #include <typeinfo>
 
 namespace fusion = boost::fusion;
 namespace mpl = boost::mpl;
 
-template <typename Expr>
-void fpp_test(Expr const & expr)
-{
- using boost::phoenix::let;
- using boost::phoenix::local_names::_a;
- using boost::phoenix::local_names::_b;
- using boost::phoenix::local_names::_c;
- using boost::phoenix::local_names::_d;
- using boost::phoenix::local_names::_e;
- using boost::phoenix::local_names::_x;
- using boost::phoenix::local_names::_y;
- using boost::phoenix::local_names::_z;
- //std::cout << typeid(typename boost::phoenix::detail::grammar_of<Expr>::type).name() << "\n";
- std::cout << typeid(typename boost::proto::matches<Expr, boost::phoenix::meta_grammar>::type).name() << "\n";
- std::cout << typeid(typename boost::phoenix::is_nullary<Expr>::type).name() << "\n";
- //std::cout << typeid(let(_a = 1, _b = 2, _c = 2, _d = 3, _e = 5)[expr]()).name() << "\n";
- //let(_a = 1/*, _b = 2, _c = 2, _d = 3, _e = 5*/)[expr]();
- //let(_a = 1, _b = 2, _c = 2, _d = 3, _e = 5)[expr]();
- std::cout << "\n";
-}
-
-template <typename Expr0, typename Expr1>
-void fpp_test(Expr0 const & expr0, Expr1 const & expr1)
-{
- fpp_test(expr0);
- fpp_test(expr1);
- fpp_test(expr0 + expr1);
-}
-
 int
 main()
 {
@@ -69,7 +40,7 @@
     using boost::phoenix::local_names::_y;
     using boost::phoenix::local_names::_z;
     using boost::phoenix::placeholders::arg1;
-
+
     {
         int x = 1;
         BOOST_TEST(
@@ -144,7 +115,7 @@
             ]
             (x) == x + 888
         );
-
+
         BOOST_TEST(x == 999);
 
         BOOST_TEST(


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