Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62711 - sandbox/SOC/2010/phoenix3/boost/phoenix/core
From: joel_at_[hidden]
Date: 2010-06-10 02:11:40


Author: djowel
Date: 2010-06-10 02:11:39 EDT (Thu, 10 Jun 2010)
New Revision: 62711
URL: http://svn.boost.org/trac/boost/changeset/62711

Log:
+ the environment concept
+ better result_of modularization
Added:
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/environment.hpp (contents, props changed)
Text files modified:
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor_result.hpp | 2
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/argument.hpp | 48 ++++++++++++++----------
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/as_actor.hpp | 77 +++++++++++++++++++++++----------------
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/is_actor.hpp | 2
   4 files changed, 76 insertions(+), 53 deletions(-)

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor_result.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor_result.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor_result.hpp 2010-06-10 02:11:39 EDT (Thu, 10 Jun 2010)
@@ -19,7 +19,7 @@
     ////////////////////////////////////////////////////////////////////////////
     // Return type computation
     ////////////////////////////////////////////////////////////////////////////
- template<typename Sig>
+ template <typename Sig, typename Enable = void>
     struct actor_result;
 
     template <typename Actor>

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/argument.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/argument.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/argument.hpp 2010-06-10 02:11:39 EDT (Thu, 10 Jun 2010)
@@ -12,6 +12,7 @@
 #include <boost/phoenix/core/actor.hpp>
 #include <boost/phoenix/core/as_actor.hpp>
 #include <boost/phoenix/core/meta_grammar.hpp>
+#include <boost/phoenix/core/environment.hpp>
 
 #include <boost/fusion/sequence/intrinsic/at.hpp>
 
@@ -22,41 +23,48 @@
 namespace boost { namespace phoenix
 {
     // function for evaluating argument placeholders like: _1
- struct argument
+
+ namespace result_of
     {
- template<typename N, template<typename> class Actor = actor >
- struct as_actor : boost::phoenix::as_actor<argument, Actor, N>
+ template <typename Env, typename N>
+ struct argument
+ : result_of::get_environment_argument<
+ Env, typename boost::result_of<eval_grammar(N)>::type>
         {};
-
- template<typename Signature>
+ }
+
+ struct argument
+ {
+ template <typename Signature>
         struct result;
 
- template<typename This, typename Env, typename N>
- struct result<This(Env &, N &)>
- : fusion::result_of::at<
- Env, typename boost::result_of<eval_grammar(N)>::type>
+ template <typename This, typename Env, typename N>
+ struct result<This(Env&, N&)>
+ : result_of::argument<Env, N>
         {};
 
- template<typename Env, typename N>
- typename boost::result_of<argument(Env &, N &)>::type
- operator()(Env & env, N &) const
+ template <typename Env, typename N>
+ typename result_of::argument<Env, N>::type
+ operator()(Env& env, N& n) const
         {
- return fusion::at<
- typename boost::result_of<eval_grammar(N)>::type>(env);
+ return get_environment_argument()(env, eval(n));
         }
     };
+
+ template <typename N>
+ struct make_argument : boost::phoenix::as_actor<argument, actor, N> {};
 
     namespace placeholders
     {
     // Phoenix style names
- argument::as_actor<mpl::int_<0> >::result_type const arg1 = {};
- argument::as_actor<mpl::int_<1> >::result_type const arg2 = {};
- argument::as_actor<mpl::int_<2> >::result_type const arg3 = {};
+ make_argument<mpl::int_<0> >::type const arg1 = {};
+ make_argument<mpl::int_<1> >::type const arg2 = {};
+ make_argument<mpl::int_<2> >::type const arg3 = {};
 
     // BLL style names
- argument::as_actor<mpl::int_<0> >::result_type const _1 = {};
- argument::as_actor<mpl::int_<1> >::result_type const _2 = {};
- argument::as_actor<mpl::int_<2> >::result_type const _3 = {};
+ make_argument<mpl::int_<0> >::type const _1 = {};
+ make_argument<mpl::int_<1> >::type const _2 = {};
+ make_argument<mpl::int_<2> >::type const _3 = {};
     }
 
     namespace arg_names

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/as_actor.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/as_actor.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/as_actor.hpp 2010-06-10 02:11:39 EDT (Thu, 10 Jun 2010)
@@ -42,6 +42,7 @@
                 , env>::type
             base_type;
         typedef Actor<base_type> result_type;
+ typedef result_type type;
 
         result_type
         operator()() const
@@ -63,6 +64,7 @@
                 , A0>::type
             base_type;
         typedef Actor<base_type> result_type;
+ typedef result_type type;
 
         result_type
         operator()( typename call_traits<A0>::param_type a0 ) const
@@ -72,7 +74,8 @@
         }
     };
 
- template<typename F, template<typename> class Actor, typename A0, typename A1>
+ template<typename F, template<typename> class Actor,
+ typename A0, typename A1>
     struct as_actor<F, Actor, A0, A1>
     {
         typedef
@@ -85,16 +88,20 @@
                 , A1>::type
             base_type;
         typedef Actor<base_type> result_type;
+ typedef result_type type;
 
         result_type
- operator()( typename call_traits<A0>::param_type a0, typename call_traits<A1>::param_type a1 ) const
+ operator()(
+ typename call_traits<A0>::param_type a0,
+ typename call_traits<A1>::param_type a1) const
         {
             actor<base_type> const e = {{funcwrap<F>(), env(), a0, a1}};
             return e;
         }
     };
 
