Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/BLI_utildefines.h
| Show First 20 Lines • Show All 776 Lines • ▼ Show 20 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name C++ Macros | /** \name C++ Macros | ||||
| * \{ */ | * \{ */ | ||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| /* Useful to port C code using enums to C++ where enums are strongly typed. | /* Useful to port C code using enums to C++ where enums are strongly typed. | ||||
| * To use after the enum declaration. */ | * To use after the enum declaration. */ | ||||
| # define ENUM_OPERATORS(_enum_type) \ | # define ENUM_OPERATORS(_enum_type, mask) \ | ||||
| inline constexpr _enum_type operator|(_enum_type a, _enum_type b) \ | inline constexpr _enum_type operator|(_enum_type a, _enum_type b) \ | ||||
| { \ | { \ | ||||
| return static_cast<_enum_type>(static_cast<int>(a) | b); \ | return static_cast<_enum_type>(static_cast<int>(a) | b); \ | ||||
| } \ | } \ | ||||
| inline constexpr _enum_type operator&(_enum_type a, _enum_type b) \ | inline constexpr _enum_type operator&(_enum_type a, _enum_type b) \ | ||||
| { \ | { \ | ||||
| return static_cast<_enum_type>(static_cast<int>(a) & b); \ | return static_cast<_enum_type>(static_cast<int>(a) & b); \ | ||||
| } \ | } \ | ||||
| inline constexpr _enum_type operator~(_enum_type a) \ | inline constexpr _enum_type operator~(_enum_type a) \ | ||||
| { \ | { \ | ||||
| return static_cast<_enum_type>(~static_cast<int>(a)); \ | return static_cast<_enum_type>(~static_cast<int>(a) & mask); \ | ||||
| } \ | } \ | ||||
| inline _enum_type &operator|=(_enum_type &a, _enum_type b) \ | inline _enum_type &operator|=(_enum_type &a, _enum_type b) \ | ||||
| { \ | { \ | ||||
| return a = static_cast<_enum_type>(static_cast<int>(a) | b); \ | return a = static_cast<_enum_type>(static_cast<int>(a) | b); \ | ||||
| } \ | } \ | ||||
| inline _enum_type &operator&=(_enum_type &a, _enum_type b) \ | inline _enum_type &operator&=(_enum_type &a, _enum_type b) \ | ||||
| { \ | { \ | ||||
| return a = static_cast<_enum_type>(static_cast<int>(a) & b); \ | return a = static_cast<_enum_type>(static_cast<int>(a) & b); \ | ||||
| } | } | ||||
| #else | #else | ||||
| /* Output nothing. */ | /* Output nothing. */ | ||||
| # define ENUM_OPERATORS(_type) | # define ENUM_OPERATORS(_type, mask) | ||||
| #endif | #endif | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Misc Macros | /** \name Misc Macros | ||||
| * \{ */ | * \{ */ | ||||
| Show All 13 Lines | |||||