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

Behdad Esfahbod behdad at kemper.freedesktop.org
Thu Nov 22 23:08:52 UTC 2018


 src/hb-null.hh          |    2 +-
 src/hb-open-type.hh     |   19 +++++++++++++++++--
 src/hb-ot-glyf-table.hh |    8 ++++++--
 3 files changed, 24 insertions(+), 5 deletions(-)

New commits:
commit e866910579e9cdc5b1ffa2e401fd0c056d44ca6a
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Nov 22 18:07:59 2018 -0500

    Enforce requiring null_size even if min_size is 0
    
    This concludes null-size enforcement changes

diff --git a/src/hb-null.hh b/src/hb-null.hh
index b87775b6..58151d72 100644
--- a/src/hb-null.hh
+++ b/src/hb-null.hh
@@ -50,7 +50,7 @@ template <typename T, typename B>
 struct _hb_null_size
 { enum { value = sizeof (T) }; };
 template <typename T>
-struct _hb_null_size<T, _hb_bool_type<(bool) (int) T::min_size> >
+struct _hb_null_size<T, _hb_bool_type<(bool) (1 + (unsigned int) T::min_size)> >
 { enum { value = T::null_size }; };
 
 template <typename T>
commit 4d4fd64ff47da04a7008d410c92e8fb4ad970781
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Nov 22 18:07:36 2018 -0500

    Allow non-nullable OffsetTo<> to non-Null'able objects

diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh
index 0ecd3c6b..f4a9a5e8 100644
--- a/src/hb-open-type.hh
+++ b/src/hb-open-type.hh
@@ -231,17 +231,31 @@ struct FixedVersion
  * Use: (base+offset)
  */
 
+template <typename Type, bool has_null>
+struct _hb_has_null
+{
+  static inline const Type *get_null (void) { return nullptr; }
+  static inline Type *get_crap (void) { return nullptr; }
+};
+template <typename Type>
+struct _hb_has_null<Type, true>
+{
+  static inline const Type *get_null (void) { return &Null(Type); }
+  static inline Type *get_crap (void) { return &Crap(Type); }
+};
+
 template <typename Type, typename OffsetType=HBUINT16, bool has_null=true>
 struct OffsetTo : Offset<OffsetType, has_null>
 {
   inline const Type& operator () (const void *base) const
   {
-    if (unlikely (this->is_null ())) return Null (Type);
+    if (unlikely (this->is_null ())) return *_hb_has_null<Type, has_null>::get_null ();
     return StructAtOffset<const Type> (base, *this);
   }
   inline Type& operator () (void *base) const
   {
     if (unlikely (this->is_null ())) return Crap (Type);
+    if (unlikely (this->is_null ())) return *_hb_has_null<Type, has_null>::get_crap ();
     return StructAtOffset<Type> (base, *this);
   }
 
commit fa9f585ec53bc7145d3bed1a4bd756d64dae1e55
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Nov 22 17:56:51 2018 -0500

    [glyf] Don't mark structs UNBOUNDED
    
    See comments.

diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh
index a3ef1ad0..c88f4338 100644
--- a/src/hb-ot-glyf-table.hh
+++ b/src/hb-ot-glyf-table.hh
@@ -56,7 +56,9 @@ struct loca
   protected:
   UnsizedArrayOf<HBUINT8>	dataZ;		/* Location data. */
   public:
-  DEFINE_SIZE_UNBOUNDED (0);
+  DEFINE_SIZE_MIN (0); /* In reality, this is UNBOUNDED() type; but since we always
+			* check the size externally, allow Null() object of it by
+			* defining it MIN() instead. */
 };
 
 
@@ -465,7 +467,9 @@ struct glyf
   protected:
   UnsizedArrayOf<HBUINT8>	dataZ;		/* Glyphs data. */
   public:
-  DEFINE_SIZE_UNBOUNDED (0);
+  DEFINE_SIZE_MIN (0); /* In reality, this is UNBOUNDED() type; but since we always
+			* check the size externally, allow Null() object of it by
+			* defining it MIN() instead. */
 };
 
 struct glyf_accelerator_t : glyf::accelerator_t {};
commit f47a60a7543dbaf41086c25a1a22ae518d8b92a9
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Nov 22 17:53:29 2018 -0500

    Mark UnsizedArrayOf<> as UNBOUNDED
    
    Since min_size is 0, Null() still accepts this type.

diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh
index 41169664..0ecd3c6b 100644
--- a/src/hb-open-type.hh
+++ b/src/hb-open-type.hh
@@ -317,6 +317,7 @@ struct OffsetTo : Offset<OffsetType, has_null>
   DEFINE_SIZE_STATIC (sizeof (OffsetType));
 };
 template <typename Type, bool has_null=true> struct LOffsetTo : OffsetTo<Type, HBUINT32, has_null> {};
+
 template <typename Base, typename OffsetType, bool has_null, typename Type>
 static inline const Type& operator + (const Base &base, const OffsetTo<Type, OffsetType, has_null> &offset) { return offset (base); }
 template <typename Base, typename OffsetType, bool has_null, typename Type>
@@ -401,7 +402,7 @@ struct UnsizedArrayOf
   public:
   Type		arrayZ[VAR];
   public:
-  DEFINE_SIZE_ARRAY (0, arrayZ);
+  DEFINE_SIZE_UNBOUNDED (0);
 };
 
 /* Unsized array of offset's */


More information about the HarfBuzz mailing list