forked from boostorg/fusion
Moved BOOST_FUSION_ADAPT_STRUCT implementation details to detail/adapt_base.hpp
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2007 Joel de Guzman
|
||||
Copyright (c) 2009-2011 Christopher Schmidt
|
||||
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)
|
||||
@ -17,8 +18,6 @@
|
||||
#include <boost/preprocessor/seq/push_front.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/empty.hpp>
|
||||
#include <boost/preprocessor/control/if.hpp>
|
||||
#include <boost/preprocessor/facilities/is_empty.hpp>
|
||||
#include <boost/preprocessor/comparison/equal.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
@ -37,49 +36,6 @@
|
||||
#include <boost/fusion/adapted/struct/detail/end_impl.hpp>
|
||||
#include <boost/fusion/adapted/struct/detail/value_of_impl.hpp>
|
||||
#include <boost/fusion/adapted/struct/detail/deref_impl.hpp>
|
||||
#include <boost/fusion/adapted/struct/detail/preprocessor/is_seq.hpp>
|
||||
|
||||
#if BOOST_PP_VARIADICS
|
||||
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_CREATE_MEMBER_TUPLE(...) \
|
||||
BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), 2), \
|
||||
BOOST_PP_IF(BOOST_PP_IS_EMPTY(BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__)), \
|
||||
((1, (BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__)) )), \
|
||||
((2, BOOST_PP_VARIADIC_TO_TUPLE(__VA_ARGS__))) \
|
||||
), \
|
||||
((1, (BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__)) )) \
|
||||
)
|
||||
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_0(...) \
|
||||
BOOST_FUSION_ADAPT_STRUCT_CREATE_MEMBER_TUPLE(__VA_ARGS__) \
|
||||
BOOST_FUSION_ADAPT_STRUCT_FILLER_1
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_1(...) \
|
||||
BOOST_FUSION_ADAPT_STRUCT_CREATE_MEMBER_TUPLE(__VA_ARGS__) \
|
||||
BOOST_FUSION_ADAPT_STRUCT_FILLER_0
|
||||
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_0_END
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_1_END
|
||||
|
||||
#else // BOOST_PP_VARIADICS
|
||||
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_CREATE_MEMBER_TUPLE(X, Y) \
|
||||
BOOST_PP_IF(BOOST_PP_IS_EMPTY(X), \
|
||||
((1, (Y))), \
|
||||
((2, (X,Y))) \
|
||||
)
|
||||
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_0(X, Y) \
|
||||
BOOST_FUSION_ADAPT_STRUCT_CREATE_MEMBER_TUPLE(X,Y) \
|
||||
BOOST_FUSION_ADAPT_STRUCT_FILLER_1
|
||||
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_1(X, Y) \
|
||||
BOOST_FUSION_ADAPT_STRUCT_CREATE_MEMBER_TUPLE(X,Y) \
|
||||
BOOST_FUSION_ADAPT_STRUCT_FILLER_0
|
||||
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_0_END
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_1_END
|
||||
|
||||
#endif // BOOST_PP_VARIADICS
|
||||
|
||||
#define BOOST_FUSION_ADAPT_AUTO BOOST_PP_EMPTY()
|
||||
|
||||
@ -105,34 +61,26 @@
|
||||
|
||||
#if BOOST_PP_VARIADICS
|
||||
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_PROCESS_PARAM(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_CREATE_MEMBER_TUPLE(elem) \
|
||||
)
|
||||
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_CREATE_MEMBER_TUPLE_FROM_VARIADICS(...) \
|
||||
BOOST_PP_SEQ_PUSH_FRONT( \
|
||||
BOOST_PP_SEQ_FOR_EACH(BOOST_FUSION_ADAPT_STRUCT_PROCESS_PARAM, unused, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)), (0,0))
|
||||
|
||||
#define BOOST_FUSION_ADAPT_STRUCT(NAME, ...) \
|
||||
# define BOOST_FUSION_ADAPT_STRUCT(NAME, ...) \
|
||||
BOOST_FUSION_ADAPT_STRUCT_BASE( \
|
||||
(0), \
|
||||
(0)(NAME), \
|
||||
struct_tag, \
|
||||
0, \
|
||||
BOOST_FUSION_ADAPT_STRUCT_CREATE_MEMBER_TUPLE_FROM_VARIADICS(__VA_ARGS__), \
|
||||
BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER(__VA_ARGS__), \
|
||||
BOOST_FUSION_ADAPT_STRUCT_C)
|
||||
|
||||
#else // BOOST_PP_VARIADICS
|
||||
|
||||
#define BOOST_FUSION_ADAPT_STRUCT(NAME, ATTRIBUTES) \
|
||||
# define BOOST_FUSION_ADAPT_STRUCT(NAME, ATTRIBUTES) \
|
||||
BOOST_FUSION_ADAPT_STRUCT_BASE( \
|
||||
(0), \
|
||||
(0)(NAME), \
|
||||
struct_tag, \
|
||||
0, \
|
||||
BOOST_PP_CAT( BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES,_END), \
|
||||
BOOST_PP_CAT( \
|
||||
BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES, \
|
||||
_END), \
|
||||
BOOST_FUSION_ADAPT_STRUCT_C)
|
||||
|
||||
#endif // BOOST_PP_VARIADICS
|
||||
|
@ -1,56 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2007 Joel de Guzman
|
||||
Copyright (c) 2009-2011 Christopher Schmidt
|
||||
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_AUTO_ADAPT_STRUCT_HPP
|
||||
#define BOOST_FUSION_ADAPTED_STRUCT_AUTO_ADAPT_STRUCT_HPP
|
||||
|
||||
#include <boost/preprocessor/seq/for_each.hpp>
|
||||
#include <boost/preprocessor/seq/pop_front.hpp>
|
||||
#include <boost/preprocessor/variadic/elem.hpp>
|
||||
#include <boost/preprocessor/variadic/to_seq.hpp>
|
||||
|
||||
#include <boost/typeof/typeof.hpp>
|
||||
|
||||
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
|
||||
|
||||
#define BOOST_FUSION_AUTO_ADAPT_STRUCT_TYPE_DEDUCER(r, NAME, ATTRIBUTE) \
|
||||
(BOOST_TYPEOF(NAME::ATTRIBUTE), ATTRIBUTE)
|
||||
|
||||
#define BOOST_FUSION_AUTO_ADAPT_STRUCT(...) \
|
||||
BOOST_FUSION_AUTO_ADAPT_STRUCT_BASE( \
|
||||
BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__), \
|
||||
BOOST_PP_SEQ_POP_FRONT(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)))
|
||||
|
||||
#define BOOST_FUSION_AUTO_ADAPT_STRUCT_BASE(NAME, ATTRIBUTES) \
|
||||
BOOST_FUSION_ADAPT_STRUCT(NAME, \
|
||||
BOOST_PP_SEQ_FOR_EACH( \
|
||||
BOOST_FUSION_AUTO_ADAPT_STRUCT_TYPE_DEDUCER, NAME, ATTRIBUTES) \
|
||||
)
|
||||
|
||||
|
||||
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_0(X, Y) \
|
||||
((X, Y)) BOOST_FUSION_ADAPT_STRUCT_FILLER_1
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_1(X, Y) \
|
||||
((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(NAME, ATTRIBUTES) \
|
||||
BOOST_FUSION_ADAPT_STRUCT_BASE( \
|
||||
(0), \
|
||||
(0)(NAME), \
|
||||
struct_tag, \
|
||||
0, \
|
||||
BOOST_PP_CAT(BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES,_END), \
|
||||
BOOST_FUSION_ADAPT_STRUCT_C)
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -2,6 +2,7 @@
|
||||
Copyright (c) 2001-2009 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
Copyright (c) 2009-2011 Christopher Schmidt
|
||||
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)
|
||||
@ -13,6 +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/preprocessor/empty.hpp>
|
||||
#include <boost/preprocessor/stringize.hpp>
|
||||
@ -25,6 +27,7 @@
|
||||
#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>
|
||||
@ -33,7 +36,6 @@
|
||||
|
||||
#include <boost/typeof/typeof.hpp>
|
||||
|
||||
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME_TEMPLATE_PARAMS(SEQ) \
|
||||
BOOST_PP_SEQ_HEAD(SEQ)<BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_TAIL(SEQ))> \
|
||||
BOOST_PP_EMPTY()
|
||||
@ -183,24 +185,54 @@
|
||||
} \
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Creates a Random Access Sequence for the struct/class named NAME_SEQ
|
||||
* \param TEMPLATE_PARAMS_SEQ
|
||||
* \param NAME_SEQ Sequence of a boolean telling if the type is a template type
|
||||
* or not, followed by the name of the type to be adapted.
|
||||
*
|
||||
* That is (0)(mystruct) means adaptation of mystruct a
|
||||
* non-template type. While (1)(my_tpl_struct) means adaptation
|
||||
* of a template based struct.
|
||||
* \param TAG The tag of the Random Access Sequence, this enables to select the
|
||||
* implementation of the sequence.
|
||||
* \param IS_VIEW Whether if this creates a sequence of a view from a sequence
|
||||
* \param ATTRIBUTES_SEQ Sequence of struct attributes to add to the list of
|
||||
* adapted elements
|
||||
* \param ATTRIBUTES_CALLBACK Macro callback used to register the attributes into
|
||||
* the sequence. Usually a call to
|
||||
* BOOST_FUSION_ADAPT_STRUCT_C_BASE.
|
||||
*/
|
||||
#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
|
||||
|
||||
#if BOOST_PP_VARIADICS
|
||||
|
||||
# define BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTE_FILLER(...) \
|
||||
BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), 2), \
|
||||
BOOST_PP_IF( \
|
||||
BOOST_PP_IS_EMPTY(BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__)), \
|
||||
((1, (BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__)) )), \
|
||||
((2, BOOST_PP_VARIADIC_TO_TUPLE(__VA_ARGS__)))), \
|
||||
((1, (BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__)) )))
|
||||
|
||||
# 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(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) \
|
||||
)
|
||||
|
||||
#else // BOOST_PP_VARIADICS
|
||||
|
||||
# define BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTE_FILLER(X, Y) \
|
||||
BOOST_PP_IF(BOOST_PP_IS_EMPTY(X), \
|
||||
((1, (Y))), \
|
||||
((2, (X,Y))) \
|
||||
)
|
||||
|
||||
|
||||
|
||||
#endif // BOOST_PP_VARIADICS
|
||||
|
||||
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_BASE( \
|
||||
TEMPLATE_PARAMS_SEQ, \
|
||||
NAME_SEQ, \
|
||||
|
Reference in New Issue
Block a user