[meta] Move more code here
This commit is contained in:
parent
8c6cbbdfa3
commit
442f4a5891
|
@ -311,26 +311,6 @@ hb_ceil_to_4 (unsigned int v)
|
||||||
return ((v - 1) | 3) + 1;
|
return ((v - 1) | 3) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> struct hb_is_signed;
|
|
||||||
template <> struct hb_is_signed<signed char> { enum { value = true }; };
|
|
||||||
template <> struct hb_is_signed<signed short> { enum { value = true }; };
|
|
||||||
template <> struct hb_is_signed<signed int> { enum { value = true }; };
|
|
||||||
template <> struct hb_is_signed<signed long> { enum { value = true }; };
|
|
||||||
template <> struct hb_is_signed<unsigned char> { enum { value = false }; };
|
|
||||||
template <> struct hb_is_signed<unsigned short> { enum { value = false }; };
|
|
||||||
template <> struct hb_is_signed<unsigned int> { enum { value = false }; };
|
|
||||||
template <> struct hb_is_signed<unsigned long> { 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 <typename T> static inline bool
|
template <typename T> static inline bool
|
||||||
hb_in_range (T u, T lo, T hi)
|
hb_in_range (T u, T lo, T hi)
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,4 +58,35 @@ struct hb_enable_if<true, T> { typedef T type; };
|
||||||
#define hb_enable_if_t(Type, Cond) hb_enable_if<(Cond), Type>::type
|
#define hb_enable_if_t(Type, Cond) hb_enable_if<(Cond), Type>::type
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Meta-functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
template <typename T> struct hb_is_signed;
|
||||||
|
template <> struct hb_is_signed<signed char> { enum { value = true }; };
|
||||||
|
template <> struct hb_is_signed<signed short> { enum { value = true }; };
|
||||||
|
template <> struct hb_is_signed<signed int> { enum { value = true }; };
|
||||||
|
template <> struct hb_is_signed<signed long> { enum { value = true }; };
|
||||||
|
template <> struct hb_is_signed<unsigned char> { enum { value = false }; };
|
||||||
|
template <> struct hb_is_signed<unsigned short> { enum { value = false }; };
|
||||||
|
template <> struct hb_is_signed<unsigned int> { enum { value = false }; };
|
||||||
|
template <> struct hb_is_signed<unsigned long> { 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<T>::value
|
||||||
|
|
||||||
|
template <bool is_signed> struct hb_signedness_int;
|
||||||
|
template <> struct hb_signedness_int<false> { typedef unsigned int value; };
|
||||||
|
template <> struct hb_signedness_int<true> { typedef signed int value; };
|
||||||
|
#define hb_signedness_int(T) hb_signedness_int<T>::value
|
||||||
|
|
||||||
|
|
||||||
#endif /* HB_META_HH */
|
#endif /* HB_META_HH */
|
||||||
|
|
|
@ -52,16 +52,12 @@ namespace OT {
|
||||||
* Int types
|
* Int types
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <bool is_signed> struct hb_signedness_int;
|
|
||||||
template <> struct hb_signedness_int<false> { typedef unsigned int value; };
|
|
||||||
template <> struct hb_signedness_int<true> { typedef signed int value; };
|
|
||||||
|
|
||||||
/* Integer types in big-endian order and no alignment requirement */
|
/* Integer types in big-endian order and no alignment requirement */
|
||||||
template <typename Type, unsigned int Size>
|
template <typename Type, unsigned int Size>
|
||||||
struct IntType
|
struct IntType
|
||||||
{
|
{
|
||||||
typedef Type type;
|
typedef Type type;
|
||||||
typedef typename hb_signedness_int<hb_is_signed<Type>::value>::value wide_type;
|
typedef typename hb_signedness_int (hb_is_signed (Type)) wide_type;
|
||||||
|
|
||||||
void set (wide_type i) { v.set (i); }
|
void set (wide_type i) { v.set (i); }
|
||||||
operator wide_type () const { return v; }
|
operator wide_type () const { return v; }
|
||||||
|
|
Loading…
Reference in New Issue