Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67622 - in sandbox/SOC/2010/phoenix3/boost/phoenix: core scope
From: thom.heller_at_[hidden]
Date: 2011-01-03 12:11:18


Author: theller
Date: 2011-01-03 12:11:16 EST (Mon, 03 Jan 2011)
New Revision: 67622
URL: http://svn.boost.org/trac/boost/changeset/67622

Log:
integrated new proto functionals, some cleanup and unpack fix for msvc
Text files modified:
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/environment.hpp | 77 +++---
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/unpack.hpp | 458 ++++++++++++++++++++++++---------------
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope/dynamic.hpp | 1
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope/lambda.hpp | 16 +
   4 files changed, 338 insertions(+), 214 deletions(-)

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/environment.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/environment.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/environment.hpp 2011-01-03 12:11:16 EST (Mon, 03 Jan 2011)
@@ -12,6 +12,7 @@
 #include <boost/fusion/container/vector.hpp>
 #include <boost/fusion/support/is_sequence.hpp>
 #include <boost/phoenix/support/iterate.hpp>
+#include <boost/proto/functional/fusion/at.hpp>
 #include <boost/utility/enable_if.hpp>
 #include <boost/utility/result_of.hpp>
 
@@ -21,39 +22,43 @@
 {
     namespace functional
     {
- template <typename N>
- struct at
- : proto::callable
- {
- typedef typename boost::remove_reference<N>::type index;
-
- template <typename Sig>
- struct result;
-
- template <typename This, typename Seq>
- struct result<This(Seq)>
- : result<This(Seq const&)>
- {};
-
- template <typename This, typename Seq>
- struct result<This(Seq &)>
- : fusion::result_of::at_c<Seq, index::value>
- {};
+ #define BOOST_PHOENIX_GET_ENVIRONMENT(NAME, N) \
+ struct NAME \
+ { \
+ BOOST_PROTO_CALLABLE() \
+ \
+ template <typename Sig> \
+ struct result; \
+ \
+ template <typename This, typename Env> \
+ struct result<This(Env)> \
+ : boost::result_of<proto::functional::at(Env, mpl::int_<N>)> \
+ {}; \
+ \
+ template <typename Env> \
+ typename result<NAME(Env const &)>::type \
+ operator()(Env const & env) const \
+ { \
+ return proto::functional::at()(env, mpl::int_<N>()); \
+ } \
+ \
+ template <typename Env> \
+ typename result<args(Env &)>::type \
+ operator()(Env & env) const \
+ { \
+ return proto::functional::at()(env, mpl::int_<N>()); \
+ } \
+ }; \
+ /**/
+ BOOST_PHOENIX_GET_ENVIRONMENT(args, 0)
+ BOOST_PHOENIX_GET_ENVIRONMENT(actions, 1)
+ #undef BOOST_PHOENIX_GET_ENVIRONMENT
 
- template <typename Seq>
- typename fusion::result_of::at_c<Seq, index::value>::type
- operator()(Seq& seq) const
- {
- return fusion::at_c<index::value>(seq);
- }
- };
-
- typedef at<mpl::int_<0> > args;
- typedef at<mpl::int_<1> > actions;
 
         struct args_at
- : proto::callable
         {
+ BOOST_PROTO_CALLABLE()
+
             template <typename Sig>
             struct result;
 
@@ -64,16 +69,14 @@
 
             template <typename This, typename N, typename Env>
             struct result<This(N, Env &)>
- : boost::result_of<
- at<N>(typename args::result<args(Env &)>::type)
- >
+ : boost::result_of<proto::functional::at(typename args::result<args(Env &)>::type, N)>
             {};
 
             template <typename N, typename Env>
             typename result<args_at(N, Env &)>::type
- operator()(N, Env& env) const
+ operator()(N const & n, Env& env) const
             {
- return at<N>()(args()(env));
+ return proto::functional::at()(args()(env), n);
             }
         };
     }
@@ -102,11 +105,5 @@
     struct is_environment : fusion::traits::is_sequence<T> {};
 }}
 
-namespace boost { namespace proto
-{
- template <typename N>
- struct is_callable<boost::phoenix::functional::at<N> > : mpl::true_ {};
-}}
-
 #endif
 

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/unpack.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/unpack.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/unpack.hpp 2011-01-03 12:11:16 EST (Mon, 03 Jan 2011)
@@ -1,4 +1,4 @@
-#if !PHOENIX_IS_ITERATING
+#if !BOOST_PP_IS_ITERATING
 
 /*=============================================================================
     Copyright (c) 2005-2010 Joel de Guzman
@@ -8,65 +8,139 @@
     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/fusion/container/vector.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/type_traits/remove_pointer.hpp>
-
-#define M3(_, N, MAX) \
- BOOST_PP_COMMA_IF(BOOST_PP_SUB(MAX, N)) \
- BOOST_PP_CAT(A, N) \
-/**/
+#include <boost/proto/functional.hpp>
 
