diff --git a/include/boost/phoenix/bind/bind.hpp b/include/boost/phoenix/bind/bind.hpp index 223d3b5..d11299a 100644 --- a/include/boost/phoenix/bind/bind.hpp +++ b/include/boost/phoenix/bind/bind.hpp @@ -22,7 +22,7 @@ namespace boost { namespace phoenix //////////////////////////////////////////////////////////////////////////// template - typename boost::result_of()>::type const + typename result_of::function::type bind(F f) { return function(f)(); diff --git a/include/boost/phoenix/core/environment.hpp b/include/boost/phoenix/core/environment.hpp index 9db974f..1bfe441 100644 --- a/include/boost/phoenix/core/environment.hpp +++ b/include/boost/phoenix/core/environment.hpp @@ -21,6 +21,7 @@ namespace boost { namespace phoenix { + //: boost::result_of)> namespace functional { #define BOOST_PHOENIX_GET_ENVIRONMENT(NAME, N) \ @@ -33,7 +34,12 @@ namespace boost { namespace phoenix \ template \ struct result \ - : boost::result_of)> \ + : result \ + {}; \ + \ + template \ + struct result \ + : fusion::result_of::at > \ {}; \ \ template \ diff --git a/include/boost/phoenix/core/unpack.hpp b/include/boost/phoenix/core/unpack.hpp deleted file mode 100644 index 45c0639..0000000 --- a/include/boost/phoenix/core/unpack.hpp +++ /dev/null @@ -1,354 +0,0 @@ -#if !BOOST_PP_IS_ITERATING - -/*============================================================================= - Copyright (c) 2005-2010 Joel de Guzman - Copyright (c) 2010 Eric Niebler - Copyright (c) 2010 Thomas Heller - - 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) -==============================================================================*/ - -#ifndef PHOENIX_CORE_UNPACK_HPP -#define PHOENIX_CORE_UNPACK_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace phoenix -{ - struct unpack {}; - - namespace detail - { - template < - typename Expr - , typename State - , typename Data - , typename Seq - , typename Fun - , typename R - , long Arity = fusion::result_of::size< - typename proto::detail::uncvref< - typename proto::when:: - template impl::result_type - >::type - >::value - > - struct unpack_impl; - } -}} - -#define PHOENIX_UNPACK_CHOICES \ - (phoenix::unpack) \ - (phoenix::unpack()) \ - (phoenix::unpack(Seq)) \ - (phoenix::unpack(Seq, Fun)) \ -/**/ - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (1, BOOST_PP_SEQ_SIZE(PHOENIX_UNPACK_CHOICES), \ - )) \ -/**/ -#include BOOST_PP_ITERATE() - -#undef PHOENIX_UNPACK_CHOICES - -#endif - -#else - -#if BOOST_PP_ITERATION_DEPTH() == 1 - -#define PHOENIX_UNPACK_I \ - BOOST_PP_DEC(BOOST_PP_FRAME_ITERATION(1)) \ -/**/ - -#define PHOENIX_UNPACK \ - BOOST_PP_SEQ_ELEM(PHOENIX_UNPACK_I, PHOENIX_UNPACK_CHOICES) \ -/**/ - -#define BOOST_PP_ITERATION_PARAMS_2 \ - (3, (1, BOOST_PROTO_MAX_ARITY, \ - )) \ -/**/ -#include BOOST_PP_ITERATE() - -#undef PHOENIX_UNPACK -#undef PHOENIX_UNPACK_I - -#elif BOOST_PP_ITERATION_DEPTH() == 2 - -#define PHOENIX_UNPACK_J \ - BOOST_PP_FRAME_ITERATION(2) \ -/**/ - -#define BOOST_PP_ITERATION_PARAMS_3 \ - (3, (BOOST_PP_DEC(PHOENIX_UNPACK_J), BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY), \ - )) \ -/**/ -#include BOOST_PP_ITERATE() - -#undef PHOENIX_UNPACK_J - -#elif BOOST_PP_ITERATION_DEPTH() == 3 - -#define PHOENIX_UNPACK_K \ - BOOST_PP_FRAME_ITERATION(3) \ -/**/ - -#define PHOENIX_UNPACK_M0(Z, N, D) \ - , A ## N \ -/**/ - -#define PHOENIX_UNPACK_SIG \ - R( \ - BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(PHOENIX_UNPACK_J), A) \ - BOOST_PP_COMMA_IF(BOOST_PP_DEC(PHOENIX_UNPACK_J)) \ - PHOENIX_UNPACK \ - BOOST_PP_REPEAT_FROM_TO( \ - BOOST_PP_FRAME_START(3) \ - , PHOENIX_UNPACK_K \ - , PHOENIX_UNPACK_M0 \ - , _ \ - ) \ - ) \ -/**/ - -#define PHOENIX_UNPACK_M1(Z, N, D) \ - BOOST_PP_COMMA_IF(BOOST_PP_NOT_EQUAL(N, D)) BOOST_PP_CAT(A, N) \ -/**/ - -#define PHOENIX_UNPACK_M2(Z, N, D) \ - , typename A ## N \ -/**/ - -#define PHOENIX_UNPACK_TYPENAME_SIG \ - BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(PHOENIX_UNPACK_J), typename A) \ - BOOST_PP_REPEAT_FROM_TO( \ - BOOST_PP_FRAME_START(3) \ - , PHOENIX_UNPACK_K \ - , PHOENIX_UNPACK_M2 \ - , _ \ - ) \ -/**/ - -namespace boost { namespace phoenix -{ - namespace detail - { - template < - typename Expr - , typename State - , typename Data - , typename Seq - , typename Fun - , typename R - BOOST_PP_COMMA_IF(BOOST_PP_DEC(PHOENIX_UNPACK_J)) - PHOENIX_UNPACK_TYPENAME_SIG - > - struct unpack_impl< - Expr - , State - , Data - , Seq - , Fun - , PHOENIX_UNPACK_SIG - , 0 - > - : proto::transform_impl - { - struct fun_type : proto::when {}; - - typedef - proto::call< - R( - BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(PHOENIX_UNPACK_J), A) - BOOST_PP_COMMA_IF( - BOOST_PP_AND( - BOOST_PP_DEC(PHOENIX_UNPACK_J) - , BOOST_PP_NOT_EQUAL( - BOOST_PP_FRAME_START(3) - , PHOENIX_UNPACK_K - ) - ) - ) - BOOST_PP_REPEAT_FROM_TO( - BOOST_PP_FRAME_START(3) - , PHOENIX_UNPACK_K - , PHOENIX_UNPACK_M1 - , BOOST_PP_FRAME_START(3) - ) - ) - > - which; - - typedef - typename which::template impl::result_type - result_type; - - result_type - operator()( - typename unpack_impl::expr_param e - , typename unpack_impl::state_param s - , typename unpack_impl::data_param d - ) const - { - return - typename which:: - template impl()(e, s, d); - } - - }; - - #define BOOST_PP_ITERATION_PARAMS_4 \ - (3, (1, BOOST_PROTO_MAX_ARITY, \ - )) - - #include BOOST_PP_ITERATE() - } -}} - -namespace boost { namespace proto { - template < - typename R - #if PHOENIX_UNPACK_I > 1 - , typename Seq - #endif - #if PHOENIX_UNPACK_I > 2 - , typename Fun - #endif - BOOST_PP_COMMA_IF(BOOST_PP_DEC(PHOENIX_UNPACK_J)) - PHOENIX_UNPACK_TYPENAME_SIG - > - struct call - : proto::transform > - { - template - struct impl - : phoenix::detail::unpack_impl< - Expr - , State - , Data - #if PHOENIX_UNPACK_I > 1 - , Seq - #else - , proto::_ - #endif - #if PHOENIX_UNPACK_I > 2 - , Fun - #else - , proto::_ - #endif - , PHOENIX_UNPACK_SIG - > - {}; - }; - -}} - -#undef PHOENIX_UNPACK_K -#undef PHOENIX_UNPACK_SIG -#undef PHOENIX_UNPACK_TYPENAME_SIG -#undef PHOENIX_UNPACK_M0 -#undef PHOENIX_UNPACK_M1 -#undef PHOENIX_UNPACK_M2 - -#else - -#define PHOENIX_UNPACK_L BOOST_PP_FRAME_ITERATION(4) - -#if PHOENIX_UNPACK_J + PHOENIX_UNPACK_K + PHOENIX_UNPACK_L - 2 > BOOST_PROTO_MAX_ARITY -//PHOENIX_UNPACK_SIG PHOENIX_UNPACK_J PHOENIX_UNPACK_K PHOENIX_UNPACK_L too much ... -#else - #define PHOENIX_UNPACK_M5(__, N, ___) \ - fun_type(proto::functional::at(Seq, mpl::int_())) \ - /**/ - - template < - typename Expr - , typename State - , typename Data - , typename Seq - , typename Fun - , typename R - BOOST_PP_COMMA_IF(BOOST_PP_DEC(PHOENIX_UNPACK_J)) - PHOENIX_UNPACK_TYPENAME_SIG - > - struct unpack_impl< - Expr - , State - , Data - , Seq - , Fun - , PHOENIX_UNPACK_SIG - , PHOENIX_UNPACK_L - > - : proto::transform_impl - { - struct fun_type : proto::when {}; - - typedef - proto::call< - R( - BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(PHOENIX_UNPACK_J), A) - BOOST_PP_COMMA_IF( - BOOST_PP_AND(BOOST_PP_DEC(PHOENIX_UNPACK_J) - , PHOENIX_UNPACK_L) - ) - BOOST_PP_ENUM(PHOENIX_UNPACK_L, PHOENIX_UNPACK_M5, _) - BOOST_PP_COMMA_IF( - BOOST_PP_AND( - PHOENIX_UNPACK_L - , BOOST_PP_NOT_EQUAL( - BOOST_PP_FRAME_START(3) - , PHOENIX_UNPACK_K - ) - ) - ) - BOOST_PP_REPEAT_FROM_TO( - BOOST_PP_FRAME_START(3) - , PHOENIX_UNPACK_K - , PHOENIX_UNPACK_M1 - , BOOST_PP_FRAME_START(3) - ) - ) - > - which; - - typedef - typename which::template impl::result_type - result_type; - - result_type - operator()( - typename unpack_impl::expr_param e - , typename unpack_impl::state_param s - , typename unpack_impl::data_param d - ) const - { - return - typename which:: - template impl()(e, s, d); - } - - }; - - #undef PHOENIX_UNPACK_M5 -#endif - -#undef PHOENIX_UNPACK_L - -#endif - -#endif - diff --git a/include/boost/phoenix/object/construct.hpp b/include/boost/phoenix/object/construct.hpp index 77d808b..48f0da5 100644 --- a/include/boost/phoenix/object/construct.hpp +++ b/include/boost/phoenix/object/construct.hpp @@ -9,7 +9,6 @@ #define PHOENIX_OBJECT_CONSTRUCT_HPP #include -#include #include #include @@ -39,14 +38,43 @@ namespace boost { namespace phoenix }; +#define PHOENIX_CONSTRUCT_CHILD(Z, N, D) proto::_child_c +#define PHOENIX_CONSTRUCT_CALL(Z, N, D) \ + proto::when< \ + expression::construct< \ + proto::terminal \ + , BOOST_PP_ENUM_PARAMS(N, meta_grammar BOOST_PP_INTERCEPT) \ + > \ + , proto::lazy< \ + construct_eval)>( \ + _env \ + , BOOST_PP_ENUM_SHIFTED( \ + BOOST_PP_INC(N) \ + , PHOENIX_CONSTRUCT_CHILD \ + , _ \ + ) \ + ) \ + > \ + > \ + /**/ + template struct default_actions::when - : proto::lazy< - construct_eval< - proto::_value(proto::_child_c<0>) - >(_env, unpack(proto::functional::pop_front(proto::_))) + : proto::or_< + proto::when< + expression::construct > + , proto::lazy< + construct_eval< + proto::_value(proto::_child_c<0>) + >(_env) + > + > + , BOOST_PP_ENUM_SHIFTED(PHOENIX_LIMIT, PHOENIX_CONSTRUCT_CALL, _) > + {}; +#undef PHOENIX_CONSTRUCT_CHILD +#undef PHOENIX_CONSTRUCT_CALL template typename expression::construct >::type const diff --git a/include/boost/phoenix/object/new.hpp b/include/boost/phoenix/object/new.hpp index c44f45e..eec8b3b 100644 --- a/include/boost/phoenix/object/new.hpp +++ b/include/boost/phoenix/object/new.hpp @@ -9,7 +9,6 @@ #define PHOENIX_OBJECT_NEW_HPP #include -#include #include #include @@ -40,14 +39,43 @@ namespace boost { namespace phoenix #include }; +#define PHOENIX_NEW_CHILD(Z, N, D) proto::_child_c +#define PHOENIX_NEW_CALL(Z, N, D) \ + proto::when< \ + expression::new_< \ + proto::terminal \ + , BOOST_PP_ENUM_PARAMS(N, meta_grammar BOOST_PP_INTERCEPT) \ + > \ + , proto::lazy< \ + new_eval)>( \ + _env \ + , BOOST_PP_ENUM_SHIFTED( \ + BOOST_PP_INC(N) \ + , PHOENIX_NEW_CHILD \ + , _ \ + ) \ + ) \ + > \ + > \ + /**/ + template struct default_actions::when - : proto::lazy< - new_eval< - proto::_value(proto::_child_c<0>) - >(_env, unpack(proto::functional::pop_front(proto::_))) + : proto::or_< + proto::when< + expression::new_ > + , proto::lazy< + new_eval< + proto::_value(proto::_child_c<0>) + >(_env) + > + > + , BOOST_PP_ENUM_SHIFTED(PHOENIX_LIMIT, PHOENIX_NEW_CALL, _) > + {}; +#undef PHOENIX_NEW_CHILD +#undef PHOENIX_NEW_CALL template typename expression::new_ >::type const diff --git a/include/boost/phoenix/operator/member.hpp b/include/boost/phoenix/operator/member.hpp index c3878a7..9714672 100644 --- a/include/boost/phoenix/operator/member.hpp +++ b/include/boost/phoenix/operator/member.hpp @@ -5,7 +5,6 @@ #include #include -#include #include #include #include @@ -28,126 +27,92 @@ namespace boost { namespace phoenix return detail::mem_fun_ptr_gen, MemPtr>(obj, ptr); } + namespace result_of + { + template < + typename Env + , typename Expr + , long Arity = proto::arity_of::value + > + struct mem_fun_ptr_eval; + + #include + } + struct mem_fun_ptr_eval : proto::callable { template struct result; + + template + struct result + : result + {}; - #define PHOENIX_MEMBER_RESULT_OF(_, N, __) \ - typename boost::result_of< \ - evaluator(BOOST_PP_CAT(A, N) const&, Env&) \ - >::type \ + template + struct result + : result_of::mem_fun_ptr_eval + {}; + + template + typename result_of::mem_fun_ptr_eval::type + operator()(Env & env, Expr const & expr) const + { + return + this->evaluate( + env + , expr + , typename proto::arity_of::type() + ); + } + + #define PHOENIX_MEMBER_EVAL(Z, N, D) \ + BOOST_PP_COMMA_IF(BOOST_PP_NOT(BOOST_PP_EQUAL(N, 2))) \ + eval(proto::child_c< N >(expr), env) \ /**/ - - #define PHOENIX_MEMBER_EVAL(_, N, __) \ - eval(BOOST_PP_CAT(a, N), env) - /**/ - + private: #define PHOENIX_ITERATION_PARAMS \ - (4, (0, PHOENIX_LIMIT, \ + (4, (2, PHOENIX_LIMIT, \ , \ PHOENIX_ITERATE_OPERATOR)) \ /**/ #include PHOENIX_ITERATE() - #undef PHOENIX_MEMBER_RESULT_OF #undef PHOENIX_MEMBER_EVAL }; template struct default_actions::when - : proto::call + : proto::call {}; }} #endif #else // PHOENIX_IS_ITERATING - - - template< - typename This - , typename Env - , typename T1 - , typename T2 - BOOST_PP_COMMA_IF(PHOENIX_ITERATION) PHOENIX_typename_A - > - struct result< - This( - Env - , T1 const& - , T2 const& - BOOST_PP_COMMA_IF(PHOENIX_ITERATION) PHOENIX_A_const_ref - ) - > - : result< - This( - Env const & - , T1 const& - , T2 const& - BOOST_PP_COMMA_IF(PHOENIX_ITERATION) PHOENIX_A_const_ref - ) - > - {}; - - template< - typename This - , typename Env - , typename T1 - , typename T2 - BOOST_PP_COMMA_IF(PHOENIX_ITERATION) PHOENIX_typename_A - > - struct result< - This( - Env & - , T1 const& - , T2 const& - BOOST_PP_COMMA_IF(PHOENIX_ITERATION) PHOENIX_A_const_ref - ) - > - : boost::result_of< - typename boost::remove_reference< - typename boost::result_of< - evaluator(T2 const &, Env&)>::type - >::type( - typename boost::result_of< - evaluator(T1 const&, Env&) - >::type - BOOST_PP_ENUM_TRAILING( - PHOENIX_ITERATION, PHOENIX_MEMBER_RESULT_OF, _ - ) - ) - > - {}; - - template < - typename Env - , typename T1 - , typename T2 - BOOST_PP_ENUM_TRAILING_PARAMS(PHOENIX_ITERATION, typename A) - > - typename result< - mem_fun_ptr_eval( - Env & - , T1 const& - , T2 const& - BOOST_PP_ENUM_TRAILING_BINARY_PARAMS( - PHOENIX_ITERATION - , A - , const & BOOST_PP_INTERCEPT - ) - ) - >::type - operator()( + + template + typename result_of::mem_fun_ptr_eval::type + evaluate( Env & env - , T1 const& t1 - , T2 const& t2 - BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(PHOENIX_ITERATION, A, const & a) + , Expr const & expr + , mpl::long_ ) const - { - return (get_pointer(eval(t1, env))->*eval(t2, env)) - (BOOST_PP_ENUM(PHOENIX_ITERATION, PHOENIX_MEMBER_EVAL, _)); - } + { + return + ( + get_pointer(eval(proto::child_c<0>(expr), env)) + ->*eval(proto::child_c<1>(expr), env) + )( + BOOST_PP_REPEAT_FROM_TO( + 2 + , PHOENIX_ITERATION + , PHOENIX_MEMBER_EVAL + , PHOENIX_ITERATION + ) + ); + } + #endif diff --git a/include/boost/phoenix/scope/lambda.hpp b/include/boost/phoenix/scope/lambda.hpp index 0ba8361..8d0c4cb 100644 --- a/include/boost/phoenix/scope/lambda.hpp +++ b/include/boost/phoenix/scope/lambda.hpp @@ -12,7 +12,6 @@ #include #include #include -#include #include namespace boost { namespace phoenix @@ -419,7 +418,19 @@ namespace boost { namespace phoenix template struct default_actions::when - : proto::call + : proto::or_< + proto::when< + expression::lambda_actor + , lambda_actor_eval(_env, proto::_child_c<0>) + > + , proto::when< + expression::lambda_actor< + rule::local_var_def_list + , meta_grammar + > + , lambda_actor_eval(_env, proto::_child_c<0>, proto::_child_c<1>) + > + > {}; template diff --git a/include/boost/phoenix/statement/try_catch.hpp b/include/boost/phoenix/statement/try_catch.hpp index e112b5f..a6371f6 100644 --- a/include/boost/phoenix/statement/try_catch.hpp +++ b/include/boost/phoenix/statement/try_catch.hpp @@ -11,7 +11,6 @@ #define PHOENIX_STATEMENT_TRY_CATCH_HPP #include -#include namespace boost { namespace phoenix { @@ -95,17 +94,45 @@ namespace boost { namespace phoenix struct try_catch_eval { + BOOST_PROTO_CALLABLE() + typedef void result_type; // bring in the operator overloads #include }; +#define PHOENIX_TRY_CATCH_CHILD(Z, N, D) proto::_child_c +#define PHOENIX_TRY_CATCH_CALL(Z, N, D) \ + proto::when< \ + expression::try_catch< \ + BOOST_PP_ENUM_PARAMS(N, proto::_ BOOST_PP_INTERCEPT) \ + > \ + , try_catch_eval( \ + _env \ + , BOOST_PP_ENUM( \ + N \ + , PHOENIX_TRY_CATCH_CHILD \ + , _ \ + ) \ + ) \ + > \ + /**/ + template struct default_actions::when - : proto::call + : proto::or_< + BOOST_PP_ENUM_SHIFTED( + BOOST_PP_INC(PHOENIX_CATCH_LIMIT) + , PHOENIX_TRY_CATCH_CALL + , _ + ) + > {}; +#undef PHOENIX_TRY_CATCH_CHILD +#undef PHOENIX_TRY_CATCH_CALL + namespace detail { struct try_catch_is_nullary