Bug 1524102 - Update HarfBuzz to version 2.3.1. r=jfkthame

Differential Revision: https://phabricator.services.mozilla.com/D18170
This commit is contained in:
Ryan VanderMeulen
2019-01-31 12:01:26 +00:00
parent 4963e62f84
commit 838d890d08
108 changed files with 2099 additions and 1800 deletions

View File

@@ -28,68 +28,58 @@
#define HB_ARRAY_HH
#include "hb.hh"
#include "hb-dsalgs.hh"
#include "hb-iter.hh"
#include "hb-null.hh"
template <typename Type>
struct hb_sorted_array_t;
template <typename Type>
struct hb_array_t
struct hb_array_t :
hb_iter_t<hb_array_t<Type>, Type>,
hb_iter_mixin_t<hb_array_t<Type>, Type>
{
typedef Type ItemType;
enum { item_size = hb_static_size (Type) };
/*
* Constructors.
*/
hb_array_t () : arrayZ (nullptr), len (0) {}
hb_array_t (const hb_array_t &o) : arrayZ (o.arrayZ), len (o.len) {}
hb_array_t (Type *array_, unsigned int len_) : arrayZ (array_), len (len_) {}
template <unsigned int len_> hb_array_t (Type (&array_)[len_]) : arrayZ (array_), len (len_) {}
hb_array_t () : arrayZ (nullptr), length (0) {}
hb_array_t (Type *array_, unsigned int length_) : arrayZ (array_), length (length_) {}
template <unsigned int length_> hb_array_t (Type (&array_)[length_]) : arrayZ (array_), length (length_) {}
/*
* Operators.
* Iterator implementation.
*/
Type& operator [] (int i_) const
typedef Type __item_type__;
Type& __item_at__ (unsigned i) const
{
unsigned int i = (unsigned int) i_;
if (unlikely (i >= len)) return CrapOrNull(Type);
if (unlikely (i >= length)) return CrapOrNull (Type);
return arrayZ[i];
}
void __forward__ (unsigned n)
{
if (unlikely (n > length))
n = length;
length -= n;
arrayZ += n;
}
void __rewind__ (unsigned n)
{
if (unlikely (n > length))
n = length;
length -= n;
}
unsigned __len__ () const { return length; }
bool __random_access__ () const { return true; }
explicit_operator bool () const { return len; }
/* Extra operators.
*/
Type * operator & () const { return arrayZ; }
Type & operator * () { return (this->operator [])[0]; }
operator hb_array_t<const Type> () { return hb_array_t<const Type> (arrayZ, len); }
operator hb_array_t<const Type> () { return hb_array_t<const Type> (arrayZ, length); }
template <typename T> operator T * () const { return arrayZ; }
hb_array_t<Type> & operator += (unsigned int count)
{
if (unlikely (count > len))
count = len;
len -= count;
arrayZ += count;
return *this;
}
hb_array_t<Type> & operator -= (unsigned int count)
{
if (unlikely (count > len))
count = len;
len -= count;
return *this;
}
hb_array_t<Type> & operator ++ () { *this += 1; }
hb_array_t<Type> & operator -- () { *this -= 1; }
hb_array_t<Type> operator + (unsigned int count)
{ hb_array_t<Type> copy (*this); *this += count; return copy; }
hb_array_t<Type> operator - (unsigned int count)
{ hb_array_t<Type> copy (*this); *this -= count; return copy; }
hb_array_t<Type> operator ++ (int)
{ hb_array_t<Type> copy (*this); ++*this; return copy; }
hb_array_t<Type> operator -- (int)
{ hb_array_t<Type> copy (*this); --*this; return copy; }
/*
* Compare, Sort, and Search.
*/
@@ -97,8 +87,8 @@ struct hb_array_t
/* Note: our compare is NOT lexicographic; it also does NOT call Type::cmp. */
int cmp (const hb_array_t<Type> &a) const
{
if (len != a.len)
return (int) a.len - (int) len;
if (length != a.length)
return (int) a.length - (int) length;
return hb_memcmp (a.arrayZ, arrayZ, get_size ());
}
static int cmp (const void *pa, const void *pb)
@@ -111,7 +101,7 @@ struct hb_array_t
template <typename T>
Type *lsearch (const T &x, Type *not_found = nullptr)
{
unsigned int count = len;
unsigned int count = length;
for (unsigned int i = 0; i < count; i++)
if (!this->arrayZ[i].cmp (x))
return &this->arrayZ[i];
@@ -120,7 +110,7 @@ struct hb_array_t
template <typename T>
const Type *lsearch (const T &x, const Type *not_found = nullptr) const
{
unsigned int count = len;
unsigned int count = length;
for (unsigned int i = 0; i < count; i++)
if (!this->arrayZ[i].cmp (x))
return &this->arrayZ[i];
@@ -129,33 +119,36 @@ struct hb_array_t
hb_sorted_array_t<Type> qsort (int (*cmp_)(const void*, const void*))
{
::qsort (arrayZ, len, item_size, cmp_);
if (likely (length))
::qsort (arrayZ, length, this->item_size, cmp_);
return hb_sorted_array_t<Type> (*this);
}
hb_sorted_array_t<Type> qsort ()
{
::qsort (arrayZ, len, item_size, Type::cmp);
if (likely (length))
::qsort (arrayZ, length, this->item_size, Type::cmp);
return hb_sorted_array_t<Type> (*this);
}
void qsort (unsigned int start, unsigned int end)
{
end = MIN (end, len);
end = MIN (end, length);
assert (start <= end);
::qsort (arrayZ + start, end - start, item_size, Type::cmp);
if (likely (start < end))
::qsort (arrayZ + start, end - start, this->item_size, Type::cmp);
}
/*
* Other methods.
*/
unsigned int get_size () const { return len * item_size; }
unsigned int get_size () const { return length * this->item_size; }
hb_array_t<Type> sub_array (unsigned int start_offset = 0, unsigned int *seg_count = nullptr /* IN/OUT */) const
{
if (!start_offset && !seg_count)
return *this;
unsigned int count = len;
unsigned int count = length;
if (unlikely (start_offset > count))
count = 0;
else
@@ -169,11 +162,11 @@ struct hb_array_t
/* Only call if you allocated the underlying array using malloc() or similar. */
void free ()
{ ::free ((void *) arrayZ); arrayZ = nullptr; len = 0; }
{ ::free ((void *) arrayZ); arrayZ = nullptr; length = 0; }
template <typename hb_sanitize_context_t>
bool sanitize (hb_sanitize_context_t *c) const
{ return c->check_array (arrayZ, len); }
{ return c->check_array (arrayZ, length); }
/*
* Members
@@ -181,11 +174,14 @@ struct hb_array_t
public:
Type *arrayZ;
unsigned int len;
unsigned int length;
};
template <typename T>
inline hb_array_t<T> hb_array (T *array, unsigned int len)
{ return hb_array_t<T> (array, len); }
template <typename T> inline hb_array_t<T>
hb_array (T *array, unsigned int length)
{ return hb_array_t<T> (array, length); }
template <typename T, unsigned int length_> inline hb_array_t<T>
hb_array (T (&array_)[length_])
{ return hb_array_t<T> (array_); }
enum hb_bfind_not_found_t
@@ -196,11 +192,15 @@ enum hb_bfind_not_found_t
};
template <typename Type>
struct hb_sorted_array_t : hb_array_t<Type>
struct hb_sorted_array_t :
hb_sorted_iter_t<hb_sorted_array_t<Type>, Type>,
hb_array_t<Type>,
hb_iter_mixin_t<hb_sorted_array_t<Type>, Type>
{
hb_sorted_array_t () : hb_array_t<Type> () {}
hb_sorted_array_t (const hb_array_t<Type> &o) : hb_array_t<Type> (o) {}
hb_sorted_array_t (Type *array_, unsigned int len_) : hb_array_t<Type> (array_, len_) {}
hb_sorted_array_t (Type *array_, unsigned int length_) : hb_array_t<Type> (array_, length_) {}
template <unsigned int length_> hb_sorted_array_t (Type (&array_)[length_]) : hb_array_t<Type> (array_) {}
hb_sorted_array_t<Type> sub_array (unsigned int start_offset, unsigned int *seg_count /* IN/OUT */) const
{ return hb_sorted_array_t<Type> (((const hb_array_t<Type> *) (this))->sub_array (start_offset, seg_count)); }
@@ -224,7 +224,7 @@ struct hb_sorted_array_t : hb_array_t<Type>
hb_bfind_not_found_t not_found = HB_BFIND_NOT_FOUND_DONT_STORE,
unsigned int to_store = (unsigned int) -1) const
{
int min = 0, max = (int) this->len - 1;
int min = 0, max = (int) this->length - 1;
const Type *array = this->arrayZ;
while (min <= max)
{
@@ -253,7 +253,7 @@ struct hb_sorted_array_t : hb_array_t<Type>
break;
case HB_BFIND_NOT_FOUND_STORE_CLOSEST:
if (max < 0 || (max < (int) this->len && array[max].cmp (x) > 0))
if (max < 0 || (max < (int) this->length && array[max].cmp (x) > 0))
max++;
*i = max;
break;
@@ -262,9 +262,12 @@ struct hb_sorted_array_t : hb_array_t<Type>
return false;
}
};
template <typename T>
inline hb_sorted_array_t<T> hb_sorted_array (T *array, unsigned int len)
{ return hb_sorted_array_t<T> (array, len); }
template <typename T> inline hb_sorted_array_t<T>
hb_sorted_array (T *array, unsigned int length)
{ return hb_sorted_array_t<T> (array, length); }
template <typename T, unsigned int length_> inline hb_sorted_array_t<T>
hb_sorted_array (T (&array_)[length_])
{ return hb_sorted_array_t<T> (array_); }
typedef hb_array_t<const char> hb_bytes_t;