ATLAS Offline Software
Loading...
Searching...
No Matches
MacroHelpers.h File Reference

Contains some helpful macros to help with repetitive code... More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CRGPU_EMPTY()
#define CRGPU_DEFER(...)
 Helper macro, defers macro expansion to the next level of evaluation to allow recursive macros.
#define CRGPU_IGNORE(...)
 Helper macro, takes the arguments and expands to nothing.
#define CRGPU_CONCAT(X, Y)
 Helper macro, concatenates two arguments.
#define CRGPU_CONCAT_HELPER(X, ...)
 Helper macro for concatenation.
#define CRGPU_STRINGIFY(X)
 Helper macro, stringifies the argument.
#define CRGPU_STRINGIFY_HELPER(...)
 Helper macro for concatenation.
#define CRGPU_GET_FIRST(X, ...)
 Helper macro, returns the first argument.
#define CRGPU_GET_SECOND(X, ...)
 Helper macro, returns the second argument.
#define CRGPU_TEST_CRGPU_END   ,1
 Definitions to check for list end.
#define CRGPU_TEST_   ,1
 Definitions to allow an empty argument to also be used as a terminator.
#define CRGPU_CHECK_FOR_END(X)
 Check for CRGPU_END (or an empty argument) to terminate list.
#define CRGPU_CHECK_FOR_END_CHECK(...)
 Implementation of checking for CRGPU_END (or an empty argument) to terminate list.
#define CRGPU_RECURSIVE_MACRO(...)
 Expands recursive macros.
#define CR_GPU_MACRO_RECURSE1(...)
 Helper macro to expand recursive macros (recursion level 1).
#define CR_GPU_MACRO_RECURSE2(...)
 Helper macro to expand recursive macros (recursion level 2).
#define CR_GPU_MACRO_RECURSE3(...)
 Helper macro to expand recursive macros (recursion level 3).
#define CR_GPU_MACRO_RECURSE4(...)
 Helper macro to expand recursive macros (recursion level 4).
#define CR_GPU_MACRO_RECURSE_BASE(...)
 Helper macro to expand recursive macros (last recursion level: simply expands the macro).
#define CRGPU_MACRO_EXPANSION(MACRO, EXTRA_ARG, ...)
 Helper macro to apply a macro to all elements of the variadic list, with EXTRA_ARG and the parenthesised rest of the arguments being passed as arguments to the macro too.
#define CRGPU_MACRO_EXPANSION_IMPL(MACRO, EXTRA_ARG, ONE, NEXT, ...)
#define CRGPU_MACRO_EXPANSION_IMPL_0   CRGPU_MACRO_EXPANSION_IMPL_DO
 Helper macro to defer macro expansion to enable recursion.
#define CRGPU_MACRO_EXPANSION_IMPL_DO()
 Helper macro to defer macro expansion to enable recursion.
#define CRGPU_MACRO_EXPANSION_IMPL_1   CRGPU_MACRO_EXPANSION_IMPL_DONT
 Helper macro to defer macro expansion to enable recursion.
#define CRGPU_MACRO_EXPANSION_IMPL_DONT()
 Helper macro to defer macro expansion to enable recursion.
#define CRGPU_MACRO_INSTANTIATION_IMPL_0   CRGPU_MACRO_INSTANTIATION_DO
 Helper macro to defer macro expansion to enable recursion.
#define CRGPU_MACRO_INSTANTIATION_IMPL_1   CRGPU_MACRO_INSTANTIATION_DONT
 Helper macro to defer macro expansion to enable recursion.
#define CRGPU_MACRO_INSTANTIATION_DO(...)
 Helper macro to defer macro expansion to enable recursion.
#define CRGPU_MACRO_INSTANTIATION_DONT(...)
 Helper macro to defer macro expansion to enable recursion.
#define CRGPU_STRING_TO_ENUM_OP(TYPE, VAR_PREFIX_PAIR, IGNORE)
 Base macro to be applied to every element for converting strings to enums.
#define CRGPU_CHEAP_STRING_TO_ENUM(VAR, PREFIX, ONE, ...)
 Checks a string variable, VAR, for matching enum identifiers (ONE and the remaining variadic arguments), for the enum starting with PREFIX.

