From 442f4a58919b8e997daf5465b948975ecbe7e3df Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 28 Dec 2018 14:34:00 -0500 Subject: [PATCH] [meta] Move more code here --- src/hb-dsalgs.hh | 20 -------------------- src/hb-meta.hh | 31 +++++++++++++++++++++++++++++++ src/hb-open-type.hh | 6 +----- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index 6a94c2284..1d102c363 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -311,26 +311,6 @@ hb_ceil_to_4 (unsigned int v) return ((v - 1) | 3) + 1; } -template struct hb_is_signed; -template <> struct hb_is_signed { enum { value = true }; }; -template <> struct hb_is_signed { enum { value = true }; }; -template <> struct hb_is_signed { enum { value = true }; }; -template <> struct hb_is_signed { enum { value = true }; }; -template <> struct hb_is_signed { enum { value = false }; }; -template <> struct hb_is_signed { enum { value = false }; }; -template <> struct hb_is_signed { enum { value = false }; }; -template <> struct hb_is_signed { enum { value = false }; }; -/* We need to define hb_is_signed for the typedefs we use on pre-Visual - * Studio 2010 for the int8_t type, since __int8/__int64 is not considered - * the same as char/long. The previous lines will suffice for the other - * types, though. Note that somehow, unsigned __int8 is considered same - * as unsigned char. - * https://github.com/harfbuzz/harfbuzz/pull/1499 - */ -#if defined(_MSC_VER) && (_MSC_VER < 1600) -template <> struct hb_is_signed<__int8> { enum { value = true }; }; -#endif - template static inline bool hb_in_range (T u, T lo, T hi) { diff --git a/src/hb-meta.hh b/src/hb-meta.hh index 1e8148a7f..ad12cd277 100644 --- a/src/hb-meta.hh +++ b/src/hb-meta.hh @@ -58,4 +58,35 @@ struct hb_enable_if { typedef T type; }; #define hb_enable_if_t(Type, Cond) hb_enable_if<(Cond), Type>::type +/* + * Meta-functions. + */ + +template struct hb_is_signed; +template <> struct hb_is_signed { enum { value = true }; }; +template <> struct hb_is_signed { enum { value = true }; }; +template <> struct hb_is_signed { enum { value = true }; }; +template <> struct hb_is_signed { enum { value = true }; }; +template <> struct hb_is_signed { enum { value = false }; }; +template <> struct hb_is_signed { enum { value = false }; }; +template <> struct hb_is_signed { enum { value = false }; }; +template <> struct hb_is_signed { enum { value = false }; }; +/* We need to define hb_is_signed for the typedefs we use on pre-Visual + * Studio 2010 for the int8_t type, since __int8/__int64 is not considered + * the same as char/long. The previous lines will suffice for the other + * types, though. Note that somehow, unsigned __int8 is considered same + * as unsigned char. + * https://github.com/harfbuzz/harfbuzz/pull/1499 + */ +#if defined(_MSC_VER) && (_MSC_VER < 1600) +template <> struct hb_is_signed<__int8> { enum { value = true }; }; +#endif +#define hb_is_signed(T) hb_is_signed::value + +template struct hb_signedness_int; +template <> struct hb_signedness_int { typedef unsigned int value; }; +template <> struct hb_signedness_int { typedef signed int value; }; +#define hb_signedness_int(T) hb_signedness_int::value + + #endif /* HB_META_HH */ diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 8a76552d6..b1e2207a6 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -52,16 +52,12 @@ namespace OT { * Int types */ -template struct hb_signedness_int; -template <> struct hb_signedness_int { typedef unsigned int value; }; -template <> struct hb_signedness_int { typedef signed int value; }; - /* Integer types in big-endian order and no alignment requirement */ template struct IntType { typedef Type type; - typedef typename hb_signedness_int::value>::value wide_type; + typedef typename hb_signedness_int (hb_is_signed (Type)) wide_type; void set (wide_type i) { v.set (i); } operator wide_type () const { return v; }