[HarfBuzz] harfbuzz-ng: Branch 'master' - 16 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Thu Apr 29 00:31:25 PDT 2010
src/hb-blob.c | 78 +++++++++-------------
src/hb-language.c | 2
src/hb-object-private.h | 44 ++++++++----
src/hb-open-type-private.hh | 61 +++++++----------
src/hb-ot-layout-gpos-private.hh | 119 ++++++++++++++++++-----------------
src/hb-ot-layout-gsub-private.hh | 68 ++++++++++----------
src/hb-ot-layout-gsubgpos-private.hh | 62 ++++++------------
src/hb-ot-tag.c | 15 ++--
src/hb-private.h | 54 +++++++++++----
9 files changed, 252 insertions(+), 251 deletions(-)
New commits:
commit ce23c9234b87513d6460fb89bad178fb8537e161
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 29 03:31:03 2010 -0400
Use BCP47 private-use tags for OpenType tag language string mapping
diff --git a/src/hb-ot-tag.c b/src/hb-ot-tag.c
index 00c8017..40356b0 100644
--- a/src/hb-ot-tag.c
+++ b/src/hb-ot-tag.c
@@ -594,10 +594,10 @@ hb_ot_tag_from_language (hb_language_t language)
lang_str = hb_language_to_string (language);
- if (0 == strcmp (lang_str, "ot:")) {
+ if (0 == strcmp (lang_str, "x-hbot")) {
char tag[4];
int i;
- lang_str += 3;
+ lang_str += 6;
i = 0;
while (i < 4 && lang_str[i]) {
tag[i] = lang_str[i];
@@ -648,16 +648,16 @@ hb_language_t
hb_ot_tag_to_language (hb_tag_t tag)
{
unsigned int i;
- unsigned char buf[8] = "ot:";
+ unsigned char buf[11] = "x-hbot";
for (i = 0; i < ARRAY_LENGTH (ot_languages); i++)
if (ot_languages[i].tag == tag)
return hb_language_from_string (ot_languages[i].language);
- buf[3] = tag >> 24;
- buf[4] = (tag >> 16) & 0xFF;
- buf[5] = (tag >> 8) & 0xFF;
- buf[6] = tag & 0xFF;
- buf[7] = '\0';
+ buf[6] = tag >> 24;
+ buf[7] = (tag >> 16) & 0xFF;
+ buf[8] = (tag >> 8) & 0xFF;
+ buf[9] = tag & 0xFF;
+ buf[10] = '\0';
return hb_language_from_string ((char *) buf);
}
commit eaf1d9a46c4a320f3b0026c0a610f95a620d566f
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 29 03:11:32 2010 -0400
Minor
diff --git a/src/hb-ot-tag.c b/src/hb-ot-tag.c
index 9597b7f..00c8017 100644
--- a/src/hb-ot-tag.c
+++ b/src/hb-ot-tag.c
@@ -658,5 +658,6 @@ hb_ot_tag_to_language (hb_tag_t tag)
buf[4] = (tag >> 16) & 0xFF;
buf[5] = (tag >> 8) & 0xFF;
buf[6] = tag & 0xFF;
+ buf[7] = '\0';
return hb_language_from_string ((char *) buf);
}
commit 3a4784fe88a0f14147ccdd3633952c9c0f3ae8f3
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 29 02:58:38 2010 -0400
Fix bug in hb_language_from_string()
Reported by Jonathan Kew.
diff --git a/src/hb-language.c b/src/hb-language.c
index ff25d7b..5d7286b 100644
--- a/src/hb-language.c
+++ b/src/hb-language.c
@@ -102,6 +102,8 @@ hb_language_from_string (const char *str)
for (p = (unsigned char *) langs[i]; *p; p++)
*p = canon_map[*p];
+ num_langs++;
+
return (hb_language_t) langs[i];
}
commit 602e4f8d5512cdf48c696ad64ad62ff97f6dbdcc
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 29 02:28:54 2010 -0400
Use const_cast
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index a062aff..a1763af 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -276,8 +276,7 @@ struct Sanitizer
_hb_sanitize_init (context, blob);
- /* Note: We drop const here */
- Type *t = CastP<Type> ((void *) context->start);
+ Type *t = CastP<Type> (const_cast<char *> (context->start));
sane = t->sanitize (SANITIZE_ARG);
if (sane) {
commit abff3580a5b229641086e0da097efee11d22ff81
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 29 02:27:20 2010 -0400
Add const
diff --git a/src/hb-object-private.h b/src/hb-object-private.h
index 93c8711..e24bc91 100644
--- a/src/hb-object-private.h
+++ b/src/hb-object-private.h
@@ -63,7 +63,7 @@ typedef struct {
#endif
static HB_GNUC_UNUSED inline hb_bool_t /* always returns TRUE */
-_hb_object_debug_out (void *obj,
+_hb_object_debug_out (const void *obj,
hb_reference_count_t *ref_count,
const char *function)
{
commit 6617eada95928457a25e29f793f1a93c6b3edaec
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 29 02:25:30 2010 -0400
Rename apply_context -> context
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index 707b37a..f3fb265 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -566,7 +566,7 @@ struct PairPosFormat1
return false;
unsigned int j = buffer->in_pos + 1;
- while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), apply_context->lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, NULL))
{
if (HB_UNLIKELY (j == end))
return false;
@@ -658,7 +658,7 @@ struct PairPosFormat2
return false;
unsigned int j = buffer->in_pos + 1;
- while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), apply_context->lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, NULL))
{
if (HB_UNLIKELY (j == end))
return false;
@@ -913,7 +913,7 @@ struct CursivePosFormat1
gpi->last = HB_OT_LAYOUT_GPOS_NO_LAST;
/* We don't handle mark glyphs here. */
- if (apply_context->property == HB_OT_LAYOUT_GLYPH_CLASS_MARK)
+ if (context->property == HB_OT_LAYOUT_GLYPH_CLASS_MARK)
return false;
unsigned int index = (this+coverage) (IN_CURGLYPH ());
@@ -941,7 +941,7 @@ struct CursivePosFormat1
POSITION (last_pos)->x_advance = gpi->anchor_x - entry_x;
}
- if (apply_context->lookup_flag & LookupFlag::RightToLeft)
+ if (context->lookup_flag & LookupFlag::RightToLeft)
{
POSITION (last_pos)->cursive_chain = last_pos - buffer->in_pos;
POSITION (last_pos)->y_offset = entry_y - gpi->anchor_y;
@@ -1252,7 +1252,7 @@ struct MarkMarkPosFormat1
if (HB_UNLIKELY (!j))
return false;
j--;
- } while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), apply_context->lookup_flag, &property));
+ } while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, &property));
if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK))
return false;
@@ -1457,12 +1457,12 @@ struct PosLookup : Lookup
unsigned int apply_depth) const
{
unsigned int lookup_type = get_type ();
- hb_apply_context_t apply_context[1];
+ hb_apply_context_t context[1];
- apply_context->nesting_level_left = nesting_level_left;
- apply_context->lookup_flag = get_flag ();
+ context->nesting_level_left = nesting_level_left;
+ context->lookup_flag = get_flag ();
- if (!_hb_ot_layout_check_glyph_property (layout_context->face, IN_CURINFO (), apply_context->lookup_flag, &apply_context->property))
+ if (!_hb_ot_layout_check_glyph_property (layout_context->face, IN_CURINFO (), context->lookup_flag, &context->property))
return false;
for (unsigned int i = 0; i < get_subtable_count (); i++)
@@ -1567,13 +1567,13 @@ static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
const GPOS &gpos = *(layout_context->face->ot_layout.gpos);
const PosLookup &l = gpos.get_lookup (lookup_index);
- if (HB_UNLIKELY (apply_context->nesting_level_left == 0))
+ if (HB_UNLIKELY (context->nesting_level_left == 0))
return false;
if (HB_UNLIKELY (context_length < 1))
return false;
- return l.apply_once (layout_context, buffer, context_length, apply_context->nesting_level_left - 1, apply_depth + 1);
+ return l.apply_once (layout_context, buffer, context_length, context->nesting_level_left - 1, apply_depth + 1);
}
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index 5e1f81c..31de65c 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -49,7 +49,7 @@ struct SingleSubstFormat1
/* We inherit the old glyph class to the substituted glyph */
if (_hb_ot_layout_has_new_glyph_classes (layout_context->face))
- _hb_ot_layout_set_glyph_property (layout_context->face, glyph_id, apply_context->property);
+ _hb_ot_layout_set_glyph_property (layout_context->face, glyph_id, context->property);
return true;
}
@@ -91,7 +91,7 @@ struct SingleSubstFormat2
/* We inherit the old glyph class to the substituted glyph */
if (_hb_ot_layout_has_new_glyph_classes (layout_context->face))
- _hb_ot_layout_set_glyph_property (layout_context->face, glyph_id, apply_context->property);
+ _hb_ot_layout_set_glyph_property (layout_context->face, glyph_id, context->property);
return true;
}
@@ -165,7 +165,7 @@ struct Sequence
/* This is a guess only ... */
if (_hb_ot_layout_has_new_glyph_classes (layout_context->face))
{
- unsigned int property = apply_context->property;
+ unsigned int property = context->property;
if (property == HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE)
property = HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH;
@@ -296,7 +296,7 @@ struct AlternateSubstFormat1
/* We inherit the old glyph class to the substituted glyph */
if (_hb_ot_layout_has_new_glyph_classes (layout_context->face))
- _hb_ot_layout_set_glyph_property (layout_context->face, glyph_id, apply_context->property);
+ _hb_ot_layout_set_glyph_property (layout_context->face, glyph_id, context->property);
return true;
}
@@ -366,7 +366,7 @@ struct Ligature
for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
{
unsigned int property;
- while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), apply_context->lookup_flag, &property))
+ while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, &property))
{
if (HB_UNLIKELY (j + count - i == end))
return false;
@@ -407,7 +407,7 @@ struct Ligature
for ( i = 1; i < count; i++ )
{
- while (_hb_ot_layout_skip_mark (layout_context->face, IN_CURINFO (), apply_context->lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (layout_context->face, IN_CURINFO (), context->lookup_flag, NULL))
_hb_buffer_add_output_glyph (buffer, IN_CURGLYPH (), i, lig_id);
(buffer->in_pos)++;
@@ -474,7 +474,7 @@ struct LigatureSubstFormat1
TRACE_APPLY ();
hb_codepoint_t glyph_id = IN_CURGLYPH ();
- bool first_is_mark = !!(apply_context->property & HB_OT_LAYOUT_GLYPH_CLASS_MARK);
+ bool first_is_mark = !!(context->property & HB_OT_LAYOUT_GLYPH_CLASS_MARK);
unsigned int index = (this+coverage) (glyph_id);
if (HB_LIKELY (index == NOT_COVERED))
@@ -766,12 +766,12 @@ struct SubstLookup : Lookup
unsigned int apply_depth) const
{
unsigned int lookup_type = get_type ();
- hb_apply_context_t apply_context[1];
+ hb_apply_context_t context[1];
- apply_context->nesting_level_left = nesting_level_left;
- apply_context->lookup_flag = get_flag ();
+ context->nesting_level_left = nesting_level_left;
+ context->lookup_flag = get_flag ();
- if (!_hb_ot_layout_check_glyph_property (layout_context->face, IN_CURINFO (), apply_context->lookup_flag, &apply_context->property))
+ if (!_hb_ot_layout_check_glyph_property (layout_context->face, IN_CURINFO (), context->lookup_flag, &context->property))
return false;
if (HB_UNLIKELY (lookup_type == SubstLookupSubTable::Extension))
@@ -910,13 +910,13 @@ static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
const GSUB &gsub = *(layout_context->face->ot_layout.gsub);
const SubstLookup &l = gsub.get_lookup (lookup_index);
- if (HB_UNLIKELY (apply_context->nesting_level_left == 0))
+ if (HB_UNLIKELY (context->nesting_level_left == 0))
return false;
if (HB_UNLIKELY (context_length < 1))
return false;
- return l.apply_once (layout_context, buffer, context_length, apply_context->nesting_level_left - 1, apply_depth + 1);
+ return l.apply_once (layout_context, buffer, context_length, context->nesting_level_left - 1, apply_depth + 1);
}
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index c0d3da9..042daa2 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -43,13 +43,13 @@
#define APPLY_ARG_DEF \
- hb_apply_context_t *apply_context, \
+ hb_apply_context_t *context, \
hb_ot_layout_context_t *layout_context, \
hb_buffer_t *buffer, \
unsigned int context_length HB_GNUC_UNUSED, \
unsigned int apply_depth HB_GNUC_UNUSED
#define APPLY_ARG \
- apply_context, \
+ context, \
layout_context, \
buffer, \
context_length, \
@@ -105,7 +105,7 @@ static inline bool match_input (APPLY_ARG_DEF,
for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
{
- while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), apply_context->lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, NULL))
{
if (HB_UNLIKELY (j + count - i == end))
return false;
@@ -132,7 +132,7 @@ static inline bool match_backtrack (APPLY_ARG_DEF,
for (unsigned int i = 0, j = buffer->out_pos - 1; i < count; i++, j--)
{
- while (_hb_ot_layout_skip_mark (layout_context->face, OUT_INFO (j), apply_context->lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (layout_context->face, OUT_INFO (j), context->lookup_flag, NULL))
{
if (HB_UNLIKELY (j + 1 == count - i))
return false;
@@ -160,7 +160,7 @@ static inline bool match_lookahead (APPLY_ARG_DEF,
for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++)
{
- while (_hb_ot_layout_skip_mark (layout_context->face, OUT_INFO (j), apply_context->lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (layout_context->face, OUT_INFO (j), context->lookup_flag, NULL))
{
if (HB_UNLIKELY (j + count - i == end))
return false;
@@ -210,7 +210,7 @@ static inline bool apply_lookup (APPLY_ARG_DEF,
*/
for (unsigned int i = 0; i < count; /* NOP */)
{
- while (_hb_ot_layout_skip_mark (layout_context->face, IN_CURINFO (), apply_context->lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (layout_context->face, IN_CURINFO (), context->lookup_flag, NULL))
{
if (HB_UNLIKELY (buffer->in_pos == end))
return true;
commit b4c7fab762935b9c182b3e2ac3415f29fc6a5558
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 29 02:24:25 2010 -0400
Rename
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index 4bfa89f..707b37a 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -87,7 +87,7 @@ struct ValueFormat : USHORT
inline unsigned int get_size () const
{ return get_len () * Value::get_size (); }
- void apply_value (hb_ot_layout_context_t *context,
+ void apply_value (hb_ot_layout_context_t *layout_context,
const char *base,
const Value *values,
hb_internal_glyph_position_t *glyph_pos) const
@@ -98,16 +98,16 @@ struct ValueFormat : USHORT
if (!format) return;
- x_scale = context->font->x_scale;
- y_scale = context->font->y_scale;
+ x_scale = layout_context->font->x_scale;
+ y_scale = layout_context->font->y_scale;
/* design units -> fractional pixel */
if (format & xPlacement) glyph_pos->x_offset += _hb_16dot16_mul_round (x_scale, *(SHORT*)values++);
if (format & yPlacement) glyph_pos->y_offset += _hb_16dot16_mul_round (y_scale, *(SHORT*)values++);
if (format & xAdvance) glyph_pos->x_advance += _hb_16dot16_mul_round (x_scale, *(SHORT*)values++);
if (format & yAdvance) glyph_pos->y_advance += _hb_16dot16_mul_round (y_scale, *(SHORT*)values++);
- x_ppem = context->font->x_ppem;
- y_ppem = context->font->y_ppem;
+ x_ppem = layout_context->font->x_ppem;
+ y_ppem = layout_context->font->y_ppem;
/* pixel -> fractional pixel */
if (format & xPlaDevice) {
if (x_ppem) glyph_pos->x_offset += (base+*(OffsetTo<Device>*)values++).get_delta (x_ppem) << 16; else values++;
@@ -194,11 +194,11 @@ struct AnchorFormat1
friend struct Anchor;
private:
- inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id HB_GNUC_UNUSED,
+ inline void get_anchor (hb_ot_layout_context_t *layout_context, hb_codepoint_t glyph_id HB_GNUC_UNUSED,
hb_position_t *x, hb_position_t *y) const
{
- *x = _hb_16dot16_mul_round (context->font->x_scale, xCoordinate);
- *y = _hb_16dot16_mul_round (context->font->y_scale, yCoordinate);
+ *x = _hb_16dot16_mul_round (layout_context->font->x_scale, xCoordinate);
+ *y = _hb_16dot16_mul_round (layout_context->font->y_scale, yCoordinate);
}
inline bool sanitize (SANITIZE_ARG_DEF) {
@@ -218,13 +218,13 @@ struct AnchorFormat2
friend struct Anchor;
private:
- inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id,
+ inline void get_anchor (hb_ot_layout_context_t *layout_context, hb_codepoint_t glyph_id,
hb_position_t *x, hb_position_t *y) const
{
/* TODO Contour
* NOTE only adjust directions with nonzero ppem */
- *x = _hb_16dot16_mul_round (context->font->x_scale, xCoordinate);
- *y = _hb_16dot16_mul_round (context->font->y_scale, yCoordinate);
+ *x = _hb_16dot16_mul_round (layout_context->font->x_scale, xCoordinate);
+ *y = _hb_16dot16_mul_round (layout_context->font->y_scale, yCoordinate);
}
inline bool sanitize (SANITIZE_ARG_DEF) {
@@ -245,17 +245,17 @@ struct AnchorFormat3
friend struct Anchor;
private:
- inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id HB_GNUC_UNUSED,
+ inline void get_anchor (hb_ot_layout_context_t *layout_context, hb_codepoint_t glyph_id HB_GNUC_UNUSED,
hb_position_t *x, hb_position_t *y) const
{
- *x = _hb_16dot16_mul_round (context->font->x_scale, xCoordinate);
- *y = _hb_16dot16_mul_round (context->font->y_scale, yCoordinate);
+ *x = _hb_16dot16_mul_round (layout_context->font->x_scale, xCoordinate);
+ *y = _hb_16dot16_mul_round (layout_context->font->y_scale, yCoordinate);
/* pixel -> fractional pixel */
- if (context->font->x_ppem)
- *x += (this+xDeviceTable).get_delta (context->font->x_ppem) << 16;
- if (context->font->y_ppem)
- *y += (this+yDeviceTable).get_delta (context->font->y_ppem) << 16;
+ if (layout_context->font->x_ppem)
+ *x += (this+xDeviceTable).get_delta (layout_context->font->x_ppem) << 16;
+ if (layout_context->font->y_ppem)
+ *y += (this+yDeviceTable).get_delta (layout_context->font->y_ppem) << 16;
}
inline bool sanitize (SANITIZE_ARG_DEF) {
@@ -280,15 +280,15 @@ ASSERT_SIZE (AnchorFormat3, 10);
struct Anchor
{
- inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id,
+ inline void get_anchor (hb_ot_layout_context_t *layout_context, hb_codepoint_t glyph_id,
hb_position_t *x, hb_position_t *y) const
{
*x = *y = 0;
switch (u.format) {
- case 1: u.format1->get_anchor (context, glyph_id, x, y); return;
- case 2: u.format2->get_anchor (context, glyph_id, x, y); return;
- case 3: u.format3->get_anchor (context, glyph_id, x, y); return;
- default: return;
+ case 1: u.format1->get_anchor (layout_context, glyph_id, x, y); return;
+ case 2: u.format2->get_anchor (layout_context, glyph_id, x, y); return;
+ case 3: u.format3->get_anchor (layout_context, glyph_id, x, y); return;
+ default: return;
}
}
@@ -375,8 +375,8 @@ struct MarkArray
hb_position_t mark_x, mark_y, base_x, base_y;
- mark_anchor.get_anchor (context, IN_CURGLYPH (), &mark_x, &mark_y);
- glyph_anchor.get_anchor (context, IN_GLYPH (glyph_pos), &base_x, &base_y);
+ mark_anchor.get_anchor (layout_context, IN_CURGLYPH (), &mark_x, &mark_y);
+ glyph_anchor.get_anchor (layout_context, IN_GLYPH (glyph_pos), &base_x, &base_y);
hb_internal_glyph_position_t *o = POSITION (buffer->in_pos);
o->x_advance = 0;
@@ -415,7 +415,7 @@ struct SinglePosFormat1
if (HB_LIKELY (index == NOT_COVERED))
return false;
- valueFormat.apply_value (context, CharP(this), values, CURPOSITION ());
+ valueFormat.apply_value (layout_context, CharP(this), values, CURPOSITION ());
buffer->in_pos++;
return true;
@@ -455,7 +455,7 @@ struct SinglePosFormat2
if (HB_LIKELY (index >= valueCount))
return false;
- valueFormat.apply_value (context, CharP(this),
+ valueFormat.apply_value (layout_context, CharP(this),
&values[index * valueFormat.get_len ()],
CURPOSITION ());
@@ -566,7 +566,7 @@ struct PairPosFormat1
return false;
unsigned int j = buffer->in_pos + 1;
- while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), apply_context->lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), apply_context->lookup_flag, NULL))
{
if (HB_UNLIKELY (j == end))
return false;
@@ -584,8 +584,8 @@ struct PairPosFormat1
{
if (IN_GLYPH (j) == record->secondGlyph)
{
- valueFormat1.apply_value (context, CharP(this), &record->values[0], CURPOSITION ());
- valueFormat2.apply_value (context, CharP(this), &record->values[len1], POSITION (j));
+ valueFormat1.apply_value (layout_context, CharP(this), &record->values[0], CURPOSITION ());
+ valueFormat2.apply_value (layout_context, CharP(this), &record->values[len1], POSITION (j));
if (len2)
j++;
buffer->in_pos = j;
@@ -658,7 +658,7 @@ struct PairPosFormat2
return false;
unsigned int j = buffer->in_pos + 1;
- while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), apply_context->lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), apply_context->lookup_flag, NULL))
{
if (HB_UNLIKELY (j == end))
return false;
@@ -675,8 +675,8 @@ struct PairPosFormat2
return false;
const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
- valueFormat1.apply_value (context, CharP(this), v, CURPOSITION ());
- valueFormat2.apply_value (context, CharP(this), v + len1, POSITION (j));
+ valueFormat1.apply_value (layout_context, CharP(this), v, CURPOSITION ());
+ valueFormat2.apply_value (layout_context, CharP(this), v + len1, POSITION (j));
if (len2)
j++;
@@ -908,7 +908,7 @@ struct CursivePosFormat1
Since horizontal advance widths or vertical advance heights
can be used alone but not together, no ambiguity occurs. */
- struct hb_ot_layout_context_t::info_t::gpos_t *gpi = &context->info.gpos;
+ struct hb_ot_layout_context_t::info_t::gpos_t *gpi = &layout_context->info.gpos;
hb_codepoint_t last_pos = gpi->last;
gpi->last = HB_OT_LAYOUT_GPOS_NO_LAST;
@@ -926,7 +926,7 @@ struct CursivePosFormat1
goto end;
hb_position_t entry_x, entry_y;
- (this+record.entryAnchor).get_anchor (context, IN_CURGLYPH (), &entry_x, &entry_y);
+ (this+record.entryAnchor).get_anchor (layout_context, IN_CURGLYPH (), &entry_x, &entry_y);
/* TODO vertical */
@@ -956,7 +956,7 @@ struct CursivePosFormat1
if (record.exitAnchor)
{
gpi->last = buffer->in_pos;
- (this+record.exitAnchor).get_anchor (context, IN_CURGLYPH (), &gpi->anchor_x, &gpi->anchor_y);
+ (this+record.exitAnchor).get_anchor (layout_context, IN_CURGLYPH (), &gpi->anchor_x, &gpi->anchor_y);
}
buffer->in_pos++;
@@ -1035,7 +1035,7 @@ struct MarkBasePosFormat1
if (HB_UNLIKELY (!j))
return false;
j--;
- } while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property));
+ } while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property));
#if 0
/* The following assertion is too strong. */
@@ -1135,7 +1135,7 @@ struct MarkLigPosFormat1
if (HB_UNLIKELY (!j))
return false;
j--;
- } while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property));
+ } while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property));
#if 0
/* The following assertion is too strong. */
@@ -1252,7 +1252,7 @@ struct MarkMarkPosFormat1
if (HB_UNLIKELY (!j))
return false;
j--;
- } while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), apply_context->lookup_flag, &property));
+ } while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), apply_context->lookup_flag, &property));
if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK))
return false;
@@ -1450,7 +1450,7 @@ struct PosLookup : Lookup
inline const PosLookupSubTable& get_subtable (unsigned int i) const
{ return this+CastR<OffsetArrayOf<PosLookupSubTable> > (subTable)[i]; }
- inline bool apply_once (hb_ot_layout_context_t *context,
+ inline bool apply_once (hb_ot_layout_context_t *layout_context,
hb_buffer_t *buffer,
unsigned int context_length,
unsigned int nesting_level_left,
@@ -1462,7 +1462,7 @@ struct PosLookup : Lookup
apply_context->nesting_level_left = nesting_level_left;
apply_context->lookup_flag = get_flag ();
- if (!_hb_ot_layout_check_glyph_property (context->face, IN_CURINFO (), apply_context->lookup_flag, &apply_context->property))
+ if (!_hb_ot_layout_check_glyph_property (layout_context->face, IN_CURINFO (), apply_context->lookup_flag, &apply_context->property))
return false;
for (unsigned int i = 0; i < get_subtable_count (); i++)
@@ -1472,7 +1472,7 @@ struct PosLookup : Lookup
return false;
}
- inline bool apply_string (hb_ot_layout_context_t *context,
+ inline bool apply_string (hb_ot_layout_context_t *layout_context,
hb_buffer_t *buffer,
hb_mask_t mask) const
{
@@ -1481,7 +1481,7 @@ struct PosLookup : Lookup
if (HB_UNLIKELY (!buffer->in_length))
return false;
- context->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST; /* no last valid glyph for cursive pos. */
+ layout_context->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST; /* no last valid glyph for cursive pos. */
buffer->in_pos = 0;
while (buffer->in_pos < buffer->in_length)
@@ -1489,7 +1489,7 @@ struct PosLookup : Lookup
bool done;
if (~IN_MASK (buffer->in_pos) & mask)
{
- done = apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL, 0);
+ done = apply_once (layout_context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL, 0);
ret |= done;
}
else
@@ -1497,7 +1497,7 @@ struct PosLookup : Lookup
done = false;
/* Contrary to properties defined in GDEF, user-defined properties
will always stop a possible cursive positioning. */
- context->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST;
+ layout_context->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST;
}
if (!done)
@@ -1529,11 +1529,11 @@ struct GPOS : GSUBGPOS
inline const PosLookup& get_lookup (unsigned int i) const
{ return CastR<PosLookup> (GSUBGPOS::get_lookup (i)); }
- inline bool position_lookup (hb_ot_layout_context_t *context,
+ inline bool position_lookup (hb_ot_layout_context_t *layout_context,
hb_buffer_t *buffer,
unsigned int lookup_index,
hb_mask_t mask) const
- { return get_lookup (lookup_index).apply_string (context, buffer, mask); }
+ { return get_lookup (lookup_index).apply_string (layout_context, buffer, mask); }
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
@@ -1564,7 +1564,7 @@ inline bool ExtensionPos::sanitize (SANITIZE_ARG_DEF)
static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
{
- const GPOS &gpos = *(context->face->ot_layout.gpos);
+ const GPOS &gpos = *(layout_context->face->ot_layout.gpos);
const PosLookup &l = gpos.get_lookup (lookup_index);
if (HB_UNLIKELY (apply_context->nesting_level_left == 0))
@@ -1573,7 +1573,7 @@ static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
if (HB_UNLIKELY (context_length < 1))
return false;
- return l.apply_once (context, buffer, context_length, apply_context->nesting_level_left - 1, apply_depth + 1);
+ return l.apply_once (layout_context, buffer, context_length, apply_context->nesting_level_left - 1, apply_depth + 1);
}
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index f3b3e83..5e1f81c 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -48,8 +48,8 @@ struct SingleSubstFormat1
_hb_buffer_replace_glyph (buffer, glyph_id);
/* We inherit the old glyph class to the substituted glyph */
- if (_hb_ot_layout_has_new_glyph_classes (context->face))
- _hb_ot_layout_set_glyph_property (context->face, glyph_id, apply_context->property);
+ if (_hb_ot_layout_has_new_glyph_classes (layout_context->face))
+ _hb_ot_layout_set_glyph_property (layout_context->face, glyph_id, apply_context->property);
return true;
}
@@ -90,8 +90,8 @@ struct SingleSubstFormat2
_hb_buffer_replace_glyph (buffer, glyph_id);
/* We inherit the old glyph class to the substituted glyph */
- if (_hb_ot_layout_has_new_glyph_classes (context->face))
- _hb_ot_layout_set_glyph_property (context->face, glyph_id, apply_context->property);
+ if (_hb_ot_layout_has_new_glyph_classes (layout_context->face))
+ _hb_ot_layout_set_glyph_property (layout_context->face, glyph_id, apply_context->property);
return true;
}
@@ -163,7 +163,7 @@ struct Sequence
0xFFFF, 0xFFFF);
/* This is a guess only ... */
- if (_hb_ot_layout_has_new_glyph_classes (context->face))
+ if (_hb_ot_layout_has_new_glyph_classes (layout_context->face))
{
unsigned int property = apply_context->property;
if (property == HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE)
@@ -171,7 +171,7 @@ struct Sequence
unsigned int count = substitute.len;
for (unsigned int n = 0; n < count; n++)
- _hb_ot_layout_set_glyph_property (context->face, substitute[n], property);
+ _hb_ot_layout_set_glyph_property (layout_context->face, substitute[n], property);
}
return true;
@@ -281,8 +281,8 @@ struct AlternateSubstFormat1
unsigned int alt_index = 0;
/* XXX callback to user to choose alternate
- if (context->face->altfunc)
- alt_index = (context->face->altfunc)(context->layout, buffer,
+ if (layout_context->face->altfunc)
+ alt_index = (layout_context->face->altfunc)(layout_context->layout, buffer,
buffer->out_pos, glyph_id,
alt_set.len, alt_set.array);
*/
@@ -295,8 +295,8 @@ struct AlternateSubstFormat1
_hb_buffer_replace_glyph (buffer, glyph_id);
/* We inherit the old glyph class to the substituted glyph */
- if (_hb_ot_layout_has_new_glyph_classes (context->face))
- _hb_ot_layout_set_glyph_property (context->face, glyph_id, apply_context->property);
+ if (_hb_ot_layout_has_new_glyph_classes (layout_context->face))
+ _hb_ot_layout_set_glyph_property (layout_context->face, glyph_id, apply_context->property);
return true;
}
@@ -366,7 +366,7 @@ struct Ligature
for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
{
unsigned int property;
- while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), apply_context->lookup_flag, &property))
+ while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), apply_context->lookup_flag, &property))
{
if (HB_UNLIKELY (j + count - i == end))
return false;
@@ -380,8 +380,8 @@ struct Ligature
return false;
}
/* This is just a guess ... */
- if (_hb_ot_layout_has_new_glyph_classes (context->face))
- _hb_ot_layout_set_glyph_class (context->face, ligGlyph,
+ if (_hb_ot_layout_has_new_glyph_classes (layout_context->face))
+ _hb_ot_layout_set_glyph_class (layout_context->face, ligGlyph,
is_mark ? HB_OT_LAYOUT_GLYPH_CLASS_MARK
: HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE);
@@ -407,7 +407,7 @@ struct Ligature
for ( i = 1; i < count; i++ )
{
- while (_hb_ot_layout_skip_mark (context->face, IN_CURINFO (), apply_context->lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (layout_context->face, IN_CURINFO (), apply_context->lookup_flag, NULL))
_hb_buffer_add_output_glyph (buffer, IN_CURGLYPH (), i, lig_id);
(buffer->in_pos)++;
@@ -759,7 +759,7 @@ struct SubstLookup : Lookup
}
- inline bool apply_once ( hb_ot_layout_context_t *context,
+ inline bool apply_once ( hb_ot_layout_context_t *layout_context,
hb_buffer_t *buffer,
unsigned int context_length,
unsigned int nesting_level_left,
@@ -771,7 +771,7 @@ struct SubstLookup : Lookup
apply_context->nesting_level_left = nesting_level_left;
apply_context->lookup_flag = get_flag ();
- if (!_hb_ot_layout_check_glyph_property (context->face, IN_CURINFO (), apply_context->lookup_flag, &apply_context->property))
+ if (!_hb_ot_layout_check_glyph_property (layout_context->face, IN_CURINFO (), apply_context->lookup_flag, &apply_context->property))
return false;
if (HB_UNLIKELY (lookup_type == SubstLookupSubTable::Extension))
@@ -796,7 +796,7 @@ struct SubstLookup : Lookup
return false;
}
- inline bool apply_string (hb_ot_layout_context_t *context,
+ inline bool apply_string (hb_ot_layout_context_t *layout_context,
hb_buffer_t *buffer,
hb_mask_t mask) const
{
@@ -813,7 +813,7 @@ struct SubstLookup : Lookup
while (buffer->in_pos < buffer->in_length)
{
if ((~IN_MASK (buffer->in_pos) & mask) &&
- apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL, 0))
+ apply_once (layout_context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL, 0))
ret = true;
else
_hb_buffer_next_glyph (buffer);
@@ -829,7 +829,7 @@ struct SubstLookup : Lookup
do
{
if ((~IN_MASK (buffer->in_pos) & mask) &&
- apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL, 0))
+ apply_once (layout_context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL, 0))
ret = true;
else
buffer->in_pos--;
@@ -863,11 +863,11 @@ struct GSUB : GSUBGPOS
inline const SubstLookup& get_lookup (unsigned int i) const
{ return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); }
- inline bool substitute_lookup (hb_ot_layout_context_t *context,
+ inline bool substitute_lookup (hb_ot_layout_context_t *layout_context,
hb_buffer_t *buffer,
unsigned int lookup_index,
hb_mask_t mask) const
- { return get_lookup (lookup_index).apply_string (context, buffer, mask); }
+ { return get_lookup (lookup_index).apply_string (layout_context, buffer, mask); }
inline bool sanitize (SANITIZE_ARG_DEF) {
@@ -907,7 +907,7 @@ inline bool ExtensionSubst::is_reverse (void) const
static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
{
- const GSUB &gsub = *(context->face->ot_layout.gsub);
+ const GSUB &gsub = *(layout_context->face->ot_layout.gsub);
const SubstLookup &l = gsub.get_lookup (lookup_index);
if (HB_UNLIKELY (apply_context->nesting_level_left == 0))
@@ -916,7 +916,7 @@ static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
if (HB_UNLIKELY (context_length < 1))
return false;
- return l.apply_once (context, buffer, context_length, apply_context->nesting_level_left - 1, apply_depth + 1);
+ return l.apply_once (layout_context, buffer, context_length, apply_context->nesting_level_left - 1, apply_depth + 1);
}
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index c317e54..c0d3da9 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -44,13 +44,13 @@
#define APPLY_ARG_DEF \
hb_apply_context_t *apply_context, \
- hb_ot_layout_context_t *context, \
+ hb_ot_layout_context_t *layout_context, \
hb_buffer_t *buffer, \
unsigned int context_length HB_GNUC_UNUSED, \
unsigned int apply_depth HB_GNUC_UNUSED
#define APPLY_ARG \
apply_context, \
- context, \
+ layout_context, \
buffer, \
context_length, \
(HB_DEBUG_APPLY ? apply_depth + 1 : 0)
@@ -105,7 +105,7 @@ static inline bool match_input (APPLY_ARG_DEF,
for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
{
- while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), apply_context->lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), apply_context->lookup_flag, NULL))
{
if (HB_UNLIKELY (j + count - i == end))
return false;
@@ -132,7 +132,7 @@ static inline bool match_backtrack (APPLY_ARG_DEF,
for (unsigned int i = 0, j = buffer->out_pos - 1; i < count; i++, j--)
{
- while (_hb_ot_layout_skip_mark (context->face, OUT_INFO (j), apply_context->lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (layout_context->face, OUT_INFO (j), apply_context->lookup_flag, NULL))
{
if (HB_UNLIKELY (j + 1 == count - i))
return false;
@@ -160,7 +160,7 @@ static inline bool match_lookahead (APPLY_ARG_DEF,
for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++)
{
- while (_hb_ot_layout_skip_mark (context->face, OUT_INFO (j), apply_context->lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (layout_context->face, OUT_INFO (j), apply_context->lookup_flag, NULL))
{
if (HB_UNLIKELY (j + count - i == end))
return false;
@@ -210,7 +210,7 @@ static inline bool apply_lookup (APPLY_ARG_DEF,
*/
for (unsigned int i = 0; i < count; /* NOP */)
{
- while (_hb_ot_layout_skip_mark (context->face, IN_CURINFO (), apply_context->lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (layout_context->face, IN_CURINFO (), apply_context->lookup_flag, NULL))
{
if (HB_UNLIKELY (buffer->in_pos == end))
return true;
commit 1376fb7bf9ef07970f0ba13dc64d6a8ab8252762
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 29 02:19:21 2010 -0400
[apply] Use a context object to reduce number of parameters passed around
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 1b33183..a062aff 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -138,15 +138,14 @@ ASSERT_STATIC (sizeof (Type) + 1 <= sizeof (_Null##Type))
context, \
(HB_DEBUG_SANITIZE ? sanitize_depth + 1 : 0)
-
-typedef struct _hb_sanitize_context_t hb_sanitize_context_t;
-struct _hb_sanitize_context_t
+struct hb_sanitize_context_t
{
const char *start, *end;
hb_bool_t writable;
unsigned int edit_count;
};
+
static HB_GNUC_UNUSED void
_hb_sanitize_init (hb_sanitize_context_t *context,
hb_blob_t *blob)
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index fe6ac63..4bfa89f 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -566,7 +566,7 @@ struct PairPosFormat1
return false;
unsigned int j = buffer->in_pos + 1;
- while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), apply_context->lookup_flag, NULL))
{
if (HB_UNLIKELY (j == end))
return false;
@@ -658,7 +658,7 @@ struct PairPosFormat2
return false;
unsigned int j = buffer->in_pos + 1;
- while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), apply_context->lookup_flag, NULL))
{
if (HB_UNLIKELY (j == end))
return false;
@@ -913,7 +913,7 @@ struct CursivePosFormat1
gpi->last = HB_OT_LAYOUT_GPOS_NO_LAST;
/* We don't handle mark glyphs here. */
- if (property == HB_OT_LAYOUT_GLYPH_CLASS_MARK)
+ if (apply_context->property == HB_OT_LAYOUT_GLYPH_CLASS_MARK)
return false;
unsigned int index = (this+coverage) (IN_CURGLYPH ());
@@ -941,7 +941,7 @@ struct CursivePosFormat1
POSITION (last_pos)->x_advance = gpi->anchor_x - entry_x;
}
- if (lookup_flag & LookupFlag::RightToLeft)
+ if (apply_context->lookup_flag & LookupFlag::RightToLeft)
{
POSITION (last_pos)->cursive_chain = last_pos - buffer->in_pos;
POSITION (last_pos)->y_offset = entry_y - gpi->anchor_y;
@@ -1028,6 +1028,7 @@ struct MarkBasePosFormat1
return false;
/* now we search backwards for a non-mark glyph */
+ unsigned int property;
unsigned int j = buffer->in_pos;
do
{
@@ -1127,6 +1128,7 @@ struct MarkLigPosFormat1
return false;
/* now we search backwards for a non-mark glyph */
+ unsigned int property;
unsigned int j = buffer->in_pos;
do
{
@@ -1243,13 +1245,14 @@ struct MarkMarkPosFormat1
return false;
/* now we search backwards for a suitable mark glyph until a non-mark glyph */
+ unsigned int property;
unsigned int j = buffer->in_pos;
do
{
if (HB_UNLIKELY (!j))
return false;
j--;
- } while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), lookup_flag, &property));
+ } while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), apply_context->lookup_flag, &property));
if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK))
return false;
@@ -1454,10 +1457,12 @@ struct PosLookup : Lookup
unsigned int apply_depth) const
{
unsigned int lookup_type = get_type ();
- unsigned int lookup_flag = get_flag ();
- unsigned int property;
+ hb_apply_context_t apply_context[1];
+
+ apply_context->nesting_level_left = nesting_level_left;
+ apply_context->lookup_flag = get_flag ();
- if (!_hb_ot_layout_check_glyph_property (context->face, IN_CURINFO (), lookup_flag, &property))
+ if (!_hb_ot_layout_check_glyph_property (context->face, IN_CURINFO (), apply_context->lookup_flag, &apply_context->property))
return false;
for (unsigned int i = 0; i < get_subtable_count (); i++)
@@ -1562,14 +1567,13 @@ static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
const GPOS &gpos = *(context->face->ot_layout.gpos);
const PosLookup &l = gpos.get_lookup (lookup_index);
- if (HB_UNLIKELY (nesting_level_left == 0))
+ if (HB_UNLIKELY (apply_context->nesting_level_left == 0))
return false;
- nesting_level_left--;
if (HB_UNLIKELY (context_length < 1))
return false;
- return l.apply_once (context, buffer, context_length, nesting_level_left, apply_depth);
+ return l.apply_once (context, buffer, context_length, apply_context->nesting_level_left - 1, apply_depth + 1);
}
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index 9940eba..f3b3e83 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -49,7 +49,7 @@ struct SingleSubstFormat1
/* We inherit the old glyph class to the substituted glyph */
if (_hb_ot_layout_has_new_glyph_classes (context->face))
- _hb_ot_layout_set_glyph_property (context->face, glyph_id, property);
+ _hb_ot_layout_set_glyph_property (context->face, glyph_id, apply_context->property);
return true;
}
@@ -91,7 +91,7 @@ struct SingleSubstFormat2
/* We inherit the old glyph class to the substituted glyph */
if (_hb_ot_layout_has_new_glyph_classes (context->face))
- _hb_ot_layout_set_glyph_property (context->face, glyph_id, property);
+ _hb_ot_layout_set_glyph_property (context->face, glyph_id, apply_context->property);
return true;
}
@@ -165,6 +165,7 @@ struct Sequence
/* This is a guess only ... */
if (_hb_ot_layout_has_new_glyph_classes (context->face))
{
+ unsigned int property = apply_context->property;
if (property == HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE)
property = HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH;
@@ -295,7 +296,7 @@ struct AlternateSubstFormat1
/* We inherit the old glyph class to the substituted glyph */
if (_hb_ot_layout_has_new_glyph_classes (context->face))
- _hb_ot_layout_set_glyph_property (context->face, glyph_id, property);
+ _hb_ot_layout_set_glyph_property (context->face, glyph_id, apply_context->property);
return true;
}
@@ -364,7 +365,8 @@ struct Ligature
for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
{
- while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), lookup_flag, &property))
+ unsigned int property;
+ while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), apply_context->lookup_flag, &property))
{
if (HB_UNLIKELY (j + count - i == end))
return false;
@@ -405,7 +407,7 @@ struct Ligature
for ( i = 1; i < count; i++ )
{
- while (_hb_ot_layout_skip_mark (context->face, IN_CURINFO (), lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (context->face, IN_CURINFO (), apply_context->lookup_flag, NULL))
_hb_buffer_add_output_glyph (buffer, IN_CURGLYPH (), i, lig_id);
(buffer->in_pos)++;
@@ -472,7 +474,7 @@ struct LigatureSubstFormat1
TRACE_APPLY ();
hb_codepoint_t glyph_id = IN_CURGLYPH ();
- bool first_is_mark = !!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK);
+ bool first_is_mark = !!(apply_context->property & HB_OT_LAYOUT_GLYPH_CLASS_MARK);
unsigned int index = (this+coverage) (glyph_id);
if (HB_LIKELY (index == NOT_COVERED))
@@ -757,17 +759,19 @@ struct SubstLookup : Lookup
}
- inline bool apply_once (hb_ot_layout_context_t *context,
- hb_buffer_t *buffer,
- unsigned int context_length,
- unsigned int nesting_level_left,
- unsigned int apply_depth) const
+ inline bool apply_once ( hb_ot_layout_context_t *context,
+ hb_buffer_t *buffer,
+ unsigned int context_length,
+ unsigned int nesting_level_left,
+ unsigned int apply_depth) const
{
unsigned int lookup_type = get_type ();
- unsigned int lookup_flag = get_flag ();
- unsigned int property;
+ hb_apply_context_t apply_context[1];
- if (!_hb_ot_layout_check_glyph_property (context->face, IN_CURINFO (), lookup_flag, &property))
+ apply_context->nesting_level_left = nesting_level_left;
+ apply_context->lookup_flag = get_flag ();
+
+ if (!_hb_ot_layout_check_glyph_property (context->face, IN_CURINFO (), apply_context->lookup_flag, &apply_context->property))
return false;
if (HB_UNLIKELY (lookup_type == SubstLookupSubTable::Extension))
@@ -906,14 +910,13 @@ static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
const GSUB &gsub = *(context->face->ot_layout.gsub);
const SubstLookup &l = gsub.get_lookup (lookup_index);
- if (HB_UNLIKELY (nesting_level_left == 0))
+ if (HB_UNLIKELY (apply_context->nesting_level_left == 0))
return false;
- nesting_level_left--;
if (HB_UNLIKELY (context_length < 1))
return false;
- return l.apply_once (context, buffer, context_length, nesting_level_left, apply_depth);
+ return l.apply_once (context, buffer, context_length, apply_context->nesting_level_left - 1, apply_depth + 1);
}
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index d27cd80..c317e54 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -43,22 +43,25 @@
#define APPLY_ARG_DEF \
+ hb_apply_context_t *apply_context, \
hb_ot_layout_context_t *context, \
- hb_buffer_t *buffer, \
- unsigned int context_length HB_GNUC_UNUSED, \
- unsigned int nesting_level_left HB_GNUC_UNUSED, \
- unsigned int lookup_flag HB_GNUC_UNUSED, \
- unsigned int property HB_GNUC_UNUSED, /* propety of first glyph */ \
- unsigned int apply_depth HB_GNUC_UNUSED
+ hb_buffer_t *buffer, \
+ unsigned int context_length HB_GNUC_UNUSED, \
+ unsigned int apply_depth HB_GNUC_UNUSED
#define APPLY_ARG \
+ apply_context, \
context, \
buffer, \
context_length, \
- nesting_level_left, \
- lookup_flag, \
- property, \
(HB_DEBUG_APPLY ? apply_depth + 1 : 0)
+struct hb_apply_context_t
+{
+ unsigned int nesting_level_left;
+ unsigned int lookup_flag;
+ unsigned int property; /* propety of first glyph (TODO remove) */
+};
+
typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const char *data);
typedef bool (*apply_lookup_func_t) (APPLY_ARG_DEF, unsigned int lookup_index);
@@ -102,7 +105,7 @@ static inline bool match_input (APPLY_ARG_DEF,
for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
{
- while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), apply_context->lookup_flag, NULL))
{
if (HB_UNLIKELY (j + count - i == end))
return false;
@@ -129,7 +132,7 @@ static inline bool match_backtrack (APPLY_ARG_DEF,
for (unsigned int i = 0, j = buffer->out_pos - 1; i < count; i++, j--)
{
- while (_hb_ot_layout_skip_mark (context->face, OUT_INFO (j), lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (context->face, OUT_INFO (j), apply_context->lookup_flag, NULL))
{
if (HB_UNLIKELY (j + 1 == count - i))
return false;
@@ -157,7 +160,7 @@ static inline bool match_lookahead (APPLY_ARG_DEF,
for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++)
{
- while (_hb_ot_layout_skip_mark (context->face, OUT_INFO (j), lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (context->face, OUT_INFO (j), apply_context->lookup_flag, NULL))
{
if (HB_UNLIKELY (j + count - i == end))
return false;
@@ -207,7 +210,7 @@ static inline bool apply_lookup (APPLY_ARG_DEF,
*/
for (unsigned int i = 0; i < count; /* NOP */)
{
- while (_hb_ot_layout_skip_mark (context->face, IN_CURINFO (), lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (context->face, IN_CURINFO (), apply_context->lookup_flag, NULL))
{
if (HB_UNLIKELY (buffer->in_pos == end))
return true;
commit 173fde7087c0db3e99409f1119530477c14072f5
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 29 01:47:30 2010 -0400
Further simplify tracing
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 1ee9c6f..1b33183 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -137,9 +137,7 @@ ASSERT_STATIC (sizeof (Type) + 1 <= sizeof (_Null##Type))
#define SANITIZE_ARG \
context, \
(HB_DEBUG_SANITIZE ? sanitize_depth + 1 : 0)
-#define SANITIZE_ARG_INIT \
- &context, \
- 1
+
typedef struct _hb_sanitize_context_t hb_sanitize_context_t;
struct _hb_sanitize_context_t
@@ -266,7 +264,8 @@ template <typename Type>
struct Sanitizer
{
static hb_blob_t *sanitize (hb_blob_t *blob) {
- hb_sanitize_context_t context;
+ hb_sanitize_context_t context[1];
+ unsigned int sanitize_depth = 0;
bool sane;
/* TODO is_sane() stuff */
@@ -276,33 +275,33 @@ struct Sanitizer
fprintf (stderr, "Sanitizer %p start %s\n", blob, __PRETTY_FUNCTION__);
#endif
- _hb_sanitize_init (&context, blob);
+ _hb_sanitize_init (context, blob);
/* Note: We drop const here */
- Type *t = CastP<Type> ((void *) context.start);
+ Type *t = CastP<Type> ((void *) context->start);
- sane = t->sanitize (SANITIZE_ARG_INIT);
+ sane = t->sanitize (SANITIZE_ARG);
if (sane) {
- if (context.edit_count) {
+ if (context->edit_count) {
#if HB_DEBUG_SANITIZE
fprintf (stderr, "Sanitizer %p passed first round with %d edits; doing a second round %s\n",
- blob, context.edit_count, __PRETTY_FUNCTION__);
+ blob, context->edit_count, __PRETTY_FUNCTION__);
#endif
/* sanitize again to ensure no toe-stepping */
- context.edit_count = 0;
- sane = t->sanitize (SANITIZE_ARG_INIT);
- if (context.edit_count) {
+ context->edit_count = 0;
+ sane = t->sanitize (SANITIZE_ARG);
+ if (context->edit_count) {
#if HB_DEBUG_SANITIZE
fprintf (stderr, "Sanitizer %p requested %d edits in second round; FAILLING %s\n",
- blob, context.edit_count, __PRETTY_FUNCTION__);
+ blob, context->edit_count, __PRETTY_FUNCTION__);
#endif
sane = false;
}
}
- _hb_sanitize_fini (&context, blob);
+ _hb_sanitize_fini (context, blob);
} else {
- unsigned int edit_count = context.edit_count;
- _hb_sanitize_fini (&context, blob);
+ unsigned int edit_count = context->edit_count;
+ _hb_sanitize_fini (context, blob);
if (edit_count && !hb_blob_is_writable (blob) && hb_blob_try_writable (blob)) {
/* ok, we made it writable by relocating. try again */
#if HB_DEBUG_SANITIZE
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index 777874b..fe6ac63 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -1450,7 +1450,8 @@ struct PosLookup : Lookup
inline bool apply_once (hb_ot_layout_context_t *context,
hb_buffer_t *buffer,
unsigned int context_length,
- unsigned int nesting_level_left) const
+ unsigned int nesting_level_left,
+ unsigned int apply_depth) const
{
unsigned int lookup_type = get_type ();
unsigned int lookup_flag = get_flag ();
@@ -1460,7 +1461,7 @@ struct PosLookup : Lookup
return false;
for (unsigned int i = 0; i < get_subtable_count (); i++)
- if (get_subtable (i).apply (APPLY_ARG_INIT, lookup_type))
+ if (get_subtable (i).apply (APPLY_ARG, lookup_type))
return true;
return false;
@@ -1483,7 +1484,7 @@ struct PosLookup : Lookup
bool done;
if (~IN_MASK (buffer->in_pos) & mask)
{
- done = apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL);
+ done = apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL, 0);
ret |= done;
}
else
@@ -1568,7 +1569,7 @@ static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
if (HB_UNLIKELY (context_length < 1))
return false;
- return l.apply_once (context, buffer, context_length, nesting_level_left);
+ return l.apply_once (context, buffer, context_length, nesting_level_left, apply_depth);
}
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index 77c27a8..9940eba 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -760,7 +760,8 @@ struct SubstLookup : Lookup
inline bool apply_once (hb_ot_layout_context_t *context,
hb_buffer_t *buffer,
unsigned int context_length,
- unsigned int nesting_level_left) const
+ unsigned int nesting_level_left,
+ unsigned int apply_depth) const
{
unsigned int lookup_type = get_type ();
unsigned int lookup_flag = get_flag ();
@@ -785,7 +786,7 @@ struct SubstLookup : Lookup
unsigned int count = get_subtable_count ();
for (unsigned int i = 0; i < count; i++)
- if (get_subtable (i).apply (APPLY_ARG_INIT, lookup_type))
+ if (get_subtable (i).apply (APPLY_ARG, lookup_type))
return true;
return false;
@@ -808,7 +809,7 @@ struct SubstLookup : Lookup
while (buffer->in_pos < buffer->in_length)
{
if ((~IN_MASK (buffer->in_pos) & mask) &&
- apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
+ apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL, 0))
ret = true;
else
_hb_buffer_next_glyph (buffer);
@@ -824,7 +825,7 @@ struct SubstLookup : Lookup
do
{
if ((~IN_MASK (buffer->in_pos) & mask) &&
- apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
+ apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL, 0))
ret = true;
else
buffer->in_pos--;
@@ -912,7 +913,7 @@ static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
if (HB_UNLIKELY (context_length < 1))
return false;
- return l.apply_once (context, buffer, context_length, nesting_level_left);
+ return l.apply_once (context, buffer, context_length, nesting_level_left, apply_depth);
}
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 88f3791..d27cd80 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -58,14 +58,6 @@
lookup_flag, \
property, \
(HB_DEBUG_APPLY ? apply_depth + 1 : 0)
-#define APPLY_ARG_INIT \
- context, \
- buffer, \
- context_length, \
- nesting_level_left, \
- lookup_flag, \
- property, \
- 1
typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const char *data);
commit bc200457430c083914a64bf4b056153506749610
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 29 01:40:26 2010 -0400
Simplify trace code
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 64acb1b..1ee9c6f 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -124,41 +124,22 @@ ASSERT_STATIC (sizeof (Type) + 1 <= sizeof (_Null##Type))
#define HB_DEBUG_SANITIZE HB_DEBUG+0
#endif
-static HB_GNUC_UNUSED inline hb_bool_t /* always returns TRUE */
-_hb_trace (const char *what,
- const char *function,
- void *obj,
- unsigned int depth,
- unsigned int max_depth)
-{
- if (depth < max_depth)
- fprintf (stderr, "%s(%p) %-*d-> %s\n",
- what,
- (obj == CharP(&_NullPool)) ? 0 : obj,
- depth, depth,
- function);
- return TRUE;
-}
-
+#define TRACE_SANITIZE() \
+ HB_STMT_START { \
+ if (HB_DEBUG_SANITIZE) \
+ _hb_trace ("SANITIZE", __PRETTY_FUNCTION__, this, sanitize_depth, HB_DEBUG_SANITIZE); \
+ } HB_STMT_END
-#if HB_DEBUG_SANITIZE
-#define TRACE_SANITIZE() _hb_trace ("SANITIZE", __PRETTY_FUNCTION__, this, sanitize_depth, HB_DEBUG_SANITIZE)
-#define TRACE_SANITIZE_ARG_DEF , unsigned int sanitize_depth HB_GNUC_UNUSED
-#define TRACE_SANITIZE_ARG , sanitize_depth + 1
-#define TRACE_SANITIZE_ARG_INIT , 1
-#else
-#define TRACE_SANITIZE() _hb_trace ("SANITIZE", __PRETTY_FUNCTION__, this, 0, HB_DEBUG_SANITIZE)
-#define TRACE_SANITIZE_ARG_DEF
-#define TRACE_SANITIZE_ARG
-#define TRACE_SANITIZE_ARG_INIT
-#endif
#define SANITIZE_ARG_DEF \
- hb_sanitize_context_t *context TRACE_SANITIZE_ARG_DEF
+ hb_sanitize_context_t *context, \
+ unsigned int sanitize_depth HB_GNUC_UNUSED
#define SANITIZE_ARG \
- context TRACE_SANITIZE_ARG
+ context, \
+ (HB_DEBUG_SANITIZE ? sanitize_depth + 1 : 0)
#define SANITIZE_ARG_INIT \
- &context TRACE_SANITIZE_ARG_INIT
+ &context, \
+ 1
typedef struct _hb_sanitize_context_t hb_sanitize_context_t;
struct _hb_sanitize_context_t
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 979026d..88f3791 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -35,24 +35,11 @@
#define HB_DEBUG_APPLY HB_DEBUG+0
#endif
-static HB_GNUC_UNUSED inline hb_bool_t /* always returns TRUE */
-_hb_trace_apply (const char *obj,
- unsigned int apply_depth,
- const char *function)
-{
- /* The following check is written in such a skewed way just
- * to quiet compiler warning. The simple version would have been:
- * if (apply_depth < HB_DEBUG_APPLY)
- */
- if (HB_DEBUG_APPLY && (int) apply_depth < HB_DEBUG_APPLY)
- fprintf (stderr, "APPLY(%p) %-*d-> %s\n",
- (obj == CharP(&_NullPool)) ? 0 : obj,
- apply_depth, apply_depth,
- function);
- return TRUE;
-}
-
-#define TRACE_APPLY() _hb_trace_apply (CharP(this), apply_depth, __PRETTY_FUNCTION__)
+#define TRACE_APPLY() \
+ HB_STMT_START { \
+ if (HB_DEBUG_APPLY) \
+ _hb_trace ("APPLY", __PRETTY_FUNCTION__, this, apply_depth, HB_DEBUG_APPLY); \
+ } HB_STMT_END
#define APPLY_ARG_DEF \
@@ -70,7 +57,7 @@ _hb_trace_apply (const char *obj,
nesting_level_left, \
lookup_flag, \
property, \
- (HB_DEBUG_APPLY ? apply_depth+1 : 0)
+ (HB_DEBUG_APPLY ? apply_depth + 1 : 0)
#define APPLY_ARG_INIT \
context, \
buffer, \
diff --git a/src/hb-private.h b/src/hb-private.h
index e4d2e54..2c118a6 100644
--- a/src/hb-private.h
+++ b/src/hb-private.h
@@ -31,9 +31,7 @@
#include "config.h"
#endif
-#ifndef HB_DEBUG
-#define HB_DEBUG 0
-#endif
+#include "hb-common.h"
#include <stdlib.h>
#include <string.h>
@@ -46,7 +44,18 @@
#include <stdio.h>
#include <errno.h>
-#include "hb-common.h"
+
+/* Essentials */
+
+#ifndef NULL
+# define NULL ((void *) 0)
+#endif
+
+#undef FALSE
+#define FALSE 0
+
+#undef TRUE
+#define TRUE 1
/* Basics */
@@ -61,16 +70,6 @@
# define HB_INTERNAL extern
#endif
-#ifndef NULL
-# define NULL ((void *) 0)
-#endif
-
-#undef FALSE
-#define FALSE 0
-
-#undef TRUE
-#define TRUE 1
-
#undef ARRAY_LENGTH
#define ARRAY_LENGTH(__array) ((signed int) (sizeof (__array) / sizeof (__array[0])))
@@ -81,6 +80,9 @@
#define _ASSERT_STATIC0(_line, _cond) _ASSERT_STATIC1 (_line, (_cond))
#define ASSERT_STATIC(_cond) _ASSERT_STATIC0 (__LINE__, (_cond))
+
+/* Misc */
+
#define ASSERT_SIZE(_type, _size) ASSERT_STATIC (sizeof (_type) == (_size))
/* Size signifying variable-sized array */
@@ -223,6 +225,24 @@ typedef int hb_mutex_t;
#define hb_be_uint32_cmp(a,b) (a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3])
+/* Debug */
+
+#ifndef HB_DEBUG
+#define HB_DEBUG 0
+#endif
+
+static HB_GNUC_UNUSED inline hb_bool_t /* always returns TRUE */
+_hb_trace (const char *what,
+ const char *function,
+ const void *obj,
+ unsigned int depth,
+ unsigned int max_depth)
+{
+ if (depth < max_depth)
+ fprintf (stderr, "%s(%p) %-*d-> %s\n", what, obj, depth, depth, function);
+ return TRUE;
+}
+
#include "hb-object-private.h"
commit 807c5b03a2251a3c29a520852639421783101b55
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Apr 28 20:25:22 2010 -0400
[sanitize] Make debug code always available to the compiler
Such that we don't break debug build all the time.
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index f64526c..64acb1b 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -121,27 +121,36 @@ ASSERT_STATIC (sizeof (Type) + 1 <= sizeof (_Null##Type))
*/
#ifndef HB_DEBUG_SANITIZE
-#define HB_DEBUG_SANITIZE HB_DEBUG
+#define HB_DEBUG_SANITIZE HB_DEBUG+0
#endif
+static HB_GNUC_UNUSED inline hb_bool_t /* always returns TRUE */
+_hb_trace (const char *what,
+ const char *function,
+ void *obj,
+ unsigned int depth,
+ unsigned int max_depth)
+{
+ if (depth < max_depth)
+ fprintf (stderr, "%s(%p) %-*d-> %s\n",
+ what,
+ (obj == CharP(&_NullPool)) ? 0 : obj,
+ depth, depth,
+ function);
+ return TRUE;
+}
+
+
#if HB_DEBUG_SANITIZE
-#include <stdio.h>
+#define TRACE_SANITIZE() _hb_trace ("SANITIZE", __PRETTY_FUNCTION__, this, sanitize_depth, HB_DEBUG_SANITIZE)
#define TRACE_SANITIZE_ARG_DEF , unsigned int sanitize_depth HB_GNUC_UNUSED
#define TRACE_SANITIZE_ARG , sanitize_depth + 1
#define TRACE_SANITIZE_ARG_INIT , 1
-#define TRACE_SANITIZE() \
- HB_STMT_START { \
- if (sanitize_depth < HB_DEBUG_SANITIZE) \
- fprintf (stderr, "SANITIZE(%p) %-*d-> %s\n", \
- (CharP(this) == CharP(&_NullPool)) ? 0 : this, \
- sanitize_depth, sanitize_depth, \
- __PRETTY_FUNCTION__); \
- } HB_STMT_END
#else
+#define TRACE_SANITIZE() _hb_trace ("SANITIZE", __PRETTY_FUNCTION__, this, 0, HB_DEBUG_SANITIZE)
#define TRACE_SANITIZE_ARG_DEF
#define TRACE_SANITIZE_ARG
#define TRACE_SANITIZE_ARG_INIT
-#define TRACE_SANITIZE() HB_STMT_START {} HB_STMT_END
#endif
#define SANITIZE_ARG_DEF \
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 629be6c..979026d 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -40,7 +40,7 @@ _hb_trace_apply (const char *obj,
unsigned int apply_depth,
const char *function)
{
- /* The following check is written in such a skewer way just
+ /* The following check is written in such a skewed way just
* to quiet compiler warning. The simple version would have been:
* if (apply_depth < HB_DEBUG_APPLY)
*/
commit 74e313c016704e1d9157c2763691c4151f049dfc
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Apr 28 15:15:09 2010 -0400
[gsubgpos] Make debug code always available to the compiler
Such that we don't break debug build all the time.
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 425ec35..629be6c 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -32,28 +32,28 @@
#ifndef HB_DEBUG_APPLY
-#define HB_DEBUG_APPLY HB_DEBUG
+#define HB_DEBUG_APPLY HB_DEBUG+0
#endif
-#if HB_DEBUG_APPLY
-#include <stdio.h>
-#define TRACE_APPLY_ARG_DEF , unsigned int apply_depth HB_GNUC_UNUSED
-#define TRACE_APPLY_ARG , apply_depth + 1
-#define TRACE_APPLY_ARG_INIT , 1
-#define TRACE_APPLY() \
- HB_STMT_START { \
- if (apply_depth < HB_DEBUG_APPLY) \
- fprintf (stderr, "APPLY(%p) %-*d-> %s\n", \
- (CharP(this) == CharP(&_NullPool)) ? 0 : this, \
- apply_depth, apply_depth, \
- __PRETTY_FUNCTION__); \
- } HB_STMT_END
-#else
-#define TRACE_APPLY_ARG_DEF
-#define TRACE_APPLY_ARG
-#define TRACE_APPLY_ARG_INIT
-#define TRACE_APPLY() HB_STMT_START {} HB_STMT_END
-#endif
+static HB_GNUC_UNUSED inline hb_bool_t /* always returns TRUE */
+_hb_trace_apply (const char *obj,
+ unsigned int apply_depth,
+ const char *function)
+{
+ /* The following check is written in such a skewer way just
+ * to quiet compiler warning. The simple version would have been:
+ * if (apply_depth < HB_DEBUG_APPLY)
+ */
+ if (HB_DEBUG_APPLY && (int) apply_depth < HB_DEBUG_APPLY)
+ fprintf (stderr, "APPLY(%p) %-*d-> %s\n",
+ (obj == CharP(&_NullPool)) ? 0 : obj,
+ apply_depth, apply_depth,
+ function);
+ return TRUE;
+}
+
+#define TRACE_APPLY() _hb_trace_apply (CharP(this), apply_depth, __PRETTY_FUNCTION__)
+
#define APPLY_ARG_DEF \
hb_ot_layout_context_t *context, \
@@ -61,24 +61,24 @@
unsigned int context_length HB_GNUC_UNUSED, \
unsigned int nesting_level_left HB_GNUC_UNUSED, \
unsigned int lookup_flag HB_GNUC_UNUSED, \
- unsigned int property HB_GNUC_UNUSED /* propety of first glyph */ \
- TRACE_APPLY_ARG_DEF
+ unsigned int property HB_GNUC_UNUSED, /* propety of first glyph */ \
+ unsigned int apply_depth HB_GNUC_UNUSED
#define APPLY_ARG \
context, \
buffer, \
context_length, \
nesting_level_left, \
lookup_flag, \
- property \
- TRACE_APPLY_ARG
+ property, \
+ (HB_DEBUG_APPLY ? apply_depth+1 : 0)
#define APPLY_ARG_INIT \
context, \
buffer, \
context_length, \
nesting_level_left, \
lookup_flag, \
- property \
- TRACE_APPLY_ARG_INIT
+ property, \
+ 1
typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const char *data);
commit 41011a6ed7c4891b20c0eddbb6d4ad9c820cfddb
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Apr 28 13:33:09 2010 -0400
Fix compiler warning about value unused
diff --git a/src/hb-object-private.h b/src/hb-object-private.h
index 6aeb6ec..93c8711 100644
--- a/src/hb-object-private.h
+++ b/src/hb-object-private.h
@@ -94,7 +94,7 @@ _hb_object_debug_out (void *obj,
#define HB_OBJECT_DO_CREATE(Type, obj) \
HB_LIKELY (( \
- ( \
+ (void) ( \
((obj) = (Type *) calloc (1, sizeof (Type))) && \
HB_OBJECT_DO_INIT_EXPR (obj) && \
HB_OBJECT_DEBUG_OUT (obj) \
commit 863df68e894b7644dcd12da88aa22f73edf829dc
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Apr 28 13:29:55 2010 -0400
[object] Make debug code always available to the compiler
Such that we don't break debug build all the time.
diff --git a/src/hb-object-private.h b/src/hb-object-private.h
index 81ab6c2..6aeb6ec 100644
--- a/src/hb-object-private.h
+++ b/src/hb-object-private.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2007 Chris Wilson
- * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2009,2010 Red Hat, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
@@ -30,20 +30,8 @@
#ifndef HB_REFCOUNT_PRIVATE_H
#define HB_REFCOUNT_PRIVATE_H
+#include "hb-private.h"
-#ifndef HB_DEBUG_OBJECT
-#define HB_DEBUG_OBJECT HB_DEBUG
-#endif
-
-#if HB_DEBUG_OBJECT
-#include <stdio.h>
-#define HB_OBJECT_DEBUG_OUT(obj) fprintf (stderr, "%p refcount=%d %s\n", \
- obj, \
- HB_REFERENCE_COUNT_GET_VALUE (obj->ref_count), \
- __FUNCTION__)
-#else
-#define HB_OBJECT_DEBUG_OUT(obj) 1
-#endif
/* Encapsulate operations on the object's reference count */
@@ -68,7 +56,30 @@ typedef struct {
-/* Helper macros */
+/* Debug */
+
+#ifndef HB_DEBUG_OBJECT
+#define HB_DEBUG_OBJECT HB_DEBUG+0
+#endif
+
+static HB_GNUC_UNUSED inline hb_bool_t /* always returns TRUE */
+_hb_object_debug_out (void *obj,
+ hb_reference_count_t *ref_count,
+ const char *function)
+{
+ if (HB_DEBUG_OBJECT)
+ fprintf (stderr, "%p refcount=%d %s\n",
+ obj,
+ HB_REFERENCE_COUNT_GET_VALUE (*ref_count),
+ function);
+ return TRUE;
+}
+
+#define HB_OBJECT_DEBUG_OUT(obj) _hb_object_debug_out ((void *) obj, &obj->ref_count, __FUNCTION__)
+
+
+
+/* Object allocation and lifecycle manamgement macros */
#define HB_OBJECT_IS_INERT(obj) \
(HB_UNLIKELY (HB_REFERENCE_COUNT_IS_INVALID ((obj)->ref_count)))
@@ -122,4 +133,5 @@ typedef struct {
} HB_STMT_END
+
#endif /* HB_REFCOUNT_PRIVATE_H */
commit 1d52151a19ed8ec776276aac5cc6ce3769e0d947
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Apr 28 13:18:41 2010 -0400
Minor
diff --git a/src/hb-private.h b/src/hb-private.h
index b33d629..e4d2e54 100644
--- a/src/hb-private.h
+++ b/src/hb-private.h
@@ -31,7 +31,6 @@
#include "config.h"
#endif
-/* #define HB_DEBUG 1 */
#ifndef HB_DEBUG
#define HB_DEBUG 0
#endif
@@ -39,10 +38,13 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
-#if HB_DEBUG
+
+/* We only use these two for debug output. However, the debug code is
+ * always seen by the compiler (and optimized out in non-debug builds.
+ * If including these becomes a problem, we can start thinking about
+ * someway around that. */
#include <stdio.h>
#include <errno.h>
-#endif
#include "hb-common.h"
commit 444fffb1ab378cb3022e2a8e9f90d20a00c82f6a
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Apr 28 13:16:38 2010 -0400
[blob] Make debug code always available to the compiler
Such that we don't break debug build all the time.
diff --git a/src/hb-blob.c b/src/hb-blob.c
index 8013de1..370148f 100644
--- a/src/hb-blob.c
+++ b/src/hb-blob.c
@@ -36,13 +36,11 @@
#endif /* HAVE_SYS_MMAN_H */
#ifndef HB_DEBUG_BLOB
-#define HB_DEBUG_BLOB HB_DEBUG
+#define HB_DEBUG_BLOB HB_DEBUG+0
#endif
-#if HB_DEBUG_BLOB
#include <stdio.h>
#include <errno.h>
-#endif
hb_blob_t _hb_blob_nil = {
HB_REFERENCE_COUNT_INVALID, /* ref_count */
@@ -181,10 +179,9 @@ hb_blob_lock (hb_blob_t *blob)
hb_mutex_lock (blob->lock);
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s (%d) -> %p\n", blob, __FUNCTION__,
- blob->lock_count, blob->data);
-#endif
+ if (HB_DEBUG_BLOB)
+ fprintf (stderr, "%p %s (%d) -> %p\n", blob, __FUNCTION__,
+ blob->lock_count, blob->data);
blob->lock_count++;
@@ -201,10 +198,9 @@ hb_blob_unlock (hb_blob_t *blob)
hb_mutex_lock (blob->lock);
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s (%d) -> %p\n", blob, __FUNCTION__,
- blob->lock_count, blob->data);
-#endif
+ if (HB_DEBUG_BLOB)
+ fprintf (stderr, "%p %s (%d) -> %p\n", blob, __FUNCTION__,
+ blob->lock_count, blob->data);
assert (blob->lock_count > 0);
blob->lock_count--;
@@ -246,35 +242,30 @@ _try_make_writable_inplace_unix_locked (hb_blob_t *blob)
#endif
if ((uintptr_t) -1L == pagesize) {
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: failed to get pagesize: %s\n", blob, __FUNCTION__, strerror (errno));
-#endif
+ if (HB_DEBUG_BLOB)
+ fprintf (stderr, "%p %s: failed to get pagesize: %s\n", blob, __FUNCTION__, strerror (errno));
return FALSE;
}
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: pagesize is %u\n", blob, __FUNCTION__, pagesize);
-#endif
+ if (HB_DEBUG_BLOB)
+ fprintf (stderr, "%p %s: pagesize is %u\n", blob, __FUNCTION__, pagesize);
mask = ~(pagesize-1);
addr = (const char *) (((uintptr_t) blob->data) & mask);
length = (const char *) (((uintptr_t) blob->data + blob->length + pagesize-1) & mask) - addr;
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: calling mprotect on [%p..%p] (%d bytes)\n",
- blob, __FUNCTION__,
- addr, addr+length, length);
-#endif
+ if (HB_DEBUG_BLOB)
+ fprintf (stderr, "%p %s: calling mprotect on [%p..%p] (%d bytes)\n",
+ blob, __FUNCTION__,
+ addr, addr+length, length);
if (-1 == mprotect ((void *) addr, length, PROT_READ | PROT_WRITE)) {
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: %s\n", blob, __FUNCTION__, strerror (errno));
-#endif
+ if (HB_DEBUG_BLOB)
+ fprintf (stderr, "%p %s: %s\n", blob, __FUNCTION__, strerror (errno));
return FALSE;
}
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: successfully made [%p..%p] (%d bytes) writable\n",
- blob, __FUNCTION__,
- addr, addr+length, length);
-#endif
+ if (HB_DEBUG_BLOB)
+ fprintf (stderr, "%p %s: successfully made [%p..%p] (%d bytes) writable\n",
+ blob, __FUNCTION__,
+ addr, addr+length, length);
return TRUE;
#else
return FALSE;
@@ -284,19 +275,16 @@ _try_make_writable_inplace_unix_locked (hb_blob_t *blob)
static void
_try_writable_inplace_locked (hb_blob_t *blob)
{
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: making writable\n", blob, __FUNCTION__);
-#endif
+ if (HB_DEBUG_BLOB)
+ fprintf (stderr, "%p %s: making writable\n", blob, __FUNCTION__);
if (_try_make_writable_inplace_unix_locked (blob)) {
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: making writable -> succeeded\n", blob, __FUNCTION__);
-#endif
+ if (HB_DEBUG_BLOB)
+ fprintf (stderr, "%p %s: making writable -> succeeded\n", blob, __FUNCTION__);
blob->mode = HB_MEMORY_MODE_WRITABLE;
} else {
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: making writable -> FAILED\n", blob, __FUNCTION__);
-#endif
+ if (HB_DEBUG_BLOB)
+ fprintf (stderr, "%p %s: making writable -> FAILED\n", blob, __FUNCTION__);
/* Failed to make writable inplace, mark that */
blob->mode = HB_MEMORY_MODE_READONLY;
}
@@ -339,19 +327,17 @@ hb_blob_try_writable (hb_blob_t *blob)
{
char *new_data;
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s (%d) -> %p\n", blob, __FUNCTION__,
- blob->lock_count, blob->data);
-#endif
+ if (HB_DEBUG_BLOB)
+ fprintf (stderr, "%p %s (%d) -> %p\n", blob, __FUNCTION__,
+ blob->lock_count, blob->data);
if (blob->lock_count)
goto done;
new_data = malloc (blob->length);
if (new_data) {
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: dupped successfully -> %p\n", blob, __FUNCTION__, blob->data);
-#endif
+ if (HB_DEBUG_BLOB)
+ fprintf (stderr, "%p %s: dupped successfully -> %p\n", blob, __FUNCTION__, blob->data);
memcpy (new_data, blob->data, blob->length);
_hb_blob_destroy_user_data (blob);
blob->mode = HB_MEMORY_MODE_WRITABLE;
More information about the HarfBuzz
mailing list