/*============================================================================== 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 ACTIV_BOOST_PHOENIX_SCOPE_DYNAMIC_HPP #define ACTIV_BOOST_PHOENIX_SCOPE_DYNAMIC_HPP #include #include #include #include #include #include #include #include #include #include #include #include #define ACTIV_BOOST_PHOENIX_DYNAMIC_TEMPLATE_PARAMS(R, DATA, I, ELEM) \ ACTIV_BOOST_PP_COMMA_IF(I) ACTIV_BOOST_PP_TUPLE_ELEM(2, 0, ELEM) \ /**/ #define ACTIV_BOOST_PHOENIX_DYNAMIC_CTOR_INIT(R, DATA, I, ELEM) \ ACTIV_BOOST_PP_COMMA_IF(I) ACTIV_BOOST_PP_TUPLE_ELEM(2, 1, ELEM)(init(this)) \ /**/ #define ACTIV_BOOST_PHOENIX_DYNAMIC_MEMBER(R, DATA, I, ELEM) \ ACTIV_BOOST_PP_CAT(member, ACTIV_BOOST_PP_INC(I)) ACTIV_BOOST_PP_TUPLE_ELEM(2, 1, ELEM); \ /**/ #define ACTIV_BOOST_PHOENIX_DYNAMIC_FILLER_0(X, Y) \ ((X, Y)) ACTIV_BOOST_PHOENIX_DYNAMIC_FILLER_1 \ /**/ #define ACTIV_BOOST_PHOENIX_DYNAMIC_FILLER_1(X, Y) \ ((X, Y)) ACTIV_BOOST_PHOENIX_DYNAMIC_FILLER_0 \ /**/ #define ACTIV_BOOST_PHOENIX_DYNAMIC_FILLER_0_END #define ACTIV_BOOST_PHOENIX_DYNAMIC_FILLER_1_END #define ACTIV_BOOST_PHOENIX_DYNAMIC_BASE(NAME, MEMBER) \ struct NAME \ : ::Boost::phoenix::dynamic< \ ACTIV_BOOST_PP_SEQ_FOR_EACH_I( \ ACTIV_BOOST_PHOENIX_DYNAMIC_TEMPLATE_PARAMS \ , _ \ , MEMBER) \ > \ { \ NAME() \ : ACTIV_BOOST_PP_SEQ_FOR_EACH_I(ACTIV_BOOST_PHOENIX_DYNAMIC_CTOR_INIT, _, MEMBER) \ {} \ \ ACTIV_BOOST_PP_SEQ_FOR_EACH_I(ACTIV_BOOST_PHOENIX_DYNAMIC_MEMBER, _, MEMBER) \ } \ /**/ #define ACTIV_BOOST_PHOENIX_DYNAMIC(NAME, MEMBER) \ ACTIV_BOOST_PHOENIX_DYNAMIC_BASE( \ NAME \ , ACTIV_BOOST_PP_CAT(ACTIV_BOOST_PHOENIX_DYNAMIC_FILLER_0 MEMBER,_END) \ ) \ /**/ ACTIV_BOOST_PHOENIX_DEFINE_EXPRESSION( (Boost)(phoenix)(dynamic_member) , (proto::terminal) (proto::terminal) ) namespace Boost { namespace phoenix { template struct dynamic_frame : noncopyable { typedef typename DynamicScope::tuple_type tuple_type; dynamic_frame(DynamicScope const& s) : tuple() , save(s.frame) , scope(s) { scope.frame = this; } template dynamic_frame(DynamicScope const& s, Tuple const& init) : tuple(init) , save(s.frame) , scope(s) { 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; }; struct dynamic_member_eval { template struct result; template struct result { typedef typename Boost::remove_pointer< typename proto::detail::uncvref< typename proto::result_of::value::type >::type >::type scope_type; typedef typename scope_type::dynamic_frame_type::tuple_type tuple_type; typedef typename fusion::result_of::at_c< tuple_type , proto::detail::uncvref< typename proto::result_of::value::type >::type::value >::type type; }; template typename result::type operator()(N, Scope s, Context const &) const { return fusion::at_c< proto::detail::uncvref< typename proto::result_of::value::type >::type::value >( proto::value(s)->frame->data() ); } }; template struct default_actions::when : call {}; //#if defined(ACTIV_BOOST_PHOENIX_NO_VARIADIC_SCOPE) template < ACTIV_BOOST_PHOENIX_typename_A_void(ACTIV_BOOST_PHOENIX_DYNAMIC_LIMIT) , typename Dummy = void > struct dynamic; // Bring in the rest ... #include //#else // // TODO: //#endif }} #endif