Chris@16: /*============================================================================== Chris@16: Copyright (c) 2005-2010 Joel de Guzman Chris@16: Copyright (c) 2010-2011 Thomas Heller Chris@16: Chris@16: Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: ==============================================================================*/ Chris@16: #ifndef BOOST_PHOENIX_SCOPE_LOCAL_VARIABLE_HPP Chris@16: #define BOOST_PHOENIX_SCOPE_LOCAL_VARIABLE_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace phoenix Chris@16: { Chris@16: namespace detail Chris@16: { Chris@16: } Chris@16: Chris@16: namespace expression Chris@16: { Chris@16: template Chris@16: struct local_variable Chris@16: : expression::terminal > Chris@16: { Chris@16: typedef typename expression::terminal >::type type; Chris@16: Chris@16: static type make() Chris@16: { Chris@16: type const e = {}; Chris@16: return e; Chris@16: } Chris@16: }; Chris@16: } Chris@16: Chris@16: namespace rule Chris@16: { Chris@16: struct local_variable Chris@16: : expression::local_variable Chris@16: {}; Chris@16: Chris@16: struct local_var_def Chris@16: : proto::assign Chris@16: {}; Chris@16: } Chris@16: Chris@16: namespace result_of Chris@16: { Chris@16: template Chris@16: struct is_nullary > > Chris@16: : mpl::false_ Chris@16: {}; Chris@16: } Chris@101: Chris@16: namespace detail Chris@16: { Chris@16: struct scope_is_nullary_actions Chris@16: { Chris@16: template Chris@16: struct when Chris@16: : boost::phoenix::is_nullary::when Chris@16: {}; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct scope_is_nullary_actions::when Chris@16: : proto::or_< Chris@16: proto::when Chris@16: , proto::otherwise< Chris@16: is_nullary::when Chris@16: > Chris@16: > Chris@16: {}; Chris@16: Chris@16: struct local_var_not_found Chris@16: { Chris@16: }; Chris@16: } Chris@16: Chris@16: template Chris@16: struct is_custom_terminal > Chris@16: : mpl::true_ Chris@16: {}; Chris@16: Chris@101: template Chris@101: struct custom_terminal > Chris@16: { Chris@16: template Chris@16: struct result; Chris@16: Chris@16: template Chris@16: struct result Chris@16: : result Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct result Chris@16: { Chris@16: typedef Chris@16: typename remove_reference< Chris@16: typename result_of::env::type Chris@16: >::type Chris@16: env_type; Chris@16: Chris@16: typedef typename detail::apply_local, env_type>::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: typename result::type Chris@16: operator()(Local, Context const & ctx) Chris@16: { Chris@16: typedef Chris@16: typename remove_reference< Chris@16: typename result_of::env::type Chris@16: >::type Chris@16: env_type; Chris@16: Chris@16: typedef typename detail::apply_local, env_type>::type return_type; Chris@16: Chris@16: static const int index_value = detail::get_index >::value; Chris@16: Chris@16: typedef detail::eval_local eval_local; Chris@16: Chris@101: // Detect if the return_type is for a value. Chris@101: //typedef typename is_value::type is_value_type; Chris@101: Chris@16: return eval_local::template get( Chris@16: phoenix::env(ctx)); Chris@16: } Chris@16: }; Chris@16: Chris@16: namespace local_names Chris@16: { Chris@16: typedef expression::local_variable::type _a_type; Chris@16: typedef expression::local_variable::type _b_type; Chris@16: typedef expression::local_variable::type _c_type; Chris@16: typedef expression::local_variable::type _d_type; Chris@16: typedef expression::local_variable::type _e_type; Chris@16: typedef expression::local_variable::type _f_type; Chris@16: typedef expression::local_variable::type _g_type; Chris@16: typedef expression::local_variable::type _h_type; Chris@16: typedef expression::local_variable::type _i_type; Chris@16: typedef expression::local_variable::type _j_type; Chris@16: typedef expression::local_variable::type _k_type; Chris@16: typedef expression::local_variable::type _l_type; Chris@16: typedef expression::local_variable::type _m_type; Chris@16: typedef expression::local_variable::type _n_type; Chris@16: typedef expression::local_variable::type _o_type; Chris@16: typedef expression::local_variable::type _p_type; Chris@16: typedef expression::local_variable::type _q_type; Chris@16: typedef expression::local_variable::type _r_type; Chris@16: typedef expression::local_variable::type _s_type; Chris@16: typedef expression::local_variable::type _t_type; Chris@16: typedef expression::local_variable::type _u_type; Chris@16: typedef expression::local_variable::type _v_type; Chris@16: typedef expression::local_variable::type _w_type; Chris@16: typedef expression::local_variable::type _x_type; Chris@16: typedef expression::local_variable::type _y_type; Chris@16: typedef expression::local_variable::type _z_type; Chris@16: Chris@16: #ifndef BOOST_PHOENIX_NO_PREDEFINED_TERMINALS Chris@16: _a_type const _a = {{{}}}; Chris@16: _b_type const _b = {{{}}}; Chris@16: _c_type const _c = {{{}}}; Chris@16: _d_type const _d = {{{}}}; Chris@16: _e_type const _e = {{{}}}; Chris@16: _f_type const _f = {{{}}}; Chris@16: _g_type const _g = {{{}}}; Chris@16: _h_type const _h = {{{}}}; Chris@16: _i_type const _i = {{{}}}; Chris@16: _j_type const _j = {{{}}}; Chris@16: _k_type const _k = {{{}}}; Chris@16: _l_type const _l = {{{}}}; Chris@16: _m_type const _m = {{{}}}; Chris@16: _n_type const _n = {{{}}}; Chris@16: _o_type const _o = {{{}}}; Chris@16: _p_type const _p = {{{}}}; Chris@16: _q_type const _q = {{{}}}; Chris@16: _r_type const _r = {{{}}}; Chris@16: _s_type const _s = {{{}}}; Chris@16: _t_type const _t = {{{}}}; Chris@16: _u_type const _u = {{{}}}; Chris@16: _v_type const _v = {{{}}}; Chris@16: _w_type const _w = {{{}}}; Chris@16: _x_type const _x = {{{}}}; Chris@16: _y_type const _y = {{{}}}; Chris@16: _z_type const _z = {{{}}}; Chris@16: #endif Chris@16: } Chris@16: }} Chris@16: Chris@16: #endif