Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67071 - in sandbox/SOC/2010/phoenix3: boost/phoenix boost/phoenix/core boost/phoenix/fusion boost/phoenix/scope libs/phoenix/test/scope
From: thom.heller_at_[hidden]
Date: 2010-12-06 14:03:48


Author: theller
Date: 2010-12-06 14:03:43 EST (Mon, 06 Dec 2010)
New Revision: 67071
URL: http://svn.boost.org/trac/boost/changeset/67071

Log:
let tests passing again
Text files modified:
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/is_nullary.hpp | 16 +++++++++
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/meta_grammar.hpp | 2
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/terminal.hpp | 12 +++---
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp | 4 +
   sandbox/SOC/2010/phoenix3/boost/phoenix/fusion/at.hpp | 4 +-
   sandbox/SOC/2010/phoenix3/boost/phoenix/operator.hpp | 48 ++++++++++++++++---------------
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope/let.hpp | 54 ++++++++++++++++++++--------------
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_variable.hpp | 61 ++++++++++++++++++++++-----------------
   sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/let_tests.cpp | 28 +++++++++++++-----
   9 files changed, 139 insertions(+), 90 deletions(-)

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 2010-12-06 14:03:43 EST (Mon, 06 Dec 2010)
@@ -43,7 +43,7 @@
 
                 template <typename Dummy>
                 struct is_nullary_::when<rule::custom_terminal, Dummy>
- : proto::lazy<is_nullary<custom_terminal<proto::_value> >(proto::_, _env)>// proto::lazy<is_nullary<proto::_value>()>
+ : proto::lazy<is_nullary<custom_terminal<proto::_> >(proto::_, _env)>//proto::make<mpl::true_()>
                 {};
 
                 template <typename Dummy>
@@ -62,6 +62,20 @@
         : 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 T>
+ struct is_nullary<T const >
+ : is_nullary<T>
+ {};
 
 }}
 

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/meta_grammar.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/meta_grammar.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/meta_grammar.hpp 2010-12-06 14:03:43 EST (Mon, 06 Dec 2010)
@@ -26,7 +26,7 @@
     struct meta_grammar
         : proto::switch_<meta_grammar>
     {
- template <typename Tag, typename Dummy = void>
+ template <typename Tag, typename Grammar = meta_grammar>
         struct case_
             : proto::not_<proto::_>
         {};

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/terminal.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/terminal.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/terminal.hpp 2010-12-06 14:03:43 EST (Mon, 06 Dec 2010)
@@ -43,8 +43,8 @@
         {};
     }
 
- template <typename Dummy>
- struct meta_grammar::case_<proto::tag::terminal, Dummy>
+ template <typename Grammar>
+ struct meta_grammar::case_<proto::tag::terminal, Grammar>
         : proto::or_<
             proto::when<rule::argument , proto::external_transform>
           , proto::when<rule::custom_terminal, proto::external_transform>
@@ -52,13 +52,13 @@
>
     {};
 
- template <typename Dummy>
- struct default_actions::when<rule::custom_terminal, Dummy>
+ template <typename Grammar>
+ struct default_actions::when<rule::custom_terminal, Grammar>
         : proto::lazy<custom_terminal<proto::_value>(proto::_value, _env)>
     {};
     
- template <typename Dummy>
- struct default_actions::when<rule::argument, Dummy>
+ template <typename Grammar>
+ struct default_actions::when<rule::argument, Grammar>
         : proto::call<functional::args_at(proto::_value, _env)>
     {};
 }}

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 2010-12-06 14:03:43 EST (Mon, 06 Dec 2010)
@@ -76,7 +76,9 @@
 
     template <typename T>
     struct is_nullary<custom_terminal<actor<T> > >
- : proto::make<typename is_nullary<T>::type()>
+ //: proto::make<typename is_nullary<T>::type()>
+ //: proto::make<mpl::false_()>
+ : proto::call<evaluator(proto::_value, fusion::vector2<fusion::vector0<>, detail::is_nullary_>())>
     {};
 
     /*

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/fusion/at.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/fusion/at.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/fusion/at.hpp 2010-12-06 14:03:43 EST (Mon, 06 Dec 2010)
@@ -53,7 +53,7 @@
         typename result_of::at_c<Env &, Tuple, N::value>::type
         operator()(Env& env, Tuple const& tuple) const
         {
- return fusion::at_c<N::value>(eval(tuple, env));
+ return fusion::at_c<0>(eval(tuple, env));
         }
     };
 
@@ -63,7 +63,7 @@
     {};
 
     template <int N, typename Tuple>
- typename expression::at_c<mpl::int_<N>, Tuple>::type
+ typename expression::at_c<mpl::int_<N>, Tuple>::type const
     at_c(Tuple const& tuple)
     {
         return expression::at_c<mpl::int_<N>, Tuple>::make(mpl::int_<N>(), tuple);

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/operator.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/operator.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/operator.hpp 2010-12-06 14:03:43 EST (Mon, 06 Dec 2010)
@@ -8,37 +8,39 @@
 #define PHOENIX_OPERATOR_HPP
 
 #define PHOENIX_UNARY_RULE(_, __, name) \
- struct name \
- : proto::unary_expr<proto::tag::name, meta_grammar> \
- {}; \
- /**/
+ template <typename Grammar> \
+ struct name \
+ : proto::unary_expr<proto::tag::name, Grammar> \
+ {}; \
+ /**/
 
 #define PHOENIX_BINARY_RULE(_, __, name) \
