From 88fdeeecc0ef57e41219d92c90f35f13cbd3a35e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 2 May 2019 14:14:33 -0700 Subject: [PATCH] [serialize] Take arguments in copy() --- src/hb-open-type.hh | 6 +++--- src/hb-serialize.hh | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 17e8d2a..cd80b3a 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -305,8 +305,8 @@ struct OffsetTo : Offset return ret; } - template - bool serialize_copy (hb_serialize_context_t *c, const T &src, const void *base) + template + bool serialize_copy (hb_serialize_context_t *c, const T &src, const void *base, Ts &&...ds) { *this = 0; if (has_null && &src == &Null (T)) @@ -314,7 +314,7 @@ struct OffsetTo : Offset c->push (); - c->copy (src); + c->copy (src, hb_forward (ds)...); c->add_link (*this, c->pop_pack (), base); } diff --git a/src/hb-serialize.hh b/src/hb-serialize.hh index 7566881..61195a4 100644 --- a/src/hb-serialize.hh +++ b/src/hb-serialize.hh @@ -366,8 +366,9 @@ struct hb_serialize_context_t return ret; } - template auto - _copy (const Type &obj, hb_priority<1>) const HB_RETURN (Type *, obj.copy (this)) + template auto + _copy (const Type &obj, hb_priority<1>, Ts &&...ds) const HB_RETURN + (Type *, obj.copy (this, hb_forward (ds)...)) template auto _copy (const Type &obj, hb_priority<0>) const -> decltype (&(obj = obj)) @@ -380,8 +381,9 @@ struct hb_serialize_context_t /* Like embed, but active: calls obj.operator=() or obj.copy() to transfer data * instead of memcpy(). */ - template - Type *copy (const Type &obj) { return _copy (obj, hb_prioritize); } + template + Type *copy (const Type &obj, Ts &&...ds) + { return _copy (obj, hb_prioritize, hb_forward (ds)...); } template hb_serialize_context_t &operator << (const Type &obj) { embed (obj); return *this; } -- 2.7.4