|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r64288 - in sandbox/SOC/2010/phoenix3: boost/phoenix/core boost/phoenix/scope boost/phoenix/scope/detail libs/phoenix/test libs/phoenix/test/scope
From: thom.heller_at_[hidden]
Date: 2010-07-23 06:17:56
Author: theller
Date: 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
New Revision: 64288
URL: http://svn.boost.org/trac/boost/changeset/64288
Log:
finished scope port
Added:
sandbox/SOC/2010/phoenix3/boost/phoenix/core/no_nullary.hpp (contents, props changed)
sandbox/SOC/2010/phoenix3/boost/phoenix/scope/detail/dynamic.hpp (contents, props changed)
sandbox/SOC/2010/phoenix3/boost/phoenix/scope/dynamic.hpp (contents, props changed)
Removed:
sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_actor.hpp
Text files modified:
sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor.hpp | 7 +-
sandbox/SOC/2010/phoenix3/boost/phoenix/core/argument.hpp | 6 ++
sandbox/SOC/2010/phoenix3/boost/phoenix/core/arity.hpp | 10 ----
sandbox/SOC/2010/phoenix3/boost/phoenix/core/compose.hpp | 2
sandbox/SOC/2010/phoenix3/boost/phoenix/core/meta_grammar.hpp | 3
sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp | 43 ++++++++++++++++++-
sandbox/SOC/2010/phoenix3/boost/phoenix/scope/detail/local_gen.hpp | 5 --
sandbox/SOC/2010/phoenix3/boost/phoenix/scope/detail/local_variable.hpp | 21 +++++++--
sandbox/SOC/2010/phoenix3/boost/phoenix/scope/lambda.hpp | 40 +++++++++++++-----
sandbox/SOC/2010/phoenix3/boost/phoenix/scope/let.hpp | 87 +++++++++++++++++----------------------
sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_variable.hpp | 7 ++
sandbox/SOC/2010/phoenix3/boost/phoenix/scope/scoped_environment.hpp | 12 ++--
sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile | 4
sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/dynamic_tests.cpp | 4
sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/lambda_tests.cpp | 27 +++++------
sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/let_tests.cpp | 37 +++++++++-------
16 files changed, 185 insertions(+), 130 deletions(-)
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor.hpp 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -14,6 +14,7 @@
#include <boost/phoenix/core/arity.hpp>
#include <boost/phoenix/core/compose.hpp>
#include <boost/phoenix/core/domain.hpp>
+#include <boost/phoenix/core/no_nullary.hpp>
#include <boost/phoenix/core/environment.hpp>
#include <boost/phoenix/core/limits.hpp>
#include <boost/phoenix/core/meta_grammar.hpp>
@@ -50,11 +51,11 @@
static const int arity = result_of::arity<Expr>::type::value;
typedef typename
- mpl::eval_if_c<
- arity == 0 // avoid calling result_of::actor when this is false
+ mpl::eval_if<
+ typename no_nullary<Expr>::type//false//arity == 0 // avoid calling result_of::actor when this is false
+ , mpl::identity<detail::error_expecting_arguments>
, boost::result_of<eval_grammar(Expr const&,
typename make_basic_environment<>::type&)>
- , mpl::identity<detail::error_expecting_arguments>
>::type
type;
};
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-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -57,6 +57,12 @@
return get_environment_argument_c<argument_id::value>(env);
}
};
+
+ template <typename Dummy>
+ struct enable_nullary<argument, Dummy>
+ : mpl::false_
+ {};
+
template <typename N>
struct make_argument : boost::phoenix::compose<argument, N> {};
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/arity.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/arity.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/arity.hpp 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -33,9 +33,6 @@
struct funcwrap;
struct env;
-
- template <typename Key>
- struct local_variable;
namespace detail
{
@@ -50,13 +47,6 @@
>
, mpl::next<proto::_value(proto::_child2)>()
>
- , proto::when<
- proto::function<
- proto::terminal<funcwrap<local_variable<proto::_> > >
- , proto::terminal<env>
- >
- , mpl::int_<100>()
- >
, proto::otherwise<
proto::fold<
proto::_
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/compose.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/compose.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/compose.hpp 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -16,8 +16,6 @@
#include <boost/proto/tags.hpp>
#include <boost/proto/make_expr.hpp>
-namespace foo { template< typename T > struct wrap{}; }
-
namespace boost { namespace phoenix
{
////////////////////////////////////////////////////////////////////////////
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/meta_grammar.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/meta_grammar.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/meta_grammar.hpp 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -66,7 +66,8 @@
: proto::or_<
proto::when<
proto::terminal<funcwrap<proto::_> >,
- mpl::deref<proto::_value>()>
+ mpl::deref<proto::_value>()
+ >
, proto::when<proto::terminal<env>, proto::_state>
, proto::_
>
Added: sandbox/SOC/2010/phoenix3/boost/phoenix/core/no_nullary.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/no_nullary.hpp 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -0,0 +1,68 @@
+/*==============================================================================
+ Copyright (c) 2005-2010 Joel de Guzman
+ 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_NO_NULLARY_HPP
+#define PHOENIX_CORE_NO_NULLARY_HPP
+
+#include <boost/mpl/or.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/deref.hpp>
+#include <boost/proto/proto_fwd.hpp>
+#include <boost/proto/matches.hpp>
+#include <boost/proto/traits.hpp>
+#include <boost/proto/tags.hpp>
+#include <boost/proto/transform/arg.hpp>
+#include <boost/proto/transform/when.hpp>
+#include <boost/proto/transform/fold.hpp>
+#include <boost/utility/result_of.hpp>
+
+namespace boost { namespace phoenix
+{
+
+ template <typename Func, typename Dummy = void>
+ struct enable_nullary
+ : mpl::true_
+ {};
+
+
+ template <typename Expr>
+ struct no_nullary;
+
+ namespace detail
+ {
+ struct no_nullary_transform
+ : proto::or_<
+ proto::when<
+ proto::terminal<funcwrap<proto::_> >
+ , mpl::not_<
+ mpl::deref<
+ enable_nullary<
+ mpl::deref<proto::_value>
+ >
+ >
+ >()
+ >
+ , proto::when<proto::terminal<proto::_>, mpl::false_()>
+ , proto::otherwise<
+ proto::fold<
+ proto::_
+ , mpl::false_()
+ , mpl::or_<no_nullary_transform, proto::_state>()
+ >
+ >
+ >
+ {};
+ }
+
+ template <typename Expr>
+ struct no_nullary
+ : boost::result_of<detail::no_nullary_transform(Expr const&)>
+ {};
+
+}}
+
+#endif
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -29,6 +29,15 @@
struct value
: boost::result_of<eval_grammar(T const&)>
{};
+
+ template <typename Env, typename Expr>
+ struct actor_value
+ : remove_const<
+ typename remove_reference<
+ typename boost::result_of<eval_grammar(Expr const&, Env&)>::type
+ >::type
+ >
+ {};
}
struct value
@@ -43,23 +52,51 @@
template<typename Env, typename T>
typename result_of::value<Env, T>::type
- operator()(Env& env, T const& t)
+ operator()(Env& env, T const& t) const
{
return eval(t);
}
};
+ struct actor_value
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Env, typename Actor>
+ struct result<This(Env&, Actor const&)>
+ : result_of::actor_value<Env, Actor>
+ {};
+
+ template<typename Env, typename Actor>
+ typename result_of::actor_value<Env, Actor>::type
+ operator()(Env& env, Actor const& actor) const
+ {
+ return eval(actor, env);
+ }
+ };
+
template <typename T>
struct make_value : compose<value, T> {};
- template<typename T>
+ template <typename Actor>
+ struct make_actor_value : compose<actor_value, Actor> {};
+
+ template <typename Expr>
+ typename make_actor_value<actor<Expr> >::type const
+ val(actor<Expr> const& a)
+ {
+ return make_actor_value<actor<Expr> >()(a);
+ }
+
+ template <typename T>
typename make_value<T>::type const
val(T const & t )
{
return make_value<T>()(t);
}
- template<typename T>
+ template <typename T>
typename make_value<T>::type const
val(T & t )
{
Added: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/detail/dynamic.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/detail/dynamic.hpp 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -0,0 +1,45 @@
+/*==============================================================================
+ Copyright (c) 2005-2010 Joel de Guzman
+ 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)
+==============================================================================*/
+
+#if !PHOENIX_IS_ITERATING
+
+#define PHOENIX_ITERATION_PARAMS \
+ (3, (4, PHOENIX_DYNAMIC_LIMIT, \
+ <boost/phoenix/scope/detail/dynamic.hpp>))
+#include PHOENIX_ITERATE()
+
+#else
+
+#define PHOENIX_SCOPE_DYNAMIC_MEMBER_I(_, n, __) \
+ typedef typename make_dynamic_member<n, self_type>::type BOOST_PP_CAT(member, BOOST_PP_INC(n));
+
+#define PHOENIX_SCOPE_DYNAMIC_MEMBER BOOST_PP_REPEAT(PHOENIX_ITERATION, PHOENIX_SCOPE_DYNAMIC_MEMBER_I, _)
+
+ template <PHOENIX_typename_A>
+ struct dynamic<PHOENIX_A> : noncopyable
+ {
+ typedef BOOST_PP_CAT(fusion::vector, PHOENIX_ITERATION)<PHOENIX_A> tuple_type;
+ typedef dynamic<PHOENIX_A> self_type;
+ typedef dynamic_frame<self_type> dynamic_frame_type;
+
+ dynamic()
+ : frame(0) {}
+
+ template <int N>
+ static typename make_dynamic_member<N, self_type>::type
+ init(self_type& scope)
+ {
+ return make_dynamic_member<N, self_type>()(dynamic_member_data<N, self_type>(static_cast<self_type &>(scope)));
+ }
+
+ PHOENIX_SCOPE_DYNAMIC_MEMBER
+
+ mutable dynamic_frame_type* frame;
+ };
+
+#endif
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/detail/local_gen.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/scope/detail/local_gen.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/detail/local_gen.hpp 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -8,16 +8,11 @@
#if !PHOENIX_IS_ITERATING
-#ifndef PHOENIX_SCOPE_DETAIL_LAMBDA_LOCAL_GEN_HPP
-#define PHOENIX_SCOPE_DETAIL_LAMBDA_LOCAL_GEN_HPP
-
#define PHOENIX_ITERATION_PARAMS \
(3, (3, PHOENIX_LOCAL_LIMIT, \
<boost/phoenix/scope/detail/local_gen.hpp>))
#include PHOENIX_ITERATE()
-#endif
-
#else
#define PHOENIX_LOCAL_GEN_ACTOR_TYPES_I(_, n, __) \
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/detail/local_variable.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/scope/detail/local_variable.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/detail/local_variable.hpp 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -21,6 +21,17 @@
namespace detail
{
+ struct compute_no_nullary
+ {
+ template <typename State, typename T>
+ struct apply
+ {
+ typedef typename
+ mpl::or_<typename no_nullary<T>::type, State>::type
+ type;
+ };
+ };
+
template <typename Env>
struct initialize_local
{
@@ -34,7 +45,7 @@
typedef typename boost::result_of<eval_grammar(expr_type const&, Env &)>::type type;
};
- initialize_local(Env const& env)
+ initialize_local(Env& env)
: env(env) {}
template <typename Expr>
@@ -44,7 +55,7 @@
return eval(expr, env);
}
- Env const& env;
+ Env& env;
};
template <int N>
@@ -136,14 +147,14 @@
{
template <typename RT, typename Env, typename Index>
static RT
- get(Env const& env, Index, mpl::false_)
+ get(Env & env, Index, mpl::false_)
{
return fusion::at<Index>(env.locals);
}
template <typename RT, typename Env, typename Index>
static RT
- get(Env const& env, Index index, mpl::true_)
+ get(Env & env, Index index, mpl::true_)
{
typedef typename
get_index<typename Env::outer_env_type::map_type, Key>::type
@@ -157,7 +168,7 @@
template <typename RT, typename Env, typename Index>
static RT
- get(Env const& env, Index index)
+ get(Env & env, Index index)
{
return get<RT>(
env
Added: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/dynamic.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/dynamic.hpp 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -0,0 +1,184 @@
+/*==============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+ Copyright (c) 2004 Daniel Wallin
+ 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_SCOPE_DYNAMIC_HPP
+#define PHOENIX_SCOPE_DYNAMIC_HPP
+
+#include <boost/assert.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/fusion/sequence/intrinsic/at.hpp>
+
+namespace boost { namespace phoenix
+{
+
+ template <typename DynamicScope>
+ struct dynamic_frame : noncopyable
+ {
+ typedef typename DynamicScope::tuple_type tuple_type;
+
+ dynamic_frame(DynamicScope const& scope)
+ : tuple()
+ , save(scope.frame)
+ , scope(scope)
+ {
+ scope.frame = this;
+ }
+
+ template <typename Tuple>
+ dynamic_frame(DynamicScope const& scope, Tuple const& init)
+ : tuple(init)
+ , save(scope.frame)
+ , scope(scope)
+ {
+ scope.frame = this;
+ }
+
+ ~dynamic_frame()
+ {
+ scope.frame = save;
+ }
+
+ tuple_type& data() { return tuple; }
+ tuple_type const& data() const { return tuple; }
+
+ private:
+ tuple_type tuple;
+ dynamic_frame *save;
+ DynamicScope const& scope;
+ };
+
+ namespace result_of
+ {
+ template <typename Env, typename Data>
+ struct dynamic_member
+ {
+ typedef typename proto::result_of::value<Data>::type::result_type type;
+ };
+ }
+
+ struct dynamic_member
+ {
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Env, typename Data>
+ struct result<This(Env&, Data)>
+ : result_of::dynamic_member<Env, typename remove_reference<Data>::type >
+ {};
+
+ template <typename This, typename Env, typename Data>
+ struct result<This(Env&, Data const&)>
+ : result_of::dynamic_member<Env, Data>
+ {};
+
+ template <typename Env, typename Data>
+ typename result_of::dynamic_member<Env, Data>::type
+ operator()(Env& env, Data const& data)
+ {
+ return proto::value(data)();
+ }
+ };
+
+ template <int N, typename DynamicScope>
+ struct dynamic_member_data
+ {
+
+ typedef typename fusion::result_of::at_c<typename DynamicScope::tuple_type, N>::type result_type;
+
+ dynamic_member_data(DynamicScope const& scope) : scope(scope) {};
+
+ result_type
+ operator()() const
+ {
+ BOOST_ASSERT(scope.frame != 0);
+ return fusion::at_c<N>(scope.frame->data());
+ }
+
+ DynamicScope const& scope;
+ };
+
+ template <int N, typename DynamicScope>
+ struct make_dynamic_member: compose<dynamic_member, dynamic_member_data<N, DynamicScope> > {};
+
+ template <PHOENIX_typename_A_void(PHOENIX_DYNAMIC_LIMIT), typename Dummy = void>
+ struct dynamic;
+
+ template <typename A0>
+ struct dynamic<A0> : noncopyable
+ {
+ typedef fusion::vector1<A0> tuple_type;
+ typedef dynamic<A0> self_type;
+ typedef dynamic_frame<self_type> dynamic_frame_type;
+
+ dynamic()
+ : frame(0) {}
+
+ template <int N>
+ static typename make_dynamic_member<N, self_type>::type
+ init(self_type& scope)
+ {
+ return make_dynamic_member<N, self_type>()(dynamic_member_data<N, self_type>(static_cast<self_type &>(scope)));
+ }
+
+ typedef typename make_dynamic_member<0, self_type>::type member1;
+
+ mutable dynamic_frame_type* frame;
+ };
+
+ template <typename A0, typename A1>
+ struct dynamic<A0, A1> : noncopyable
+ {
+ typedef fusion::vector2<A0, A1> tuple_type;
+ typedef dynamic<A0, A1> self_type;
+ typedef dynamic_frame<self_type> dynamic_frame_type;
+
+ dynamic()
+ : frame(0) {}
+
+ template <int N>
+ static typename make_dynamic_member<N, self_type>::type
+ init(self_type& scope)
+ {
+ return make_dynamic_member<N, self_type>()(dynamic_member_data<N, self_type>(static_cast<self_type &>(scope)));
+ }
+
+ typedef typename make_dynamic_member<0, self_type>::type member1;
+ typedef typename make_dynamic_member<1, self_type>::type member2;
+
+ mutable dynamic_frame_type* frame;
+ };
+
+ template <typename A0, typename A1, typename A2>
+ struct dynamic<A0, A1, A2> : noncopyable
+ {
+ typedef fusion::vector3<A0, A1, A2> tuple_type;
+ typedef dynamic<A0, A1, A2> self_type;
+ typedef dynamic_frame<self_type> dynamic_frame_type;
+
+ dynamic()
+ : frame(0) {}
+
+ template <int N>
+ static typename make_dynamic_member<N, self_type>::type
+ init(self_type& scope)
+ {
+ return make_dynamic_member<N, self_type>()(dynamic_member_data<N, self_type>(static_cast<self_type &>(scope)));
+ }
+
+ typedef typename make_dynamic_member<0, self_type>::type member1;
+ typedef typename make_dynamic_member<1, self_type>::type member2;
+ typedef typename make_dynamic_member<2, self_type>::type member3;
+
+ mutable dynamic_frame_type* frame;
+ };
+
+ // Bring in the rest ...
+ #include <boost/phoenix/scope/detail/dynamic.hpp>
+}}
+
+#endif
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 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -11,6 +11,7 @@
#include <boost/fusion/include/transform.hpp>
#include <boost/fusion/include/as_vector.hpp>
+#include <boost/fusion/include/mpl.hpp>
#include <boost/phoenix/core/limits.hpp>
#include <boost/phoenix/scope/scoped_environment.hpp>
#include <boost/phoenix/core/actor.hpp>
@@ -45,7 +46,7 @@
template <typename This, typename Env, typename Expr, typename OuterEnv, typename Locals>
struct result<This(Env&, Expr const&, OuterEnv const&, Locals const&)>
- : result_of::lambda<Env, Expr, OuterEnv, Locals, Map>
+ : result_of::lambda<Env, Expr, OuterEnv, Locals, Map>
{};
template <typename Env, typename Expr, typename OuterEnv, typename Locals>
@@ -54,7 +55,13 @@
{
typedef typename result_of::lambda<Env, Expr, OuterEnv, Locals, Map>::environment environment;
- environment args(env, proto::value(outer_env), proto::value(locals));
+ typename remove_const<
+ typename remove_reference<
+ typename boost::result_of<eval_grammar(OuterEnv const&)>::type
+ >::type
+ >::type a(eval(outer_env));
+
+ environment args(env, a, proto::value(locals));
return eval(expr, args);
}
@@ -63,6 +70,7 @@
template <typename Expr, typename OuterEnv, typename Locals, typename Map>
struct make_lambda : compose<lambda_eval<Map>, Expr, OuterEnv, Locals> {};
+ template <typename Vars>
struct lambda_actor_eval
{
template <typename Sig>
@@ -80,6 +88,16 @@
return proto::value(a)(env);
}
};
+
+ template <typename Vars, typename Dummy>
+ struct enable_nullary<lambda_actor_eval<Vars>, Dummy>
+ : mpl::not_< typename mpl::fold<
+ Vars
+ , mpl::false_
+ , detail::compute_no_nullary
+ >::type >
+ {};
+
template <typename Expr, typename Vars, typename Map>
struct lambda_actor
@@ -114,8 +132,8 @@
typedef typename result<lambda_actor(Env&)>::locals_type locals_type;
return make_lambda<
- Expr, Env, locals_type, Map
- >()(expr, env, fusion::as_vector(fusion::transform(vars, detail::initialize_local<Env>(env))));
+ Expr, Env, locals_type, Map
+ >()(expr, env, fusion::as_vector(fusion::transform(vars, detail::initialize_local<Env>(env))));
}
Expr expr;
@@ -123,15 +141,15 @@
};
template <typename Expr, typename Vars, typename Map>
- struct make_lambda_actor: compose<lambda_actor_eval, lambda_actor<Expr, Vars, Map> > {};
-
+ struct make_lambda_actor: compose<lambda_actor_eval<Vars>, lambda_actor<Expr, Vars, Map> > {};
+
template <typename Vars, typename Map>
struct lambda_actor_gen
{
template <typename Expr>
typename make_lambda_actor<Expr, Vars, Map>::type const
- operator[](Expr const expr) const
+ operator[](Expr const& expr) const
{
return make_lambda_actor<Expr, Vars, Map>()(lambda_actor<Expr, Vars, Map>(expr, vars));
}
@@ -139,7 +157,7 @@
lambda_actor_gen(Vars const& vars)
: vars(vars) {}
- Vars const& vars;
+ Vars vars;
};
struct lambda_gen
@@ -199,9 +217,9 @@
);
}
- #define PHOENIX_LOCAL_GEN_NAME lambda_actor_gen
- #include <boost/phoenix/scope/detail/local_gen.hpp>
- #undef PHOENIX_LOCAL_GEN_NAME
+ #define PHOENIX_LOCAL_GEN_NAME lambda_actor_gen
+ #include <boost/phoenix/scope/detail/local_gen.hpp>
+ #undef PHOENIX_LOCAL_GEN_NAME
};
lambda_gen const lambda = lambda_gen();
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/let.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/scope/let.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/let.hpp 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -21,69 +21,51 @@
namespace boost { namespace phoenix
{
- struct let_eval
- {
- template <typename Sig>
- struct result;
-
- template <typename This, typename Env, typename A>
- struct result<This(Env&, A const&)>
- : boost::result_of<typename proto::result_of::value<A>::type(Env&)>
- {};
-
- template <typename Env, typename A>
- typename result<let_eval(Env&, A const&)>::type const
- operator()(Env& env, A const& a)
- {
- return proto::value(a)(env);
- }
- };
-
- template <typename Expr, typename Vars, typename Map>
- struct let_actor
+ template <typename Map>
+ struct let_eval
{
- let_actor(Expr const& expr, Vars const& vars)
- : expr(expr)
- , vars(vars)
- {}
-
template <typename Sig>
struct result;
-
- template <typename This, typename Env>
- struct result<This(Env&)>
+
+ template <typename This, typename Env, typename Expr, typename Vars>
+ struct result<This(Env&, Expr const&, Vars const&)>
{
typedef typename
fusion::result_of::as_vector<
typename fusion::result_of::transform<
- Vars
+ typename proto::result_of::value<Vars>::type
, detail::initialize_local<Env>
>::type
>::type
locals_type;
-
- typedef scoped_environment<Env, Env, locals_type, Map> env_type;
+
+ typedef scoped_environment<Env, Env, locals_type, Map> env_type;
- typedef typename boost::result_of<eval_grammar(Expr const&, env_type&)>::type type;
+ typedef typename boost::result_of<eval_grammar(Expr const&, env_type&)>::type type;
};
- template <typename Env>
- typename result<let_actor(Env&)>::type const
- operator()(Env& env) const
- {
- typedef typename result<let_actor(Env&)>::locals_type locals_type;
-
- scoped_environment<Env, Env, locals_type, Map> args(env, env, as_vector(fusion::transform(vars, detail::initialize_local<Env>(env))));
+ template <typename Env, typename Expr, typename Vars>
+ typename result<let_eval(Env&, Expr const&, Vars const&)>::type
+ operator()(Env& env, Expr const& expr, Vars const& vars)
+ {
+ typename result<let_eval(Env&, Expr const&, Vars const&)>::env_type
+ args(
+ env
+ , env
+ , fusion::as_vector(
+ fusion::transform(
+ proto::value(vars)
+ , detail::initialize_local<Env>(env)
+ )
+ )
+ );
return eval(expr, args);
}
-
- Expr expr;
- Vars vars;
};
template <typename Expr, typename Vars, typename Map>
- struct make_let: compose<let_eval, let_actor<Expr, Vars, Map> > {};
+ struct make_let: compose<let_eval<Map>, Expr, Vars> {};
template <typename Vars, typename Map>
struct let_actor_gen
@@ -91,15 +73,24 @@
template <typename Expr>
typename make_let<Expr, Vars, Map>::type const
- operator[](Expr const expr) const
+ operator[](Expr const& expr) const
{
- return make_let<Expr, Vars, Map>()(let_actor<Expr, Vars, Map>(expr, vars));
+ typedef typename
+ fusion::result_of::as_vector<
+ typename fusion::result_of::transform<
+ Vars
+ , detail::initialize_local<fusion::vector1<int&> >
+ >::type
+ >::type
+ locals_type;
+
+ return make_let<Expr, Vars, Map>()(expr, vars);
}
let_actor_gen(Vars const& vars)
: vars(vars) {}
- Vars const& vars;
+ Vars vars;
};
struct let_gen
@@ -159,8 +150,8 @@
);
}
- #define PHOENIX_LOCAL_GEN_NAME let_actor_gen
- #include <boost/phoenix/scope/detail/local_gen.hpp>
+ #define PHOENIX_LOCAL_GEN_NAME let_actor_gen
+ #include <boost/phoenix/scope/detail/local_gen.hpp>
#undef PHOENIX_LOCAL_GEN_NAME
};
Deleted: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_actor.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_actor.hpp 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
+++ (empty file)
@@ -1,150 +0,0 @@
-/*==============================================================================
- Copyright (c) 2005-2010 Joel de Guzman
- 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_SCOPE_LOCAL_ACTOR_HPP
-#define PHOENIX_SCOPE_LOCAL_ACTOR_HPP
-
-#include <boost/phoenix/core/actor.hpp>
-#include <boost/phoenix/support/element_at.hpp>
-
-namespace boost { namespace phoenix
-{
- namespace result_of
- {
- template <typename Expr, typename OuterEnv, typename Locals, typename Map, typename A0 = void, typename A1 = void>
- struct local_actor;
-
- template <typename Expr, typename OuterEnv, typename Locals, typename Map, typename A0>
- struct local_actor<Expr, OuterEnv, Locals, Map, A0>
- {
- typedef typename make_basic_environment<A0>::type basic_env;
- typedef scoped_environment<basic_env, OuterEnv, Locals, Map> args;
-
- typedef typename boost::result_of<eval_grammar(Expr const&, args&)>::type type;
- };
- }
-
- template <typename Expr>//, typename OuterEnv, typename Locals, typename Map>
- struct local_actor
- : actor<Expr>
- {
- typedef actor<Expr> base_type;
-
- local_actor(base_type const& base)//LambdaExpr const& lambda_expr, OuterEnv const& outer_env, Locals const& locals)
- : base_type(base)
- //, outer_env(eval(element_at_c<0>(*this)))
- //, locals(eval(element_at_c<1>(*this)))
- /*: base_type(lambda_expr)
- , outer_env(outer_env)
- , locals(locals)*/
- {}
-
- typedef typename boost::result_of<eval_grammar(typename result_of::element_value_at_c<Expr, 0>::type const&)>::type outer_env_type;
- typedef typename boost::result_of<eval_grammar(typename result_of::element_value_at_c<Expr, 1>::type const&)>::type locals_type;
- typedef typename boost::result_of<eval_grammar(typename result_of::element_value_at_c<Expr, 2>::type const&)>::type map_type;
-
- template <typename Sig>
- struct result;
-
- template <typename This, typename A0>
- struct result<This(A0)>
- : result_of::local_actor<Expr, outer_env_type, locals_type, map_type, A0>
- {};
- /*
-
- int
- operator()() const
- {
- typename make_basic_environment<>::type env;
- scoped_environment<typename make_basic_environment<>::type, outer_env_type, locals_type, map_type> args(env, outer_env, locals);
-
- return eval(*this, args);
- }
-
- template <typename A0>
- int//typename result_of::local_actor<outer_env_type, locals_type, map_type, A0 const&>::type
- operator()(A0 const& a0) const
- {
- typename make_basic_environment<A0 const&>::type env(a0);
- scoped_environment<typename make_basic_environment<A0 const&>::type, outer_env_type, locals_type, map_type> args(env, outer_env, locals);
-
- return eval(*this, args);
- }
-
- template <typename A0>
- typename result_of::local_actor<Expr, outer_env_type, locals_type, map_type, A0&>::type
- operator()(A0& a0) const
- {
- typename make_basic_environment<A0&>::type env(a0);
- scoped_environment<typename make_basic_environment<A0&>::type, outer_env_type, locals_type, map_type> args(env, outer_env, locals);
-
- return eval(*this, args);
- }
-
- outer_env_type const& outer_env;
- locals_type const& locals;
- */
- };
-
- template <typename Expr>
- struct local_eval
- {
- template <typename Sig>
- struct result;
-
- template <typename This, typename Env, typename OuterEnv, typename Locals, typename Map>
- struct result<This(Env&, OuterEnv const&, Locals const&, Map const&)>
- : boost::result_of<eval_grammar(Expr const&, scoped_environment<Env, OuterEnv, Locals, Map>&)>
- {};
-
- local_eval(Expr const& expr) : expr(expr) {}
-
- template <typename Env, typename OuterEnv, typename Locals, typename Map>
- typename boost::result_of<eval_grammar(Expr const&, scoped_environment<Env, OuterEnv, Locals, Map>&)>::type
- operator()(Env& env, OuterEnv const& outer_env, Locals const& locals, Map const&) const
- {
- std::cout << typeid(Env).name() << "\n\n";
- std::cout << typeid(OuterEnv).name() << "\n\n";
- std::cout << typeid(Locals).name() << "\n\n";
- std::cout << typeid(Expr).name() << "\n\n";
- scoped_environment<Env, OuterEnv, Locals, Map> args(env, outer_env, locals);
- return eval(expr, args);
- }
-
- Expr expr;
- };
-
- template <typename Expr, typename OuterEnv, typename Locals, typename Map>
- struct make_local_actor //: compose_ex<local_eval, local_actor, OuterEnv, Locals, Map>
- {
- typedef typename
- proto::result_of::make_expr<
- proto::tag::function
- , default_domain_with_basic_expr
- , local_eval<Expr>//, Map>//lambda_actor_eval<LambdaExpr, Vars, Map>
- , env
- , OuterEnv
- , Locals
- , Map
- >::type
- base_type;
-
- typedef local_actor<base_type> type;
- typedef type result_type;
-
- result_type const
- operator()(Expr const& expr, OuterEnv const& outer_env, Locals const& locals) const
- {
- actor<base_type> const e = {local_eval<Expr>(expr), env(), outer_env, locals, Map()};
-
- return e;
- }
- };
-
-}}
-
-#endif
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_variable.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_variable.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_variable.hpp 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -48,7 +48,7 @@
typedef typename result_of::local_variable<Env, Key>::type return_type;
typedef typename Env::map_type map_type;
typedef typename
- detail::get_index<typename Env::map_type, Key>::type
+ detail::get_index<map_type, Key>::type
index_type;
typedef detail::eval_local<Key> eval_local;
@@ -61,6 +61,11 @@
template <typename Key>
struct make_local_variable : compose<local_variable<Key> > {};
+
+ template <typename Key, typename Dummy>
+ struct enable_nullary<local_variable<Key>, Dummy>
+ : mpl::false_
+ {};
namespace local_names
{
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/scoped_environment.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/scope/scoped_environment.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/scoped_environment.hpp 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -46,14 +46,14 @@
// overload get_environment_argument_c to return the correct argument
template <int N, typename Env, typename OuterEnv, typename Locals, typename Map>
- typename result_of::get_environment_argument<scoped_environment<Env, OuterEnv, Locals, Map>, mpl::int_<N> >::type
+ typename result_of::get_environment_argument<scoped_environment<Env, OuterEnv, Locals, Map>, mpl::int_<N> >::type
get_environment_argument_c(scoped_environment<Env, OuterEnv, Locals, Map>& env)
{
return fusion::at_c<N>(env.env);
}
- template <int N, typename Env, typename OuterEnv, typename Locals, typename Map>
- typename result_of::get_environment_argument<scoped_environment<Env, OuterEnv, Locals, Map>, mpl::int_<N> >::type
+ template <int N, typename Env, typename OuterEnv, typename Locals, typename Map>
+ typename result_of::get_environment_argument<scoped_environment<Env, OuterEnv, Locals, Map>, mpl::int_<N> >::type
get_environment_argument_c(scoped_environment<Env, OuterEnv, Locals, Map> const& env)
{
return fusion::at_c<N>(env.env);
@@ -66,14 +66,14 @@
typedef Locals locals_type;
typedef Map map_type;
- scoped_environment(Env& env, OuterEnv const& outer_env, Locals const& locals)
+ scoped_environment(Env& env, OuterEnv& outer_env, Locals const& locals)
: env(env)
, outer_env(outer_env)
, locals(locals) {}
Env& env;
- OuterEnv const& outer_env;
- Locals const& locals;
+ OuterEnv& outer_env;
+ Locals locals;
};
}}
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-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -73,8 +73,8 @@
;
test-suite phoenix_scope :
-# [ run scope/lambda_tests.cpp ]
-# [ run scope/let_tests.cpp ]
+ [ run scope/lambda_tests.cpp ]
+ [ run scope/let_tests.cpp ]
# [ run scope/dynamic_tests.cpp ]
# [ run scope/bug_000008.cpp : : : $(multi-threading) ]
;
Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/dynamic_tests.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/dynamic_tests.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/dynamic_tests.cpp 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -16,7 +16,7 @@
struct my_dynamic : ::boost::phoenix::dynamic<int, std::string, double>
{
- my_dynamic() : num(*this), message(*this), real(*this) {}
+ my_dynamic() : num(init<0>(*this)), message(init<1>(*this)), real(init<2>(*this)) {}
member1 num;
member2 message;
@@ -75,5 +75,5 @@
BOOST_TEST(clos.message() == "Hello " + std::string("World "));
}
- return 0;
+ return boost::report_errors();
}
Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/lambda_tests.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/lambda_tests.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/lambda_tests.cpp 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -60,22 +60,20 @@
function<push_back_impl> const push_back = push_back_impl();
}}
-using namespace boost::phoenix;
-using namespace boost::phoenix::arg_names;
-using namespace boost::phoenix::local_names;
-using namespace std;
-
struct zzz {};
-template <typename Expr>
-void blubb(Expr const& expr)
-{
- std::cout << typeid( typename boost::phoenix::result_of::actor<Expr, boost::fusion::vector1<int&> >::type ).name() << "\n";
-}
-
int
main()
{
+ using boost::phoenix::lambda;
+ using boost::phoenix::let;
+ using boost::phoenix::ref;
+ using boost::phoenix::arg_names::_1;
+ using boost::phoenix::arg_names::_2;
+ using boost::phoenix::local_names::_a;
+ using boost::phoenix::local_names::_b;
+ using boost::phoenix::placeholders::arg1;
+
{
int x = 1;
int y = lambda[_1]()(x);
@@ -183,12 +181,11 @@
}
{
- /*
// $$$ Fixme. This should not be failing $$$
- int x = (let(_a = lambda[val(1)])[_a])()();
- //~ BOOST_TEST(x == 1);
- */
+ //int x = (let(_a = lambda[val(1)])[_a])(0)(0);
+ //BOOST_TEST(x == 1);
}
+
return boost::report_errors();
}
Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/let_tests.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/let_tests.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/let_tests.cpp 2010-07-23 06:17:53 EDT (Fri, 23 Jul 2010)
@@ -10,23 +10,32 @@
#include <vector>
#define PHOENIX_LIMIT 6
-#define PHOENIX_LOCAL_LIMIT 10
#include <boost/phoenix/core/limits.hpp>
#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/scope.hpp>
#include <boost/phoenix/core.hpp>
#include <boost/phoenix/operator.hpp>
-#include <boost/phoenix/scope.hpp>
#include <boost/phoenix/function.hpp>
-using namespace boost::phoenix;
-using namespace boost::phoenix::arg_names;
-using namespace boost::phoenix::local_names;
-using namespace std;
-
int
main()
{
+ using boost::phoenix::let;
+ using boost::phoenix::val;
+ using boost::phoenix::arg_names::_1;
+ using boost::phoenix::arg_names::_2;
+ using boost::phoenix::arg_names::_3;
+ using boost::phoenix::local_names::_a;
+ using boost::phoenix::local_names::_b;
+ using boost::phoenix::local_names::_c;
+ using boost::phoenix::local_names::_d;
+ using boost::phoenix::local_names::_e;
+ using boost::phoenix::local_names::_x;
+ using boost::phoenix::local_names::_y;
+ using boost::phoenix::local_names::_z;
+ using boost::phoenix::placeholders::arg1;
+
{
int x = 1;
BOOST_TEST(
@@ -38,7 +47,6 @@
);
}
- /*
{
int x = 1, y = 10;
BOOST_TEST(
@@ -49,9 +57,7 @@
(x, y) == x + y
);
}
- */
- /*
{
int x = 1, y = 10, z = 13;
BOOST_TEST(
@@ -81,7 +87,6 @@
);
}
-
{
int x = 999;
BOOST_TEST(
@@ -105,16 +110,17 @@
(x) == x + 888
);
- BOOST_TEST(x == 999);
+ BOOST_TEST(x == 999);
}
{
+ // FIXME do not require a argument to return int
BOOST_TEST(
let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5)
[
_a + _b + _c + _d + _e
]
- () == 1 + 2 + 3 + 4 + 5
+ (0) == 1 + 2 + 3 + 4 + 5
);
}
@@ -130,9 +136,9 @@
// show that we can return a local from an outer scope
int y = 0;
int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y);
+
BOOST_TEST(x == 1);
}
- */
{
// show that this code returns an lvalue
@@ -144,11 +150,10 @@
{
// show that what you put in is what you get out
int i = 1;
- int& j = let(_a = arg1)[ _a ](i);
+ int& j = let(_a = arg1)[_a](i);
BOOST_TEST(&i == &j);
}
-
return boost::report_errors();
}
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