ATLAS Offline Software
Macros
MacroHelpers.h File Reference
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(...)   __VA_ARGS__ CRGPU_EMPTY()
 Helper macro, defers macro expansion to the next level of evaluation to allow recursive macros. More...
 
#define CRGPU_IGNORE(...)
 Helper macro, takes the arguments and expands to nothing. More...
 
#define CRGPU_CONCAT(X, Y)   CRGPU_CONCAT_HELPER(X, Y)
 Helper macro, concatenates two arguments. More...
 
#define CRGPU_CONCAT_HELPER(X, ...)   X ## __VA_ARGS__
 Helper macro for concatenation. More...
 
#define CRGPU_STRINGIFY(X)   CRGPU_STRINGIFY_HELPER(X)
 Helper macro, stringifies the argument. More...
 
#define CRGPU_STRINGIFY_HELPER(...)   #__VA_ARGS__
 Helper macro for concatenation. More...
 
#define CRGPU_GET_FIRST(X, ...)   X
 Helper macro, returns the first argument. More...
 
#define CRGPU_GET_SECOND(X, ...)   CRGPU_GET_FIRST(__VA_ARGS__, X)
 Helper macro, returns the second argument. More...
 
#define CRGPU_TEST_CRGPU_END   ,1
 Definitions to check for list end. More...
 
#define CRGPU_TEST_   ,1
 Definitions to allow an empty argument to also be used as a terminator. More...
 
#define CRGPU_CHECK_FOR_END(X)   CRGPU_CHECK_FOR_END_CHECK(CRGPU_TEST_ ## X, 0)
 Check for CRGPU_END (or an empty argument) to terminate list. More...
 
#define CRGPU_CHECK_FOR_END_CHECK(...)   CRGPU_GET_SECOND(__VA_ARGS__,)
 Implementation of checking for CRGPU_END (or an empty argument) to terminate list. More...
 
#define CRGPU_RECURSIVE_MACRO(...)   CR_GPU_MACRO_RECURSE1(CR_GPU_MACRO_RECURSE1(CR_GPU_MACRO_RECURSE1(CR_GPU_MACRO_RECURSE1(__VA_ARGS__))))
 Expands recursive macros. More...
 
#define CR_GPU_MACRO_RECURSE1(...)   CR_GPU_MACRO_RECURSE2(CR_GPU_MACRO_RECURSE2(CR_GPU_MACRO_RECURSE2(CR_GPU_MACRO_RECURSE2(__VA_ARGS__))))
 Helper macro to expand recursive macros (recursion level 1). More...
 
#define CR_GPU_MACRO_RECURSE2(...)   CR_GPU_MACRO_RECURSE3(CR_GPU_MACRO_RECURSE3(CR_GPU_MACRO_RECURSE3(CR_GPU_MACRO_RECURSE3(__VA_ARGS__))))
 Helper macro to expand recursive macros (recursion level 2). More...
 
#define CR_GPU_MACRO_RECURSE3(...)   CR_GPU_MACRO_RECURSE4(CR_GPU_MACRO_RECURSE4(CR_GPU_MACRO_RECURSE4(CR_GPU_MACRO_RECURSE4(__VA_ARGS__))))
 Helper macro to expand recursive macros (recursion level 3). More...
 
#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__))))
 Helper macro to expand recursive macros (recursion level 4). More...
 
#define CR_GPU_MACRO_RECURSE_BASE(...)   __VA_ARGS__
 Helper macro to expand recursive macros (last recursion level: simply expands the macro). More...
 
#define CRGPU_MACRO_EXPANSION(MACRO, EXTRA_ARG, ...)   CRGPU_MACRO_EXPANSION_IMPL(MACRO, EXTRA_ARG, __VA_ARGS__, CRGPU_END, CRGPU_END)
 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. More...
 
#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. More...
 
#define CRGPU_MACRO_EXPANSION_IMPL_DO()   CRGPU_MACRO_EXPANSION_IMPL
 Helper macro to defer macro expansion to enable recursion. More...
 
#define CRGPU_MACRO_EXPANSION_IMPL_1   CRGPU_MACRO_EXPANSION_IMPL_DONT
 Helper macro to defer macro expansion to enable recursion. More...
 
#define CRGPU_MACRO_EXPANSION_IMPL_DONT()   CRGPU_IGNORE
 Helper macro to defer macro expansion to enable recursion. More...
 
