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

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Oct 23 04:22:58 UTC 2018


 src/hb-atomic.hh              |    5 +----
 src/hb-common.cc              |    2 +-
 src/hb-ft.cc                  |    2 +-
 src/hb-null.hh                |    4 ++--
 src/hb-open-type.hh           |    6 ++----
 src/hb-ot-color-colr-table.hh |    2 +-
 src/hb-ot-color-cpal-table.hh |    8 ++------
 src/hb-static.cc              |    1 -
 src/hb.hh                     |    9 +++++++++
 9 files changed, 19 insertions(+), 20 deletions(-)

New commits:
commit 17ffbc070ff4190d8ebaf88f8db62f19e6fa370d
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Oct 22 21:22:25 2018 -0700

    [color] Use Index for colorIdx
    
    Doesn't matter, but matches the description.

diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh
index 7c5c35d8..b480af51 100644
--- a/src/hb-ot-color-colr-table.hh
+++ b/src/hb-ot-color-colr-table.hh
@@ -47,7 +47,7 @@ struct LayerRecord
 
   public:
   GlyphID	glyphId;	/* Glyph ID of layer glyph */
-  HBUINT16	colorIdx;	/* Index value to use with a
+  Index		colorIdx;	/* Index value to use with a
 				 * selected color palette.
 				 * An index value of 0xFFFF
 				 * is a special case indicating
commit 07386ea410af13e8fc844eb939a6c6e47c2adaf1
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Oct 22 21:18:27 2018 -0700

    Remove const and references when binding Null()
    
    Fixes https://github.com/harfbuzz/harfbuzz/issues/1299
    
    Removes anomaly I was seeing in cpal table trying to use implicit Null(NameID).

diff --git a/src/hb-atomic.hh b/src/hb-atomic.hh
index 5cb7ca5d..697de19c 100644
--- a/src/hb-atomic.hh
+++ b/src/hb-atomic.hh
@@ -278,14 +278,11 @@ struct hb_atomic_int_t
 };
 
 
-template <typename T> struct hb_remove_ptr_t { typedef T value; };
-template <typename T> struct hb_remove_ptr_t<T *> { typedef T value; };
-
 #define HB_ATOMIC_PTR_INIT(V)          {V}
 template <typename P>
 struct hb_atomic_ptr_t
 {
-  typedef typename hb_remove_ptr_t<P>::value T;
+  typedef typename hb_remove_pointer<P>::value T;
 
   inline void init (T* v_ = nullptr) { set_relaxed (v_); }
   inline void set_relaxed (T* v_) const { hb_atomic_ptr_impl_set_relaxed (&v, v_); }
diff --git a/src/hb-common.cc b/src/hb-common.cc
index ba48dd56..ccdb4dd9 100644
--- a/src/hb-common.cc
+++ b/src/hb-common.cc
@@ -761,7 +761,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_ptr_t<HB_LOCALE_T>::value,
+static struct hb_C_locale_lazy_loader_t : hb_lazy_loader_t<hb_remove_pointer<HB_LOCALE_T>::value,
 							  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 18fb72a7..fbf36268 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -737,7 +737,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_ptr_t<FT_Library>::value,
+static struct hb_ft_library_lazy_loader_t : hb_lazy_loader_t<hb_remove_pointer<FT_Library>::value,
 							     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 87662265..3d8a1ae6 100644
--- a/src/hb-null.hh
+++ b/src/hb-null.hh
@@ -47,7 +47,7 @@ static inline Type const & Null (void) {
   static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE.");
   return *reinterpret_cast<Type const *> (_hb_NullPool);
 }
-#define Null(Type) Null<Type>()
+#define Null(Type) Null<typename hb_remove_const<typename hb_remove_reference<Type>::value>::value>()
 
 /* Specializations for arbitrary-content Null objects expressed in bytes. */
 #define DECLARE_NULL_NAMESPACE_BYTES(Namespace, Type) \
@@ -90,7 +90,7 @@ static inline Type& Crap (void) {
   *obj = Null(Type);
   return *obj;
 }
-#define Crap(Type) Crap<Type>()
+#define Crap(Type) Crap<typename hb_remove_const<typename hb_remove_reference<Type>::value>::value>()
 
 template <typename Type>
 struct CrapOrNull {
diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh
index dc2f1f7c..19081447 100644
--- a/src/hb-open-type.hh
+++ b/src/hb-open-type.hh
@@ -149,16 +149,14 @@ struct Tag : HBUINT32
 /* Glyph index number, same as uint16 (length = 16 bits) */
 typedef HBUINT16 GlyphID;
 
-/* Name-table index, same as uint16 (length = 16 bits) */
-struct NameID : HBUINT16 {};
-DECLARE_NULL_NAMESPACE_BYTES (OT, NameID);
-
 /* Script/language-system/feature index */
 struct Index : HBUINT16 {
   enum { NOT_FOUND_INDEX = 0xFFFFu };
 };
 DECLARE_NULL_NAMESPACE_BYTES (OT, Index);
 
+typedef Index NameID;
+
 /* Offset, Null offset = 0 */
 template <typename Type, bool has_null=true>
 struct Offset : Type
diff --git a/src/hb-ot-color-cpal-table.hh b/src/hb-ot-color-cpal-table.hh
index 3f2165c4..7dd0c0f9 100644
--- a/src/hb-ot-color-cpal-table.hh
+++ b/src/hb-ot-color-cpal-table.hh
@@ -63,9 +63,7 @@ struct CPALV1Tail
 		       unsigned int palette_index,
 		       unsigned int palette_count) const
   {
-    /* XXX the Null(NameID) returned by hb_array_t is wrong. Figure out why
-     * and remove the explicit bound check. */
-    if (!paletteLabelsZ || palette_index >= palette_count) return HB_NAME_ID_INVALID;
+    if (!paletteLabelsZ) return HB_NAME_ID_INVALID;
     return hb_array_t<const NameID> ((base+paletteLabelsZ).arrayZ, palette_count)[palette_index];
   }
 
@@ -74,9 +72,7 @@ struct CPALV1Tail
 		     unsigned int color_index,
 		     unsigned int color_count) const
   {
-    /* XXX the Null(NameID) returned by hb_array_t is wrong. Figure out why
-     * and remove the explicit bound check. */
-    if (!colorLabelsZ || color_index >= color_count) return HB_NAME_ID_INVALID;
+    if (!colorLabelsZ) return HB_NAME_ID_INVALID;
     return hb_array_t<const NameID> ((base+colorLabelsZ).arrayZ, color_count)[color_index];
   }
 
diff --git a/src/hb-static.cc b/src/hb-static.cc
index 53889a5a..e5507960 100644
--- a/src/hb-static.cc
+++ b/src/hb-static.cc
@@ -40,7 +40,6 @@
 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)] = {};
 /*thread_local*/ hb_vector_size_impl_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {};
 
-DEFINE_NULL_NAMESPACE_BYTES (OT, NameID) =  {0xFF,0xFF};
 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};
diff --git a/src/hb.hh b/src/hb.hh
index 098b5660..ea474298 100644
--- a/src/hb.hh
+++ b/src/hb.hh
@@ -495,6 +495,15 @@ _hb_memalign(void **memptr, size_t alignment, size_t size)
 #define HB_SCRIPT_MYANMAR_ZAWGYI	((hb_script_t) HB_TAG ('Q','a','a','g'))
 
 
+/* 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; };
+template <typename T> struct hb_remove_reference { typedef T value; };
+template <typename T> struct hb_remove_reference<T &> { typedef T value; };
+template <typename T> struct hb_remove_pointer { typedef T value; };
+template <typename T> struct hb_remove_pointer<T *> { typedef T value; };
+
+
 /* Headers we include for everyone.  Keep sorted.  They express dependency amongst
  * themselves, but no other file should include them.*/
 #include "hb-atomic.hh"


More information about the HarfBuzz mailing list