-#define M2(UNPACK, N, ARITY) \
- BOOST_PP_ENUM_PARAMS(N, A) \
- BOOST_PP_COMMA_IF(N) \
- UNPACK BOOST_PP_REPEAT_FROM_TO(N, ARITY, M3, ARITY) \
-/**/
-
-#define M0(Z, N, __) BOOST_PP_CAT(BOOST_PP_REPEAT_, Z)(BOOST_PP_INC(N), M1, N)
+#define UNPACK_CHOICES \
+ (phoenix::unpack) \
+ (phoenix::unpack()) \
+ (phoenix::unpack(Seq)) \
+ (phoenix::unpack(Seq, Fun))
 
 namespace boost { namespace phoenix
 {
     struct unpack {};
-
+
     namespace detail
     {
- template <unsigned N>
- struct fusion_at_c
- : proto::callable
- {
- template <typename Sig>
- struct result;
+ 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;
+ }
+}}
 
- template <typename This, typename Seq>
- struct result<This(Seq)>
- : result<This(Seq const &)>
- {};
-
- template <typename This, typename Seq>
- struct result<This(Seq &)>
- : fusion::result_of::at_c<Seq, N>
- {};
-
- template <typename Seq>
- typename fusion::result_of::at_c<Seq, N>::type
- operator()(Seq & seq) const
- {
- return fusion::at_c<N>(seq);
- }
+#define BOOST_PP_ITERATION_PARAMS_1 \
+ (3, (1, BOOST_PP_SEQ_SIZE(UNPACK_CHOICES), \
+ <boost/phoenix/core/unpack.hpp>)) \
+/**/
+#include BOOST_PP_ITERATE()
 
- template <typename Seq>
- typename fusion::result_of::at_c<Seq const, N>::type
- operator()(Seq const & seq) const
- {
- return fusion::at_c<N>(seq);
- }
- };
+#undef M0
+#undef M1
+#undef M2
+#undef M3
+#undef M4
+#undef M5
+#undef I
+#undef J
+#undef K
+#undef L
+#undef UNPACK_CHOICES
+
+#endif
+
+#else
+
+#if BOOST_PP_ITERATION_DEPTH() == 1
+
+#define I \
+ BOOST_PP_DEC(BOOST_PP_FRAME_ITERATION(1)) \
+/**/
+
+#define UNPACK \
+ BOOST_PP_SEQ_ELEM(I, UNPACK_CHOICES) \
+/**/
+
+#define BOOST_PP_ITERATION_PARAMS_2 \
+ (3, (1, BOOST_PROTO_MAX_ARITY, \
+ <boost/phoenix/core/unpack.hpp>)) \
+/**/
+#include BOOST_PP_ITERATE()
+#undef UNPACK
+
+#elif BOOST_PP_ITERATION_DEPTH() == 2
+
+#define J \
+ BOOST_PP_FRAME_ITERATION(2) \
+/**/
+
+#define BOOST_PP_ITERATION_PARAMS_3 \
+ (3, (BOOST_PP_DEC(J), BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY), \
+ <boost/phoenix/core/unpack.hpp>)) \
+/**/
+#include BOOST_PP_ITERATE()
+
+#elif BOOST_PP_ITERATION_DEPTH() == 3
+
+#define K \
+ BOOST_PP_FRAME_ITERATION(3) \
+/**/
+
+#define M0(Z, N, D) \
+ , A ## N \
+/**/
+
+#define SIG \
+ R( \
+ BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(J), A) \
+ BOOST_PP_COMMA_IF(BOOST_PP_DEC(J)) \
+ UNPACK \
+ BOOST_PP_REPEAT_FROM_TO(BOOST_PP_FRAME_START(3), K, M0, _) \
+ ) \
+/**/
 