#define CRGPU_MACRO_INSTANTIATION_IMPL_0   CRGPU_MACRO_INSTANTIATION_DO
 Helper macro to defer macro expansion to enable recursion. More...
 
#define CRGPU_MACRO_INSTANTIATION_IMPL_1   CRGPU_MACRO_INSTANTIATION_DONT
 Helper macro to defer macro expansion to enable recursion. More...
 
#define CRGPU_MACRO_INSTANTIATION_DO(...)   __VA_ARGS__
 Helper macro to defer macro expansion to enable recursion. More...
 
#define CRGPU_MACRO_INSTANTIATION_DONT(...)   CRGPU_IGNORE
 Helper macro to defer macro expansion to enable recursion. More...
 
#define CRGPU_STRING_TO_ENUM_OP(TYPE, VAR_PREFIX_PAIR, IGNORE)
 Base macro to be applied to every element for converting strings to enums. More...
 
#define CRGPU_CHEAP_STRING_TO_ENUM(VAR, PREFIX, ONE, ...)   if (false) { return PREFIX::ONE; } CRGPU_MACRO_EXPANSION(CRGPU_STRING_TO_ENUM_OP, (VAR, PREFIX), ONE, __VA_ARGS__)
 Checks a string variable, VAR, for matching enum identifiers (ONE and the remaining variadic arguments), for the enum starting with PREFIX. More...
 

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 (   ...)    CR_GPU_MACRO_RECURSE2(CR_GPU_MACRO_RECURSE2(CR_GPU_MACRO_RECURSE2(CR_GPU_MACRO_RECURSE2(__VA_ARGS__))))

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

Definition at line 75 of file MacroHelpers.h.

◆ CR_GPU_MACRO_RECURSE2

#define CR_GPU_MACRO_RECURSE2 (   ...)    CR_GPU_MACRO_RECURSE3(CR_GPU_MACRO_RECURSE3(CR_GPU_MACRO_RECURSE3(CR_GPU_MACRO_RECURSE3(__VA_ARGS__))))

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

Definition at line 79 of file MacroHelpers.h.

◆ CR_GPU_MACRO_RECURSE3

#define CR_GPU_MACRO_RECURSE3 (   ...)    CR_GPU_MACRO_RECURSE4(CR_GPU_MACRO_RECURSE4(CR_GPU_MACRO_RECURSE4(CR_GPU_MACRO_RECURSE4(__VA_ARGS__))))

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

Definition at line 83 of file MacroHelpers.h.

◆ CR_GPU_MACRO_RECURSE4

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

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

Definition at line 87 of file MacroHelpers.h.

◆ CR_GPU_MACRO_RECURSE_BASE

#define CR_GPU_MACRO_RECURSE_BASE (   ...)    __VA_ARGS__

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

Definition at line 91 of file MacroHelpers.h.

◆ CRGPU_CHEAP_STRING_TO_ENUM

#define CRGPU_CHEAP_STRING_TO_ENUM (   VAR,
  PREFIX,
  ONE,
  ... 
)    if (false) { return PREFIX::ONE; } CRGPU_MACRO_EXPANSION(CRGPU_STRING_TO_ENUM_OP, (VAR, PREFIX), ONE, __VA_ARGS__)

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 149 of file MacroHelpers.h.

◆ CRGPU_CHECK_FOR_END

#define CRGPU_CHECK_FOR_END (   X)    CRGPU_CHECK_FOR_END_CHECK(CRGPU_TEST_ ## X, 0)

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

Definition at line 63 of file MacroHelpers.h.

◆ CRGPU_CHECK_FOR_END_CHECK

#define CRGPU_CHECK_FOR_END_CHECK (   ...)    CRGPU_GET_SECOND(__VA_ARGS__,)

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

Definition at line 67 of file MacroHelpers.h.

◆ CRGPU_CONCAT

#define CRGPU_CONCAT (   X,
 
)    CRGPU_CONCAT_HELPER(X, Y)

Helper macro, concatenates two arguments.

Definition at line 30 of file MacroHelpers.h.

◆ CRGPU_CONCAT_HELPER

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

Helper macro for concatenation.

Definition at line 34 of file MacroHelpers.h.

◆ CRGPU_DEFER

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

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

Definition at line 21 of file MacroHelpers.h.

◆ CRGPU_EMPTY

#define CRGPU_EMPTY ( )