Detailed Description

Contains some helpful macros to help with repetitive code...

Definition in file MacroHelpers.h.

Macro Definition Documentation

◆ CR_GPU_MACRO_RECURSE1

#define CR_GPU_MACRO_RECURSE1 ( ...)
Value:
#define CR_GPU_MACRO_RECURSE2(...)
Helper macro to expand recursive macros (recursion level 2).

Helper macro to expand recursive macros (recursion level 1).

Definition at line 74 of file MacroHelpers.h.

◆ CR_GPU_MACRO_RECURSE2

#define CR_GPU_MACRO_RECURSE2 ( ...)
Value:
#define CR_GPU_MACRO_RECURSE3(...)
Helper macro to expand recursive macros (recursion level 3).

Helper macro to expand recursive macros (recursion level 2).

Definition at line 78 of file MacroHelpers.h.

◆ CR_GPU_MACRO_RECURSE3

#define CR_GPU_MACRO_RECURSE3 ( ...)
Value:
#define CR_GPU_MACRO_RECURSE4(...)
Helper macro to expand recursive macros (recursion level 4).

Helper macro to expand recursive macros (recursion level 3).

Definition at line 82 of file MacroHelpers.h.

◆ CR_GPU_MACRO_RECURSE4

#define CR_GPU_MACRO_RECURSE4 ( ...)
Value:
#define CR_GPU_MACRO_RECURSE_BASE(...)
Helper macro to expand recursive macros (last recursion level: simply expands the macro).

Helper macro to expand recursive macros (recursion level 4).

Definition at line 86 of file MacroHelpers.h.

◆ CR_GPU_MACRO_RECURSE_BASE

#define CR_GPU_MACRO_RECURSE_BASE ( ...)
Value:
__VA_ARGS__

Helper macro to expand recursive macros (last recursion level: simply expands the macro).

Definition at line 90 of file MacroHelpers.h.

◆ CRGPU_CHEAP_STRING_TO_ENUM

#define CRGPU_CHEAP_STRING_TO_ENUM ( VAR,
PREFIX,
ONE,
... )
Value:
if (false) { return PREFIX::ONE; } CRGPU_MACRO_EXPANSION(CRGPU_STRING_TO_ENUM_OP, (VAR, PREFIX), ONE, __VA_ARGS__)
#define CRGPU_MACRO_EXPANSION(MACRO, EXTRA_ARG,...)
Helper macro to apply a macro to all elements of the variadic list, with EXTRA_ARG and the parenthesi...
#define CRGPU_STRING_TO_ENUM_OP(TYPE, VAR_PREFIX_PAIR, IGNORE)
Base macro to be applied to every element for converting strings to enums.
static const string PREFIX

Checks a string variable, VAR, for matching enum identifiers (ONE and the remaining variadic arguments), for the enum starting with PREFIX.

Warning
Should be wrapped in CRGPU_RECURSIVE_MACRO to work properly.

Definition at line 148 of file MacroHelpers.h.

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__)

◆ CRGPU_CHECK_FOR_END

#define CRGPU_CHECK_FOR_END ( X)
Value:
#define CRGPU_TEST_
Definitions to allow an empty argument to also be used as a terminator.
#define CRGPU_CHECK_FOR_END_CHECK(...)
Implementation of checking for CRGPU_END (or an empty argument) to terminate list.

Check for CRGPU_END (or an empty argument) to terminate list.

Definition at line 62 of file MacroHelpers.h.

◆ CRGPU_CHECK_FOR_END_CHECK

#define CRGPU_CHECK_FOR_END_CHECK ( ...)
Value:
CRGPU_GET_SECOND(__VA_ARGS__,)
#define CRGPU_GET_SECOND(X,...)
Helper macro, returns the second argument.

Implementation of checking for CRGPU_END (or an empty argument) to terminate list.

Definition at line 66 of file MacroHelpers.h.

◆ CRGPU_CONCAT

