[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; tok = p;
} }
action ensure_glyphs { action ensure_glyphs { if (unlikely (!buffer->ensure_glyphs ())) return false; }
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS)) action ensure_unicode { if (unlikely (!buffer->ensure_unicode ())) return false; }
{
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 parse_glyph_name { action parse_glyph_name {
/* TODO Unescape \" and \\ if found. */ /* 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; tok = p;
} }
action ensure_glyphs { action ensure_glyphs { if (unlikely (!buffer->ensure_glyphs ())) return false; }
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS)) action ensure_unicode { if (unlikely (!buffer->ensure_unicode ())) return false; }
{
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 parse_glyph { action parse_glyph {
/* TODO Unescape delimeters. */ /* TODO Unescape delimeters. */

View File

@ -339,6 +339,29 @@ struct hb_buffer_t
bool ensure_inplace (unsigned int size) bool ensure_inplace (unsigned int size)
{ return likely (!size || size < allocated); } { 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 make_room_for (unsigned int num_in, unsigned int num_out);
HB_INTERNAL bool shift_forward (unsigned int count); HB_INTERNAL bool shift_forward (unsigned int count);