Factoring out of adapt_struct.hpp all the FILLER_* macros details.

As of BOOST_FUSION_ADAPT_STRUCT without type deduction, there were only
simple attributes filler. Now this need more complex logic to handle both
API: the backward compatible one with type specificiation, the one without
type specification and the non-variadic one which enables omitting the type
specification by providing BOOST_FUSION_ADAPT_AUTO instead of the type.

That's why I extracted the FILLER_* macros details in a separate source
file.
This commit is contained in:
Damien Buhl (alias daminetreg)
2014-06-11 00:13:14 +02:00
parent c851252f65
commit 687b2cf097
3 changed files with 59 additions and 45 deletions

View File

@ -12,10 +12,6 @@
#include <boost/fusion/support/config.hpp>
#include <boost/preprocessor/config/config.hpp>
#include <boost/preprocessor/variadic.hpp>
#include <boost/preprocessor/variadic/to_seq.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/preprocessor/seq/push_front.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/empty.hpp>
#include <boost/preprocessor/comparison/equal.hpp>
@ -37,8 +33,6 @@
#include <boost/fusion/adapted/struct/detail/value_of_impl.hpp>
#include <boost/fusion/adapted/struct/detail/deref_impl.hpp>
#define BOOST_FUSION_ADAPT_AUTO BOOST_PP_EMPTY()
#define BOOST_FUSION_ADAPT_STRUCT_C(TEMPLATE_PARAMS_SEQ, NAME_SEQ, I, ATTRIBUTE)\
BOOST_FUSION_ADAPT_STRUCT_C_BASE( \
TEMPLATE_PARAMS_SEQ, \
@ -59,6 +53,8 @@
BOOST_FUSION_ADAPT_STRUCT_C)
#define BOOST_FUSION_ADAPT_AUTO BOOST_PP_EMPTY()
#if BOOST_PP_VARIADICS
# define BOOST_FUSION_ADAPT_STRUCT(NAME, ...) \

View File

@ -14,7 +14,7 @@
#include <boost/fusion/support/config.hpp>
#include <boost/config.hpp>
#include <boost/fusion/support/tag_of_fwd.hpp>
#include <boost/fusion/adapted/struct/detail/preprocessor/is_seq.hpp>
#include <boost/fusion/adapted/struct/detail/adapt_base_attr_filler.hpp>
#include <boost/preprocessor/empty.hpp>
#include <boost/preprocessor/stringize.hpp>
@ -27,7 +27,6 @@
#include <boost/preprocessor/tuple/eat.hpp>
#include <boost/preprocessor/tuple/elem.hpp>
#include <boost/preprocessor/arithmetic/dec.hpp>
#include <boost/preprocessor/facilities/is_empty.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/tag.hpp>
#include <boost/mpl/eval_if.hpp>
@ -189,43 +188,6 @@
} \
};
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_0(X, Y) \
BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTE_FILLER(X,Y) \
BOOST_FUSION_ADAPT_STRUCT_FILLER_1
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_1(X, Y) \
BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTE_FILLER(X,Y) \
BOOST_FUSION_ADAPT_STRUCT_FILLER_0
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_0_END
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_1_END
#define BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTE_FILLER(X, Y) \
BOOST_PP_IF(BOOST_PP_IS_EMPTY(X), \
((1, (Y))), \
((2, (X,Y))) \
)
#if BOOST_PP_VARIADICS
# define BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER_OP(r, data, elem) \
BOOST_PP_IF(BOOST_FUSION_PP_IS_SEQ(elem), \
BOOST_PP_CAT( BOOST_FUSION_ADAPT_STRUCT_FILLER_0 elem ,_END), \
BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTE_FILLER(BOOST_FUSION_ADAPT_AUTO, \
elem) \
)
# define BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER(...) \
BOOST_PP_SEQ_PUSH_FRONT( \
BOOST_PP_SEQ_FOR_EACH( \
BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER_OP, \
unused, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)), \
(0,0) \
)
#endif // BOOST_PP_VARIADICS
#define BOOST_FUSION_ADAPT_STRUCT_BASE( \
TEMPLATE_PARAMS_SEQ, \
NAME_SEQ, \

View File

@ -0,0 +1,56 @@
/*=============================================================================
Copyright (c) 2013-2014 Damien Buhl
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 BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_BASE_ATTR_FILLER_HPP
#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_BASE_ATTR_FILLER_HPP
#include <boost/config.hpp>
#include <boost/fusion/adapted/struct/detail/preprocessor/is_seq.hpp>
#include <boost/preprocessor/empty.hpp>
#include <boost/preprocessor/facilities/is_empty.hpp>
#include <boost/preprocessor/variadic/to_seq.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/preprocessor/seq/push_front.hpp>
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_0(X, Y) \
BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTE_FILLER(X,Y) \
BOOST_FUSION_ADAPT_STRUCT_FILLER_1
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_1(X, Y) \
BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTE_FILLER(X,Y) \
BOOST_FUSION_ADAPT_STRUCT_FILLER_0
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_0_END
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_1_END
#define BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTE_FILLER(X, Y) \
BOOST_PP_IF(BOOST_PP_IS_EMPTY(X), \
((1, (Y))), \
((2, (X,Y))) \
)
#if BOOST_PP_VARIADICS
# define BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER_OP(r, data, elem) \
BOOST_PP_IF(BOOST_FUSION_PP_IS_SEQ(elem), \
BOOST_PP_CAT( BOOST_FUSION_ADAPT_STRUCT_FILLER_0 elem ,_END), \
BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTE_FILLER(BOOST_FUSION_ADAPT_AUTO, \
elem) \
)
# define BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER(...) \
BOOST_PP_SEQ_PUSH_FRONT( \
BOOST_PP_SEQ_FOR_EACH( \
BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER_OP, \
unused, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)), \
(0,0) \
)
#endif // BOOST_PP_VARIADICS
#endif