|
|
|
@ -896,27 +896,22 @@ hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2, T lo3, T hi3) |
|
|
|
|
* one enum to another... So this doesn't provide the type-checking that I |
|
|
|
|
* originally had in mind... :(. |
|
|
|
|
* |
|
|
|
|
* On MSVC use DEFINE_ENUM_FLAG_OPERATORS. See: |
|
|
|
|
* https://github.com/behdad/harfbuzz/pull/163
|
|
|
|
|
* For MSVC warnings, see: https://github.com/behdad/harfbuzz/pull/163
|
|
|
|
|
*/ |
|
|
|
|
#ifdef _MSC_VER |
|
|
|
|
# pragma warning(disable:4200) |
|
|
|
|
# pragma warning(disable:4800) |
|
|
|
|
# define HB_MARK_AS_FLAG_T(flags_t) DEFINE_ENUM_FLAG_OPERATORS (##flags_t##); |
|
|
|
|
#else |
|
|
|
|
# define HB_MARK_AS_FLAG_T(flags_t) template <> class hb_mark_as_flags_t<flags_t> {}; |
|
|
|
|
template <class T> class hb_mark_as_flags_t; |
|
|
|
|
template <class T> static inline T operator | (T l, T r) |
|
|
|
|
{ hb_mark_as_flags_t<T> unused HB_UNUSED; return T ((unsigned int) l | (unsigned int) r); } |
|
|
|
|
template <class T> static inline T operator & (T l, T r) |
|
|
|
|
{ hb_mark_as_flags_t<T> unused HB_UNUSED; return T ((unsigned int) l & (unsigned int) r); } |
|
|
|
|
template <class T> static inline T operator ~ (T r) |
|
|
|
|
{ hb_mark_as_flags_t<T> unused HB_UNUSED; return T (~(unsigned int) r); } |
|
|
|
|
template <class T> static inline T& operator |= (T &l, T r) |
|
|
|
|
{ hb_mark_as_flags_t<T> unused HB_UNUSED; l = l | r; return l; } |
|
|
|
|
template <class T> static inline T& operator &= (T& l, T r) |
|
|
|
|
{ hb_mark_as_flags_t<T> unused HB_UNUSED; l = l & r; return l; } |
|
|
|
|
#endif |
|
|
|
|
# define HB_MARK_AS_FLAG_T(T) \ |
|
|
|
|
extern "C++" { \
|
|
|
|
|
static inline T operator | (T l, T r) { return T ((unsigned) l | (unsigned) r); } \
|
|
|
|
|
static inline T operator & (T l, T r) { return T ((unsigned) l & (unsigned) r); } \
|
|
|
|
|
static inline T operator ^ (T l, T r) { return T ((unsigned) l ^ (unsigned) r); } \
|
|
|
|
|
static inline T operator ~ (T r) { return T (~(unsigned int) r); } \
|
|
|
|
|
static inline T& operator |= (T &l, T r) { l = l | r; return l; } \
|
|
|
|
|
static inline T& operator &= (T& l, T r) { l = l & r; return l; } \
|
|
|
|
|
static inline T& operator ^= (T& l, T r) { l = l ^ r; return l; } \
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Useful for set-operations on small enums.
|
|
|
|
|