diff options
author | Kevin Smith <git@kismith.co.uk> | 2013-01-12 18:41:34 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2013-01-13 10:36:26 (GMT) |
commit | f3bc816af1b0d61452de973963e453bf3b3f95a2 (patch) | |
tree | e895f8afa3580e6cff6f5ad2017d45bf147a17c2 /3rdParty/Boost/src/boost/spirit/home/phoenix/scope | |
parent | 188fc285c6555eadd3c9d50ab8a94adcade78d89 (diff) | |
download | swift-f3bc816af1b0d61452de973963e453bf3b3f95a2.zip swift-f3bc816af1b0d61452de973963e453bf3b3f95a2.tar.bz2 |
Adding in the spirit Boost stuff
Change-Id: I4f127ce61667243b64081b0aa309028d5077045f
Diffstat (limited to '3rdParty/Boost/src/boost/spirit/home/phoenix/scope')
6 files changed, 734 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/detail/local_gen.hpp b/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/detail/local_gen.hpp new file mode 100644 index 0000000..6a74df6 --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/detail/local_gen.hpp @@ -0,0 +1,57 @@ +/*============================================================================= + Copyright (c) 2001-2007 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 BOOST_PP_IS_ITERATING +// Allow multiple inclusion. let.hpp and lambda.hpp will have the guards + +#include <boost/preprocessor/iterate.hpp> +#include <boost/preprocessor/repetition/enum.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> + +#define PHOENIX_LOCAL_GEN_PARAM(z, n, data) \ + actor<composite<assign_eval \ + , fusion::vector<local_variable<K##n>, V##n> > > const& a##n + +#define PHOENIX_LOCAL_GEN_ACTOR(z, n, data) \ + fusion::at_c<1>(a##n) + +#define BOOST_PP_ITERATION_PARAMS_1 \ + (3, (3, PHOENIX_LOCAL_LIMIT, \ + "boost/spirit/home/phoenix/scope/detail/local_gen.hpp")) +#include BOOST_PP_ITERATE() + +#undef PHOENIX_LOCAL_GEN_PARAM +#undef PHOENIX_LOCAL_GEN_ACTOR + +/////////////////////////////////////////////////////////////////////////////// +// +// Preprocessor vertical repetition code +// +/////////////////////////////////////////////////////////////////////////////// +#else // defined(BOOST_PP_IS_ITERATING) + +#define N BOOST_PP_ITERATION() + + template < + BOOST_PP_ENUM_PARAMS(N, typename K) + , BOOST_PP_ENUM_PARAMS(N, typename V) + > + PHOENIX_LOCAL_GEN_NAME< + fusion::vector<BOOST_PP_ENUM_PARAMS(N, V)> + , detail::map_local_index_to_tuple<BOOST_PP_ENUM_PARAMS(N, K)> + > + operator()( + BOOST_PP_ENUM(N, PHOENIX_LOCAL_GEN_PARAM, _) + ) const + { + return fusion::vector<BOOST_PP_ENUM_PARAMS(N, V)>( + BOOST_PP_ENUM(N, PHOENIX_LOCAL_GEN_ACTOR, _)); + } + +#undef N +#endif // defined(BOOST_PP_IS_ITERATING) + + diff --git a/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/detail/local_variable.hpp b/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/detail/local_variable.hpp new file mode 100644 index 0000000..1ad7932 --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/detail/local_variable.hpp @@ -0,0 +1,198 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2004 Daniel Wallin + + 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_DETAIL_LOCAL_VARIABLE_HPP +#define PHOENIX_SCOPE_DETAIL_LOCAL_VARIABLE_HPP + +#include <boost/mpl/int.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/equal_to.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/mpl/less.hpp> +#include <boost/mpl/size.hpp> +#include <boost/fusion/include/at.hpp> +#include <boost/fusion/include/value_at.hpp> +#include <boost/preprocessor/enum.hpp> +#include <boost/preprocessor/repeat.hpp> +#include <boost/type_traits/remove_reference.hpp> +#include <boost/type_traits/is_reference.hpp> + +#define PHOENIX_MAP_LOCAL_TEMPLATE_PARAM(z, n, data) \ + typename T##n = unused<n> + +#define PHOENIX_MAP_LOCAL_DISPATCH(z, n, data) \ + typedef char(&result##n)[n+2]; \ + static result##n get(T##n*); + +namespace boost { namespace phoenix +{ + template <typename Env, typename OuterEnv, typename Locals, typename Map> + struct scoped_environment; + + namespace detail + { + template <typename Env> + struct initialize_local + { + template <class F> + struct result; + + template <class F, class Actor> + struct result<F(Actor)> + { + typedef typename remove_reference<Actor>::type actor_type; + typedef typename actor_type::template result<Env>::type type; + }; + + initialize_local(Env const& env) + : env(env) {} + + template <typename Actor> + typename result<initialize_local(Actor)>::type + operator()(Actor const& actor) const + { + return actor.eval(env); + } + + Env const& env; + + private: + // silence MSVC warning C4512: assignment operator could not be generated + initialize_local& operator= (initialize_local const&); + }; + + template <typename T> + struct is_scoped_environment : mpl::false_ {}; + + template <typename Env, typename OuterEnv, typename Locals, typename Map> + struct is_scoped_environment<scoped_environment<Env, OuterEnv, Locals, Map> > + : mpl::true_ {}; + + template <int N> + struct unused; + + template <BOOST_PP_ENUM( + PHOENIX_LOCAL_LIMIT, PHOENIX_MAP_LOCAL_TEMPLATE_PARAM, _)> + struct map_local_index_to_tuple + { + typedef char(¬_found)[1]; + static not_found get(...); + + BOOST_PP_REPEAT(PHOENIX_LOCAL_LIMIT, PHOENIX_MAP_LOCAL_DISPATCH, _) + }; + + template<typename T> + T* generate_pointer(); + + template <typename Map, typename Tag> + struct get_index + { + BOOST_STATIC_CONSTANT(int, + value = ( + static_cast<int>((sizeof(Map::get(generate_pointer<Tag>()))) / sizeof(char)) - 2 + )); + + // if value == -1, Tag is not found + typedef mpl::int_<value> type; + }; + + template <typename Local, typename Env> + struct apply_local; + + template <typename Local, typename Env> + struct outer_local + { + typedef typename + apply_local<Local, typename Env::outer_env_type>::type + type; + }; + + template <typename Locals, typename Index> + struct get_local_or_void + { + typedef typename + mpl::eval_if< + mpl::less<Index, mpl::size<Locals> > + , fusion::result_of::at<Locals, Index> + , mpl::identity<fusion::void_> + >::type + type; + }; + + template <typename Local, typename Env, typename Index> + struct get_local_from_index + { + typedef typename + mpl::eval_if< + mpl::equal_to<Index, mpl::int_<-1> > + , outer_local<Local, Env> + , get_local_or_void<typename Env::locals_type, Index> + >::type + type; + }; + + template <typename Local, typename Env> + struct get_local + { + typedef typename + get_index< + typename Env::map_type, typename Local::key_type>::type + index_type; + + typedef typename + get_local_from_index<Local, Env, index_type>::type + type; + }; + + template <typename Local, typename Env> + struct apply_local + { + // $$$ TODO: static assert that Env is a scoped_environment $$$ + typedef typename get_local<Local, Env>::type type; + }; + + template <typename Key> + struct eval_local + { + template <typename RT, typename Env, typename Index> + static RT + get(Env const& env, Index, mpl::false_) + { + return RT(fusion::at<Index>(env.locals)); + } + + template <typename RT, typename Env, typename Index> + static RT + get(Env const& env, Index index, mpl::true_) + { + typedef typename + get_index<typename Env::outer_env_type::map_type, Key>::type + index_type; + + return get<RT>( + env.outer_env + , index_type() + , mpl::equal_to<index_type, mpl::int_<-1> >()); + } + + template <typename RT, typename Env, typename Index> + static RT + get(Env const& env, Index index) + { + return get<RT>( + env + , index + , mpl::equal_to<Index, mpl::int_<-1> >()); + } + }; + } +}} + +#undef PHOENIX_MAP_LOCAL_TEMPLATE_PARAM +#undef PHOENIX_MAP_LOCAL_DISPATCH +#endif diff --git a/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/lambda.hpp b/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/lambda.hpp new file mode 100644 index 0000000..c4a7ce8 --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/lambda.hpp @@ -0,0 +1,176 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2004 Daniel Wallin + + 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_LAMBDA_HPP +#define PHOENIX_SCOPE_LAMBDA_HPP + +#include <boost/spirit/home/phoenix/core/limits.hpp> +#include <boost/spirit/home/phoenix/core/composite.hpp> +#include <boost/spirit/home/phoenix/scope/scoped_environment.hpp> +#include <boost/spirit/home/phoenix/scope/detail/local_variable.hpp> +#include <boost/spirit/home/phoenix/detail/local_reference.hpp> +#include <boost/spirit/home/phoenix/core/actor.hpp> +#include <boost/fusion/include/transform.hpp> +#include <boost/fusion/include/as_vector.hpp> + +namespace boost { namespace phoenix +{ + template <typename Base, typename OuterEnv, typename Locals, typename Map> + struct lambda_eval : Base + { + template <typename Env> + struct result + { + typedef typename Base::template + result<scoped_environment<Env, OuterEnv, Locals, Map> >::type + result_type; + + typedef typename + detail::unwrap_local_reference<result_type>::type + type; + }; + + lambda_eval( + Base const& base + , OuterEnv const& outer_env + , Locals const& locals) + : Base(base) + , outer_env(outer_env) + , locals(locals) {} + + template <typename Env> + typename result<Env>::type + eval(Env const& env) const + { + typedef typename result<Env>::type RT; + return RT(Base::eval( + scoped_environment<Env, OuterEnv, Locals, Map>( + env, outer_env, locals))); + } + + OuterEnv outer_env; + mutable Locals locals; + }; + + template <typename Base, typename Vars, typename Map> + struct lambda_actor + { + typedef typename + mpl::fold< + Vars + , mpl::false_ + , detail::compute_no_nullary + >::type + no_nullary; + + template <typename Env> + struct result + { + typedef typename + fusion::result_of::as_vector< + typename fusion::result_of::transform< + Vars + , detail::initialize_local<Env> + >::type + >::type + locals_type; + + typedef actor<lambda_eval<Base, Env, locals_type, Map> > type; + }; + + lambda_actor(Base const& f, Vars const& vars) + : f(f), vars(vars) {} + + template <typename Env> + typename result<Env>::type + eval(Env const& env) const + { + typedef typename result<Env>::type result_type; + + return result_type( + f, env, fusion::as_vector( + fusion::transform( + vars + , detail::initialize_local<Env>(env) + ))); + } + + Base f; + Vars vars; + }; + + template <typename Vars, typename Map> + struct lambda_actor_gen + { + template <typename Base> + actor<lambda_actor<Base, Vars, Map> > const + operator[](actor<Base> const& f) const + { + return lambda_actor<Base, Vars, Map>(f, vars); + } + + lambda_actor_gen(Vars const& vars) + : vars(vars) {} + + Vars vars; + }; + + template <typename Key> + struct local_variable; // forward + struct assign_eval; // forward + + struct lambda_gen + : lambda_actor_gen< + fusion::vector<> + , detail::map_local_index_to_tuple<> > + { + typedef + lambda_actor_gen< + fusion::vector<> + , detail::map_local_index_to_tuple<> > + base_type; + + lambda_gen() + : base_type(fusion::vector<>()) + { + } + + template <typename K0, typename V0> + lambda_actor_gen< + fusion::vector<V0> + , detail::map_local_index_to_tuple<K0> + > + operator()( + actor<composite<assign_eval, fusion::vector<local_variable<K0>, V0> > > const& a0 + ) const + { + return fusion::vector<V0>(fusion::at_c<1>(a0)); + } + + template <typename K0, typename K1, typename V0, typename V1> + lambda_actor_gen< + fusion::vector<V0, V1> + , detail::map_local_index_to_tuple<K0, K1> + > + operator()( + actor<composite<assign_eval, fusion::vector<local_variable<K0>, V0> > > const& a0 + , actor<composite<assign_eval, fusion::vector<local_variable<K1>, V1> > > const& a1 + ) const + { + return fusion::vector<V0, V1>(fusion::at_c<1>(a0), fusion::at_c<1>(a1)); + } + + // Bring in the rest... + #define PHOENIX_LOCAL_GEN_NAME lambda_actor_gen + #include <boost/spirit/home/phoenix/scope/detail/local_gen.hpp> + #undef PHOENIX_LOCAL_GEN_NAME + }; + + lambda_gen const lambda = lambda_gen(); +}} + +#endif diff --git a/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/let.hpp b/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/let.hpp new file mode 100644 index 0000000..40e951a --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/let.hpp @@ -0,0 +1,145 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2004 Daniel Wallin + + 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_LET_HPP +#define PHOENIX_SCOPE_LET_HPP + +#include <boost/spirit/home/phoenix/core/limits.hpp> +#include <boost/spirit/home/phoenix/core/composite.hpp> +#include <boost/spirit/home/phoenix/scope/scoped_environment.hpp> +#include <boost/spirit/home/phoenix/scope/detail/local_variable.hpp> +#include <boost/spirit/home/phoenix/detail/local_reference.hpp> +#include <boost/spirit/home/phoenix/core/actor.hpp> +#include <boost/fusion/include/transform.hpp> +#include <boost/fusion/include/as_vector.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/bool.hpp> + +namespace boost { namespace phoenix +{ + template <typename Base, typename Vars, typename Map> + struct let_actor : Base + { + typedef typename + mpl::fold< + Vars + , mpl::false_ + , detail::compute_no_nullary + >::type + no_nullary; + + template <typename Env> + struct result + { + typedef typename + fusion::result_of::as_vector< + typename fusion::result_of::transform< + Vars + , detail::initialize_local<Env> + >::type + >::type + locals_type; + + typedef typename Base::template + result<scoped_environment<Env, Env, locals_type, Map> >::type + result_type; + + typedef typename + detail::unwrap_local_reference<result_type>::type + type; + }; + + let_actor(Base const& base, Vars const& vars) + : Base(base), vars(vars) {} + + template <typename Env> + typename result<Env>::type + eval(Env const& env) const + { + typedef typename + fusion::result_of::as_vector< + typename fusion::result_of::transform< + Vars + , detail::initialize_local<Env> + >::type + >::type + locals_type; + + locals_type locals = + fusion::as_vector( + fusion::transform( + vars + , detail::initialize_local<Env>(env))); + + typedef typename result<Env>::type RT; + return RT(Base::eval( + scoped_environment<Env, Env, locals_type, Map>( + env + , env + , locals))); + } + + Vars vars; + }; + + template <typename Vars, typename Map> + struct let_actor_gen + { + template <typename Base> + actor<let_actor<Base, Vars, Map> > const + operator[](actor<Base> const& base) const + { + return let_actor<Base, Vars, Map>(base, vars); + } + + let_actor_gen(Vars const& vars) + : vars(vars) {} + + Vars vars; + }; + + template <typename Key> + struct local_variable; // forward + struct assign_eval; // forward + + struct let_gen + { + template <typename K0, typename V0> + let_actor_gen< + fusion::vector<V0> + , detail::map_local_index_to_tuple<K0> + > + operator()( + actor<composite<assign_eval, fusion::vector<local_variable<K0>, V0> > > const& a0 + ) const + { + return fusion::vector<V0>(fusion::at_c<1>(a0)); + } + + template <typename K0, typename K1, typename V0, typename V1> + let_actor_gen< + fusion::vector<V0, V1> + , detail::map_local_index_to_tuple<K0, K1> + > + operator()( + actor<composite<assign_eval, fusion::vector<local_variable<K0>, V0> > > const& a0 + , actor<composite<assign_eval, fusion::vector<local_variable<K1>, V1> > > const& a1 + ) const + { + return fusion::vector<V0, V1>(fusion::at_c<1>(a0), fusion::at_c<1>(a1)); + } + + // Bring in the rest... + #define PHOENIX_LOCAL_GEN_NAME let_actor_gen + #include <boost/spirit/home/phoenix/scope/detail/local_gen.hpp> + #undef PHOENIX_LOCAL_GEN_NAME + }; + + let_gen const let = let_gen(); +}} + +#endif diff --git a/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/local_variable.hpp b/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/local_variable.hpp new file mode 100644 index 0000000..5987ed4 --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/local_variable.hpp @@ -0,0 +1,111 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2004 Daniel Wallin + + 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_VARIABLE_HPP +#define PHOENIX_SCOPE_LOCAL_VARIABLE_HPP + +#include <boost/spirit/home/phoenix/core/limits.hpp> +#include <boost/spirit/home/phoenix/detail/local_reference.hpp> +#include <boost/spirit/home/phoenix/scope/detail/local_variable.hpp> +#include <boost/spirit/home/phoenix/core/actor.hpp> +#include <boost/mpl/bool.hpp> + +namespace boost { namespace phoenix +{ + template <typename Key> + struct local_variable + { + typedef Key key_type; + + // This will prevent actor::operator()() from kicking in. + // Actually, we do not need all actor::operator()s for + // all arities, but this will suffice. The nullary + // actor::operator() is particularly troublesome because + // it is always eagerly evaluated by the compiler. + typedef mpl::true_ no_nullary; + + template <typename Env> + struct result : detail::apply_local<local_variable<Key>, Env> {}; + + template <typename Env> + typename result<Env>::type + eval(Env const& env) const + { + typedef typename result<Env>::type return_type; + typedef typename + detail::get_index<typename Env::map_type, Key>::type + index_type; + typedef detail::eval_local<Key> eval_local; + + return eval_local::template get<return_type>( + env + , index_type()); + } + + private: + // silence MSVC warning C4512: assignment operator could not be generated + local_variable& operator= (local_variable const&); + }; + + namespace local_names + { + actor<local_variable<struct _a_key> > const _a + = local_variable<struct _a_key>(); + actor<local_variable<struct _b_key> > const _b + = local_variable<struct _b_key>(); + actor<local_variable<struct _c_key> > const _c + = local_variable<struct _c_key>(); + actor<local_variable<struct _d_key> > const _d + = local_variable<struct _d_key>(); + actor<local_variable<struct _e_key> > const _e + = local_variable<struct _e_key>(); + actor<local_variable<struct _f_key> > const _f + = local_variable<struct _f_key>(); + actor<local_variable<struct _g_key> > const _g + = local_variable<struct _g_key>(); + actor<local_variable<struct _h_key> > const _h + = local_variable<struct _h_key>(); + actor<local_variable<struct _i_key> > const _i + = local_variable<struct _i_key>(); + actor<local_variable<struct _j_key> > const _j + = local_variable<struct _j_key>(); + actor<local_variable<struct _k_key> > const _k + = local_variable<struct _k_key>(); + actor<local_variable<struct _l_key> > const _l + = local_variable<struct _l_key>(); + actor<local_variable<struct _m_key> > const _m + = local_variable<struct _m_key>(); + actor<local_variable<struct _n_key> > const _n + = local_variable<struct _n_key>(); + actor<local_variable<struct _o_key> > const _o + = local_variable<struct _o_key>(); + actor<local_variable<struct _p_key> > const _p + = local_variable<struct _p_key>(); + actor<local_variable<struct _q_key> > const _q + = local_variable<struct _q_key>(); + actor<local_variable<struct _r_key> > const _r + = local_variable<struct _r_key>(); + actor<local_variable<struct _s_key> > const _s + = local_variable<struct _s_key>(); + actor<local_variable<struct _t_key> > const _t + = local_variable<struct _t_key>(); + actor<local_variable<struct _u_key> > const _u + = local_variable<struct _u_key>(); + actor<local_variable<struct _v_key> > const _v + = local_variable<struct _v_key>(); + actor<local_variable<struct _w_key> > const _w + = local_variable<struct _w_key>(); + actor<local_variable<struct _x_key> > const _x + = local_variable<struct _x_key>(); + actor<local_variable<struct _y_key> > const _y + = local_variable<struct _y_key>(); + actor<local_variable<struct _z_key> > const _z + = local_variable<struct _z_key>(); + } +}} + +#endif diff --git a/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/scoped_environment.hpp b/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/scoped_environment.hpp new file mode 100644 index 0000000..b23f9ee --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/phoenix/scope/scoped_environment.hpp @@ -0,0 +1,47 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2004 Daniel Wallin + + 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_SCOPED_ENVIRONMENT_HPP +#define PHOENIX_SCOPE_SCOPED_ENVIRONMENT_HPP + +namespace boost { namespace phoenix +{ + template <typename Env, typename OuterEnv, typename Locals, typename Map> + struct scoped_environment + { + typedef Env env_type; + typedef OuterEnv outer_env_type; + typedef Locals locals_type; + typedef Map map_type; + typedef typename Env::args_type args_type; + typedef typename Env::tie_type tie_type; + + scoped_environment( + Env const& env + , OuterEnv const& outer_env + , Locals& locals) + : env(env) + , outer_env(outer_env) + , locals(locals) {} + + tie_type const& + args() const + { + return env.args(); + } + + Env const& env; + OuterEnv const& outer_env; + Locals& locals; + + private: + // silence MSVC warning C4512: assignment operator could not be generated + scoped_environment& operator= (scoped_environment const&); + }; +}} + +#endif |