[HarfBuzz] harfbuzz: Branch 'master'
Behdad Esfahbod
behdad at kemper.freedesktop.org
Fri Nov 20 13:22:44 PST 2015
src/hb-private.hh | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
New commits:
commit f94c0ecbb1488138d3ec3b9d6d9fb78113dfee4f
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Nov 20 13:21:29 2015 -0800
Define HB_MARK_AS_FLAG_T as a macro instead of using templates
The generic template operator overloading was causing more problems than it
solved. Eg:
https://github.com/behdad/harfbuzz/pull/163
https://github.com/behdad/harfbuzz/issues/175
So, just use macros.
Fixes https://github.com/behdad/harfbuzz/issues/175
Fixes https://github.com/behdad/harfbuzz/pull/178
diff --git a/src/hb-private.hh b/src/hb-private.hh
index b735c0d..76cf737 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -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.
More information about the HarfBuzz
mailing list