- struct name \
- : proto::binary_expr<proto::tag::name, meta_grammar, meta_grammar> \
- {}; \
- /**/
+ template <typename Grammar> \
+ struct name \
+ : proto::binary_expr<proto::tag::name, Grammar, Grammar> \
+ {}; \
+ /**/
 
 #define PHOENIX_GRAMMAR(_, __, name) \
- template <typename Dummy> \
- struct meta_grammar::case_<proto::tag::name, Dummy> \
- : proto::when<rule::name, proto::external_transform> \
- {}; \
- /**/
+ template <typename Grammar> \
+ struct meta_grammar::case_<proto::tag::name, Grammar> \
+ : proto::when<rule::name<Grammar>, proto::external_transform> \
+ {}; \
+ /**/
 
 #define PHOENIX_UNARY_OPERATORS(ops) \
- namespace rule { \
- BOOST_PP_SEQ_FOR_EACH(PHOENIX_UNARY_RULE, _, ops) \
- } \
- BOOST_PP_SEQ_FOR_EACH(PHOENIX_GRAMMAR, _, ops) \
- /**/
+ namespace rule { \
+ BOOST_PP_SEQ_FOR_EACH(PHOENIX_UNARY_RULE, _, ops) \
+ } \
+ BOOST_PP_SEQ_FOR_EACH(PHOENIX_GRAMMAR, _, ops) \
+ /**/
 
 #define PHOENIX_BINARY_OPERATORS(ops) \
- namespace rule { \
- BOOST_PP_SEQ_FOR_EACH(PHOENIX_BINARY_RULE, _, ops) \
- } \
- BOOST_PP_SEQ_FOR_EACH(PHOENIX_GRAMMAR, _, ops) \
- /**/
+ namespace rule { \
+ BOOST_PP_SEQ_FOR_EACH(PHOENIX_BINARY_RULE, _, ops) \
+ } \
+ BOOST_PP_SEQ_FOR_EACH(PHOENIX_GRAMMAR, _, ops) \
+ /**/
 
 #include <boost/phoenix/version.hpp>
 #include <boost/phoenix/operator/arithmetic.hpp>

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 2010-12-06 14:03:43 EST (Mon, 06 Dec 2010)
@@ -18,10 +18,16 @@
 namespace boost { namespace phoenix
 {
     struct let_grammar
- : proto::or_<
- proto::when<rule::local_variable, proto::external_transform>
- , meta_grammar
- >
+ : proto::switch_<let_grammar>
+ {
+ template <typename Tag>
+ struct case_ : meta_grammar::case_<Tag, let_grammar>
+ {};
+ };
+
+ template <>
+ struct let_grammar::case_<tag::local_variable>
+ : proto::when<rule::local_variable, proto::external_transform>
     {};
     
     struct let_evaluator
@@ -42,6 +48,13 @@
         {};
     };
 
+ /*
+ template <>
+ struct meta_transform<let_actions>
+ : let_grammar
+ {};
+ */
+
     PHOENIX_DEFINE_EXPRESSION(
         let
       , (rule::local_var_def_list)
@@ -49,6 +62,20 @@
         //(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)
+ , mpl::true_()//let_evaluator(proto::_child_c<1>, _env)
+ >()
+ >
+ //: proto::make<mpl::true_()>
+ {};
+ }
+
     struct let_eval
     {
         template <typename Sig>
@@ -128,7 +155,7 @@
                 new_env(scoped_env, let_actions());//functional::actions()(env));
 
             std::cout << ":(\n";
- std::cout << typeid(Let).name() << "\n";
+ //std::cout << typeid(Let).name() << "\n";
 
             return let_evaluator()(let, new_env);
             //return eval(let, new_env);
@@ -204,23 +231,6 @@
     };
 
     let_local_gen const let = {};
-
- namespace detail
- {
- struct let_is_nullary
- : proto::or_<
- proto::when<rule::let, mpl::and_<let_is_nullary(proto::_child_c<0>, _env), let_is_nullary(proto::_child_c<1>, _env)>() >
- , proto::when<rule::local_var_def_list, detail::local_var_def_is_nullary(proto::_, _env)>
- , proto::when<rule::local_variable, mpl::true_()>
- , proto::otherwise<evaluator(proto::_, _env)>
- >
- {};
-
- template <typename Dummy>
- struct is_nullary_::when<rule::let, Dummy>
- : proto::make<let_is_nullary>
- {};
- }
 }}
 
 #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 2010-12-06 14:03:43 EST (Mon, 06 Dec 2010)
