adapt_base_attr_filler.hpp 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*=============================================================================
  2. Copyright (c) 2013-2014 Damien Buhl
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #ifndef BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_BASE_ATTR_FILLER_HPP
  7. #define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_BASE_ATTR_FILLER_HPP
  8. #include <boost/config.hpp>
  9. #include <boost/fusion/adapted/struct/detail/adapt_auto.hpp>
  10. #include <boost/fusion/adapted/struct/detail/preprocessor/is_seq.hpp>
  11. #include <boost/mpl/aux_/preprocessor/token_equal.hpp>
  12. #include <boost/preprocessor/config/config.hpp>
  13. #include <boost/preprocessor/control/iif.hpp>
  14. #include <boost/preprocessor/control/expr_iif.hpp>
  15. #include <boost/preprocessor/logical/compl.hpp>
  16. #include <boost/preprocessor/tuple/elem.hpp>
  17. #include <boost/preprocessor/seq/for_each.hpp>
  18. #include <boost/preprocessor/seq/push_front.hpp>
  19. #include <boost/preprocessor/facilities/expand.hpp>
  20. #include <boost/preprocessor/facilities/is_empty.hpp>
  21. #define BOOST_FUSION_ADAPT_STRUCT_FILLER_0(X, Y) \
  22. BOOST_FUSION_ADAPT_STRUCT_WRAP_ATTR(X,Y) \
  23. BOOST_FUSION_ADAPT_STRUCT_FILLER_1
  24. #define BOOST_FUSION_ADAPT_STRUCT_FILLER_1(X, Y) \
  25. BOOST_FUSION_ADAPT_STRUCT_WRAP_ATTR(X,Y) \
  26. BOOST_FUSION_ADAPT_STRUCT_FILLER_0
  27. #define BOOST_FUSION_ADAPT_STRUCT_FILLER_0_END
  28. #define BOOST_FUSION_ADAPT_STRUCT_FILLER_1_END
  29. #define BOOST_FUSION_ADAPT_STRUCT_WRAP_ATTR(X, Y) \
  30. BOOST_PP_IIF(BOOST_MPL_PP_TOKEN_EQUAL(auto, BOOST_PP_EXPAND(X)), \
  31. ((1, (Y))), \
  32. ((2, (X,Y))) \
  33. )
  34. #define BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE) \
  35. BOOST_PP_TUPLE_ELEM(2, 0, ATTRIBUTE)
  36. #define BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR(ATTRIBUTE) \
  37. BOOST_PP_TUPLE_ELEM(2, 1, ATTRIBUTE)
  38. #if BOOST_PP_VARIADICS
  39. # define BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER_OP(r, unused, elem) \
  40. BOOST_PP_IIF(BOOST_FUSION_PP_IS_SEQ(elem), \
  41. BOOST_PP_CAT(BOOST_FUSION_ADAPT_STRUCT_FILLER_0 elem ,_END), \
  42. BOOST_PP_EXPR_IIF(BOOST_PP_COMPL(BOOST_PP_IS_EMPTY(elem)), \
  43. BOOST_FUSION_ADAPT_STRUCT_WRAP_ATTR(auto, elem)))
  44. # define BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER(VA_ARGS_SEQ) \
  45. BOOST_PP_SEQ_PUSH_FRONT( \
  46. BOOST_PP_SEQ_FOR_EACH( \
  47. BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER_OP, \
  48. unused, VA_ARGS_SEQ), \
  49. (0,0))
  50. #endif // BOOST_PP_VARIADICS
  51. #endif