]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*============================================================================= |
2 | Copyright (c) 2013-2014 Damien Buhl | |
3 | ||
4 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
5 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 | ==============================================================================*/ | |
7 | ||
8 | #ifndef BOOST_FUSION_ADAPTED_ADT_DETAIL_ADAPT_BASE_ATTR_FILLER_HPP | |
9 | #define BOOST_FUSION_ADAPTED_ADT_DETAIL_ADAPT_BASE_ATTR_FILLER_HPP | |
10 | ||
11 | #include <boost/config.hpp> | |
12 | ||
13 | #include <boost/fusion/adapted/struct/detail/adapt_auto.hpp> | |
14 | #include <boost/fusion/adapted/struct/detail/preprocessor/is_seq.hpp> | |
15 | ||
16 | #include <boost/mpl/aux_/preprocessor/token_equal.hpp> | |
17 | ||
18 | #include <boost/preprocessor/arithmetic/dec.hpp> | |
19 | #include <boost/preprocessor/control/iif.hpp> | |
20 | #include <boost/preprocessor/logical/or.hpp> | |
21 | #include <boost/preprocessor/tuple/elem.hpp> | |
22 | #include <boost/preprocessor/variadic/to_seq.hpp> | |
23 | #include <boost/preprocessor/variadic/size.hpp> | |
24 | #include <boost/preprocessor/variadic/elem.hpp> | |
25 | #include <boost/preprocessor/seq/seq.hpp> | |
26 | #include <boost/preprocessor/seq/rest_n.hpp> | |
27 | ||
28 | ||
29 | #define BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR_SIZE(ATTRIBUTE) \ | |
30 | BOOST_PP_TUPLE_ELEM(2, 0, ATTRIBUTE) | |
31 | ||
32 | #define BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR(ATTRIBUTE) \ | |
33 | BOOST_PP_TUPLE_ELEM(2, 1, ATTRIBUTE) | |
34 | ||
35 | #if BOOST_PP_VARIADICS | |
36 | ||
37 | # define BOOST_FUSION_ADAPT_ADT_FILLER_0(...) \ | |
38 | BOOST_FUSION_ADAPT_ADT_FILLER(__VA_ARGS__) \ | |
39 | BOOST_FUSION_ADAPT_ADT_FILLER_1 | |
40 | ||
41 | # define BOOST_FUSION_ADAPT_ADT_FILLER_1(...) \ | |
42 | BOOST_FUSION_ADAPT_ADT_FILLER(__VA_ARGS__) \ | |
43 | BOOST_FUSION_ADAPT_ADT_FILLER_0 | |
44 | ||
45 | # define BOOST_FUSION_ADAPT_ADT_FILLER_0_END | |
46 | # define BOOST_FUSION_ADAPT_ADT_FILLER_1_END | |
47 | ||
48 | // MSVC don't compile when using BOOST_PP_BITOR instead of BOOST_PP_OR. | |
49 | # define BOOST_FUSION_ADAPT_ADT_FILLER(...) \ | |
50 | BOOST_PP_IIF( \ | |
51 | BOOST_PP_OR( \ | |
52 | BOOST_MPL_PP_TOKEN_EQUAL(auto, \ | |
53 | BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__)), \ | |
54 | BOOST_MPL_PP_TOKEN_EQUAL(auto, \ | |
55 | BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__))), \ | |
56 | \ | |
57 | BOOST_FUSION_ADAPT_ADT_WRAP_ATTR( \ | |
58 | BOOST_PP_VARIADIC_ELEM(2, __VA_ARGS__), \ | |
59 | BOOST_FUSION_WORKAROUND_VARIADIC_EMPTINESS_LAST_ELEM(__VA_ARGS__) \ | |
60 | ), \ | |
61 | BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(__VA_ARGS__)) | |
62 | ||
63 | # define BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(...) \ | |
64 | ((BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__))) | |
65 | ||
66 | # define BOOST_FUSION_WORKAROUND_VARIADIC_EMPTINESS_LAST_ELEM(...) \ | |
67 | BOOST_PP_SEQ_HEAD(BOOST_PP_SEQ_REST_N( \ | |
68 | BOOST_PP_DEC(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__)), \ | |
69 | BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__))) | |
70 | ||
71 | #else // BOOST_PP_VARIADICS | |
72 | ||
73 | # define BOOST_FUSION_ADAPT_ADT_FILLER_0(A, B, C, D) \ | |
74 | BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(A,B,C,D) \ | |
75 | BOOST_FUSION_ADAPT_ADT_FILLER_1 | |
76 | ||
77 | # define BOOST_FUSION_ADAPT_ADT_FILLER_1(A, B, C, D) \ | |
78 | BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(A,B,C,D) \ | |
79 | BOOST_FUSION_ADAPT_ADT_FILLER_0 | |
80 | ||
81 | # define BOOST_FUSION_ADAPT_ADT_FILLER_0_END | |
82 | # define BOOST_FUSION_ADAPT_ADT_FILLER_1_END | |
83 | ||
84 | # define BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(A, B, C, D) \ | |
85 | BOOST_PP_IIF(BOOST_MPL_PP_TOKEN_EQUAL(auto, A), \ | |
86 | ((2, (C,D))), \ | |
87 | ((4, (A,B,C,D))) \ | |
88 | ) | |
89 | ||
90 | #endif // BOOST_PP_VARIADICS | |
91 | ||
92 | #endif |