@@ -198,6 +198,41 @@
>
         {};
     }
+ namespace detail
+ {
+ template <typename Dummy>
+ struct is_nullary_::when<rule::local_variable, Dummy>
+ : proto::make<mpl::true_()>
+ /*: proto::if_<
+ //is_scoped_environment<functional::args(proto::_state)>()
+ foo(functional::args(proto::_state))
+ , mpl::false_()
+ , mpl::true_()
+ >*/
+ {};
+
+ struct local_var_def_is_nullary
+ : proto::or_<
+ proto::when<
+ proto::comma<proto::_, proto::_>//local_var_def_is_nullary, rule::local_var_def>
+ , mpl::and_<
+ local_var_def_is_nullary(proto::_left, proto::_state)
+ //, mpl::false_()//, local_var_def_is_nullary(proto::_right, proto::_state)
+ //, evaluator(proto::_right(proto::_right), proto::_state)
+ //, is_nullary<proto::_right(proto::_right)>()
+ , evaluator(proto::_right(proto::_right), fusion::vector2<fusion::vector0<>, detail::is_nullary_>())
+ >()
+ >
+ , proto::when<
+ proto::_
+ //, mpl::false_()
+ , evaluator(proto::_child_c<1>, fusion::vector2<fusion::vector0<>, detail::is_nullary_>())
+ //, is_nullary<proto::_child_c<1> >()
+ //, proto::lazy<is_nullary<custom_terminal<proto::_child_c<1> > >(proto::_child_c<1>, _env)>
+ >
+ >
+ {};
+ }
 
     namespace detail
     {
@@ -293,21 +328,6 @@
             */
         {};
 
- struct local_var_def_is_nullary
- : proto::or_<
- proto::when<
- proto::comma<local_var_def_is_nullary, rule::local_var_def>
- , mpl::and_<
- local_var_def_is_nullary(proto::_left, _env)
- , evaluator(proto::_right(proto::_right), _env)
- >()
- >
- , proto::when<
- rule::local_var_def
- , evaluator(proto::_right, _env)
- >
- >
- {};
     }
 
     template <typename Key>
@@ -465,17 +485,6 @@
             : is_scoped_environment<Env>
         {};
     };
-
- template <typename T>
- struct is_nullary<custom_terminal<local_variable<T> > >
- : proto::make<mpl::false_()>
- /*: proto::if_<
- //is_scoped_environment<functional::args(proto::_state)>()
- foo(functional::args(proto::_state))
- , mpl::false_()
- , mpl::true_()
- >*/
- {};
 #endif
     
     namespace local_names

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 2010-12-06 14:03:43 EST (Mon, 06 Dec 2010)
@@ -23,9 +23,22 @@
 namespace fusion = boost::fusion;
 namespace mpl = boost::mpl;
 
-int test()
+template <typename Expr>
+void fpp_test(Expr const & expr)
 {
- return 5;
+ 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::proto::matches<Expr, boost::phoenix::let_grammar>::type).name() << "\n";
+ std::cout << typeid(typename boost::proto::matches<Expr, boost::phoenix::meta_grammar>::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]();
 }
 
 int
@@ -82,14 +95,13 @@
         );
     }
 
- /*
     {
         int x = 1, y = 10;
         BOOST_TEST(
             let(_x = _1)
             [
                 _x +
- let(_x = _2)
+ let(_x = _2)
                     [
                         -_x
                     ]
@@ -123,6 +135,7 @@
         
         BOOST_TEST(x == 999);
 
+ /*
         BOOST_TEST(
             let(_x = val(_1)) // _x holds x by value
             [
@@ -130,18 +143,18 @@
             ]
             (x) == x + 888
         );
+ */
         
         BOOST_TEST(x == 999);
     }
 
     {
- // FIXME
         BOOST_TEST(
             let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5)
             [
                 _a + _b + _c + _d + _e
             ]
- (0) == 1 + 2 + 3 + 4 + 5
+ () == 1 + 2 + 3 + 4 + 5
         );
     }
 
@@ -152,7 +165,7 @@
         (_a + _b)(i);
     }
 #endif
-
+
     {
         // show that we can return a local from an outer scope
         int y = 0;
@@ -189,7 +202,6 @@
         let(_a = _1)[_a = _2](i, 2);
         BOOST_TEST(i == 2);
     }
- */
 
     return boost::report_errors();
 }


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