From 88a41472404a8e7754e1099ca4a5b2146dae5298 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 2 May 2019 14:22:31 -0700 Subject: [PATCH] [serializer] Accept exact type in serialize_subset/copy() --- src/hb-open-type.hh | 12 ++++++------ src/hb-ot-layout-common.hh | 33 ++------------------------------- src/hb-ot-layout-gpos-table.hh | 6 ++++++ src/hb-ot-layout-gsub-table.hh | 6 ++++++ 4 files changed, 20 insertions(+), 37 deletions(-) diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index cd80b3a..808e182 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -284,11 +284,11 @@ struct OffsetTo : Offset return * (Type *) Offset::serialize (c, base); } - template - bool serialize_subset (hb_subset_context_t *c, const T &src, const void *base, Ts &&...ds) + template + bool serialize_subset (hb_subset_context_t *c, const Type &src, const void *base, Ts &&...ds) { *this = 0; - if (has_null && &src == &Null (T)) + if (has_null && &src == &Null (Type)) return false; auto *s = c->serializer; @@ -305,11 +305,11 @@ struct OffsetTo : Offset return ret; } - template - bool serialize_copy (hb_serialize_context_t *c, const T &src, const void *base, Ts &&...ds) + template + bool serialize_copy (hb_serialize_context_t *c, const Type &src, const void *base, Ts &&...ds) { *this = 0; - if (has_null && &src == &Null (T)) + if (has_null && &src == &Null (Type)) return false; c->push (); diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index c8dcc32..3089801 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -715,23 +715,6 @@ struct Lookup return_trace (true); } - /* Older compilers need this to NOT be locally defined in a function. */ - template - struct SubTableSubsetWrapper - { - SubTableSubsetWrapper (const TSubTable &subtable_, - unsigned int lookup_type_) : - subtable (subtable_), - lookup_type (lookup_type_) {} - - bool subset (hb_subset_context_t *c) const - { return subtable.dispatch (c, lookup_type); } - - private: - const TSubTable &subtable; - unsigned int lookup_type; - }; - template bool subset (hb_subset_context_t *c) const { @@ -746,23 +729,11 @@ struct Lookup OffsetArrayOf& out_subtables = out->get_subtables (); unsigned int count = subTable.len; for (unsigned int i = 0; i < count; i++) - { - SubTableSubsetWrapper wrapper (this+subtables[i], get_type ()); - - out_subtables[i].serialize_subset (c, wrapper, out); - } + out_subtables[i].serialize_subset (c, this+subtables[i], out, get_type ()); return_trace (true); } - /* Older compilers need this to NOT be locally defined in a function. */ - template - struct SubTableSanitizeWrapper : TSubTable - { - bool sanitize (hb_sanitize_context_t *c, unsigned int lookup_type) const - { return this->dispatch (c, lookup_type); } - }; - template bool sanitize (hb_sanitize_context_t *c) const { @@ -774,7 +745,7 @@ struct Lookup if (!markFilteringSet.sanitize (c)) return_trace (false); } - if (unlikely (!CastR>> (subTable) + if (unlikely (!CastR> (subTable) .sanitize (c, this, get_type ()))) return_trace (false); diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index 407ce9e..4b752fc 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1525,6 +1525,12 @@ struct PosLookupSubTable } } + /* XXX Remove? */ + bool subset (hb_subset_context_t *c, unsigned lookup_type) const + { return dispatch (c, lookup_type); } + bool sanitize (hb_sanitize_context_t *c, unsigned lookup_type) const + { return dispatch (c, lookup_type); } + protected: union { SinglePos single; diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index be78c1a..4a6f48f 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -1170,6 +1170,12 @@ struct SubstLookupSubTable } } + /* XXX Remove? */ + bool subset (hb_subset_context_t *c, unsigned lookup_type) const + { return dispatch (c, lookup_type); } + bool sanitize (hb_sanitize_context_t *c, unsigned lookup_type) const + { return dispatch (c, lookup_type); } + protected: union { SingleSubst single; -- 2.7.4