#define CRGPU_CONCAT ( X,
Y )
Value:
#define CRGPU_CONCAT_HELPER(X,...)
Helper macro for concatenation.

Helper macro, concatenates two arguments.

Definition at line 29 of file MacroHelpers.h.

◆ CRGPU_CONCAT_HELPER

#define CRGPU_CONCAT_HELPER ( X,
... )
Value:
X ## __VA_ARGS__

Helper macro for concatenation.

Definition at line 33 of file MacroHelpers.h.

◆ CRGPU_DEFER

#define CRGPU_DEFER ( ...)
Value:
__VA_ARGS__ CRGPU_EMPTY()
#define CRGPU_EMPTY()

Helper macro, defers macro expansion to the next level of evaluation to allow recursive macros.

Definition at line 20 of file MacroHelpers.h.

◆ CRGPU_EMPTY

#define CRGPU_EMPTY ( )

Definition at line 16 of file MacroHelpers.h.

◆ CRGPU_GET_FIRST

#define CRGPU_GET_FIRST ( X,
... )
Value:
X

Helper macro, returns the first argument.

Definition at line 47 of file MacroHelpers.h.

◆ CRGPU_GET_SECOND

#define CRGPU_GET_SECOND ( X,
... )
Value:
CRGPU_GET_FIRST(__VA_ARGS__, X)
#define CRGPU_GET_FIRST(X,...)
Helper macro, returns the first argument.

Helper macro, returns the second argument.

Definition at line 51 of file MacroHelpers.h.

◆ CRGPU_IGNORE

#define CRGPU_IGNORE ( ...)

Helper macro, takes the arguments and expands to nothing.

Definition at line 25 of file MacroHelpers.h.

◆ CRGPU_MACRO_EXPANSION

#define CRGPU_MACRO_EXPANSION ( MACRO,
EXTRA_ARG,
... )
Value:
CRGPU_MACRO_EXPANSION_IMPL(MACRO, EXTRA_ARG, __VA_ARGS__, CRGPU_END, CRGPU_END)
#define CRGPU_MACRO_EXPANSION_IMPL(MACRO, EXTRA_ARG, ONE, NEXT,...)

Helper macro to apply a macro to all elements of the variadic list, with EXTRA_ARG and the parenthesised rest of the arguments being passed as arguments to the macro too.

Definition at line 96 of file MacroHelpers.h.

96#define CRGPU_MACRO_EXPANSION(MACRO, EXTRA_ARG, ... ) \
97 CRGPU_MACRO_EXPANSION_IMPL(MACRO, EXTRA_ARG, __VA_ARGS__, CRGPU_END, CRGPU_END)

◆ CRGPU_MACRO_EXPANSION_IMPL

#define CRGPU_MACRO_EXPANSION_IMPL ( MACRO,
EXTRA_ARG,
ONE,
NEXT,
... )
Value:
CRGPU_DEFER(CRGPU_CONCAT(CRGPU_MACRO_INSTANTIATION_IMPL_, CRGPU_CHECK_FOR_END(ONE))) (MACRO) (ONE, EXTRA_ARG, (NEXT, __VA_ARGS__) ) \
CRGPU_DEFER(CRGPU_CONCAT(CRGPU_MACRO_EXPANSION_IMPL_, CRGPU_CHECK_FOR_END(NEXT))) () (MACRO, EXTRA_ARG, NEXT, __VA_ARGS__ )
#define CRGPU_DEFER(...)
Helper macro, defers macro expansion to the next level of evaluation to allow recursive macros.
#define CRGPU_CONCAT(X, Y)
Helper macro, concatenates two arguments.
#define CRGPU_CHECK_FOR_END(X)
Check for CRGPU_END (or an empty argument) to terminate list.

Definition at line 99 of file MacroHelpers.h.

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__ )

◆ CRGPU_MACRO_EXPANSION_IMPL_0

#define CRGPU_MACRO_EXPANSION_IMPL_0   CRGPU_MACRO_EXPANSION_IMPL_DO

Helper macro to defer macro expansion to enable recursion.

Definition at line 105 of file MacroHelpers.h.

◆ CRGPU_MACRO_EXPANSION_IMPL_1

