[buffer] Add assert_unicode()/assert_glyphs() and use internally
This commit is contained in:
parent
5ef0613909
commit
77e704d1db
|
@ -476,8 +476,7 @@ hb_buffer_serialize_glyphs (hb_buffer_t *buffer,
|
|||
if (buf_size)
|
||||
*buf = '\0';
|
||||
|
||||
assert ((!buffer->len && (buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID)) ||
|
||||
(buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS));
|
||||
buffer->assert_glyphs ();
|
||||
|
||||
if (!buffer->have_positions)
|
||||
flags |= HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS;
|
||||
|
@ -574,8 +573,7 @@ hb_buffer_serialize_unicode (hb_buffer_t *buffer,
|
|||
if (buf_size)
|
||||
*buf = '\0';
|
||||
|
||||
assert ((!buffer->len && (buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID)) ||
|
||||
(buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE));
|
||||
buffer->assert_unicode ();
|
||||
|
||||
if (unlikely (start == end))
|
||||
return 0;
|
||||
|
@ -749,8 +747,7 @@ hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
|
|||
end_ptr = &end;
|
||||
*end_ptr = buf;
|
||||
|
||||
assert ((!buffer->len && (buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID)) ||
|
||||
(buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS));
|
||||
buffer->assert_glyphs ();
|
||||
|
||||
if (unlikely (hb_object_is_immutable (buffer)))
|
||||
{
|
||||
|
@ -819,9 +816,7 @@ hb_buffer_deserialize_unicode (hb_buffer_t *buffer,
|
|||
end_ptr = &end;
|
||||
*end_ptr = buf;
|
||||
|
||||
assert ((!buffer->len && (buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID)) ||
|
||||
(buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE));
|
||||
|
||||
buffer->assert_unicode ();
|
||||
|
||||
if (unlikely (hb_object_is_immutable (buffer)))
|
||||
{
|
||||
|
|
|
@ -617,8 +617,7 @@ hb_buffer_t::unsafe_to_break_from_outbuffer (unsigned int start, unsigned int en
|
|||
void
|
||||
hb_buffer_t::guess_segment_properties ()
|
||||
{
|
||||
assert ((content_type == HB_BUFFER_CONTENT_TYPE_UNICODE) ||
|
||||
(!len && (content_type == HB_BUFFER_CONTENT_TYPE_INVALID)));
|
||||
assert_unicode ();
|
||||
|
||||
/* If script is set to INVALID, guess from buffer contents */
|
||||
if (props.script == HB_SCRIPT_INVALID) {
|
||||
|
@ -1532,8 +1531,7 @@ hb_buffer_add_utf (hb_buffer_t *buffer,
|
|||
typedef typename utf_t::codepoint_t T;
|
||||
const hb_codepoint_t replacement = buffer->replacement;
|
||||
|
||||
assert ((buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE) ||
|
||||
(!buffer->len && (buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID)));
|
||||
buffer->assert_unicode ();
|
||||
|
||||
if (unlikely (hb_object_is_immutable (buffer)))
|
||||
return;
|
||||
|
@ -1853,8 +1851,8 @@ void
|
|||
hb_buffer_normalize_glyphs (hb_buffer_t *buffer)
|
||||
{
|
||||
assert (buffer->have_positions);
|
||||
assert ((buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS) ||
|
||||
(!buffer->len && (buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID)));
|
||||
|
||||
buffer->assert_glyphs ();
|
||||
|
||||
bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction);
|
||||
|
||||
|
|
|
@ -339,6 +339,16 @@ struct hb_buffer_t
|
|||
bool ensure_inplace (unsigned int size)
|
||||
{ return likely (!size || size < allocated); }
|
||||
|
||||
void assert_glyphs ()
|
||||
{
|
||||
assert ((content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS) ||
|
||||
(!len && (content_type == HB_BUFFER_CONTENT_TYPE_INVALID)));
|
||||
}
|
||||
void assert_unicode ()
|
||||
{
|
||||
assert ((content_type == HB_BUFFER_CONTENT_TYPE_UNICODE) ||
|
||||
(!len && (content_type == HB_BUFFER_CONTENT_TYPE_INVALID)));
|
||||
}
|
||||
bool ensure_glyphs ()
|
||||
{
|
||||
if (unlikely (content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS))
|
||||
|
|
|
@ -401,7 +401,8 @@ _hb_shape_plan_execute_internal (hb_shape_plan_t *shape_plan,
|
|||
return true;
|
||||
|
||||
assert (!hb_object_is_immutable (buffer));
|
||||
assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE);
|
||||
|
||||
buffer->assert_unicode ();
|
||||
|
||||
if (unlikely (hb_object_is_inert (shape_plan)))
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue