[aat] Another try at fixing Lookup null objects...
authorBehdad Esfahbod <behdad@behdad.org>
Thu, 18 Oct 2018 04:41:25 +0000 (21:41 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Thu, 18 Oct 2018 04:45:27 +0000 (21:45 -0700)
Ugly as hell, and don't even understand why some bits are needed.
But the logic is sound.

src/hb-aat-layout-common.hh
src/hb-static.cc

index 37f6d03..741e502 100644 (file)
@@ -291,10 +291,27 @@ struct Lookup
   LookupFormat8<T>     format8;
   } u;
   public:
-  DEFINE_SIZE_MIN (0); /* 0 min size, makes sure this cannot be used on null pool,
-                       * because Format0 has unbounded size depending on num_glyphs.
-                       * We cannot define custom null bytes for a template :(. */
+  DEFINE_SIZE_UNION (2, format);
 };
+/* Lookup 0 has unbounded size (dependant on num_glyphs).  So we need to defined
+ * special NULL objects for Lookup<> objects, but since it's template our macros
+ * don't work.  So we have to hand-code them here.  UGLY. */
+} /* Close namespace. */
+/* Ugly hand-coded null objects for template Lookup<> :(. */
+extern HB_INTERNAL const unsigned char _hb_Null_AAT_Lookup[2];
+template <>
+/*static*/ inline const AAT::Lookup<OT::HBUINT16>& Null<AAT::Lookup<OT::HBUINT16> > (void) {
+  return *reinterpret_cast<const AAT::Lookup<OT::HBUINT16> *> (_hb_Null_AAT_Lookup);
+}
+template <>
+/*static*/ inline const AAT::Lookup<OT::HBUINT32>& Null<AAT::Lookup<OT::HBUINT32> > (void) {
+  return *reinterpret_cast<const AAT::Lookup<OT::HBUINT32> *> (_hb_Null_AAT_Lookup);
+}
+template <>
+/*static*/ inline const AAT::Lookup<OT::Offset<OT::HBUINT16, false>>& Null<AAT::Lookup<OT::Offset<OT::HBUINT16, false>> > (void) {
+  return *reinterpret_cast<const AAT::Lookup<OT::Offset<OT::HBUINT16, false>> *> (_hb_Null_AAT_Lookup);
+}
+namespace AAT {
 
 
 /*
index 5112d77..0b92443 100644 (file)
@@ -41,6 +41,10 @@ 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};
+/* Hand-coded because Lookup is a template.
+ * Not sure why I need the extern "C" :(.
+ * Sad. */
+extern "C" HB_INTERNAL const unsigned char _hb_Null_AAT_Lookup[2] = {0xFF, 0xFF};
 
 
 void