annotate DEPENDENCIES/generic/include/boost/phoenix/scope/dynamic.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*==============================================================================
Chris@16 2 Copyright (c) 2001-2010 Joel de Guzman
Chris@16 3 Copyright (c) 2004 Daniel Wallin
Chris@16 4 Copyright (c) 2010 Thomas Heller
Chris@16 5
Chris@16 6 Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8 ==============================================================================*/
Chris@16 9 #ifndef BOOST_PHOENIX_SCOPE_DYNAMIC_HPP
Chris@16 10 #define BOOST_PHOENIX_SCOPE_DYNAMIC_HPP
Chris@16 11
Chris@16 12 #include <boost/phoenix/core/limits.hpp>
Chris@16 13 #include <boost/assert.hpp>
Chris@16 14 #include <boost/noncopyable.hpp>
Chris@16 15 #include <boost/fusion/sequence/intrinsic/at.hpp>
Chris@16 16 #include <boost/phoenix/core/expression.hpp>
Chris@16 17 #include <boost/phoenix/core/meta_grammar.hpp>
Chris@16 18 #include <boost/phoenix/core/call.hpp>
Chris@16 19 #include <boost/phoenix/support/iterate.hpp>
Chris@16 20 #include <boost/preprocessor/seq/for_each.hpp>
Chris@16 21 #include <boost/preprocessor/seq/fold_left.hpp>
Chris@16 22 #include <boost/preprocessor/punctuation/comma.hpp>
Chris@16 23 #include <boost/type_traits/remove_pointer.hpp>
Chris@16 24
Chris@16 25 #define BOOST_PHOENIX_DYNAMIC_TEMPLATE_PARAMS(R, DATA, I, ELEM) \
Chris@16 26 BOOST_PP_COMMA_IF(I) BOOST_PP_TUPLE_ELEM(2, 0, ELEM) \
Chris@16 27 /**/
Chris@16 28
Chris@16 29 #define BOOST_PHOENIX_DYNAMIC_CTOR_INIT(R, DATA, I, ELEM) \
Chris@16 30 BOOST_PP_COMMA_IF(I) BOOST_PP_TUPLE_ELEM(2, 1, ELEM)(init<I>(this)) \
Chris@16 31 /**/
Chris@16 32
Chris@16 33 #define BOOST_PHOENIX_DYNAMIC_MEMBER(R, DATA, I, ELEM) \
Chris@16 34 BOOST_PP_CAT(member, BOOST_PP_INC(I)) BOOST_PP_TUPLE_ELEM(2, 1, ELEM); \
Chris@16 35 /**/
Chris@16 36
Chris@16 37 #define BOOST_PHOENIX_DYNAMIC_FILLER_0(X, Y) \
Chris@16 38 ((X, Y)) BOOST_PHOENIX_DYNAMIC_FILLER_1 \
Chris@16 39 /**/
Chris@16 40
Chris@16 41 #define BOOST_PHOENIX_DYNAMIC_FILLER_1(X, Y) \
Chris@16 42 ((X, Y)) BOOST_PHOENIX_DYNAMIC_FILLER_0 \
Chris@16 43 /**/
Chris@16 44
Chris@16 45 #define BOOST_PHOENIX_DYNAMIC_FILLER_0_END
Chris@16 46 #define BOOST_PHOENIX_DYNAMIC_FILLER_1_END
Chris@16 47
Chris@16 48 #define BOOST_PHOENIX_DYNAMIC_BASE(NAME, MEMBER) \
Chris@16 49 struct NAME \
Chris@16 50 : ::boost::phoenix::dynamic< \
Chris@16 51 BOOST_PP_SEQ_FOR_EACH_I( \
Chris@16 52 BOOST_PHOENIX_DYNAMIC_TEMPLATE_PARAMS \
Chris@16 53 , _ \
Chris@16 54 , MEMBER) \
Chris@16 55 > \
Chris@16 56 { \
Chris@16 57 NAME() \
Chris@16 58 : BOOST_PP_SEQ_FOR_EACH_I(BOOST_PHOENIX_DYNAMIC_CTOR_INIT, _, MEMBER) \
Chris@16 59 {} \
Chris@16 60 \
Chris@16 61 BOOST_PP_SEQ_FOR_EACH_I(BOOST_PHOENIX_DYNAMIC_MEMBER, _, MEMBER) \
Chris@16 62 } \
Chris@16 63 /**/
Chris@16 64
Chris@16 65 #define BOOST_PHOENIX_DYNAMIC(NAME, MEMBER) \
Chris@16 66 BOOST_PHOENIX_DYNAMIC_BASE( \
Chris@16 67 NAME \
Chris@16 68 , BOOST_PP_CAT(BOOST_PHOENIX_DYNAMIC_FILLER_0 MEMBER,_END) \
Chris@16 69 ) \
Chris@16 70 /**/
Chris@16 71
Chris@16 72 BOOST_PHOENIX_DEFINE_EXPRESSION(
Chris@16 73 (boost)(phoenix)(dynamic_member)
Chris@16 74 , (proto::terminal<proto::_>)
Chris@16 75 (proto::terminal<proto::_>)
Chris@16 76 )
Chris@16 77
Chris@16 78 namespace boost { namespace phoenix
Chris@16 79 {
Chris@16 80 template <typename DynamicScope>
Chris@16 81 struct dynamic_frame : noncopyable
Chris@16 82 {
Chris@16 83 typedef typename DynamicScope::tuple_type tuple_type;
Chris@16 84
Chris@16 85 dynamic_frame(DynamicScope const& s)
Chris@16 86 : tuple()
Chris@16 87 , save(s.frame)
Chris@16 88 , scope(s)
Chris@16 89 {
Chris@16 90 scope.frame = this;
Chris@16 91 }
Chris@16 92
Chris@16 93 template <typename Tuple>
Chris@16 94 dynamic_frame(DynamicScope const& s, Tuple const& init)
Chris@16 95 : tuple(init)
Chris@16 96 , save(s.frame)
Chris@16 97 , scope(s)
Chris@16 98 {
Chris@16 99 scope.frame = this;
Chris@16 100 }
Chris@16 101
Chris@16 102 ~dynamic_frame()
Chris@16 103 {
Chris@16 104 scope.frame = save;
Chris@16 105 }
Chris@16 106
Chris@16 107 tuple_type& data() { return tuple; }
Chris@16 108 tuple_type const& data() const { return tuple; }
Chris@16 109
Chris@16 110 private:
Chris@16 111 tuple_type tuple;
Chris@16 112 dynamic_frame *save;
Chris@16 113 DynamicScope const& scope;
Chris@16 114 };
Chris@16 115
Chris@16 116 struct dynamic_member_eval
Chris@16 117 {
Chris@16 118 template <typename Sig>
Chris@16 119 struct result;
Chris@16 120
Chris@16 121 template <typename This, typename N, typename Scope, typename Context>
Chris@16 122 struct result<This(N, Scope, Context)>
Chris@16 123 {
Chris@16 124 typedef
Chris@16 125 typename boost::remove_pointer<
Chris@16 126 typename proto::detail::uncvref<
Chris@16 127 typename proto::result_of::value<Scope>::type
Chris@16 128 >::type
Chris@16 129 >::type
Chris@16 130 scope_type;
Chris@16 131 typedef
Chris@16 132 typename scope_type::dynamic_frame_type::tuple_type
Chris@16 133 tuple_type;
Chris@16 134
Chris@16 135 typedef
Chris@16 136 typename fusion::result_of::at_c<
Chris@16 137 tuple_type
Chris@16 138 , proto::detail::uncvref<
Chris@16 139 typename proto::result_of::value<N>::type
Chris@16 140 >::type::value
Chris@16 141 >::type
Chris@16 142 type;
Chris@16 143
Chris@16 144 };
Chris@16 145
Chris@16 146 template <typename N, typename Scope, typename Context>
Chris@16 147 typename result<dynamic_member_eval(N, Scope, Context)>::type
Chris@16 148 operator()(N, Scope s, Context const &) const
Chris@16 149 {
Chris@16 150 return
Chris@16 151 fusion::at_c<
Chris@16 152 proto::detail::uncvref<
Chris@16 153 typename proto::result_of::value<N>::type
Chris@16 154 >::type::value
Chris@16 155 >(
Chris@16 156 proto::value(s)->frame->data()
Chris@16 157 );
Chris@16 158 }
Chris@16 159 };
Chris@16 160
Chris@16 161 template <typename Dummy>
Chris@16 162 struct default_actions::when<rule::dynamic_member, Dummy>
Chris@16 163 : call<dynamic_member_eval>
Chris@16 164 {};
Chris@16 165
Chris@16 166 template <
Chris@16 167 BOOST_PHOENIX_typename_A_void(BOOST_PHOENIX_DYNAMIC_LIMIT)
Chris@16 168 , typename Dummy = void
Chris@16 169 >
Chris@16 170 struct dynamic;
Chris@16 171
Chris@16 172 // Bring in the rest ...
Chris@16 173 #include <boost/phoenix/scope/detail/dynamic.hpp>
Chris@16 174 }}
Chris@16 175
Chris@16 176 #endif