|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r66826 - in sandbox/SOC/2010/phoenix3: boost/phoenix boost/phoenix/core boost/phoenix/statement libs/phoenix/test libs/phoenix/test/boost_bind_compatibility libs/phoenix/test/function libs/phoenix/test/object libs/phoenix/test/operator libs/phoenix/test/statement
From: thom.heller_at_[hidden]
Date: 2010-11-28 13:11:55
Author: theller
Date: 2010-11-28 13:11:52 EST (Sun, 28 Nov 2010)
New Revision: 66826
URL: http://svn.boost.org/trac/boost/changeset/66826
Log:
temporary commit for work on try_catch
Text files modified:
sandbox/SOC/2010/phoenix3/boost/phoenix/core/expression.hpp | 8 +-
sandbox/SOC/2010/phoenix3/boost/phoenix/core/limits.hpp | 10 +-
sandbox/SOC/2010/phoenix3/boost/phoenix/statement.hpp | 2
sandbox/SOC/2010/phoenix3/boost/phoenix/statement/throw.hpp | 57 ++++++++++++---
sandbox/SOC/2010/phoenix3/boost/phoenix/statement/try_catch.hpp | 141 +++++++++++++++++++++++++++++++++++++++
sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile | 2
sandbox/SOC/2010/phoenix3/libs/phoenix/test/boost_bind_compatibility/bind_eq_test.cpp | 2
sandbox/SOC/2010/phoenix3/libs/phoenix/test/boost_bind_compatibility/bind_function_test.cpp | 8 +-
sandbox/SOC/2010/phoenix3/libs/phoenix/test/function/function_tests.cpp | 5 +
sandbox/SOC/2010/phoenix3/libs/phoenix/test/object/new_delete_tests.cpp | 12 ---
sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/arithmetic_tests.cpp | 2
sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/exceptions.cpp | 14 +++
sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/switch_tests.cpp | 3
13 files changed, 217 insertions(+), 49 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-28 13:11:52 EST (Sun, 28 Nov 2010)
@@ -22,19 +22,19 @@
template <
template <typename> class Actor
, typename Tag
- , PHOENIX_typename_A_void(PHOENIX_LIMIT)
+ , PHOENIX_typename_A_void(PHOENIX_COMPOSITE_LIMIT)
, typename Dummy = void>
struct expr_ext;
- template <typename Tag, PHOENIX_typename_A_void(PHOENIX_LIMIT), typename Dummy = void>
- struct expr : expr_ext<actor, Tag, PHOENIX_A(PHOENIX_LIMIT)> {};
+ template <typename Tag, PHOENIX_typename_A_void(PHOENIX_COMPOSITE_LIMIT), typename Dummy = void>
+ struct expr : expr_ext<actor, Tag, PHOENIX_A(PHOENIX_COMPOSITE_LIMIT)> {};
struct default_domain_with_basic_expr
: proto::domain<proto::use_basic_expr<proto::default_generator> >
{};
#define PHOENIX_ITERATION_PARAMS \
- (3, (1, PHOENIX_ACTOR_LIMIT, \
+ (3, (1, PHOENIX_COMPOSITE_LIMIT, \
<boost/phoenix/core/expression.hpp>))
#include PHOENIX_ITERATE()
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/limits.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/limits.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/limits.hpp 2010-11-28 13:11:52 EST (Sun, 28 Nov 2010)
@@ -40,13 +40,13 @@
#endif
#if !defined(PHOENIX_COMPOSITE_LIMIT)
-# define PHOENIX_COMPOSITE_LIMIT PHOENIX_LIMIT
+# define PHOENIX_COMPOSITE_LIMIT BOOST_PP_INC(PHOENIX_LIMIT)
#elif (PHOENIX_COMPOSITE_LIMIT < 5)
# error "PHOENIX_COMPOSITE_LIMIT is set too low"
#endif
#if !defined(PHOENIX_MEMBER_LIMIT)
-# define PHOENIX_MEMBER_LIMIT BOOST_PP_DEC(BOOST_PP_DEC(PHOENIX_COMPOSITE_LIMIT))
+# define PHOENIX_MEMBER_LIMIT BOOST_PP_DEC(PHOENIX_COMPOSITE_LIMIT)
#elif (PHOENIX_MEMBER_LIMIT > PHOENIX_COMPOSITE_LIMIT)
# error "PHOENIX_MEMBER_LIMIT > PHOENIX_COMPOSITE_LIMIT"
#elif (PHOENIX_MEMBER_LIMIT < 3)
@@ -54,7 +54,7 @@
#endif
#if !defined(PHOENIX_CATCH_LIMIT)
-# define PHOENIX_CATCH_LIMIT BOOST_PP_DEC(PHOENIX_COMPOSITE_LIMIT)
+# define PHOENIX_CATCH_LIMIT PHOENIX_COMPOSITE_LIMIT
#elif (PHOENIX_CATCH_LIMIT < 1)
# error "PHOENIX_CATCH_LIMIT is set too low"
#endif
@@ -78,10 +78,10 @@
#endif
#if !defined(BOOST_PROTO_MAX_ARITY)
-# define BOOST_PROTO_MAX_ARITY PHOENIX_COMPOSITE_LIMIT
+# define BOOST_PROTO_MAX_ARITY BOOST_PP_INC(PHOENIX_COMPOSITE_LIMIT)
# if !defined(BOOST_MPL_LIMIT_METAFUNCTION_ARITY)
# define BOOST_MPL_LIMIT_METAFUNCTION_ARITY BOOST_PROTO_MAX_ARITY
-# define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
+//# define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
# endif
#elif (BOOST_PROTO_MAX_ARITY < PHOENIX_COMPOSE_LIMIT)
# error "BOOST_PROTO_MAX_ARITY < PHOENIX_COMPOSE_LIMIT"
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-28 13:11:52 EST (Sun, 28 Nov 2010)
@@ -13,7 +13,7 @@
#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/throw.hpp>
//#include <boost/phoenix/statement/try_catch.hpp>
#include <boost/phoenix/statement/while.hpp>
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/statement/throw.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/statement/throw.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/statement/throw.hpp 2010-11-28 13:11:52 EST (Sun, 28 Nov 2010)
@@ -9,20 +9,42 @@
#ifndef PHOENIX_STATEMENT_THROW_HPP
#define PHOENIX_STATEMENT_THROW_HPP
-#include <boost/phoenix/core/compose.hpp>
-#include <boost/phoenix/core/actor.hpp>
+#include <boost/phoenix/core/expression.hpp>
namespace boost { namespace phoenix
{
- namespace result_of
+ namespace tag
{
- template <typename Env, typename ThrowExpr = void, typename Dummy=void>
+ struct throw_ {};
+ }
+
+ namespace expression
+ {
+ template <typename A = mpl::na>
struct throw_
- {
- typedef void type;
- };
+ : expr<tag::throw_, A>
+ {};
}
+ namespace rule
+ {
+ struct throw_
+ : expression::throw_<meta_grammar>
+ {};
+
+ struct rethrow_
+ : expression::throw_<proto::terminal<mpl::na> >
+ {};
+ }
+
+ template <typename Dummy>
+ struct meta_grammar::case_<tag::throw_, Dummy>
+ : proto::or_<
+ proto::when<rule::rethrow_, proto::external_transform>
+ , proto::when<rule::throw_, proto::external_transform>
+ >
+ {};
+
struct throw_eval
{
typedef void result_type;
@@ -41,21 +63,28 @@
throw eval(throw_expr, env);
}
};
+
+ template <typename Dummy>
+ struct default_actions::when<rule::rethrow_, Dummy>
+ : proto::call<throw_eval(_env)>
+ {};
+
+ template <typename Dummy>
+ struct default_actions::when<rule::throw_, Dummy>
+ : proto::call<throw_eval(_env, proto::_child_c<0>)>
+ {};
- template <typename ThrowExpr = void>
- struct make_throw : compose<throw_eval, ThrowExpr> {};
-
- make_throw<>::type const
+ expression::throw_<>::type const
throw_()
{
- return make_throw<>()();
+ return expression::throw_<>::make(mpl::na());
}
template <typename ThrowExpr>
- typename make_throw<ThrowExpr>::type const
+ typename expression::throw_<ThrowExpr>::type const
throw_(ThrowExpr const& throw_expr)
{
- return make_throw<ThrowExpr>()(throw_expr);
+ return expression::throw_<ThrowExpr>::make(throw_expr);
}
}}
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-28 13:11:52 EST (Sun, 28 Nov 2010)
@@ -12,12 +12,148 @@
#ifndef PHOENIX_STATEMENT_TRY_CATCH_HPP
#define PHOENIX_STATEMENT_TRY_CATCH_HPP
-#include <boost/phoenix/core/compose.hpp>
-#include <boost/phoenix/support/element_at.hpp>
+#include <boost/phoenix/core/expression.hpp>
#include <boost/phoenix/support/iterate.hpp>
namespace boost { namespace phoenix
{
+ template <typename Expr>
+ struct try_catch_actor;
+
+ template <typename>
+ struct catch_exception {};
+
+ PHOENIX_DEFINE_EXPRESSION_EXT(
+ try_catch_actor
+ , try_
+ , (meta_grammar)
+ )
+
+ PHOENIX_DEFINE_EXPRESSION(
+ catch_
+ , (proto::terminal<catch_exception<proto::_> >)
+ (meta_grammar)
+ )
+
+ /*
+ PHOENIX_DEFINE_EXPRESSION(
+ catch_all
+ , (proto::terminal<catch_exception<mpl::na> >)
+ )
+
+ namespace tag
+ {
+ struct try_catch;
+ }
+
+ namespace detail
+ {
+ struct try_catch_grammar
+ : proto::nary_expr<
+ , tag::try_catch
+ , rule::try_
+ , proto::vararg<rule::catch_>
+ , proto::or_<
+ rule::catch_
+ , rule::catch_all
+ >
+ >
+ {};
+ }
+ */
+
+ PHOENIX_DEFINE_EXPRESSION_VARARG(
+ try_catch
+ , (proto::_)
+ , PHOENIX_CATCH_LIMIT
+ )
+
+ template <typename TryCatch>
+ struct catch_all_gen
+ {
+ template <typename Expr>
+ void
+ operator[](Expr const & expr)
+ {
+ }
+ };
+
+ namespace detail
+ {
+ template <typename TryCatch, typename Exception, typename Expr, long Arity = proto::arity_of<TryCatch>::value>
+ struct catch_push_back;
+
+ 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 typename gen_type::type type;
+
+ static type make(TryCatch const& try_catch, Expr const& catch_)
+ {
+ return gen_type::make(try_catch, catch_expr::make);
+ }
+ };
+ }
+
+ template <typename TryCatch, typename Exception>
+ struct catch_gen
+ {
+ catch_gen(TryCatch const& try_catch) : try_catch(try_catch) {}
+
+ template <typename Expr>
+ detail::catch_push_back<TryCatch, Exception, Expr>
+ 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
+ }
+
+ TryCatch const & try_catch;
+ };
+
+ template <
+ typename Expr
+ >
+ struct try_catch_actor;
+
+ template <typename Expr>
+ struct try_catch_actor
+ : actor<Expr>
+ {
+ typedef try_catch_actor<Expr> that_type;
+ typedef actor<Expr> base_type;
+
+ try_catch_actor(base_type const& expr) : base_type(expr) {};
+
+ template <typename Exception>
+ catch_gen<that_type, Exception> const
+ catch_() const
+ {
+ return catch_gen<that_type, Exception>(*this);
+ }
+
+ catch_all_gen<that_type> catch_all;
+ };
+
+ struct try_gen
+ {
+ template <typename Try>
+ typename expression::try_<Try>::type const
+ operator[](Try const & try_) const
+ {
+ return expression::try_<Try>::make(try_);
+ }
+ };
+
+ try_gen const try_ = {};
+ /*
namespace result_of
{
template <typename Env, PHOENIX_typename_A_void(PHOENIX_CATCH_LIMIT)>
@@ -185,6 +321,7 @@
};
try_gen const try_ = try_gen();
+*/
}}
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-28 13:11:52 EST (Sun, 28 Nov 2010)
@@ -122,7 +122,7 @@
# #[ run include/bind_bind_member_function.cpp ]
# #[ run include/bind_bind_member_variable.cpp ]
# [ run include/bind.cpp ]
- [ run include/core_actor.cpp ]
+# [ run include/core_actor.cpp ]
# [ run include/core_argument.cpp ]
# [ run include/core_arity.cpp ]
# [ run include/core_compose.cpp ]
Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/boost_bind_compatibility/bind_eq_test.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/boost_bind_compatibility/bind_eq_test.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/boost_bind_compatibility/bind_eq_test.cpp 2010-11-28 13:11:52 EST (Sun, 28 Nov 2010)
@@ -17,7 +17,7 @@
#endif
-#define PHOENIX_LIMIT 10
+#define PHOENIX_LIMIT 11
#include <boost/phoenix/core.hpp>
#include <boost/phoenix/bind.hpp>
Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/boost_bind_compatibility/bind_function_test.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/boost_bind_compatibility/bind_function_test.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/boost_bind_compatibility/bind_function_test.cpp 2010-11-28 13:11:52 EST (Sun, 28 Nov 2010)
@@ -16,6 +16,10 @@
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/bind.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(push, 3)
#endif
@@ -27,10 +31,6 @@
#pragma warning(pop)
#endif
-#include <boost/phoenix/core.hpp>
-#include <boost/phoenix/bind.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
int f( int x )
{
return x;
Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/function/function_tests.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/function/function_tests.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/function/function_tests.cpp 2010-11-28 13:11:52 EST (Sun, 28 Nov 2010)
@@ -4,6 +4,7 @@
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)
==============================================================================*/
+
#include <iostream>
#include <cmath>
#include <boost/detail/lightweight_test.hpp>
@@ -11,6 +12,10 @@
#include <boost/phoenix/operator.hpp>
#include <boost/phoenix/function.hpp>
+#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
+#include <boost/mpl/multiplies.hpp>
+#undef BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
+
struct test_impl
{
typedef void result_type;
Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/object/new_delete_tests.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/object/new_delete_tests.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/object/new_delete_tests.cpp 2010-11-28 13:11:52 EST (Sun, 28 Nov 2010)
@@ -57,15 +57,3 @@
BOOST_TEST(n == 0);
return boost::report_errors();
}
-//PHOENIX_DEFINE_EXPRESSION_VARARG(new_, (proto::terminal<detail::target<proto::_> >)(meta_grammar), PHOENIX_LIMIT)
-
-/*
-#include <boost/preprocessor/comparison/equal.hpp>
-
-
-#define SEQ (h)
-
-BOOST_PP_SEQ_ELEM(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(SEQ)), SEQ)
-
-BOOST_PP_IF(BOOST_PP_EQUAL(1, BOOST_PP_SEQ_SIZE(SEQ)), BOOST_PP_EMPTY(), BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_POP_BACK(SEQ)))
-*/
Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/arithmetic_tests.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/arithmetic_tests.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/arithmetic_tests.cpp 2010-11-28 13:11:52 EST (Sun, 28 Nov 2010)
@@ -54,7 +54,7 @@
BOOST_TEST((123 % val(456))() == 123 % 456);
}
{
- // testcase contributed from Philip Reh, failed in Phoenix V2
+ // Testcase contributed from Philipp Reh, failed in Phoenix V2
using boost::phoenix::arg_names::arg1;
using boost::phoenix::arg_names::arg2;
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-28 13:11:52 EST (Sun, 28 Nov 2010)
@@ -36,7 +36,6 @@
BOOST_TEST(err.what() == string("error"));
}
}
-
{
try
{
@@ -56,6 +55,17 @@
}
}
{
+ try_
+ [
+ throw_(runtime_error("error"))
+ ]
+ .catch_<exception>()
+ [
+ std::cout << ref("caught ...\n")
+ ];
+ }
+ /*
+ {
bool caught_exception = false;
try_
@@ -65,7 +75,6 @@
BOOST_TEST(caught_exception);
}
-
{
bool caught_exception = false;
try_
@@ -98,5 +107,6 @@
BOOST_TEST(caught_correct_exception);
}
+*/
return boost::report_errors();
}
Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/switch_tests.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/switch_tests.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/switch_tests.cpp 2010-11-28 13:11:52 EST (Sun, 28 Nov 2010)
@@ -5,7 +5,7 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
-#define PHOENIX_LIMIT 10
+#define PHOENIX_LIMIT 6
#include <iostream>
#include <vector>
@@ -70,7 +70,6 @@
case_<2>(cout << val("<2>") << endl),
case_<3>(cout << val("<3>") << endl),
case_<4>(cout << val("<4>") << endl),
- default_(cout << val("<over 4>") << endl),
default_(cout << val("<over 4>") << endl)
]
);
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