[serialize] Add a couple small methods
This commit is contained in:
parent
d1f29908c2
commit
22acd424ca
|
@ -443,6 +443,7 @@ struct hb_serialize_context_t
|
||||||
this->debug_depth = 0;
|
this->debug_depth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* To be called around main operation. */
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
inline Type *start_serialize (void)
|
inline Type *start_serialize (void)
|
||||||
{
|
{
|
||||||
|
@ -453,7 +454,6 @@ struct hb_serialize_context_t
|
||||||
|
|
||||||
return start_embed<Type> ();
|
return start_embed<Type> ();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void end_serialize (void)
|
inline void end_serialize (void)
|
||||||
{
|
{
|
||||||
DEBUG_MSG_LEVEL (SERIALIZE, this->start, 0, -1,
|
DEBUG_MSG_LEVEL (SERIALIZE, this->start, 0, -1,
|
||||||
|
@ -463,6 +463,22 @@ struct hb_serialize_context_t
|
||||||
this->ran_out_of_room ? "RAN OUT OF ROOM" : "did not ran out of room");
|
this->ran_out_of_room ? "RAN OUT OF ROOM" : "did not ran out of room");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline unsigned int length (void) const { return this->head - this->start; }
|
||||||
|
|
||||||
|
inline void align (unsigned int alignment)
|
||||||
|
{
|
||||||
|
unsigned int l = length () % alignment;
|
||||||
|
if (l)
|
||||||
|
allocate_size<void> (alignment - l);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Type>
|
||||||
|
inline Type *start_embed (void)
|
||||||
|
{
|
||||||
|
Type *ret = reinterpret_cast<Type *> (this->head);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
inline Type *allocate_size (unsigned int size)
|
inline Type *allocate_size (unsigned int size)
|
||||||
{
|
{
|
||||||
|
@ -482,13 +498,6 @@ struct hb_serialize_context_t
|
||||||
return this->allocate_size<Type> (Type::min_size);
|
return this->allocate_size<Type> (Type::min_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
|
||||||
inline Type *start_embed (void)
|
|
||||||
{
|
|
||||||
Type *ret = reinterpret_cast<Type *> (this->head);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
inline Type *embed (const Type &obj)
|
inline Type *embed (const Type &obj)
|
||||||
{
|
{
|
||||||
|
|
|
@ -161,8 +161,7 @@ typedef struct OffsetTable
|
||||||
memcpy (start, hb_blob_get_data (blob, nullptr), rec.length);
|
memcpy (start, hb_blob_get_data (blob, nullptr), rec.length);
|
||||||
|
|
||||||
/* 4-byte allignment. */
|
/* 4-byte allignment. */
|
||||||
if (rec.length % 4)
|
c->align (4);
|
||||||
c->allocate_size<void> (4 - rec.length % 4);
|
|
||||||
const char *end = (const char *) c->head;
|
const char *end = (const char *) c->head;
|
||||||
|
|
||||||
if (tags[i] == HB_OT_TAG_head && end - start >= head::static_size)
|
if (tags[i] == HB_OT_TAG_head && end - start >= head::static_size)
|
||||||
|
|
|
@ -1312,6 +1312,7 @@ struct GSUB : GSUBGPOS
|
||||||
inline bool subset (hb_subset_context_t<Serializer> *c)
|
inline bool subset (hb_subset_context_t<Serializer> *c)
|
||||||
{
|
{
|
||||||
TRACE_SUBSET (this);
|
TRACE_SUBSET (this);
|
||||||
|
//struct GSUB *out = c->serializer->start_embed<GSUB> ();
|
||||||
//XXX if (unlikely (!GSUBGPOS::subset (c))) return_trace (false);
|
//XXX if (unlikely (!GSUBGPOS::subset (c))) return_trace (false);
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue