mirror of
https://github.com/boostorg/contract.git
synced 2026-01-26 06:22:42 +00:00
cleaning up before parsing assertions
This commit is contained in:
@@ -22,7 +22,8 @@
|
||||
// Precondition: A macro named `cat_to_comma_prefix ## token-to-check` must be
|
||||
// #defined to expand to `,`.
|
||||
// Precondition: tokens must start with a token concatenable to a macro name
|
||||
// (e.g., a literal or integral token) or with parenthesis.
|
||||
// (e.g., a literal or integral token) or with parenthesis (i.e.,
|
||||
// leading parenthesis are allowed).
|
||||
#define BOOST_CONTRACT_EXT_PP_KEYWORD_UTILITY_IS_FRONT( \
|
||||
cat_to_comma_prefix, tokens) \
|
||||
BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_HAS_PAREN(tokens), \
|
||||
@@ -34,14 +35,12 @@
|
||||
// Precondition: A macro named `token-to-check ## cat_to_comma_postfix` must be
|
||||
// #defined to expand to `,`.
|
||||
// Precondition: tokens must end with a token concatenable to a macro name
|
||||
// (e.g., a literal or integral token) or with parenthesis.
|
||||
// (e.g., a literal or integral token) and trailing parenthesis
|
||||
// are NOT allowed.
|
||||
#define BOOST_CONTRACT_EXT_PP_KEYWORD_UTILITY_IS_BACK( \
|
||||
cat_to_comma_postfix, tokens) \
|
||||
BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_HAS_PAREN(tokens), \
|
||||
0 BOOST_PP_TUPLE_EAT(2) \
|
||||
, \
|
||||
BOOST_CONTRACT_EXT_PP_KEYWORD_UTILITY_IS_CHECK_ \
|
||||
)(tokens, cat_to_comma_postfix)
|
||||
BOOST_CONTRACT_EXT_PP_KEYWORD_UTILITY_IS_CHECK_( \
|
||||
tokens, cat_to_comma_postfix)
|
||||
|
||||
#endif // #include guard
|
||||
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
|
||||
/* PUBLIC */
|
||||
|
||||
// TODO: Is this /really/ needed? After all pp-traits are impl, try to remove
|
||||
// this and see if it's really needed.
|
||||
// TODO: Same thing for *any* use of BOOST_PP_EXPAND: make sure these are all
|
||||
// absolutely necessary!
|
||||
|
||||
// Expand its argument once
|
||||
// NOTE: `BOOST_PP_EXPAND` expands it twice instead:
|
||||
// EXPAND_ONCE(x) --> x (x expanded once)
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
|
||||
#ifndef BOOST_CONTRACT_EXT_PP_VARIADIC_ENUM_TO_SEQ_HPP_
|
||||
#define BOOST_CONTRACT_EXT_PP_VARIADIC_ENUM_TO_SEQ_HPP_
|
||||
|
||||
#include <boost/contract/ext_/preprocessor/utility/nil.hpp>
|
||||
#include <boost/preprocessor/variadic/to_seq.hpp>
|
||||
#include <boost/preprocessor/seq/pop_back.hpp>
|
||||
#include <boost/preprocessor/seq/elem.hpp>
|
||||
#include <boost/preprocessor/seq/size.hpp>
|
||||
#include <boost/preprocessor/tuple/eat.hpp>
|
||||
#include <boost/preprocessor/arithmetic/dec.hpp>
|
||||
#include <boost/preprocessor/logical/compl.hpp>
|
||||
#include <boost/preprocessor/control/iif.hpp>
|
||||
|
||||
/* PRIVATE */
|
||||
|
||||
// Wrapped with parenthesis after removal of NIL so to make it a pp-seq elem.
|
||||
#define BOOST_CONTRACT_EXT_PP_VARIADIC_ENUM_TO_SEQ_REMOVE_NIL_(back) \
|
||||
(BOOST_CONTRACT_EXT_PP_NIL_REMOVE_BACK(back))
|
||||
|
||||
#define BOOST_CONTRACT_EXT_PP_VARIADIC_ENUM_TO_SEQ_BACK_(seq, back) \
|
||||
BOOST_PP_SEQ_POP_BACK(seq) \
|
||||
BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_IS_NIL_FRONT(back), \
|
||||
BOOST_PP_TUPLE_EAT(1) \
|
||||
, \
|
||||
BOOST_CONTRACT_EXT_PP_VARIADIC_ENUM_TO_SEQ_REMOVE_NIL_ \
|
||||
)(back)
|
||||
|
||||
#define BOOST_CONTRACT_EXT_PP_VARIADIC_ENUM_TO_SEQ_(seq) \
|
||||
BOOST_CONTRACT_EXT_PP_VARIADIC_ENUM_TO_SEQ_BACK_(seq, \
|
||||
BOOST_PP_SEQ_ELEM(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(seq)), seq))
|
||||
|
||||
/* PUBLIC */
|
||||
|
||||
// Expand EMPTY() to EMPTY(), otherwise variadic to seq allowing for an
|
||||
// optional trailing comma (like with C++ enumerations):
|
||||
// `` to ``
|
||||
// `x, ..., y` to (x)...(y)
|
||||
// `x, ..., y,` to (x)...(y) (handle optional trailing comma `,`)
|
||||
// Implementation: Tokens must be front-concatenable and cannot be specified as
|
||||
// NIL (because they are internally for being NIL).
|
||||
#define BOOST_CONTRACT_EXT_PP_VARIADIC_ENUM_TO_SEQ(...) \
|
||||
BOOST_CONTRACT_EXT_PP_VARIADIC_ENUM_TO_SEQ_( \
|
||||
BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__ BOOST_PP_NIL))
|
||||
|
||||
#endif // #include guard
|
||||
|
||||
20
include/boost/contract/ext_/preprocessor/variadic/to_seq.hpp
Normal file
20
include/boost/contract/ext_/preprocessor/variadic/to_seq.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
#ifndef BOOST_CONTRACT_EXT_PP_VARIADIC_TO_SEQ_HPP_
|
||||
#define BOOST_CONTRACT_EXT_PP_VARIADIC_TO_SEQ_HPP_
|
||||
|
||||
#include <boost/contract/ext_/preprocessor/utility/empty.hpp>
|
||||
#include <boost/preprocessor/variadic/to_seq.hpp>
|
||||
#include <boost/preprocessor/control/iif.hpp>
|
||||
|
||||
/* PUBLIC */
|
||||
|
||||
// Expand EMPTY() to EMPTY(), otherwise expand variadic data to pp-seq.
|
||||
#define BOOST_CONTRACT_EXT_PP_VARIADIC_TO_SEQ(...) \
|
||||
BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_IS_EMPTY(__VA_ARGS__), \
|
||||
BOOST_PP_EMPTY \
|
||||
, \
|
||||
BOOST_PP_VARIADIC_TO_SEQ \
|
||||
)(__VA_ARGS__)
|
||||
|
||||
#endif // #include guard
|
||||
|
||||
Reference in New Issue
Block a user