[aat] Another try at fixing Lookup null objects...

Ugly as hell, and don't even understand why some bits are needed.
But the logic is sound.
This commit is contained in:
Behdad Esfahbod 2018-10-17 21:41:25 -07:00
parent 191eef823f
commit 9e8a9b846e
2 changed files with 24 additions and 3 deletions

View File

@ -291,10 +291,27 @@ struct Lookup
LookupFormat8<T> format8; LookupFormat8<T> format8;
} u; } u;
public: public:
DEFINE_SIZE_MIN (0); /* 0 min size, makes sure this cannot be used on null pool, DEFINE_SIZE_UNION (2, format);
* because Format0 has unbounded size depending on num_glyphs.
* We cannot define custom null bytes for a template :(. */
}; };
/* 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 {
/* /*

View 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, Index) = {0xFF,0xFF};
DEFINE_NULL_NAMESPACE_BYTES (OT, LangSys) = {0x00,0x00, 0xFF,0xFF, 0x00,0x00}; 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, 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 void