Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66883 - in sandbox/SOC/2010/phoenix3: boost/phoenix boost/phoenix/core boost/phoenix/statement libs/phoenix/test/statement
From: thom.heller_at_[hidden]
Date: 2010-11-30 01:26:09


Author: theller
Date: 2010-11-30 01:26:02 EST (Tue, 30 Nov 2010)
New Revision: 66883
URL: http://svn.boost.org/trac/boost/changeset/66883

Log:
temporary commit for work on try_catch
Text files modified:
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/expression.hpp | 59 +++++++++++++++++++++++------
   sandbox/SOC/2010/phoenix3/boost/phoenix/statement.hpp | 2
   sandbox/SOC/2010/phoenix3/boost/phoenix/statement/try_catch.hpp | 78 +++++++++++++++++++++++++++++++++------
   sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/exceptions.cpp | 8 ++++
   4 files changed, 120 insertions(+), 27 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-30 01:26:02 EST (Tue, 30 Nov 2010)
@@ -166,17 +166,31 @@
     {}; \
     /**/
 
-#if 0
-//TODO: adapt
 #define PHOENIX_DEFINE_EXPRESSION_EXT_VARARG_R(_, N, NAME) \
- template <PHOENIX_typename_A(N)> \
- struct BOOST_PP_TUPLE_ELEM(2, 1, NAME) <PHOENIX_A(N)> \
+ template < \
+ PHOENIX_typename_A( \
+ BOOST_PP_ADD( \
+ N \
+ , BOOST_PP_SEQ_SIZE(BOOST_PP_TUPLE_ELEM(3, 1, NAME)) \
+ ) \
+ ) \
+ > \
+ struct BOOST_PP_TUPLE_ELEM(3, 0, NAME)< \
+ PHOENIX_A( \
+ BOOST_PP_ADD(N, BOOST_PP_SEQ_SIZE(BOOST_PP_TUPLE_ELEM(3, 1, NAME))) \
+ ) \
+ > \
         : expr_ext< \
- BOOST_PP_TUPLE_ELEM(2, 0, NAME) \
- , tag:: BOOST_PP_TUPLE_ELEM(2, 1, NAME) \
- , PHOENIX_A(N)> \
+ BOOST_PP_TUPLE_ELEM(3, 2, NAME) \
+ , tag:: BOOST_PP_TUPLE_ELEM(3, 0, NAME) \
+ , PHOENIX_A( \
+ BOOST_PP_ADD( \
+ N \
+ , BOOST_PP_SEQ_SIZE(BOOST_PP_TUPLE_ELEM(3, 1, NAME)) \
+ ) \
+ ) \
+ > \
     {}; \
- /**/
 
 #define PHOENIX_DEFINE_EXPRESSION_EXT_VARARG(ACTOR, NAME, GRAMMAR, LIMIT) \
     namespace tag { \
@@ -185,18 +199,38 @@
                                                                                 \
     namespace expression \
     { \
- template <PHOENIX_typename_A_void(LIMIT), typename Dummy = void> \
+ template < \
+ PHOENIX_typename_A_void( \
+ BOOST_PP_ADD(LIMIT, BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(GRAMMAR))) \
+ ) \
+ , typename Dummy = void \
+ > \
         struct NAME; \
                                                                                 \
         BOOST_PP_REPEAT_FROM_TO( \
             1 \
- , LIMIT \
- , PHOENIX_DEFINE_EXPRESSION_VARARG_R, (ACTOR, NAME)) \
+ , BOOST_PP_ADD(LIMIT, BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(GRAMMAR))) \
+ , PHOENIX_DEFINE_EXPRESSION_EXT_VARARG_R \
+ , (NAME, BOOST_PP_SEQ_POP_BACK(GRAMMAR), ACTOR) \
+ ) \
     } \
                                                                                 \
     namespace rule { \
         struct NAME \
- : expression:: NAME <proto::vararg<GRAMMAR> > \
+ : expression:: NAME < \
+ BOOST_PP_IF( \
+ BOOST_PP_EQUAL(1, BOOST_PP_SEQ_SIZE(GRAMMAR)) \
+ , BOOST_PP_EMPTY() \
+ , BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_POP_BACK(GRAMMAR)) \
+ ) \
+ BOOST_PP_COMMA_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(GRAMMAR))) \
+ proto::vararg< \
+ BOOST_PP_SEQ_ELEM( \
+ BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(GRAMMAR)) \
+ , GRAMMAR \
+ ) \
+ > \
+ > \
         {}; \
     } \
                                                                                 \
@@ -205,7 +239,6 @@
         : proto::when<rule:: NAME, proto::external_transform> \
     {}; \
     /**/
-#endif
 
 #endif
 

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-30 01:26:02 EST (Tue, 30 Nov 2010)
@@ -14,7 +14,7 @@
 #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/try_catch.hpp>
 #include <boost/phoenix/statement/while.hpp>
 
 #endif

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 2010-11-30 01:26:02 EST (Tue, 30 Nov 2010)
@@ -62,8 +62,9 @@
     }
     */
     
- PHOENIX_DEFINE_EXPRESSION_VARARG(
- try_catch
+ PHOENIX_DEFINE_EXPRESSION_EXT_VARARG(
+ try_catch_actor
+ , try_catch
       , (proto::_)
       , PHOENIX_CATCH_LIMIT
     )
@@ -86,13 +87,70 @@
         template <typename TryCatch, typename Exception, typename Expr>
         struct catch_push_back<TryCatch, Exception, Expr, 1>
         {
- typedef typename expression::catch_<Exception, Expr>::type const catch_expr;
- typedef expression::try_catch<TryCatch, catch_expr> gen_type;
+ typedef expression::catch_<catch_exception<Exception>, Expr> catch_expr;
+
+ typedef expression::try_catch<
+ TryCatch//typename proto::result_of::child_c<TryCatch, 0>::type
+ , typename catch_expr::type> gen_type;
             typedef typename gen_type::type type;
 
             static type make(TryCatch const& try_catch, Expr const& catch_)
             {
- return gen_type::make(try_catch, catch_expr::make);
+ std::cout << typeid(TryCatch).name() << "\n\n";
+ std::cout << typeid(type).name() << "\n\n";
+ return
+ gen_type::make(
+ try_catch//proto::child_c<0>(try_catch)
+ , catch_expr::make(catch_exception<Exception>(), catch_)
+ );
+ }
+ };
+
+ template <typename TryCatch, typename Exception, typename Expr>
+ struct catch_push_back<TryCatch, Exception, Expr, 2>
+ {
+ typedef expression::catch_<catch_exception<Exception>, Expr> catch_expr;
+
+ typedef expression::try_catch<
+ typename proto::result_of::child_c<TryCatch, 0>::type
+ , typename proto::result_of::child_c<TryCatch, 1>::type
+ , typename catch_expr::type> gen_type;
+ typedef typename gen_type::type type;
+
+ static type make(TryCatch const& try_catch, Expr const& catch_)
+ {
+ std::cout << typeid(TryCatch).name() << "\n\n";
+ std::cout << typeid(type).name() << "\n";
+ return
+ gen_type::make(
+ proto::child_c<0>(try_catch)
+ , proto::child_c<1>(try_catch)
+ , catch_expr::make(catch_exception<Exception>(), catch_)
+ );
+ }
+ };
+
+ template <typename TryCatch, typename Exception, typename Expr>
+ struct catch_push_back<TryCatch, Exception, Expr, 3>
+ {
+ typedef expression::catch_<catch_exception<Exception>, Expr> catch_expr;
+
+ typedef expression::try_catch<
+ typename proto::result_of::child_c<TryCatch, 0>::type
+ , typename proto::result_of::child_c<TryCatch, 1>::type
+ , typename proto::result_of::child_c<TryCatch, 2>::type
+ , typename catch_expr::type> gen_type;
+ typedef typename gen_type::type type;
+
+ static type make(TryCatch const& try_catch, Expr const& catch_)
+ {
+ return
+ gen_type::make(
+ proto::child_c<0>(try_catch)
+ , proto::child_c<1>(try_catch)
+ , proto::child_c<2>(try_catch)
+ , catch_expr::make(catch_exception<Exception>(), catch_)
+ );
             }
         };
     }
@@ -103,16 +161,10 @@
         catch_gen(TryCatch const& try_catch) : try_catch(try_catch) {}
 
         template <typename Expr>
- detail::catch_push_back<TryCatch, Exception, Expr>
+ typename detail::catch_push_back<TryCatch, Exception, Expr>::type
         operator[](Expr const& expr) const
         {
- typedef typename expression::catch_<Exception, Expr>::type const catch_expr;
-
- std::cout << "Catch gen\n";
- std::cout << typeid(TryCatch).name() << "\n";
- std::cout << typeid(detail::catch_push_back<TryCatch, catch_expr>).name() << "\n";a
-
- return detail::catch_push_back<TryCatch
+ return detail::catch_push_back<TryCatch, Exception, Expr>::make(try_catch, expr);
         }
 
         TryCatch const & try_catch;

Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/exceptions.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/exceptions.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/exceptions.cpp 2010-11-30 01:26:02 EST (Tue, 30 Nov 2010)
@@ -62,6 +62,14 @@
         .catch_<exception>()
         [
             std::cout << ref("caught ...\n")
+ ]
+ .catch_<exception>()
+ [
+ std::cout << ref("caught ...\n")
+ ]
+ .catch_<exception>()
+ [
+ std::cout << ref("caught ...\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