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) 2001-2007 Joel de Guzman
|
||||||
Copyright (c) 2009-2011 Christopher Schmidt
|
Copyright (c) 2009-2011 Christopher Schmidt
|
||||||
|
Copyright (c) 2013-2014 Damien Buhl
|
||||||
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
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)
|
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/seq/push_front.hpp>
|
||||||
#include <boost/preprocessor/cat.hpp>
|
#include <boost/preprocessor/cat.hpp>
|
||||||
#include <boost/preprocessor/empty.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/preprocessor/comparison/equal.hpp>
|
||||||
#include <boost/type_traits/add_reference.hpp>
|
#include <boost/type_traits/add_reference.hpp>
|
||||||
#include <boost/type_traits/is_const.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/end_impl.hpp>
|
||||||
#include <boost/fusion/adapted/struct/detail/value_of_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/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()
|
#define BOOST_FUSION_ADAPT_AUTO BOOST_PP_EMPTY()
|
||||||
|
|
||||||
@ -105,35 +61,27 @@
|
|||||||
|
|
||||||
#if BOOST_PP_VARIADICS
|
#if BOOST_PP_VARIADICS
|
||||||
|
|
||||||
#define BOOST_FUSION_ADAPT_STRUCT_PROCESS_PARAM(r, data, elem) \
|
# define BOOST_FUSION_ADAPT_STRUCT(NAME, ...) \
|
||||||
BOOST_PP_IF(BOOST_FUSION_PP_IS_SEQ(elem), \
|
BOOST_FUSION_ADAPT_STRUCT_BASE( \
|
||||||
BOOST_PP_CAT( BOOST_FUSION_ADAPT_STRUCT_FILLER_0 elem ,_END), \
|
(0), \
|
||||||
BOOST_FUSION_ADAPT_STRUCT_CREATE_MEMBER_TUPLE(elem) \
|
(0)(NAME), \
|
||||||
)
|
struct_tag, \
|
||||||
|
0, \
|
||||||
#define BOOST_FUSION_ADAPT_STRUCT_CREATE_MEMBER_TUPLE_FROM_VARIADICS(...) \
|
BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER(__VA_ARGS__), \
|
||||||
BOOST_PP_SEQ_PUSH_FRONT( \
|
BOOST_FUSION_ADAPT_STRUCT_C)
|
||||||
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, ...) \
|
|
||||||
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_C)
|
|
||||||
|
|
||||||
#else // BOOST_PP_VARIADICS
|
#else // BOOST_PP_VARIADICS
|
||||||
|
|
||||||
#define BOOST_FUSION_ADAPT_STRUCT(NAME, ATTRIBUTES) \
|
# define BOOST_FUSION_ADAPT_STRUCT(NAME, ATTRIBUTES) \
|
||||||
BOOST_FUSION_ADAPT_STRUCT_BASE( \
|
BOOST_FUSION_ADAPT_STRUCT_BASE( \
|
||||||
(0), \
|
(0), \
|
||||||
(0)(NAME), \
|
(0)(NAME), \
|
||||||
struct_tag, \
|
struct_tag, \
|
||||||
0, \
|
0, \
|
||||||
BOOST_PP_CAT( BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES,_END), \
|
BOOST_PP_CAT( \
|
||||||
BOOST_FUSION_ADAPT_STRUCT_C)
|
BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES, \
|
||||||
|
_END), \
|
||||||
|
BOOST_FUSION_ADAPT_STRUCT_C)
|
||||||
|
|
||||||
#endif // BOOST_PP_VARIADICS
|
#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) 2001-2009 Joel de Guzman
|
||||||
Copyright (c) 2005-2006 Dan Marsden
|
Copyright (c) 2005-2006 Dan Marsden
|
||||||
Copyright (c) 2009-2011 Christopher Schmidt
|
Copyright (c) 2009-2011 Christopher Schmidt
|
||||||
|
Copyright (c) 2013-2014 Damien Buhl
|
||||||
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
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)
|
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/fusion/support/config.hpp>
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/fusion/support/tag_of_fwd.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/empty.hpp>
|
||||||
#include <boost/preprocessor/stringize.hpp>
|
#include <boost/preprocessor/stringize.hpp>
|
||||||
@ -25,14 +27,14 @@
|
|||||||
#include <boost/preprocessor/tuple/eat.hpp>
|
#include <boost/preprocessor/tuple/eat.hpp>
|
||||||
#include <boost/preprocessor/tuple/elem.hpp>
|
#include <boost/preprocessor/tuple/elem.hpp>
|
||||||
#include <boost/preprocessor/arithmetic/dec.hpp>
|
#include <boost/preprocessor/arithmetic/dec.hpp>
|
||||||
|
#include <boost/preprocessor/facilities/is_empty.hpp>
|
||||||
#include <boost/mpl/bool.hpp>
|
#include <boost/mpl/bool.hpp>
|
||||||
#include <boost/mpl/tag.hpp>
|
#include <boost/mpl/tag.hpp>
|
||||||
#include <boost/mpl/eval_if.hpp>
|
#include <boost/mpl/eval_if.hpp>
|
||||||
#include <boost/mpl/identity.hpp>
|
#include <boost/mpl/identity.hpp>
|
||||||
#include <boost/type_traits/add_const.hpp>
|
#include <boost/type_traits/add_const.hpp>
|
||||||
|
|
||||||
#include <boost/typeof/typeof.hpp>
|
#include <boost/typeof/typeof.hpp>
|
||||||
|
|
||||||
|
|
||||||
#define BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME_TEMPLATE_PARAMS(SEQ) \
|
#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_SEQ_HEAD(SEQ)<BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_TAIL(SEQ))> \
|
||||||
@ -183,24 +185,54 @@
|
|||||||
} \
|
} \
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_0(X, Y) \
|
||||||
* \brief Creates a Random Access Sequence for the struct/class named NAME_SEQ
|
BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTE_FILLER(X,Y) \
|
||||||
* \param TEMPLATE_PARAMS_SEQ
|
BOOST_FUSION_ADAPT_STRUCT_FILLER_1
|
||||||
* \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.
|
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_1(X, Y) \
|
||||||
*
|
BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTE_FILLER(X,Y) \
|
||||||
* That is (0)(mystruct) means adaptation of mystruct a
|
BOOST_FUSION_ADAPT_STRUCT_FILLER_0
|
||||||
* non-template type. While (1)(my_tpl_struct) means adaptation
|
|
||||||
* of a template based struct.
|
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_0_END
|
||||||
* \param TAG The tag of the Random Access Sequence, this enables to select the
|
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_1_END
|
||||||
* implementation of the sequence.
|
|
||||||
* \param IS_VIEW Whether if this creates a sequence of a view from a sequence
|
#if BOOST_PP_VARIADICS
|
||||||
* \param ATTRIBUTES_SEQ Sequence of struct attributes to add to the list of
|
|
||||||
* adapted elements
|
# define BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTE_FILLER(...) \
|
||||||
* \param ATTRIBUTES_CALLBACK Macro callback used to register the attributes into
|
BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), 2), \
|
||||||
* the sequence. Usually a call to
|
BOOST_PP_IF( \
|
||||||
* BOOST_FUSION_ADAPT_STRUCT_C_BASE.
|
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( \
|
#define BOOST_FUSION_ADAPT_STRUCT_BASE( \
|
||||||
TEMPLATE_PARAMS_SEQ, \
|
TEMPLATE_PARAMS_SEQ, \
|
||||||
NAME_SEQ, \
|
NAME_SEQ, \
|
||||||
|
Reference in New Issue
Block a user