2
0
mirror of https://github.com/boostorg/phoenix.git synced 2026-02-13 12:42:11 +00:00

removed unpack. fixes MSVC errors

[SVN r67909]
This commit is contained in:
Thomas Heller
2011-01-10 09:12:35 +00:00
parent 548af35f39
commit 8b725fc683
8 changed files with 177 additions and 466 deletions

View File

@@ -22,7 +22,7 @@ namespace boost { namespace phoenix
////////////////////////////////////////////////////////////////////////////
template <typename F>
typename boost::result_of<function<F>()>::type const
typename result_of::function<F>::type
bind(F f)
{
return function<F>(f)();

View File

@@ -21,6 +21,7 @@
namespace boost { namespace phoenix
{
//: boost::result_of<proto::functional::at(Env, mpl::int_<N>)>
namespace functional
{
#define BOOST_PHOENIX_GET_ENVIRONMENT(NAME, N) \
@@ -33,7 +34,12 @@ namespace boost { namespace phoenix
\
template <typename This, typename Env> \
struct result<This(Env)> \
: boost::result_of<proto::functional::at(Env, mpl::int_<N>)> \
: result<This(Env const &)> \
{}; \
\
template <typename This, typename Env> \
struct result<This(Env &)> \
: fusion::result_of::at<Env, mpl::int_<N> > \
{}; \
\
template <typename Env> \

View File

@@ -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 <boost/fusion/include/size.hpp>
#include <boost/preprocessor/comparison/not_equal.hpp>
#include <boost/preprocessor/iteration/iterate.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_trailing.hpp>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
#include <boost/preprocessor/seq/elem.hpp>
#include <boost/preprocessor/seq/size.hpp>
#include <boost/proto/proto.hpp>
#include <boost/proto/functional.hpp>
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<proto::_, Seq>::
template impl<Expr, State, Data>::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), \
<boost/phoenix/core/unpack.hpp>)) \
/**/
#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, \
<boost/phoenix/core/unpack.hpp>)) \
/**/
#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), \
<boost/phoenix/core/unpack.hpp>)) \
/**/
#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<Expr, State, Data>
{
struct fun_type : proto::when<proto::_, Fun> {};
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<Expr, State, Data>::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<Expr, State, Data>()(e, s, d);
}
};
#define BOOST_PP_ITERATION_PARAMS_4 \
(3, (1, BOOST_PROTO_MAX_ARITY, \
<boost/phoenix/core/unpack.hpp>))
#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<PHOENIX_UNPACK_SIG>
: proto::transform<call<PHOENIX_UNPACK_SIG> >
{
template <typename Expr, typename State, typename Data>
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_<N>())) \
/**/
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<Expr, State, Data>
{
struct fun_type : proto::when<proto::_, Fun> {};
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<Expr, State, Data>::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<Expr, State, Data>()(e, s, d);
}
};
#undef PHOENIX_UNPACK_M5
#endif
#undef PHOENIX_UNPACK_L
#endif
#endif

View File

@@ -9,7 +9,6 @@
#define PHOENIX_OBJECT_CONSTRUCT_HPP
#include <boost/phoenix/core/expression.hpp>
#include <boost/phoenix/core/unpack.hpp>
#include <boost/phoenix/support/iterate.hpp>
#include <boost/proto/fusion.hpp>
@@ -39,14 +38,43 @@ namespace boost { namespace phoenix
};
#define PHOENIX_CONSTRUCT_CHILD(Z, N, D) proto::_child_c<N>
#define PHOENIX_CONSTRUCT_CALL(Z, N, D) \
proto::when< \
expression::construct< \
proto::terminal<proto::_> \
, BOOST_PP_ENUM_PARAMS(N, meta_grammar BOOST_PP_INTERCEPT) \
> \
, proto::lazy< \
construct_eval<proto::_value(proto::_child_c<0>)>( \
_env \
, BOOST_PP_ENUM_SHIFTED( \
BOOST_PP_INC(N) \
, PHOENIX_CONSTRUCT_CHILD \
, _ \
) \
) \
> \
> \
/**/
template <typename Dummy>
struct default_actions::when<rule::construct, Dummy>
: proto::lazy<
construct_eval<
proto::_value(proto::_child_c<0>)
>(_env, unpack(proto::functional::pop_front(proto::_)))
: proto::or_<
proto::when<
expression::construct<proto::terminal<proto::_> >
, 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 T>
typename expression::construct<detail::target<T> >::type const

View File