#define CRGPU_MACRO_EXPANSION_IMPL_1   CRGPU_MACRO_EXPANSION_IMPL_DONT

Helper macro to defer macro expansion to enable recursion.

Definition at line 113 of file MacroHelpers.h.

◆ CRGPU_MACRO_EXPANSION_IMPL_DO

#define CRGPU_MACRO_EXPANSION_IMPL_DO ( )
Value:

Helper macro to defer macro expansion to enable recursion.

Definition at line 109 of file MacroHelpers.h.

◆ CRGPU_MACRO_EXPANSION_IMPL_DONT

#define CRGPU_MACRO_EXPANSION_IMPL_DONT ( )
Value:
#define CRGPU_IGNORE(...)
Helper macro, takes the arguments and expands to nothing.

Helper macro to defer macro expansion to enable recursion.

Definition at line 117 of file MacroHelpers.h.

◆ CRGPU_MACRO_INSTANTIATION_DO

#define CRGPU_MACRO_INSTANTIATION_DO ( ...)
Value:
__VA_ARGS__

Helper macro to defer macro expansion to enable recursion.

Definition at line 129 of file MacroHelpers.h.

◆ CRGPU_MACRO_INSTANTIATION_DONT

#define CRGPU_MACRO_INSTANTIATION_DONT ( ...)
Value:

Helper macro to defer macro expansion to enable recursion.

Definition at line 133 of file MacroHelpers.h.

◆ CRGPU_MACRO_INSTANTIATION_IMPL_0

#define CRGPU_MACRO_INSTANTIATION_IMPL_0   CRGPU_MACRO_INSTANTIATION_DO

Helper macro to defer macro expansion to enable recursion.

Definition at line 121 of file MacroHelpers.h.

◆ CRGPU_MACRO_INSTANTIATION_IMPL_1

#define CRGPU_MACRO_INSTANTIATION_IMPL_1   CRGPU_MACRO_INSTANTIATION_DONT

Helper macro to defer macro expansion to enable recursion.

Definition at line 125 of file MacroHelpers.h.

◆ CRGPU_RECURSIVE_MACRO

#define CRGPU_RECURSIVE_MACRO ( ...)
Value:
#define CR_GPU_MACRO_RECURSE1(...)
Helper macro to expand recursive macros (recursion level 1).

Expands recursive macros.

Wrap the recursive macro call in CRGPU_RECURSIVE_MACRO to make it work.

Definition at line 70 of file MacroHelpers.h.

◆ CRGPU_STRING_TO_ENUM_OP

#define CRGPU_STRING_TO_ENUM_OP ( TYPE,
VAR_PREFIX_PAIR,
IGNORE )
Value:
else if (CRGPU_GET_FIRST VAR_PREFIX_PAIR == CRGPU_STRINGIFY(TYPE)) \
{ return CRGPU_GET_SECOND VAR_PREFIX_PAIR::TYPE; }
#define CRGPU_STRINGIFY(X)
Helper macro, stringifies the argument.
#define TYPE(CODE, TYP, IOTYP)

Base macro to be applied to every element for converting strings to enums.

Definition at line 137 of file MacroHelpers.h.

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; }

◆ CRGPU_STRINGIFY

#define CRGPU_STRINGIFY ( X)
Value:
#define CRGPU_STRINGIFY_HELPER(...)
Helper macro for concatenation.

Helper macro, stringifies the argument.

Definition at line 38 of file MacroHelpers.h.

◆ CRGPU_STRINGIFY_HELPER

#define CRGPU_STRINGIFY_HELPER ( ...)
Value:
#__VA_ARGS__

Helper macro for concatenation.

Definition at line 42 of file MacroHelpers.h.

◆ CRGPU_TEST_

#define CRGPU_TEST_   ,1

Definitions to allow an empty argument to also be used as a terminator.

Definition at line 58 of file MacroHelpers.h.

◆ CRGPU_TEST_CRGPU_END

#define CRGPU_TEST_CRGPU_END   ,1

Definitions to check for list end.

Definition at line 55 of file MacroHelpers.h.