1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-02 16:48:55 +00:00

HarfBuzz: Update to version 4.3.0

This commit is contained in:
bruvzg
2022-05-23 13:18:11 +03:00
parent 3568b3deea
commit 797ccd3ef8
45 changed files with 3052 additions and 2659 deletions

View File

@@ -29,6 +29,7 @@
#include "hb.hh"
#include "hb-array.hh"
#include "hb-meta.hh"
#include "hb-null.hh"
@@ -42,6 +43,7 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
using c_array_t = typename std::conditional<sorted, hb_sorted_array_t<const Type>, hb_array_t<const Type>>::type;
hb_vector_t () = default;
hb_vector_t (std::nullptr_t) : hb_vector_t () {}
hb_vector_t (std::initializer_list<Type> lst) : hb_vector_t ()
{
alloc (lst.size ());
@@ -59,7 +61,8 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
hb_vector_t (const hb_vector_t &o) : hb_vector_t ()
{
alloc (o.length);
hb_copy (o, *this);
if (unlikely (in_error ())) return;
copy_vector (o);
}
hb_vector_t (hb_vector_t &&o)
{
@@ -70,9 +73,8 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
}
~hb_vector_t () { fini (); }
private:
int allocated = 0; /* == -1 means allocation failed. */
public:
int allocated = 0; /* == -1 means allocation failed. */
unsigned int length = 0;
public:
Type *arrayZ = nullptr;
@@ -108,7 +110,10 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
{
reset ();
alloc (o.length);
hb_copy (o, *this);
if (unlikely (in_error ())) return *this;
copy_vector (o);
return *this;
}
hb_vector_t& operator = (hb_vector_t &&o)
@@ -184,12 +189,14 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
{
if (unlikely (!resize (length + 1)))
return &Crap (Type);
return &arrayZ[length - 1];
return std::addressof (arrayZ[length - 1]);
}
template <typename T>
template <typename T,
typename T2 = Type,
hb_enable_if (!std::is_copy_constructible<T2>::value &&
std::is_copy_assignable<T>::value)>
Type *push (T&& v)
{
/* TODO Emplace? */
Type *p = push ();
if (p == &Crap (Type))
// If push failed to allocate then don't copy v, since this may cause
@@ -199,18 +206,34 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
*p = std::forward<T> (v);
return p;
}
template <typename T,
typename T2 = Type,
hb_enable_if (std::is_copy_constructible<T2>::value)>
Type *push (T&& v)
{
if (unlikely (!alloc (length + 1)))
// If push failed to allocate then don't copy v, since this may cause
// the created copy to leak memory since we won't have stored a
// reference to it.
return &Crap (Type);
/* Emplace. */
length++;
Type *p = std::addressof (arrayZ[length - 1]);
return new (p) Type (std::forward<T> (v));
}
bool in_error () const { return allocated < 0; }
template <typename T = Type,
hb_enable_if (std::is_trivially_copy_assignable<T>::value)>
hb_enable_if (hb_is_trivially_copy_assignable(T))>
Type *
realloc_vector (unsigned new_allocated)
{
return (Type *) hb_realloc (arrayZ, new_allocated * sizeof (Type));
}
template <typename T = Type,
hb_enable_if (!std::is_trivially_copy_assignable<T>::value)>
hb_enable_if (!hb_is_trivially_copy_assignable(T))>
Type *
realloc_vector (unsigned new_allocated)
{
@@ -230,8 +253,7 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
}
template <typename T = Type,
hb_enable_if (std::is_trivially_constructible<T>::value ||
!std::is_default_constructible<T>::value)>
hb_enable_if (hb_is_trivially_constructible(T))>
void
grow_vector (unsigned size)
{
@@ -239,8 +261,7 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
length = size;
}
template <typename T = Type,
hb_enable_if (!std::is_trivially_constructible<T>::value &&
std::is_default_constructible<T>::value)>
hb_enable_if (!hb_is_trivially_constructible(T))>
void
grow_vector (unsigned size)
{
@@ -252,14 +273,52 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
}
template <typename T = Type,
hb_enable_if (std::is_trivially_destructible<T>::value)>
hb_enable_if (hb_is_trivially_copyable (T))>
void
copy_vector (const hb_vector_t &other)
{
length = other.length;
hb_memcpy ((void *) arrayZ, (const void *) other.arrayZ, length * item_size);
}
template <typename T = Type,
hb_enable_if (!hb_is_trivially_copyable (T) &&
std::is_copy_constructible<T>::value)>
void
copy_vector (const hb_vector_t &other)
{
length = 0;
while (length < other.length)
{
length++;
new (std::addressof (arrayZ[length - 1])) Type (other.arrayZ[length - 1]);
}
}
template <typename T = Type,
hb_enable_if (!hb_is_trivially_copyable (T) &&
!std::is_copy_constructible<T>::value &&
std::is_default_constructible<T>::value &&
std::is_copy_assignable<T>::value)>
void
copy_vector (const hb_vector_t &other)
{
length = 0;
while (length < other.length)
{
length++;
new (std::addressof (arrayZ[length - 1])) Type ();
arrayZ[length - 1] = other.arrayZ[length - 1];
}
}
template <typename T = Type,
hb_enable_if (hb_is_trivially_destructible(T))>
void
shrink_vector (unsigned size)
{
length = size;
}
template <typename T = Type,
hb_enable_if (!std::is_trivially_destructible<T>::value)>
hb_enable_if (!hb_is_trivially_destructible(T))>
void
shrink_vector (unsigned size)
{
@@ -271,7 +330,7 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
}
template <typename T = Type,
hb_enable_if (std::is_trivially_copy_assignable<T>::value)>
hb_enable_if (hb_is_trivially_copy_assignable(T))>
void
shift_down_vector (unsigned i)
{
@@ -280,7 +339,7 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
(length - i) * sizeof (Type));
}
template <typename T = Type,
hb_enable_if (!std::is_trivially_copy_assignable<T>::value)>
hb_enable_if (!hb_is_trivially_copy_assignable(T))>
void
shift_down_vector (unsigned i)
{
@@ -341,7 +400,7 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
Type pop ()
{
if (!length) return Null (Type);
Type v = std::move (arrayZ[length - 1]);
Type v = arrayZ[length - 1];
arrayZ[length - 1].~Type ();
length--;
return v;
@@ -351,8 +410,8 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
{
if (unlikely (i >= length))
return;
arrayZ[i].~Type ();
shift_down_vector (i + 1);
arrayZ[length - 1].~Type ();
length--;
}