[buffer] Add ensure_glyphs()/ensure_unicode()

Use in deserialize. To be used more.
This commit is contained in:
Behdad Esfahbod 2020-10-15 01:54:28 -06:00
parent 84dd65a874
commit 5ef0613909
5 changed files with 1269 additions and 1582 deletions

File diff suppressed because it is too large Load Diff

View File

@ -52,25 +52,8 @@ action tok {
tok = p;
}
action ensure_glyphs {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS))
{
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
return false;
assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS;
}
}
action ensure_unicode {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_UNICODE))
{
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
return false;
assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE;
}
}
action ensure_glyphs { if (unlikely (!buffer->ensure_glyphs ())) return false; }
action ensure_unicode { if (unlikely (!buffer->ensure_unicode ())) return false; }
action parse_glyph_name {
/* TODO Unescape \" and \\ if found. */

File diff suppressed because it is too large Load Diff

View File

@ -52,25 +52,8 @@ action tok {
tok = p;
}
action ensure_glyphs {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS))
{
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
return false;
assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS;
}
}
action ensure_unicode {
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_UNICODE))
{
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
return false;
assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE;
}
}
action ensure_glyphs { if (unlikely (!buffer->ensure_glyphs ())) return false; }
action ensure_unicode { if (unlikely (!buffer->ensure_unicode ())) return false; }
action parse_glyph {
/* TODO Unescape delimeters. */

View File

@ -339,6 +339,29 @@ struct hb_buffer_t
bool ensure_inplace (unsigned int size)
{ return likely (!size || size < allocated); }
bool ensure_glyphs ()
{
if (unlikely (content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS))
{
if (content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
return false;
assert (len == 0);
content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS;
}
return true;
}
bool ensure_unicode ()
{
if (unlikely (content_type != HB_BUFFER_CONTENT_TYPE_UNICODE))
{
if (content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
return false;
assert (len == 0);
content_type = HB_BUFFER_CONTENT_TYPE_UNICODE;
}
return true;
}
HB_INTERNAL bool make_room_for (unsigned int num_in, unsigned int num_out);
HB_INTERNAL bool shift_forward (unsigned int count);