|
ATLAS Offline Software
|
Go to the documentation of this file.
9 #ifndef CALORECGPU_MACROHELPERS_H
10 #define CALORECGPU_MACROHELPERS_H
20 #define CRGPU_DEFER(...) __VA_ARGS__ CRGPU_EMPTY()
25 #define CRGPU_IGNORE(...)
29 #define CRGPU_CONCAT(X, Y) CRGPU_CONCAT_HELPER(X, Y)
33 #define CRGPU_CONCAT_HELPER(X,...) X ## __VA_ARGS__
38 #define CRGPU_STRINGIFY(X) CRGPU_STRINGIFY_HELPER(X)
42 #define CRGPU_STRINGIFY_HELPER(...) #__VA_ARGS__
47 #define CRGPU_GET_FIRST(X, ...) X
51 #define CRGPU_GET_SECOND(X, ...) CRGPU_GET_FIRST(__VA_ARGS__, X)
55 #define CRGPU_TEST_CRGPU_END ,1
58 #define CRGPU_TEST_ ,1
62 #define CRGPU_CHECK_FOR_END(X) CRGPU_CHECK_FOR_END_CHECK(CRGPU_TEST_ ## X, 0)
66 #define CRGPU_CHECK_FOR_END_CHECK(...) CRGPU_GET_SECOND(__VA_ARGS__,)
70 #define CRGPU_RECURSIVE_MACRO(...) CR_GPU_MACRO_RECURSE1(CR_GPU_MACRO_RECURSE1(CR_GPU_MACRO_RECURSE1(CR_GPU_MACRO_RECURSE1(__VA_ARGS__))))
74 #define CR_GPU_MACRO_RECURSE1(...) CR_GPU_MACRO_RECURSE2(CR_GPU_MACRO_RECURSE2(CR_GPU_MACRO_RECURSE2(CR_GPU_MACRO_RECURSE2(__VA_ARGS__))))
78 #define CR_GPU_MACRO_RECURSE2(...) CR_GPU_MACRO_RECURSE3(CR_GPU_MACRO_RECURSE3(CR_GPU_MACRO_RECURSE3(CR_GPU_MACRO_RECURSE3(__VA_ARGS__))))
82 #define CR_GPU_MACRO_RECURSE3(...) CR_GPU_MACRO_RECURSE4(CR_GPU_MACRO_RECURSE4(CR_GPU_MACRO_RECURSE4(CR_GPU_MACRO_RECURSE4(__VA_ARGS__))))
86 #define CR_GPU_MACRO_RECURSE4(...) CR_GPU_MACRO_RECURSE_BASE(CR_GPU_MACRO_RECURSE_BASE(CR_GPU_MACRO_RECURSE_BASE(CR_GPU_MACRO_RECURSE_BASE(__VA_ARGS__))))
90 #define CR_GPU_MACRO_RECURSE_BASE(...) __VA_ARGS__
96 #define CRGPU_MACRO_EXPANSION(MACRO, EXTRA_ARG, ... ) \
97 CRGPU_MACRO_EXPANSION_IMPL(MACRO, EXTRA_ARG, __VA_ARGS__, CRGPU_END, CRGPU_END)
99 #define CRGPU_MACRO_EXPANSION_IMPL(MACRO, EXTRA_ARG, ONE, NEXT, ... ) \
100 CRGPU_DEFER(CRGPU_CONCAT(CRGPU_MACRO_INSTANTIATION_IMPL_, CRGPU_CHECK_FOR_END(ONE))) (MACRO) (ONE, EXTRA_ARG, (NEXT, __VA_ARGS__) ) \
101 CRGPU_DEFER(CRGPU_CONCAT(CRGPU_MACRO_EXPANSION_IMPL_, CRGPU_CHECK_FOR_END(NEXT))) () (MACRO, EXTRA_ARG, NEXT, __VA_ARGS__ )
105 #define CRGPU_MACRO_EXPANSION_IMPL_0 CRGPU_MACRO_EXPANSION_IMPL_DO
109 #define CRGPU_MACRO_EXPANSION_IMPL_DO() CRGPU_MACRO_EXPANSION_IMPL
113 #define CRGPU_MACRO_EXPANSION_IMPL_1 CRGPU_MACRO_EXPANSION_IMPL_DONT
117 #define CRGPU_MACRO_EXPANSION_IMPL_DONT() CRGPU_IGNORE
121 #define CRGPU_MACRO_INSTANTIATION_IMPL_0 CRGPU_MACRO_INSTANTIATION_DO
125 #define CRGPU_MACRO_INSTANTIATION_IMPL_1 CRGPU_MACRO_INSTANTIATION_DONT
129 #define CRGPU_MACRO_INSTANTIATION_DO(...) __VA_ARGS__
133 #define CRGPU_MACRO_INSTANTIATION_DONT(...) CRGPU_IGNORE
137 #define CRGPU_STRING_TO_ENUM_OP(TYPE, VAR_PREFIX_PAIR, IGNORE) \
138 else if (CRGPU_GET_FIRST VAR_PREFIX_PAIR == CRGPU_STRINGIFY(TYPE)) \
139 { return CRGPU_GET_SECOND VAR_PREFIX_PAIR::TYPE; }
148 #define CRGPU_CHEAP_STRING_TO_ENUM(VAR, PREFIX, ONE, ...) \
149 if (false) { return PREFIX::ONE; } CRGPU_MACRO_EXPANSION(CRGPU_STRING_TO_ENUM_OP, (VAR, PREFIX), ONE, __VA_ARGS__)
162 #endif //CALORECGPU_MACROHELPERS_H