[serialize] Pass offset to serialize_copy()

This commit is contained in:
Behdad Esfahbod 2019-05-31 14:34:34 -07:00
parent 87dd4bff1c
commit 9260441624
4 changed files with 12 additions and 8 deletions

View File

@ -320,17 +320,21 @@ struct OffsetTo : Offset<OffsetType, has_null>
/* TODO: Somehow merge this with previous function into a serialize_dispatch(). */ /* TODO: Somehow merge this with previous function into a serialize_dispatch(). */
template <typename ...Ts> template <typename ...Ts>
bool serialize_copy (hb_serialize_context_t *c, const Type &src, const void *base, Ts&&... ds) bool serialize_copy (hb_serialize_context_t *c,
const OffsetTo& src,
const void *src_base,
const void *dst_base,
Ts&&... ds)
{ {
*this = 0; *this = 0;
if (has_null && &src == _hb_has_null<Type, has_null>::get_null ()) if (src.is_null ())
return false; return false;
c->push (); c->push ();
bool ret = c->copy (src, hb_forward<Ts> (ds)...); bool ret = c->copy (src_base+src, hb_forward<Ts> (ds)...);
c->add_link (*this, c->pop_pack (), base); c->add_link (*this, c->pop_pack (), dst_base);
return ret; return ret;
} }

View File

@ -279,10 +279,10 @@ struct Script
TRACE_SUBSET (this); TRACE_SUBSET (this);
auto *out = c->serializer->embed (*this); auto *out = c->serializer->embed (*this);
if (unlikely (!out)) return_trace (false); if (unlikely (!out)) return_trace (false);
out->defaultLangSys.serialize_copy (c->serializer, this+defaultLangSys, out); out->defaultLangSys.serialize_copy (c->serializer, defaultLangSys, this, out);
unsigned int count = langSys.len; unsigned int count = langSys.len;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
out->langSys.arrayZ[i].offset.serialize_copy (c->serializer, this+langSys[i].offset, out); out->langSys.arrayZ[i].offset.serialize_copy (c->serializer, langSys[i].offset, this, out);
return_trace (true); return_trace (true);
} }

View File

@ -2695,7 +2695,7 @@ struct GSUBGPOS
out); out);
if (version.to_int () >= 0x00010001u) if (version.to_int () >= 0x00010001u)
out->featureVars.serialize_copy (c->serializer, this+featureVars, out); out->featureVars.serialize_copy (c->serializer, featureVars, this, out);
return_trace (true); return_trace (true);
} }

View File

@ -104,7 +104,7 @@ struct NameRecord
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
auto *out = c->embed (this); auto *out = c->embed (this);
if (unlikely (!out)) return_trace (nullptr); if (unlikely (!out)) return_trace (nullptr);
out->offset.serialize_copy (c, src_base + offset, dst_base, length); out->offset.serialize_copy (c, offset, src_base, dst_base, length);
return_trace (out); return_trace (out);
} }