+#define M1(Z, N, D) \
+ BOOST_PP_COMMA_IF(BOOST_PP_NOT_EQUAL(N, D)) BOOST_PP_CAT(A, N) \
+/**/
+
+#define M2(Z, N, D) \
+ , typename A ## N \
+/**/
+
+#define TYPENAME_SIG \
+ BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(J), typename A) \
+ BOOST_PP_REPEAT_FROM_TO(BOOST_PP_FRAME_START(3), K, M2, _) \
+/**/
+
+namespace boost { namespace phoenix
+{
+ namespace detail
+ {
         template <
             typename Expr
           , typename State
@@ -74,146 +148,182 @@
           , 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 M5(_, N, __) fun_type(fusion_at_c< N >(Seq))
-
- #define M1(Z, N, ARITY) \
- template <typename Expr, typename State, typename Data, typename Seq, typename Fun, typename R BOOST_PP_ENUM_TRAILING_PARAMS(ARITY, typename A)> \
- struct unpack_impl<Expr, State, Data, Seq, Fun, R(M2(unpack, N, ARITY)), EXPR_N> \
- : proto::transform_impl<Expr, State, Data> \
- { \
- struct fun_type : proto::when<proto::_, Fun> {}; \
- \
- typedef proto::call<R(M2(BOOST_PP_ENUM(EXPR_N, M5, EXPR_N), N, ARITY))> \
- 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 PHOENIX_ITERATION_PARAMS \
- (3, (1, BOOST_PROTO_MAX_ARITY, \
- <boost/phoenix/core/unpack.hpp>))
-#include PHOENIX_ITERATE()
-
- #undef M1
-
-#define M1(Z, N, ARITY) \
- template <typename Expr, typename State, typename Data, typename Seq, typename Fun, typename R BOOST_PP_ENUM_TRAILING_PARAMS(ARITY, typename A)> \
- struct unpack_impl<Expr, State, Data, Seq, Fun, R(M2(unpack, N, ARITY)), 0> \
- : proto::transform_impl<Expr, State, Data> \
- { \
- struct fun_type : proto::when<proto::_, Fun> {}; \
- \
- typedef proto::call<R(BOOST_PP_ENUM_PARAMS(ARITY, A))> \
- 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); \
- } \
- \
- }; \
- /**/
+ BOOST_PP_COMMA_IF(BOOST_PP_DEC(J)) TYPENAME_SIG
+ >
+ struct unpack_impl<
+ Expr
+ , State
+ , Data
+ , Seq
+ , Fun
+ , 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(J), A)
+ BOOST_PP_COMMA_IF(
+ BOOST_PP_AND(
+ BOOST_PP_DEC(J)
+ , BOOST_PP_NOT_EQUAL(BOOST_PP_FRAME_START(3), K)
+ )
+ )
+ BOOST_PP_REPEAT_FROM_TO(
+ BOOST_PP_FRAME_START(3)
+ , K
+ , 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);
+ }
+
+ };
 
- BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, M0, _)
- #undef M1
+ #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 I > 1
+ , typename Seq
+ #endif
+ #if I > 2
+ , typename Fun
+ #endif
+ BOOST_PP_COMMA_IF(BOOST_PP_DEC(J)) TYPENAME_SIG
+ >
+ struct call<SIG>
+ : proto::transform<call<SIG> >
+ {
+ template <typename Expr, typename State, typename Data>
+ struct impl
+ : phoenix::detail::unpack_impl<
+ Expr
+ , State
+ , Data
+ #if I > 1
+ , Seq
+ #else
+ , proto::_
+ #endif
+ #if I > 2
+ , Fun
+ #else
+ , proto::_
+ #endif
+ , SIG
+ >
+ {};
+ };
 
-namespace boost { namespace proto
-{
- template <unsigned N>
- struct is_callable<phoenix::detail::fusion_at_c<N> > : mpl::true_ {};
+}}
 
