Index: third_party/harfbuzz-ng/src/hb-open-type-private.hh |
diff --git a/third_party/harfbuzz-ng/src/hb-open-type-private.hh b/third_party/harfbuzz-ng/src/hb-open-type-private.hh |
index 477d9e28b2c8a1487dd5e58ea395136d58f96e5d..75a0f568d118e8a817c297797a5c9cd1e4c2a0cc 100644 |
--- a/third_party/harfbuzz-ng/src/hb-open-type-private.hh |
+++ b/third_party/harfbuzz-ng/src/hb-open-type-private.hh |
@@ -179,10 +179,13 @@ struct hb_sanitize_context_t |
inline const char *get_name (void) { return "SANITIZE"; } |
static const unsigned int max_debug_depth = HB_DEBUG_SANITIZE; |
typedef bool return_t; |
+ template <typename T, typename F> |
+ inline bool may_dispatch (const T *obj, const F *format) |
+ { return format->sanitize (this); } |
template <typename T> |
inline return_t dispatch (const T &obj) { return obj.sanitize (this); } |
static return_t default_return_value (void) { return true; } |
- bool stop_sublookup_iteration (const return_t r HB_UNUSED) const { return false; } |
+ bool stop_sublookup_iteration (const return_t r) const { return !r; } |
inline void init (hb_blob_t *b) |
{ |
@@ -270,9 +273,9 @@ struct hb_sanitize_context_t |
} |
template <typename Type, typename ValueType> |
- inline bool try_set (Type *obj, const ValueType &v) { |
+ inline bool try_set (const Type *obj, const ValueType &v) { |
if (this->may_edit (obj, obj->static_size)) { |
- obj->set (v); |
+ const_cast<Type *> (obj)->set (v); |
return true; |
} |
return false; |
@@ -546,12 +549,6 @@ struct BEInt<Type, 2> |
return (v[0] << 8) |
+ (v[1] ); |
} |
- inline bool operator == (const BEInt<Type, 2>& o) const |
- { |
- return v[0] == o.v[0] |
- && v[1] == o.v[1]; |
- } |
- inline bool operator != (const BEInt<Type, 2>& o) const { return !(*this == o); } |
private: uint8_t v[2]; |
}; |
template <typename Type> |
@@ -570,13 +567,6 @@ struct BEInt<Type, 3> |
+ (v[1] << 8) |
+ (v[2] ); |
} |
- inline bool operator == (const BEInt<Type, 3>& o) const |
- { |
- return v[0] == o.v[0] |
- && v[1] == o.v[1] |
- && v[2] == o.v[2]; |
- } |
- inline bool operator != (const BEInt<Type, 3>& o) const { return !(*this == o); } |
private: uint8_t v[3]; |
}; |
template <typename Type> |
@@ -597,14 +587,6 @@ struct BEInt<Type, 4> |
+ (v[2] << 8) |
+ (v[3] ); |
} |
- inline bool operator == (const BEInt<Type, 4>& o) const |
- { |
- return v[0] == o.v[0] |
- && v[1] == o.v[1] |
- && v[2] == o.v[2] |
- && v[3] == o.v[3]; |
- } |
- inline bool operator != (const BEInt<Type, 4>& o) const { return !(*this == o); } |
private: uint8_t v[4]; |
}; |
@@ -614,12 +596,19 @@ struct IntType |
{ |
inline void set (Type i) { v.set (i); } |
inline operator Type(void) const { return v; } |
- inline bool operator == (const IntType<Type,Size> &o) const { return v == o.v; } |
- inline bool operator != (const IntType<Type,Size> &o) const { return v != o.v; } |
+ inline bool operator == (const IntType<Type,Size> &o) const { return (Type) v == (Type) o.v; } |
+ inline bool operator != (const IntType<Type,Size> &o) const { return !(*this == o); } |
static inline int cmp (const IntType<Type,Size> *a, const IntType<Type,Size> *b) { return b->cmp (*a); } |
- inline int cmp (IntType<Type,Size> va) const { Type a = va; Type b = v; return a < b ? -1 : a == b ? 0 : +1; } |
- inline int cmp (Type a) const { Type b = v; return a < b ? -1 : a == b ? 0 : +1; } |
- inline bool sanitize (hb_sanitize_context_t *c) { |
+ inline int cmp (Type a) const |
+ { |
+ Type b = v; |
+ if (sizeof (Type) < sizeof (int)) |
+ return (int) a - (int) b; |
+ else |
+ return a < b ? -1 : a == b ? 0 : +1; |
+ } |
+ inline bool sanitize (hb_sanitize_context_t *c) const |
+ { |
TRACE_SANITIZE (this); |
return TRACE_RETURN (likely (c->check_struct (this))); |
} |
@@ -646,7 +635,8 @@ typedef USHORT UFWORD; |
* 1904. The value is represented as a signed 64-bit integer. */ |
struct LONGDATETIME |
{ |
- inline bool sanitize (hb_sanitize_context_t *c) { |
+ inline bool sanitize (hb_sanitize_context_t *c) const |
+ { |
TRACE_SANITIZE (this); |
return TRACE_RETURN (likely (c->check_struct (this))); |
} |
@@ -670,7 +660,10 @@ struct Tag : ULONG |
DEFINE_NULL_DATA (Tag, " "); |
/* Glyph index number, same as uint16 (length = 16 bits) */ |
-typedef USHORT GlyphID; |
+struct GlyphID : USHORT { |
+ static inline int cmp (const GlyphID *a, const GlyphID *b) { return b->USHORT::cmp (*a); } |
+ inline int cmp (hb_codepoint_t a) const { return (int) a - (int) *this; } |
+}; |
/* Script/language-system/feature index */ |
struct Index : USHORT { |
@@ -719,7 +712,8 @@ struct FixedVersion |
{ |
inline uint32_t to_int (void) const { return (major << 16) + minor; } |
- inline bool sanitize (hb_sanitize_context_t *c) { |
+ inline bool sanitize (hb_sanitize_context_t *c) const |
+ { |
TRACE_SANITIZE (this); |
return TRACE_RETURN (c->check_struct (this)); |
} |
@@ -747,33 +741,35 @@ struct OffsetTo : Offset<OffsetType> |
return StructAtOffset<Type> (base, offset); |
} |
- inline Type& serialize (hb_serialize_context_t *c, void *base) |
+ inline Type& serialize (hb_serialize_context_t *c, const void *base) |
{ |
Type *t = c->start_embed<Type> (); |
this->set ((char *) t - (char *) base); /* TODO(serialize) Overflow? */ |
return *t; |
} |
- inline bool sanitize (hb_sanitize_context_t *c, void *base) { |
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base) const |
+ { |
TRACE_SANITIZE (this); |
if (unlikely (!c->check_struct (this))) return TRACE_RETURN (false); |
unsigned int offset = *this; |
if (unlikely (!offset)) return TRACE_RETURN (true); |
- Type &obj = StructAtOffset<Type> (base, offset); |
+ const Type &obj = StructAtOffset<Type> (base, offset); |
return TRACE_RETURN (likely (obj.sanitize (c)) || neuter (c)); |
} |
template <typename T> |
- inline bool sanitize (hb_sanitize_context_t *c, void *base, T user_data) { |
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base, T user_data) const |
+ { |
TRACE_SANITIZE (this); |
if (unlikely (!c->check_struct (this))) return TRACE_RETURN (false); |
unsigned int offset = *this; |
if (unlikely (!offset)) return TRACE_RETURN (true); |
- Type &obj = StructAtOffset<Type> (base, offset); |
+ const Type &obj = StructAtOffset<Type> (base, offset); |
return TRACE_RETURN (likely (obj.sanitize (c, user_data)) || neuter (c)); |
} |
/* Set the offset to Null */ |
- inline bool neuter (hb_sanitize_context_t *c) { |
+ inline bool neuter (hb_sanitize_context_t *c) const { |
return c->try_set (this, 0); |
} |
DEFINE_SIZE_STATIC (sizeof(OffsetType)); |
@@ -838,7 +834,8 @@ struct ArrayOf |
return TRACE_RETURN (true); |
} |
- inline bool sanitize (hb_sanitize_context_t *c) { |
+ inline bool sanitize (hb_sanitize_context_t *c) const |
+ { |
TRACE_SANITIZE (this); |
if (unlikely (!sanitize_shallow (c))) return TRACE_RETURN (false); |
@@ -853,7 +850,8 @@ struct ArrayOf |
return TRACE_RETURN (true); |
} |
- inline bool sanitize (hb_sanitize_context_t *c, void *base) { |
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base) const |
+ { |
TRACE_SANITIZE (this); |
if (unlikely (!sanitize_shallow (c))) return TRACE_RETURN (false); |
unsigned int count = len; |
@@ -863,7 +861,8 @@ struct ArrayOf |
return TRACE_RETURN (true); |
} |
template <typename T> |
- inline bool sanitize (hb_sanitize_context_t *c, void *base, T user_data) { |
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base, T user_data) const |
+ { |
TRACE_SANITIZE (this); |
if (unlikely (!sanitize_shallow (c))) return TRACE_RETURN (false); |
unsigned int count = len; |
@@ -884,7 +883,8 @@ struct ArrayOf |
} |
private: |
- inline bool sanitize_shallow (hb_sanitize_context_t *c) { |
+ inline bool sanitize_shallow (hb_sanitize_context_t *c) const |
+ { |
TRACE_SANITIZE (this); |
return TRACE_RETURN (c->check_struct (this) && c->check_array (this, Type::static_size, len)); |
} |
@@ -910,12 +910,14 @@ struct OffsetListOf : OffsetArrayOf<Type> |
return this+this->array[i]; |
} |
- inline bool sanitize (hb_sanitize_context_t *c) { |
+ inline bool sanitize (hb_sanitize_context_t *c) const |
+ { |
TRACE_SANITIZE (this); |
return TRACE_RETURN (OffsetArrayOf<Type>::sanitize (c, this)); |
} |
template <typename T> |
- inline bool sanitize (hb_sanitize_context_t *c, T user_data) { |
+ inline bool sanitize (hb_sanitize_context_t *c, T user_data) const |
+ { |
TRACE_SANITIZE (this); |
return TRACE_RETURN (OffsetArrayOf<Type>::sanitize (c, this, user_data)); |
} |
@@ -949,12 +951,14 @@ struct HeadlessArrayOf |
return TRACE_RETURN (true); |
} |
- inline bool sanitize_shallow (hb_sanitize_context_t *c) { |
+ inline bool sanitize_shallow (hb_sanitize_context_t *c) const |
+ { |
return c->check_struct (this) |
&& c->check_array (this, Type::static_size, len); |
} |
- inline bool sanitize (hb_sanitize_context_t *c) { |
+ inline bool sanitize (hb_sanitize_context_t *c) const |
+ { |
TRACE_SANITIZE (this); |
if (unlikely (!sanitize_shallow (c))) return TRACE_RETURN (false); |