Definition at line 17 of file MacroHelpers.h.

◆ CRGPU_GET_FIRST

#define CRGPU_GET_FIRST (   X,
  ... 
)    X

Helper macro, returns the first argument.

Definition at line 48 of file MacroHelpers.h.

◆ CRGPU_GET_SECOND

#define CRGPU_GET_SECOND (   X,
  ... 
)    CRGPU_GET_FIRST(__VA_ARGS__, X)

Helper macro, returns the second argument.

Definition at line 52 of file MacroHelpers.h.

◆ CRGPU_IGNORE

#define CRGPU_IGNORE (   ...)

Helper macro, takes the arguments and expands to nothing.

Definition at line 26 of file MacroHelpers.h.

◆ CRGPU_MACRO_EXPANSION

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

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 97 of file MacroHelpers.h.

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

Definition at line 100 of file MacroHelpers.h.

◆ 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 106 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 114 of file MacroHelpers.h.

◆ CRGPU_MACRO_EXPANSION_IMPL_DO

#define CRGPU_MACRO_EXPANSION_IMPL_DO ( )    CRGPU_MACRO_EXPANSION_IMPL

Helper macro to defer macro expansion to enable recursion.

Definition at line 110 of file MacroHelpers.h.

◆ CRGPU_MACRO_EXPANSION_IMPL_DONT

#define CRGPU_MACRO_EXPANSION_IMPL_DONT ( )    CRGPU_IGNORE

Helper macro to defer macro expansion to enable recursion.

Definition at line 118 of file MacroHelpers.h.

◆ CRGPU_MACRO_INSTANTIATION_DO

#define CRGPU_MACRO_INSTANTIATION_DO (   ...)    __VA_ARGS__

Helper macro to defer macro expansion to enable recursion.

Definition at line 130 of file MacroHelpers.h.

◆ CRGPU_MACRO_INSTANTIATION_DONT

#define CRGPU_MACRO_INSTANTIATION_DONT (   ...)    CRGPU_IGNORE

Helper macro to defer macro expansion to enable recursion.

Definition at line 134 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 122 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 126 of file MacroHelpers.h.

◆ CRGPU_RECURSIVE_MACRO

#define CRGPU_RECURSIVE_MACRO (   ...)    CR_GPU_MACRO_RECURSE1(CR_GPU_MACRO_RECURSE1(CR_GPU_MACRO_RECURSE1(CR_GPU_MACRO_RECURSE1(__VA_ARGS__))))

Expands recursive macros.

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

Definition at line 71 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)) \

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

Definition at line 138 of file MacroHelpers.h.

◆ CRGPU_STRINGIFY

#define CRGPU_STRINGIFY (   X)    CRGPU_STRINGIFY_HELPER(X)

Helper macro, stringifies the argument.

Definition at line 39 of file MacroHelpers.h.

◆ CRGPU_STRINGIFY_HELPER

#define CRGPU_STRINGIFY_HELPER (   ...)    #__VA_ARGS__

Helper macro for concatenation.

Definition at line 43 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 59 of file MacroHelpers.h.

◆ CRGPU_TEST_CRGPU_END

#define CRGPU_TEST_CRGPU_END   ,1

Definitions to check for list end.

Definition at line 56 of file MacroHelpers.h.

CRGPU_CONCAT
#define CRGPU_CONCAT(X, Y)
Helper macro, concatenates two arguments.
Definition: MacroHelpers.h:29
CRGPU_DEFER
#define CRGPU_DEFER(...)
Helper macro, defers macro expansion to the next level of evaluation to allow recursive macros.
Definition: MacroHelpers.h:20
CRGPU_CHECK_FOR_END
#define CRGPU_CHECK_FOR_END(X)
Check for CRGPU_END (or an empty argument) to terminate list.
Definition: MacroHelpers.h:62
CRGPU_GET_SECOND
#define CRGPU_GET_SECOND(X,...)
Helper macro, returns the second argument.
Definition: MacroHelpers.h:51
CRGPU_GET_FIRST
#define CRGPU_GET_FIRST(X,...)
Helper macro, returns the first argument.
Definition: MacroHelpers.h:47
TYPE
#define TYPE(CODE, TYP, IOTYP)
CRGPU_STRINGIFY
#define CRGPU_STRINGIFY(X)
Helper macro, stringifies the argument.
Definition: MacroHelpers.h:38