[serializer] Accept exact type in serialize_subset/copy()
This commit is contained in:
parent
88fdeeecc0
commit
88a4147240
|
@ -284,11 +284,11 @@ struct OffsetTo : Offset<OffsetType, has_null>
|
|||
return * (Type *) Offset<OffsetType>::serialize (c, base);
|
||||
}
|
||||
|
||||
template <typename T, typename ...Ts>
|
||||
bool serialize_subset (hb_subset_context_t *c, const T &src, const void *base, Ts &&...ds)
|
||||
template <typename ...Ts>
|
||||
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<OffsetType, has_null>
|
|||
return ret;
|
||||
}
|
||||
|
||||
template <typename T, typename ...Ts>
|
||||
bool serialize_copy (hb_serialize_context_t *c, const T &src, const void *base, Ts &&...ds)
|
||||
template <typename ...Ts>
|
||||
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 ();
|
||||
|
|
|
@ -715,23 +715,6 @@ struct Lookup
|
|||
return_trace (true);
|
||||
}
|
||||
|
||||
/* Older compilers need this to NOT be locally defined in a function. */
|
||||
template <typename TSubTable>
|
||||
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 <typename TSubTable>
|
||||
bool subset (hb_subset_context_t *c) const
|
||||
{
|
||||
|
@ -746,23 +729,11 @@ struct Lookup
|
|||
OffsetArrayOf<TSubTable>& out_subtables = out->get_subtables<TSubTable> ();
|
||||
unsigned int count = subTable.len;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
SubTableSubsetWrapper<TSubTable> 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 <typename TSubTable>
|
||||
struct SubTableSanitizeWrapper : TSubTable
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c, unsigned int lookup_type) const
|
||||
{ return this->dispatch (c, lookup_type); }
|
||||
};
|
||||
|
||||
template <typename TSubTable>
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
|
@ -774,7 +745,7 @@ struct Lookup
|
|||
if (!markFilteringSet.sanitize (c)) return_trace (false);
|
||||
}
|
||||
|
||||
if (unlikely (!CastR<OffsetArrayOf<SubTableSanitizeWrapper<TSubTable>>> (subTable)
|
||||
if (unlikely (!CastR<OffsetArrayOf<TSubTable>> (subTable)
|
||||
.sanitize (c, this, get_type ())))
|
||||
return_trace (false);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue