[HarfBuzz] harfbuzz: Branch 'master' - 9 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Sat Nov 24 05:33:07 UTC 2018


 src/hb-aat-layout-common.hh |    6 ++++--
 src/hb-atomic.hh            |    2 +-
 src/hb-blob.hh              |    4 ++--
 src/hb-common.cc            |    2 +-
 src/hb-dsalgs.hh            |    2 ++
 src/hb-ft.cc                |    2 +-
 src/hb-null.hh              |   30 +++++++++++++++++++++++++-----
 src/hb-open-file.hh         |    4 +---
 src/hb-open-type.hh         |    7 +++++++
 src/hb-ot-cmap-table.hh     |    1 +
 src/hb-static.cc            |    4 +++-
 src/hb-vector.hh            |   11 ++++++++---
 src/hb.hh                   |    3 +++
 13 files changed, 59 insertions(+), 19 deletions(-)

New commits:
commit bb2a2065080a3099eb0dc82d1df0891ad2601316
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Nov 24 00:31:40 2018 -0500

    Assert that item-type of arrays have static size

diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh
index da8aad01..c133a532 100644
--- a/src/hb-dsalgs.hh
+++ b/src/hb-dsalgs.hh
@@ -562,6 +562,8 @@ struct hb_bytes_t
 template <typename Type>
 struct hb_array_t
 {
+  static_assert ((bool) (unsigned) hb_static_size (Type), "");
+
   inline hb_array_t (void) : arrayZ (nullptr), len (0) {}
   inline hb_array_t (Type *array_, unsigned int len_) : arrayZ (array_), len (len_) {}
 
diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh
index 17bc9c5b..1c7b738b 100644
--- a/src/hb-open-type.hh
+++ b/src/hb-open-type.hh
@@ -345,6 +345,8 @@ static inline Type& operator + (Base &base, OffsetTo<Type, OffsetType, has_null>
 template <typename Type>
 struct UnsizedArrayOf
 {
+  static_assert ((bool) (unsigned) hb_static_size (Type), "");
+
   enum { item_size = Type::static_size };
 
   HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type);
@@ -449,6 +451,8 @@ struct UnsizedOffsetListOf : UnsizedOffsetArrayOf<Type, OffsetType, has_null>
 template <typename Type, typename LenType=HBUINT16>
 struct ArrayOf
 {
+  static_assert ((bool) (unsigned) hb_static_size (Type), "");
+
   enum { item_size = Type::static_size };
 
   HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (ArrayOf, Type, LenType);
diff --git a/src/hb-vector.hh b/src/hb-vector.hh
index 926f0054..c1d7f946 100644
--- a/src/hb-vector.hh
+++ b/src/hb-vector.hh
@@ -34,6 +34,8 @@
 template <typename Type, unsigned int PreallocedCount=8>
 struct hb_vector_t
 {
+  static_assert ((bool) (unsigned) hb_static_size (Type), "");
+
   typedef Type ItemType;
   enum { item_size = sizeof (Type) };
 
commit 690d9eb83d3421b397b0cb824cd768d6d73cbf12
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Nov 24 00:29:22 2018 -0500

    [vector] Rename

diff --git a/src/hb-vector.hh b/src/hb-vector.hh
index c1f680ed..926f0054 100644
--- a/src/hb-vector.hh
+++ b/src/hb-vector.hh
@@ -31,13 +31,13 @@
 #include "hb.hh"
 
 
-template <typename Type, unsigned int StaticSize=8>
+template <typename Type, unsigned int PreallocedCount=8>
 struct hb_vector_t
 {
   typedef Type ItemType;
   enum { item_size = sizeof (Type) };
 
-  HB_NO_COPY_ASSIGN_TEMPLATE2 (hb_vector_t, Type, StaticSize);
+  HB_NO_COPY_ASSIGN_TEMPLATE2 (hb_vector_t, Type, PreallocedCount);
   inline hb_vector_t (void) { init (); }
   inline ~hb_vector_t (void) { fini (); }
 
@@ -45,7 +45,7 @@ struct hb_vector_t
   private:
   unsigned int allocated; /* == 0 means allocation failed. */
   Type *arrayZ_;
-  Type static_array[StaticSize];
+  Type static_array[PreallocedCount];
   public:
 
   void init (void)
commit ba38378fd4374f3d44bdc9aa0de902401b60b13d
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Nov 24 00:27:57 2018 -0500

    [aat] Minor

diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh
index 7340996e..2c09a796 100644
--- a/src/hb-aat-layout-common.hh
+++ b/src/hb-aat-layout-common.hh
@@ -436,8 +436,10 @@ struct Entry
      * which ensures that data has a simple sanitize(). To be determined
      * if I need to remove that as well.
      *
-     * XXX Because we are a template, our DEFINE_SIZE_STATIC assertion
-     * wouldn't be checked. */
+     * HOWEVER! Because we are a template, our DEFINE_SIZE_STATIC
+     * assertion wouldn't be checked, hence the line below. */
+    static_assert (T::static_size, "");
+
     return_trace (c->check_struct (this));
   }
 
commit 39b9d63b014380d421cc9b94a49dd411c7a5aabf
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Nov 24 00:25:40 2018 -0500

    Add hb_static_size(T)

diff --git a/src/hb-null.hh b/src/hb-null.hh
index c0cefc9a..1583d5b9 100644
--- a/src/hb-null.hh
+++ b/src/hb-null.hh
@@ -44,6 +44,7 @@
 /* The hard way...
  * https://stackoverflow.com/questions/7776448/sfinae-tried-with-bool-gives-compiler-error-template-argument-tvalue-invol
  */
+
 template<bool> struct _hb_bool_type {};
 
 template <typename T, typename B>
@@ -58,6 +59,24 @@ struct hb_null_size
 { enum { value = _hb_null_size<T, _hb_bool_type<true> >::value }; };
 #define hb_null_size(T) hb_null_size<T>::value
 
+/* This doesn't belong here, but since is copy/paste from above, put it here. */
+
+template <typename T, typename B>
+struct _hb_static_size
+{ enum { value = sizeof (T) }; };
+template <typename T>
+struct _hb_static_size<T, _hb_bool_type<(bool) (1 + (unsigned int) T::min_size)> >
+{ enum { value = T::static_size }; };
+
+template <typename T>
+struct hb_static_size
+{ enum { value = _hb_static_size<T, _hb_bool_type<true> >::value }; };
+#define hb_static_size(T) hb_static_size<T>::value
+
+
+/*
+ * Null()
+ */
 extern HB_INTERNAL
 hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)];
 
commit f99abcc37990a478189dda691d1fdac7b9d51386
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Nov 24 00:22:21 2018 -0500

    Add template-function convenience macros

diff --git a/src/hb-atomic.hh b/src/hb-atomic.hh
index 64ed257b..265de126 100644
--- a/src/hb-atomic.hh
+++ b/src/hb-atomic.hh
@@ -282,7 +282,7 @@ struct hb_atomic_int_t
 template <typename P>
 struct hb_atomic_ptr_t
 {
-  typedef typename hb_remove_pointer<P>::value T;
+  typedef typename hb_remove_pointer (P) T;
 
   inline void init (T* v_ = nullptr) { set_relaxed (v_); }
   inline void set_relaxed (T* v_) { hb_atomic_ptr_impl_set_relaxed (&v, v_); }
diff --git a/src/hb-blob.hh b/src/hb-blob.hh
index 4f9d8f04..bf2132bd 100644
--- a/src/hb-blob.hh
+++ b/src/hb-blob.hh
@@ -60,7 +60,7 @@ struct hb_blob_t
   template <typename Type>
   inline const Type* as (void) const
   {
-    return length < hb_null_size<Type>::value ? &Null(Type) : reinterpret_cast<const Type *> (data);
+    return length < hb_null_size (Type) ? &Null(Type) : reinterpret_cast<const Type *> (data);
   }
   inline hb_bytes_t as_bytes (void) const
   {
@@ -86,7 +86,7 @@ struct hb_blob_t
 template <typename P>
 struct hb_blob_ptr_t
 {
-  typedef typename hb_remove_pointer<P>::value T;
+  typedef typename hb_remove_pointer (P) T;
 
   inline hb_blob_ptr_t (hb_blob_t *b_ = nullptr) : b (b_) {}
   inline hb_blob_t * operator = (hb_blob_t *b_) { return b = b_; }
diff --git a/src/hb-common.cc b/src/hb-common.cc
index b7f9ad68..c3cffccb 100644
--- a/src/hb-common.cc
+++ b/src/hb-common.cc
@@ -784,7 +784,7 @@ parse_uint32 (const char **pp, const char *end, uint32_t *pv)
 static void free_static_C_locale (void);
 #endif
 
-static struct hb_C_locale_lazy_loader_t : hb_lazy_loader_t<hb_remove_pointer<HB_LOCALE_T>::value,
+static struct hb_C_locale_lazy_loader_t : hb_lazy_loader_t<hb_remove_pointer (HB_LOCALE_T),
 							  hb_C_locale_lazy_loader_t>
 {
   static inline HB_LOCALE_T create (void)
diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index fff0e285..633e0ecd 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -748,7 +748,7 @@ hb_ft_font_create_referenced (FT_Face ft_face)
 static void free_static_ft_library (void);
 #endif
 
-static struct hb_ft_library_lazy_loader_t : hb_lazy_loader_t<hb_remove_pointer<FT_Library>::value,
+static struct hb_ft_library_lazy_loader_t : hb_lazy_loader_t<hb_remove_pointer (FT_Library),
 							     hb_ft_library_lazy_loader_t>
 {
   static inline FT_Library create (void)
diff --git a/src/hb-null.hh b/src/hb-null.hh
index 58151d72..c0cefc9a 100644
--- a/src/hb-null.hh
+++ b/src/hb-null.hh
@@ -56,6 +56,7 @@ struct _hb_null_size<T, _hb_bool_type<(bool) (1 + (unsigned int) T::min_size)> >
 template <typename T>
 struct hb_null_size
 { enum { value = _hb_null_size<T, _hb_bool_type<true> >::value }; };
+#define hb_null_size(T) hb_null_size<T>::value
 
 extern HB_INTERNAL
 hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)];
@@ -63,10 +64,10 @@ hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_
 /* Generic nul-content Null objects. */
 template <typename Type>
 static inline Type const & Null (void) {
-  static_assert (hb_null_size<Type>::value <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE.");
+  static_assert (hb_null_size (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE.");
   return *reinterpret_cast<Type const *> (_hb_NullPool);
 }
-#define Null(Type) Null<typename hb_remove_const<typename hb_remove_reference<Type>::value>::value>()
+#define Null(Type) Null<typename hb_remove_const (typename hb_remove_reference (Type))> ()
 
 /* Specializations for arbitrary-content Null objects expressed in bytes. */
 #define DECLARE_NULL_NAMESPACE_BYTES(Namespace, Type) \
@@ -104,12 +105,12 @@ extern HB_INTERNAL
 /* CRAP pool: Common Region for Access Protection. */
 template <typename Type>
 static inline Type& Crap (void) {
-  static_assert (hb_null_size<Type>::value <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE.");
+  static_assert (hb_null_size (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE.");
   Type *obj = reinterpret_cast<Type *> (_hb_CrapPool);
   memcpy (obj, &Null(Type), sizeof (*obj));
   return *obj;
 }
-#define Crap(Type) Crap<typename hb_remove_const<typename hb_remove_reference<Type>::value>::value>()
+#define Crap(Type) Crap<typename hb_remove_const (typename hb_remove_reference (Type))> ()
 
 template <typename Type>
 struct CrapOrNull {
@@ -129,7 +130,7 @@ struct CrapOrNull<const Type> {
 template <typename P>
 struct hb_nonnull_ptr_t
 {
-  typedef typename hb_remove_pointer<P>::value T;
+  typedef typename hb_remove_pointer (P) T;
 
   inline hb_nonnull_ptr_t (T *v_ = nullptr) : v (v_) {}
   inline T * operator = (T *v_) { return v = v_; }
diff --git a/src/hb.hh b/src/hb.hh
index bc322a81..c771d1fb 100644
--- a/src/hb.hh
+++ b/src/hb.hh
@@ -508,10 +508,13 @@ _hb_memalign(void **memptr, size_t alignment, size_t size)
 /* Some really basic things everyone wants. */
 template <typename T> struct hb_remove_const { typedef T value; };
 template <typename T> struct hb_remove_const<const T> { typedef T value; };
+#define hb_remove_const(T) hb_remove_const<T>::value
 template <typename T> struct hb_remove_reference { typedef T value; };
 template <typename T> struct hb_remove_reference<T &> { typedef T value; };
+#define hb_remove_reference(T) hb_remove_reference<T>::value
 template <typename T> struct hb_remove_pointer { typedef T value; };
 template <typename T> struct hb_remove_pointer<T *> { typedef T value; };
+#define hb_remove_pointer(T) hb_remove_pointer<T>::value
 
 
 /* Headers we include for everyone.  Keep sorted.  They express dependency amongst
commit ec83b2228e0bbb6df7e7b94dad49db32b041af4a
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Nov 23 19:58:49 2018 -0500

    Add null bytes for CmapSubtableLongGroup

diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh
index 4297550f..70373ee8 100644
--- a/src/hb-ot-cmap-table.hh
+++ b/src/hb-ot-cmap-table.hh
@@ -417,6 +417,7 @@ struct CmapSubtableLongGroup
   public:
   DEFINE_SIZE_STATIC (12);
 };
+DECLARE_NULL_NAMESPACE_BYTES (OT, CmapSubtableLongGroup);
 
 template <typename UINT>
 struct CmapSubtableTrimmed
diff --git a/src/hb-static.cc b/src/hb-static.cc
index 73d9528e..3ea64024 100644
--- a/src/hb-static.cc
+++ b/src/hb-static.cc
@@ -27,10 +27,11 @@
 #include "hb.hh"
 
 #include "hb-open-type.hh"
-#include "hb-ot-layout-common.hh"
 #include "hb-aat-layout-common.hh"
+#include "hb-ot-layout-common.hh"
 
 #include "hb-face.hh"
+#include "hb-ot-cmap-table.hh"
 #include "hb-ot-head-table.hh"
 #include "hb-ot-maxp-table.hh"
 
@@ -42,6 +43,7 @@ hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_
 DEFINE_NULL_NAMESPACE_BYTES (OT, Index) =  {0xFF,0xFF};
 DEFINE_NULL_NAMESPACE_BYTES (OT, LangSys) = {0x00,0x00, 0xFF,0xFF, 0x00,0x00};
 DEFINE_NULL_NAMESPACE_BYTES (OT, RangeRecord) = {0x00,0x01, 0x00,0x00, 0x00, 0x00};
+DEFINE_NULL_NAMESPACE_BYTES (OT, CmapSubtableLongGroup) = {0x00,0x00,0x00,0x01, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00};
 /* Hand-coded because Lookup is a template.  Sad. */
 const unsigned char _hb_Null_AAT_Lookup[2] = {0xFF, 0xFF};
 
commit e2ffb33a534a427c760dae53d0469eeced4343ba
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Nov 23 16:24:28 2018 -0500

    Remove lsearch for small TableDirectorys

diff --git a/src/hb-open-file.hh b/src/hb-open-file.hh
index 2ef6d775..cd5f9dbc 100644
--- a/src/hb-open-file.hh
+++ b/src/hb-open-file.hh
@@ -111,9 +111,7 @@ typedef struct OffsetTable
   {
     Tag t;
     t.set (tag);
-    /* Linear-search for small tables to work around fonts with unsorted
-     * table list. */
-    int i = tables.len < 64 ? tables.lsearch (t) : tables.bsearch (t);
+    int i = tables.bsearch (t);
     if (table_index)
       *table_index = i == -1 ? (unsigned) Index::NOT_FOUND_INDEX : (unsigned) i;
     return i != -1;
commit 04f7e5536924e7f277d72b8cb9d878239877c331
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Nov 23 16:07:43 2018 -0500

    [arrays] Add as_array() to hb_vector_t<>

diff --git a/src/hb-vector.hh b/src/hb-vector.hh
index 7056a5b5..c1f680ed 100644
--- a/src/hb-vector.hh
+++ b/src/hb-vector.hh
@@ -89,6 +89,9 @@ struct hb_vector_t
     return arrayZ()[i];
   }
 
+  inline hb_array_t<Type> as_array (void) { return hb_array_t<Type> (arrayZ(), len); }
+  inline hb_array_t<const Type> as_array (void) const { return hb_array_t<const Type> (arrayZ(), len); }
+
   template <typename T> inline operator  T * (void) { return arrayZ(); }
   template <typename T> inline operator const T * (void) const { return arrayZ(); }
 
commit c514f65181390ab98b0f738632f71cda31e46b68
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Nov 23 16:04:56 2018 -0500

    [arrays] Add as_array() to ArrayOf<>

diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh
index f4a9a5e8..17bc9c5b 100644
--- a/src/hb-open-type.hh
+++ b/src/hb-open-type.hh
@@ -479,6 +479,9 @@ struct ArrayOf
   inline unsigned int get_size (void) const
   { return len.static_size + len * Type::static_size; }
 
+  inline hb_array_t<Type> as_array (void) { return hb_array_t<Type> (arrayZ, len); }
+  inline hb_array_t<const Type> as_array (void) const { return hb_array_t<const Type> (arrayZ, len); }
+
   inline bool serialize (hb_serialize_context_t *c,
 			 unsigned int items_len)
   {


More information about the HarfBuzz mailing list