- template<typename F, template<typename> class Actor, typename A0, typename A1, typename A2>
+ template <typename F, template<typename> class Actor,
+ typename A0, typename A1, typename A2>
     struct as_actor<F, Actor, A0, A1, A2>
     {
         typedef
@@ -108,9 +115,13 @@
                 , A2>::type
             base_type;
         typedef Actor<base_type> result_type;
+ typedef result_type type;
 
         result_type
- operator()( typename call_traits<A0>::param_type a0, typename call_traits<A1>::param_type a1, typename call_traits<A2>::param_type a2) const
+ operator()(
+ typename call_traits<A0>::param_type a0,
+ typename call_traits<A1>::param_type a1,
+ typename call_traits<A2>::param_type a2) const
         {
             actor<base_type> const e = {{funcwrap<F>(), env(), a0, a1, a2}};
             return e;
@@ -120,33 +131,37 @@
 }}
 
 /*
-#define BOOST_PP_LOCAL_MACRO( N ) \
- namespace boost { namespace phoenix \
- { \
- template<typename F, template<typename> class Actor \
- BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)> \
- struct as_actor<F, Actor BOOST_PP_ENUM_TRAILING_PARAMS(N, A)> \
- { \
- typedef \
- typename proto::result_of::make_expr< \
- proto::tag::function \
- , proto::default_domain \
- , funcwrap< F > \
- , env BOOST_PP_ENUM_TRAILING_PARAMS(N, A) \
- >::type \
- base_type; \
- \
- typedef Actor<base_type> result_type; \
- \
- result_type \
- operator()( \
- BOOST_PP_ENUM_BINARY_PARAMS(N, typename call_traits< A, >::param_type a)) const \
- { \
- actor<base_type> const e = {{funcwrap< F >(), env() BOOST_PP_ENUM_TRAILING_PARAMS(N, a)}};\
- return e; \
- } \
- }; \
- }}
+#define BOOST_PP_LOCAL_MACRO( N ) \
+namespace boost { namespace phoenix \
+{ \
+ template<typename F, template<typename> class Actor \
+ BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)> \
+ struct as_actor<F, Actor BOOST_PP_ENUM_TRAILING_PARAMS(N, A)> \
+ { \
+ typedef \
+ typename proto::result_of::make_expr< \
+ proto::tag::function \
+ , proto::default_domain \
+ , funcwrap< F > \
+ , env BOOST_PP_ENUM_TRAILING_PARAMS(N, A) \
+ >::type \
+ base_type; \
+ \
+ typedef Actor<base_type> result_type; \
+ typedef result_type type; \
+ \
+ result_type \
+ operator()( \
+ BOOST_PP_ENUM_BINARY_PARAMS(N, \
+ typename call_traits< A, >::param_type a)) const \
+ { \
+ actor<base_type> const e = {{ \
+ funcwrap< F >(), env() BOOST_PP_ENUM_TRAILING_PARAMS(N, a) \
+ }}; \
+ return e; \
+ } \
+ }; \
+}}
 
 #define BOOST_PP_LOCAL_LIMITS ( 0, 3 )
 #include BOOST_PP_LOCAL_ITERATE()

Added: sandbox/SOC/2010/phoenix3/boost/phoenix/core/environment.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/environment.hpp 2010-06-10 02:11:39 EDT (Thu, 10 Jun 2010)
@@ -0,0 +1,43 @@
+/*==============================================================================
+ Copyright (c) 2005-2010 Joel de Guzman
+
+ 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_ENVIRONMENT_HPP
+#define PHOENIX_CORE_ENVIRONMENT_HPP
+
+#include <boost/fusion/support/is_sequence.hpp>
+
+namespace boost { namespace phoenix
+{
+// template <typename T, typename Enable = void>
+// struct is_environment : fusion::is_sequence<T> {};
+
+ namespace result_of
+ {
+ template <typename Env, typename N>
+ struct get_environment_argument
+ : fusion::result_of::at_c<Env, N::value> {};
+ }
+
+ // Get the Nth argument from the environment
+ struct get_environment_argument
+ {
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Env, typename N>
+ struct result<This(Env&, N)>
+ : result_of::get_environment_argument<Env, N> {};
+
+ template <typename Env, typename N>
+ typename result_of::get_environment_argument<Env, N>::type
+ operator()(Env& env, N) const
+ {
+ return fusion::at_c<N::value>(env);
+ }
+ };
+}}
+
+#endif

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/is_actor.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/is_actor.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/is_actor.hpp 2010-06-10 02:11:39 EDT (Thu, 10 Jun 2010)
@@ -16,7 +16,7 @@
 // Tests if T is an actor. Evaluates to mpl::true_ or mpl::false_
 //
 ///////////////////////////////////////////////////////////////////////////////
- template <typename T>
+ template <typename T, typename Enable = void>
     struct is_actor : mpl::false_ {};
 
     template <typename Expr>


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