@@ -9,7 +9,6 @@
#define PHOENIX_OBJECT_NEW_HPP
#include <boost/phoenix/core/expression.hpp>
#include <boost/phoenix/core/unpack.hpp>
#include <boost/phoenix/support/iterate.hpp>
#include <boost/proto/fusion.hpp>
@@ -40,14 +39,43 @@ namespace boost { namespace phoenix
#include <boost/phoenix/object/detail/new_eval.hpp>
};
#define PHOENIX_NEW_CHILD(Z, N, D) proto::_child_c<N>
#define PHOENIX_NEW_CALL(Z, N, D) \
proto::when< \
expression::new_< \
proto::terminal<proto::_> \
, BOOST_PP_ENUM_PARAMS(N, meta_grammar BOOST_PP_INTERCEPT) \
> \
, proto::lazy< \
new_eval<proto::_value(proto::_child_c<0>)>( \
_env \
, BOOST_PP_ENUM_SHIFTED( \
BOOST_PP_INC(N) \
, PHOENIX_NEW_CHILD \
, _ \
) \
) \
> \
> \
/**/
template <typename Dummy>
struct default_actions::when<rule::new_, Dummy>
: proto::lazy<
new_eval<
proto::_value(proto::_child_c<0>)
>(_env, unpack(proto::functional::pop_front(proto::_)))
: proto::or_<
proto::when<
expression::new_<proto::terminal<proto::_> >
, 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 T>
typename expression::new_<detail::target<T> >::type const

View File

@@ -5,7 +5,6 @@
#include <boost/get_pointer.hpp>
#include <boost/phoenix/core/expression.hpp>
#include <boost/phoenix/core/unpack.hpp>
#include <boost/phoenix/operator/detail/mem_fun_ptr_gen.hpp>
#include <boost/phoenix/support/iterate.hpp>
#include <boost/type_traits/is_member_function_pointer.hpp>
@@ -28,126 +27,92 @@ namespace boost { namespace phoenix
return detail::mem_fun_ptr_gen<actor<Object>, MemPtr>(obj, ptr);
}
namespace result_of
{
template <
typename Env
, typename Expr
, long Arity = proto::arity_of<Expr>::value
>
struct mem_fun_ptr_eval;
#include <boost/phoenix/operator/detail/mem_fun_ptr_eval_result_of.hpp>
}
struct mem_fun_ptr_eval
: proto::callable
{
template<typename Sig>
struct result;
template <typename This, typename Env, typename Expr>
struct result<This(Env, Expr const &)>
: result<This(Env const &, Expr const &)>
{};
#define PHOENIX_MEMBER_RESULT_OF(_, N, __) \
typename boost::result_of< \
evaluator(BOOST_PP_CAT(A, N) const&, Env&) \
>::type \
template <typename This, typename Env, typename Expr>
struct result<This(Env &, Expr const &)>
: result_of::mem_fun_ptr_eval<Env, Expr>
{};
template <typename Env, typename Expr>
typename result_of::mem_fun_ptr_eval<Env, Expr>::type
operator()(Env & env, Expr const & expr) const
{
return
this->evaluate(
env
, expr
, typename proto::arity_of<Expr>::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, \
<boost/phoenix/operator/member.hpp>, \
PHOENIX_ITERATE_OPERATOR)) \
/**/
#include PHOENIX_ITERATE()
#undef PHOENIX_MEMBER_RESULT_OF
#undef PHOENIX_MEMBER_EVAL
};
template <typename Dummy>
struct default_actions::when<rule::mem_fun_ptr, Dummy>
: proto::call<mem_fun_ptr_eval(_env, unpack)>
: proto::call<mem_fun_ptr_eval(_env, proto::_)>
{};
}}
#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 Env, typename Expr>
typename result_of::mem_fun_ptr_eval<Env, Expr>::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_<PHOENIX_ITERATION>
) 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

View File

@@ -12,7 +12,6 @@
#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
@@ -419,7 +418,19 @@ namespace boost { namespace phoenix
template <typename Dummy>
struct default_actions::when<rule::lambda_actor, Dummy>
: proto::call<lambda_actor_eval(_env, unpack)>
: proto::or_<
proto::when<
expression::lambda_actor<meta_grammar>
, 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 <typename Locals = void, typename Dummy = void>

View File

@@ -11,7 +11,6 @@
#define PHOENIX_STATEMENT_TRY_CATCH_HPP
#include <boost/phoenix/core/expression.hpp>
#include <boost/phoenix/core/unpack.hpp>
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 <boost/phoenix/statement/detail/try_catch_eval.hpp>
};
#define PHOENIX_TRY_CATCH_CHILD(Z, N, D) proto::_child_c<N>
#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 <typename Dummy>
struct default_actions::when<rule::try_catch, Dummy>
: proto::call<try_catch_eval(_env, unpack(proto::_))>
: 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