- #define M1(Z, N, ARITY) \
- template <typename R BOOST_PP_ENUM_TRAILING_PARAMS(ARITY, typename A)> \
- struct call<R(M2(phoenix::unpack(), N, ARITY))> \
- : proto::transform<call<R(M2(phoenix::unpack(), N, ARITY))> > \
- { \
- template <typename Expr, typename State, typename Data> \
- struct impl \
- : phoenix::detail::unpack_impl< \
- Expr, State, Data, proto::_, proto::_, R(M2(phoenix::unpack, N, ARITY))> \
- {}; \
- }; \
- \
- template <typename R BOOST_PP_ENUM_TRAILING_PARAMS(ARITY, typename A)> \
- struct call<R(M2(phoenix::unpack, N, ARITY))> \
- : proto::transform<call<R(M2(phoenix::unpack, N, ARITY))> > \
- { \
- template <typename Expr, typename State, typename Data> \
- struct impl \
- : phoenix::detail::unpack_impl< \
- Expr, State, Data, proto::_, proto::_, R(M2(phoenix::unpack, N, ARITY))> \
- {}; \
- }; \
- \
- template <typename R, typename Seq \
- BOOST_PP_ENUM_TRAILING_PARAMS(ARITY, typename A)> \
- struct call<R(M2(phoenix::unpack(Seq), N, ARITY))> \
- : proto::transform<call<R(M2(phoenix::unpack(Seq), N, ARITY))> > \
- { \
- template <typename Expr, typename State, typename Data> \
- struct impl \
- : phoenix::detail::unpack_impl< \
- Expr, State, Data, typename boost::remove_pointer<Seq>::type, proto::_, R(M2(phoenix::unpack, N, ARITY))> \
- { \
- }; \
- }; \
- \
- template <typename R, typename Seq, typename Fun \
- BOOST_PP_ENUM_TRAILING_PARAMS(ARITY, typename A)> \
- struct call<R(M2(phoenix::unpack(Seq, Fun), N, ARITY))> \
- : proto::transform<call<R(M2(phoenix::unpack(Seq, Fun), N, ARITY))> > \
- { \
- template <typename Expr, typename State, typename Data> \
- struct impl \
- : phoenix::detail::unpack_impl<Expr, State, Data, typename boost::remove_pointer<Seq>::type, Fun, R(M2(phoenix::unpack, N, ARITY))> \
- {}; \
- }; \
+#else
+
+#define L BOOST_PP_FRAME_ITERATION(4)
+
+//BOOST_PP_SUB(BOOST_PP_ADD(BOOST_PP_ADD(J, K), L), 2)
+#if J + K + L - 2 > BOOST_PROTO_MAX_ARITY
+//SIG J K L too much ...
+#else
+ #undef M5
+ #define M5(__, N, ___) \
+ fun_type(proto::functional::at(Seq, mpl::int_<N>())) \
     /**/
-
- BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, M0, _)
 
- #undef M1
+ template <
+ typename Expr
+ , typename State
+ , typename Data
+ , typename Seq
+ , typename Fun
+ , typename R
+ BOOST_PP_COMMA_IF(BOOST_PP_DEC(J)) TYPENAME_SIG
+ >
+ struct unpack_impl<
+ Expr
+ , State
+ , Data
+ , Seq
+ , Fun
+ , SIG
+ , L
+ >
+ : proto::transform_impl<Expr, State, Data>
+ {
+ struct fun_type : proto::when<proto::_, Fun> {};
 
-}}
-
-#undef M3
-#undef M2
-#undef M0
+ typedef
+ proto::call<
+ R(
+ BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(J), A)
+ BOOST_PP_COMMA_IF(BOOST_PP_AND(BOOST_PP_DEC(J), L))
+ BOOST_PP_ENUM(L, M5, _)
+ BOOST_PP_COMMA_IF(
+ BOOST_PP_AND(
+ L
+ , BOOST_PP_NOT_EQUAL(BOOST_PP_FRAME_START(3), K)
+ )
+ )
+ BOOST_PP_REPEAT_FROM_TO(
+ BOOST_PP_FRAME_START(3)
+ , K
+ , 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);
+ }
 
-#endif
+ };
 
-#else // BOOST_PP_IS_ITERATING
+#endif
 
-#define EXPR_N BOOST_PP_ITERATION()
-
- BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, M0, _)
+#endif
 
 #endif
+

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/dynamic.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/scope/dynamic.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/dynamic.hpp 2011-01-03 12:11:16 EST (Mon, 03 Jan 2011)
@@ -17,6 +17,7 @@
 #include <boost/preprocessor/seq/for_each.hpp>
 #include <boost/preprocessor/seq/fold_left.hpp>
 #include <boost/preprocessor/punctuation/comma.hpp>
+#include <boost/type_traits/remove_pointer.hpp>
 
 #define BOOST_PHOENIX_DYNAMIC_TEMPLATE_PARAMS(R, DATA, I, ELEM) \
       BOOST_PP_COMMA_IF(I) BOOST_PP_TUPLE_ELEM(2, 0, ELEM) \

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/lambda.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/scope/lambda.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/lambda.hpp 2011-01-03 12:11:16 EST (Mon, 03 Jan 2011)
@@ -21,6 +21,7 @@
 #include <boost/phoenix/support/iterate.hpp>
 */
 #include <boost/phoenix/core/limits.hpp>
+#include <boost/mpl/int.hpp>
 #include <boost/phoenix/core/actor.hpp>
 #include <boost/phoenix/scope/local_variable.hpp>
 
@@ -326,6 +327,21 @@
     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, unpack)//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>


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