Rename hb_string_t to hb_bytes_t

This commit is contained in:
Behdad Esfahbod 2018-05-08 01:57:27 -07:00
parent bd021a6720
commit 08e280fd84
3 changed files with 17 additions and 17 deletions

View File

@ -141,7 +141,7 @@ struct post
inline bool get_glyph_name (hb_codepoint_t glyph, inline bool get_glyph_name (hb_codepoint_t glyph,
char *buf, unsigned int buf_len) const char *buf, unsigned int buf_len) const
{ {
hb_string_t s = find_glyph_name (glyph); hb_bytes_t s = find_glyph_name (glyph);
if (!s.len) if (!s.len)
return false; return false;
if (!buf_len) if (!buf_len)
@ -185,7 +185,7 @@ struct post
} }
} }
hb_string_t st (name, len); hb_bytes_t st (name, len);
const uint16_t *gid = (const uint16_t *) hb_bsearch_r (&st, gids, count, sizeof (gids[0]), cmp_key, (void *) this); const uint16_t *gid = (const uint16_t *) hb_bsearch_r (&st, gids, count, sizeof (gids[0]), cmp_key, (void *) this);
if (gid) if (gid)
{ {
@ -220,23 +220,23 @@ struct post
static inline int cmp_key (const void *pk, const void *po, void *arg) static inline int cmp_key (const void *pk, const void *po, void *arg)
{ {
const accelerator_t *thiz = (const accelerator_t *) arg; const accelerator_t *thiz = (const accelerator_t *) arg;
const hb_string_t *key = (const hb_string_t *) pk; const hb_bytes_t *key = (const hb_bytes_t *) pk;
uint16_t o = * (const uint16_t *) po; uint16_t o = * (const uint16_t *) po;
return thiz->find_glyph_name (o).cmp (*key); return thiz->find_glyph_name (o).cmp (*key);
} }
inline hb_string_t find_glyph_name (hb_codepoint_t glyph) const inline hb_bytes_t find_glyph_name (hb_codepoint_t glyph) const
{ {
if (version == 0x00010000) if (version == 0x00010000)
{ {
if (glyph >= NUM_FORMAT1_NAMES) if (glyph >= NUM_FORMAT1_NAMES)
return hb_string_t (); return hb_bytes_t ();
return format1_names (glyph); return format1_names (glyph);
} }
if (version != 0x00020000 || glyph >= glyphNameIndex->len) if (version != 0x00020000 || glyph >= glyphNameIndex->len)
return hb_string_t (); return hb_bytes_t ();
unsigned int index = glyphNameIndex->array[glyph]; unsigned int index = glyphNameIndex->array[glyph];
if (index < NUM_FORMAT1_NAMES) if (index < NUM_FORMAT1_NAMES)
@ -244,14 +244,14 @@ struct post
index -= NUM_FORMAT1_NAMES; index -= NUM_FORMAT1_NAMES;
if (index >= index_to_offset.len) if (index >= index_to_offset.len)
return hb_string_t (); return hb_bytes_t ();
unsigned int offset = index_to_offset.array[index]; unsigned int offset = index_to_offset.array[index];
const uint8_t *data = pool + offset; const uint8_t *data = pool + offset;
unsigned int name_length = *data; unsigned int name_length = *data;
data++; data++;
return hb_string_t ((const char *) data, name_length); return hb_bytes_t ((const char *) data, name_length);
} }
private: private:

View File

@ -1052,12 +1052,12 @@ hb_options (void)
/* String type. */ /* String type. */
struct hb_string_t struct hb_bytes_t
{ {
inline hb_string_t (void) : bytes (nullptr), len (0) {} inline hb_bytes_t (void) : bytes (nullptr), len (0) {}
inline hb_string_t (const char *bytes_, unsigned int len_) : bytes (bytes_), len (len_) {} inline hb_bytes_t (const char *bytes_, unsigned int len_) : bytes (bytes_), len (len_) {}
inline int cmp (const hb_string_t &a) const inline int cmp (const hb_bytes_t &a) const
{ {
if (len != a.len) if (len != a.len)
return (int) a.len - (int) len; return (int) a.len - (int) len;
@ -1066,8 +1066,8 @@ struct hb_string_t
} }
static inline int cmp (const void *pa, const void *pb) static inline int cmp (const void *pa, const void *pb)
{ {
hb_string_t *a = (hb_string_t *) pa; hb_bytes_t *a = (hb_bytes_t *) pa;
hb_string_t *b = (hb_string_t *) pb; hb_bytes_t *b = (hb_bytes_t *) pb;
return b->cmp (*a); return b->cmp (*a);
} }

View File

@ -66,12 +66,12 @@ static const unsigned int HB_STRING_ARRAY_OFFS_NAME[] =
sizeof (HB_STRING_ARRAY_TYPE_NAME) sizeof (HB_STRING_ARRAY_TYPE_NAME)
}; };
static inline hb_string_t static inline hb_bytes_t
HB_STRING_ARRAY_NAME (unsigned int i) HB_STRING_ARRAY_NAME (unsigned int i)
{ {
assert (i < ARRAY_LENGTH (HB_STRING_ARRAY_OFFS_NAME) - 1); assert (i < ARRAY_LENGTH (HB_STRING_ARRAY_OFFS_NAME) - 1);
return hb_string_t (HB_STRING_ARRAY_POOL_NAME.str + HB_STRING_ARRAY_OFFS_NAME[i], return hb_bytes_t (HB_STRING_ARRAY_POOL_NAME.str + HB_STRING_ARRAY_OFFS_NAME[i],
HB_STRING_ARRAY_OFFS_NAME[i + 1] - HB_STRING_ARRAY_OFFS_NAME[i] - 1); HB_STRING_ARRAY_OFFS_NAME[i + 1] - HB_STRING_ARRAY_OFFS_NAME[i] - 1);
} }
#undef HB_STRING_ARRAY_TYPE_NAME #undef HB_STRING_ARRAY_TYPE_NAME