summaryrefslogtreecommitdiff
path: root/Build/source/libs/harfbuzz/harfbuzz-0.9.7
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-0.9.7')
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-open-file-private.hh10
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-open-type-private.hh82
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-head-table.hh2
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-hhea-table.hh2
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-hmtx-table.hh2
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-common-private.hh44
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gdef-table.hh24
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gpos-table.hh524
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gsub-table.hh752
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gsubgpos-private.hh806
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout.cc116
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout.h4
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-maxp-table.hh2
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-name-table.hh6
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-private.hh64
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-shape-plan.cc1
16 files changed, 1228 insertions, 1213 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-open-file-private.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-open-file-private.hh
index 250504ae20b..20d5e871697 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-open-file-private.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-open-file-private.hh
@@ -54,7 +54,7 @@ struct TTCHeader;
typedef struct TableRecord
{
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this));
}
@@ -103,7 +103,7 @@ typedef struct OffsetTable
public:
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) && c->check_array (tables, TableRecord::static_size, numTables));
}
@@ -131,7 +131,7 @@ struct TTCHeaderVersion1
inline const OpenTypeFontFace& get_face (unsigned int i) const { return this+table[i]; }
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (table.sanitize (c, this));
}
@@ -170,7 +170,7 @@ struct TTCHeader
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (unlikely (!u.header.version.sanitize (c))) return TRACE_RETURN (false);
switch (u.header.version.major) {
case 2: /* version 2 is compatible with version 1 */
@@ -232,7 +232,7 @@ struct OpenTypeFontFile
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (unlikely (!u.tag.sanitize (c))) return TRACE_RETURN (false);
switch (u.tag) {
case CFFTag: /* All the non-collection tags */
diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-open-type-private.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-open-type-private.hh
index 2372235a5ae..2e03dc3d0ca 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-open-type-private.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-open-type-private.hh
@@ -37,7 +37,6 @@
namespace OT {
-
/*
* Casts
*/
@@ -166,24 +165,12 @@ ASSERT_STATIC (Type::min_size + 1 <= sizeof (_Null##Type))
#endif
-#define TRACE_SANITIZE(this) \
- hb_auto_trace_t<HB_DEBUG_SANITIZE, bool> trace \
- (&c->debug_depth, c->get_name (), this, HB_FUNC, \
- "");
+#define TRACE_SANITIZE() \
+ hb_auto_trace_t<HB_DEBUG_SANITIZE> trace (&c->debug_depth, "SANITIZE", this, HB_FUNC, "");
struct hb_sanitize_context_t
{
- inline const char *get_name (void) { return "SANITIZE"; }
- static const unsigned int max_debug_depth = HB_DEBUG_SANITIZE;
- typedef bool return_t;
- template <typename T>
- inline return_t process (const T &obj) { return obj.sanitize (this); }
- static return_t default_return_value (void) { return true; }
- bool stop_sublookup_iteration (const return_t r) const { return false; }
- return_t recurse (unsigned int lookup_index)
- { return default_return_value (); }
-
inline void init (hb_blob_t *b)
{
this->blob = hb_blob_reference (b);
@@ -218,11 +205,10 @@ struct hb_sanitize_context_t
{
const char *p = (const char *) base;
- hb_auto_trace_t<HB_DEBUG_SANITIZE, bool> trace
- (&this->debug_depth, "SANITIZE", this->blob, NULL,
- "check_range [%p..%p] (%d bytes) in [%p..%p]",
- p, p + len, len,
- this->start, this->end);
+ hb_auto_trace_t<HB_DEBUG_SANITIZE> trace (&this->debug_depth, "SANITIZE", this->blob, NULL,
+ "check_range [%p..%p] (%d bytes) in [%p..%p]",
+ p, p + len, len,
+ this->start, this->end);
return TRACE_RETURN (likely (this->start <= p && p <= this->end && (unsigned int) (this->end - p) >= len));
}
@@ -232,11 +218,10 @@ struct hb_sanitize_context_t
const char *p = (const char *) base;
bool overflows = _hb_unsigned_int_mul_overflows (len, record_size);
- hb_auto_trace_t<HB_DEBUG_SANITIZE, bool> trace
- (&this->debug_depth, "SANITIZE", this->blob, NULL,
- "check_array [%p..%p] (%d*%d=%ld bytes) in [%p..%p]",
- p, p + (record_size * len), record_size, len, (unsigned long) record_size * len,
- this->start, this->end);
+ hb_auto_trace_t<HB_DEBUG_SANITIZE> trace (&this->debug_depth, "SANITIZE", this->blob, NULL,
+ "check_array [%p..%p] (%d*%d=%ld bytes) in [%p..%p]",
+ p, p + (record_size * len), record_size, len, (unsigned long) record_size * len,
+ this->start, this->end);
return TRACE_RETURN (likely (!overflows && this->check_range (base, record_size * len)));
}
@@ -252,12 +237,11 @@ struct hb_sanitize_context_t
const char *p = (const char *) base;
this->edit_count++;
- hb_auto_trace_t<HB_DEBUG_SANITIZE, bool> trace
- (&this->debug_depth, "SANITIZE", this->blob, NULL,
- "may_edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s",
- this->edit_count,
- p, p + len, len,
- this->start, this->end);
+ hb_auto_trace_t<HB_DEBUG_SANITIZE> trace (&this->debug_depth, "SANITIZE", this->blob, NULL,
+ "may_edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s",
+ this->edit_count,
+ p, p + len, len,
+ this->start, this->end);
return TRACE_RETURN (this->writable);
}
@@ -352,10 +336,8 @@ struct Sanitizer
#endif
-#define TRACE_SERIALIZE(this) \
- hb_auto_trace_t<HB_DEBUG_SERIALIZE, bool> trace \
- (&c->debug_depth, "SERIALIZE", c, HB_FUNC, \
- "");
+#define TRACE_SERIALIZE() \
+ hb_auto_trace_t<HB_DEBUG_SERIALIZE> trace (&c->debug_depth, "SERIALIZE", c, HB_FUNC, "");
struct hb_serialize_context_t
@@ -549,7 +531,7 @@ struct IntType
inline int cmp (IntType<Type> va) const { Type a = va; Type b = v; return a < b ? -1 : a == b ? 0 : +1; }
inline int cmp (Type a) const { Type b = v; return a < b ? -1 : a == b ? 0 : +1; }
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (likely (c->check_struct (this)));
}
protected:
@@ -574,7 +556,7 @@ typedef USHORT UFWORD;
struct LONGDATETIME
{
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (likely (c->check_struct (this)));
}
private:
@@ -638,7 +620,7 @@ struct FixedVersion
inline uint32_t to_int (void) const { return (major << 16) + minor; }
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this));
}
@@ -678,7 +660,7 @@ struct GenericOffsetTo : OffsetType
}
inline bool sanitize (hb_sanitize_context_t *c, void *base) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (unlikely (!c->check_struct (this))) return TRACE_RETURN (false);
unsigned int offset = *this;
if (unlikely (!offset)) return TRACE_RETURN (true);
@@ -687,7 +669,7 @@ struct GenericOffsetTo : OffsetType
}
template <typename T>
inline bool sanitize (hb_sanitize_context_t *c, void *base, T user_data) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (unlikely (!c->check_struct (this))) return TRACE_RETURN (false);
unsigned int offset = *this;
if (unlikely (!offset)) return TRACE_RETURN (true);
@@ -751,7 +733,7 @@ struct GenericArrayOf
inline bool serialize (hb_serialize_context_t *c,
unsigned int items_len)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
len.set (items_len); /* TODO(serialize) Overflow? */
if (unlikely (!c->extend (*this))) return TRACE_RETURN (false);
@@ -762,7 +744,7 @@ struct GenericArrayOf
Supplier<Type> &items,
unsigned int items_len)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!serialize (c, items_len))) return TRACE_RETURN (false);
for (unsigned int i = 0; i < items_len; i++)
array[i] = items[i];
@@ -771,7 +753,7 @@ struct GenericArrayOf
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (unlikely (!sanitize_shallow (c))) return TRACE_RETURN (false);
/* Note: for structs that do not reference other structs,
@@ -786,7 +768,7 @@ struct GenericArrayOf
return TRACE_RETURN (true);
}
inline bool sanitize (hb_sanitize_context_t *c, void *base) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (unlikely (!sanitize_shallow (c))) return TRACE_RETURN (false);
unsigned int count = len;
for (unsigned int i = 0; i < count; i++)
@@ -796,7 +778,7 @@ struct GenericArrayOf
}
template <typename T>
inline bool sanitize (hb_sanitize_context_t *c, void *base, T user_data) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (unlikely (!sanitize_shallow (c))) return TRACE_RETURN (false);
unsigned int count = len;
for (unsigned int i = 0; i < count; i++)
@@ -807,7 +789,7 @@ struct GenericArrayOf
private:
inline bool sanitize_shallow (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) && c->check_array (this, Type::static_size, len));
}
@@ -849,12 +831,12 @@ struct OffsetListOf : OffsetArrayOf<Type>
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (OffsetArrayOf<Type>::sanitize (c, this));
}
template <typename T>
inline bool sanitize (hb_sanitize_context_t *c, T user_data) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (OffsetArrayOf<Type>::sanitize (c, this, user_data));
}
};
@@ -877,7 +859,7 @@ struct HeadlessArrayOf
Supplier<Type> &items,
unsigned int items_len)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
len.set (items_len); /* TODO(serialize) Overflow? */
if (unlikely (!items_len)) return TRACE_RETURN (true);
@@ -894,7 +876,7 @@ struct HeadlessArrayOf
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (unlikely (!sanitize_shallow (c))) return TRACE_RETURN (false);
/* Note: for structs that do not reference other structs,
diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-head-table.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-head-table.hh
index 3a9451295de..b3b3a14c682 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-head-table.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-head-table.hh
@@ -52,7 +52,7 @@ struct head
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) && likely (version.major == 1));
}
diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-hhea-table.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-hhea-table.hh
index 2b89c4e0208..fa3088cc3ca 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-hhea-table.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-hhea-table.hh
@@ -45,7 +45,7 @@ struct hhea
static const hb_tag_t Tag = HB_OT_TAG_hhea;
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) && likely (version.major == 1));
}
diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-hmtx-table.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-hmtx-table.hh
index b94337d0be7..e09996ce42e 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-hmtx-table.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-hmtx-table.hh
@@ -53,7 +53,7 @@ struct hmtx
static const hb_tag_t Tag = HB_OT_TAG_hmtx;
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
/* We don't check for anything specific here. The users of the
* struct do all the hard work... */
return TRACE_RETURN (true);
diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-common-private.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-common-private.hh
index 0b753b83346..10dc3c47b06 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-common-private.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-common-private.hh
@@ -61,7 +61,7 @@ struct Record
}
inline bool sanitize (hb_sanitize_context_t *c, void *base) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) && offset.sanitize (c, base));
}
@@ -115,7 +115,7 @@ struct RecordListOf : RecordArrayOf<Type>
{ return this+RecordArrayOf<Type>::operator [](i).offset; }
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (RecordArrayOf<Type>::sanitize (c, this));
}
};
@@ -129,7 +129,7 @@ struct RangeRecord
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this));
}
@@ -193,7 +193,7 @@ struct LangSys
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) && featureIndex.sanitize (c));
}
@@ -231,7 +231,7 @@ struct Script
inline const LangSys& get_default_lang_sys (void) const { return this+defaultLangSys; }
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (defaultLangSys.sanitize (c, this) && langSys.sanitize (c, this));
}
@@ -251,7 +251,7 @@ typedef RecordListOf<Script> ScriptList;
struct FeatureParamsSize
{
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this));
}
@@ -266,7 +266,7 @@ struct FeatureParams
* the length of the table to that of the FeatureParamsSize. */
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this));
}
@@ -291,7 +291,7 @@ struct Feature
{ return this+featureParams; }
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) && lookupIndex.sanitize (c) &&
featureParams.sanitize (c, this));
}
@@ -350,7 +350,7 @@ struct Lookup
uint32_t lookup_props,
unsigned int num_subtables)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
lookupType.set (lookup_type);
lookupFlag.set (lookup_props & 0xFFFF);
@@ -364,7 +364,7 @@ struct Lookup
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
/* Real sanitize of the subtables is done by GSUB/GPOS/... */
if (!(c->check_struct (this) && subTable.sanitize (c))) return TRACE_RETURN (false);
if (lookupFlag & LookupFlag::UseMarkFilteringSet)
@@ -409,7 +409,7 @@ struct CoverageFormat1
Supplier<GlyphID> &glyphs,
unsigned int num_glyphs)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
glyphArray.len.set (num_glyphs);
if (unlikely (!c->extend (glyphArray))) return TRACE_RETURN (false);
@@ -420,7 +420,7 @@ struct CoverageFormat1
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (glyphArray.sanitize (c));
}
@@ -477,7 +477,7 @@ struct CoverageFormat2
Supplier<GlyphID> &glyphs,
unsigned int num_glyphs)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
if (unlikely (!num_glyphs)) return TRACE_RETURN (true);
@@ -506,7 +506,7 @@ struct CoverageFormat2
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (rangeRecord.sanitize (c));
}
@@ -573,6 +573,8 @@ struct CoverageFormat2
struct Coverage
{
+ inline unsigned int operator () (hb_codepoint_t glyph_id) const { return get_coverage (glyph_id); }
+
inline unsigned int get_coverage (hb_codepoint_t glyph_id) const
{
switch (u.format) {
@@ -586,7 +588,7 @@ struct Coverage
Supplier<GlyphID> &glyphs,
unsigned int num_glyphs)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
unsigned int num_ranges = 1;
for (unsigned int i = 1; i < num_glyphs; i++)
@@ -601,7 +603,7 @@ struct Coverage
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -712,7 +714,7 @@ struct ClassDefFormat1
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) && classValue.sanitize (c));
}
@@ -755,7 +757,7 @@ struct ClassDefFormat2
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (rangeRecord.sanitize (c));
}
@@ -786,6 +788,8 @@ struct ClassDefFormat2
struct ClassDef
{
+ inline unsigned int operator () (hb_codepoint_t glyph_id) const { return get_class (glyph_id); }
+
inline unsigned int get_class (hb_codepoint_t glyph_id) const
{
switch (u.format) {
@@ -796,7 +800,7 @@ struct ClassDef
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -888,7 +892,7 @@ struct Device
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) && c->check_range (this, this->get_size ()));
}
diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gdef-table.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gdef-table.hh
index ff2d09c51f0..900dedd1a3f 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gdef-table.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gdef-table.hh
@@ -51,7 +51,7 @@ struct AttachList
unsigned int *point_count /* IN/OUT */,
unsigned int *point_array /* OUT */) const
{
- unsigned int index = (this+coverage).get_coverage (glyph_id);
+ unsigned int index = (this+coverage) (glyph_id);
if (index == NOT_COVERED)
{
if (point_count)
@@ -72,7 +72,7 @@ struct AttachList
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (coverage.sanitize (c, this) && attachPoint.sanitize (c, this));
}
@@ -102,7 +102,7 @@ struct CaretValueFormat1
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this));
}
@@ -128,7 +128,7 @@ struct CaretValueFormat2
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this));
}
@@ -151,7 +151,7 @@ struct CaretValueFormat3
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) && deviceTable.sanitize (c, this));
}
@@ -179,7 +179,7 @@ struct CaretValue
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -220,7 +220,7 @@ struct LigGlyph
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (carets.sanitize (c, this));
}
@@ -242,7 +242,7 @@ struct LigCaretList
unsigned int *caret_count /* IN/OUT */,
hb_position_t *caret_array /* OUT */) const
{
- unsigned int index = (this+coverage).get_coverage (glyph_id);
+ unsigned int index = (this+coverage) (glyph_id);
if (index == NOT_COVERED)
{
if (caret_count)
@@ -254,7 +254,7 @@ struct LigCaretList
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (coverage.sanitize (c, this) && ligGlyph.sanitize (c, this));
}
@@ -276,7 +276,7 @@ struct MarkGlyphSetsFormat1
{ return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; }
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (coverage.sanitize (c, this));
}
@@ -300,7 +300,7 @@ struct MarkGlyphSets
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -365,7 +365,7 @@ struct GDEF
{ return version.to_int () >= 0x00010002 && (this+markGlyphSetsDef[0]).covers (set_index, glyph_id); }
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (version.sanitize (c) &&
likely (version.major == 1) &&
glyphClassDef.sanitize (c, this) &&
diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gpos-table.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gpos-table.hh
index 8f0d38feeba..afe18b5fc80 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gpos-table.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gpos-table.hh
@@ -172,12 +172,12 @@ struct ValueFormat : USHORT
}
inline bool sanitize_value (hb_sanitize_context_t *c, void *base, Value *values) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_range (values, get_size ()) && (!has_device () || sanitize_value_devices (c, base, values)));
}
inline bool sanitize_values (hb_sanitize_context_t *c, void *base, Value *values, unsigned int count) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
unsigned int len = get_len ();
if (!c->check_array (values, get_size (), count)) return TRACE_RETURN (false);
@@ -195,7 +195,7 @@ struct ValueFormat : USHORT
/* Just sanitize referenced Device tables. Doesn't check the values themselves. */
inline bool sanitize_values_stride_unsafe (hb_sanitize_context_t *c, void *base, Value *values, unsigned int count, unsigned int stride) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!has_device ()) return TRACE_RETURN (true);
@@ -212,6 +212,9 @@ struct ValueFormat : USHORT
struct AnchorFormat1
{
+ friend struct Anchor;
+
+ private:
inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id HB_UNUSED,
hb_position_t *x, hb_position_t *y) const
{
@@ -220,7 +223,7 @@ struct AnchorFormat1
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this));
}
@@ -234,6 +237,9 @@ struct AnchorFormat1
struct AnchorFormat2
{
+ friend struct Anchor;
+
+ private:
inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id,
hb_position_t *x, hb_position_t *y) const
{
@@ -249,7 +255,7 @@ struct AnchorFormat2
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this));
}
@@ -264,6 +270,9 @@ struct AnchorFormat2
struct AnchorFormat3
{
+ friend struct Anchor;
+
+ private:
inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id HB_UNUSED,
hb_position_t *x, hb_position_t *y) const
{
@@ -277,7 +286,7 @@ struct AnchorFormat3
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) && xDeviceTable.sanitize (c, this) && yDeviceTable.sanitize (c, this));
}
@@ -312,7 +321,7 @@ struct Anchor
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -342,7 +351,7 @@ struct AnchorMatrix
}
inline bool sanitize (hb_sanitize_context_t *c, unsigned int cols) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!c->check_struct (this)) return TRACE_RETURN (false);
if (unlikely (rows > 0 && cols >= ((unsigned int) -1) / rows)) return TRACE_RETURN (false);
unsigned int count = rows * cols;
@@ -367,7 +376,7 @@ struct MarkRecord
friend struct MarkArray;
inline bool sanitize (hb_sanitize_context_t *c, void *base) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) && markAnchor.sanitize (c, base));
}
@@ -387,7 +396,7 @@ struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage orde
const AnchorMatrix &anchors, unsigned int class_count,
unsigned int glyph_pos) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
const MarkRecord &record = ArrayOf<MarkRecord>::operator[](mark_index);
unsigned int mark_class = record.klass;
@@ -409,7 +418,7 @@ struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage orde
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (ArrayOf<MarkRecord>::sanitize (c, this));
}
};
@@ -419,11 +428,9 @@ struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage orde
struct SinglePosFormat1
{
- inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
- {
- TRACE_COLLECT_GLYPHS (this);
- (this+coverage).add_coverage (&c->input);
- }
+ friend struct SinglePos;
+
+ private:
inline const Coverage &get_coverage (void) const
{
@@ -432,8 +439,8 @@ struct SinglePosFormat1
inline bool apply (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
- unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
+ TRACE_APPLY ();
+ unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
valueFormat.apply_value (c->font, c->direction, this,
@@ -444,7 +451,7 @@ struct SinglePosFormat1
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) && coverage.sanitize (c, this) && valueFormat.sanitize_value (c, this, values));
}
@@ -464,11 +471,9 @@ struct SinglePosFormat1
struct SinglePosFormat2
{
- inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
- {
- TRACE_COLLECT_GLYPHS (this);
- (this+coverage).add_coverage (&c->input);
- }
+ friend struct SinglePos;
+
+ private:
inline const Coverage &get_coverage (void) const
{
@@ -477,8 +482,8 @@ struct SinglePosFormat2
inline bool apply (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
- unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
+ TRACE_APPLY ();
+ unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
if (likely (index >= valueCount)) return TRACE_RETURN (false);
@@ -492,7 +497,7 @@ struct SinglePosFormat2
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) && coverage.sanitize (c, this) && valueFormat.sanitize_values (c, this, values, valueCount));
}
@@ -512,19 +517,31 @@ struct SinglePosFormat2
struct SinglePos
{
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c) const
+ friend struct PosLookupSubTable;
+
+ private:
+
+ inline const Coverage &get_coverage (void) const
{
- TRACE_PROCESS (this);
switch (u.format) {
- case 1: return TRACE_RETURN (c->process (u.format1));
- case 2: return TRACE_RETURN (c->process (u.format2));
- default:return TRACE_RETURN (c->default_return_value ());
+ case 1: return u.format1.get_coverage ();
+ case 2: return u.format2.get_coverage ();
+ default:return Null(Coverage);
+ }
+ }
+
+ inline bool apply (hb_apply_context_t *c) const
+ {
+ TRACE_APPLY ();
+ switch (u.format) {
+ case 1: return TRACE_RETURN (u.format1.apply (c));
+ case 2: return TRACE_RETURN (u.format2.apply (c));
+ default:return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -560,34 +577,17 @@ struct PairSet
{
friend struct PairPosFormat1;
- inline void collect_glyphs (hb_collect_glyphs_context_t *c,
- const ValueFormat *valueFormats) const
- {
- TRACE_COLLECT_GLYPHS (this);
- unsigned int len1 = valueFormats[0].get_len ();
- unsigned int len2 = valueFormats[1].get_len ();
- unsigned int record_size = USHORT::static_size * (1 + len1 + len2);
-
- const PairValueRecord *record = CastP<PairValueRecord> (array);
- unsigned int count = len;
- for (unsigned int i = 0; i < count; i++)
- {
- c->input.add (record->secondGlyph);
- record = &StructAtOffset<PairValueRecord> (record, record_size);
- }
- }
-
inline bool apply (hb_apply_context_t *c,
const ValueFormat *valueFormats,
unsigned int pos) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
unsigned int len1 = valueFormats[0].get_len ();
unsigned int len2 = valueFormats[1].get_len ();
unsigned int record_size = USHORT::static_size * (1 + len1 + len2);
- const PairValueRecord *record = CastP<PairValueRecord> (array);
unsigned int count = len;
+ const PairValueRecord *record = CastP<PairValueRecord> (array);
for (unsigned int i = 0; i < count; i++)
{
if (c->buffer->info[pos].codepoint == record->secondGlyph)
@@ -615,7 +615,7 @@ struct PairSet
};
inline bool sanitize (hb_sanitize_context_t *c, const sanitize_closure_t *closure) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!(c->check_struct (this)
&& c->check_array (array, USHORT::static_size * closure->stride, len))) return TRACE_RETURN (false);
@@ -635,14 +635,9 @@ struct PairSet
struct PairPosFormat1
{
- inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
- {
- TRACE_COLLECT_GLYPHS (this);
- (this+coverage).add_coverage (&c->input);
- unsigned int count = pairSet.len;
- for (unsigned int i = 0; i < count; i++)
- (this+pairSet[i]).collect_glyphs (c, &valueFormat1);
- }
+ friend struct PairPos;
+
+ private:
inline const Coverage &get_coverage (void) const
{
@@ -651,11 +646,11 @@ struct PairPosFormat1
inline bool apply (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1);
if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
- unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
+ unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
if (!skippy_iter.next ()) return TRACE_RETURN (false);
@@ -664,7 +659,7 @@ struct PairPosFormat1
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
unsigned int len1 = valueFormat1.get_len ();
unsigned int len2 = valueFormat2.get_len ();
@@ -698,23 +693,9 @@ struct PairPosFormat1
struct PairPosFormat2
{
- inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
- {
- TRACE_COLLECT_GLYPHS (this);
- /* (this+coverage).add_coverage (&c->input); // Don't need this. */
-
- /* TODO only add values for pairs that have nonzero adjustments. */
+ friend struct PairPos;
- unsigned int count1 = class1Count;
- const ClassDef &klass1 = this+classDef1;
- for (unsigned int i = 0; i < count1; i++)
- klass1.add_class (&c->input, i);
-
- unsigned int count2 = class2Count;
- const ClassDef &klass2 = this+classDef2;
- for (unsigned int i = 0; i < count2; i++)
- klass2.add_class (&c->input, i);
- }
+ private:
inline const Coverage &get_coverage (void) const
{
@@ -723,11 +704,11 @@ struct PairPosFormat2
inline bool apply (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1);
if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
- unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
+ unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
if (!skippy_iter.next ()) return TRACE_RETURN (false);
@@ -736,8 +717,8 @@ struct PairPosFormat2
unsigned int len2 = valueFormat2.get_len ();
unsigned int record_len = len1 + len2;
- unsigned int klass1 = (this+classDef1).get_class (c->buffer->cur().codepoint);
- unsigned int klass2 = (this+classDef2).get_class (c->buffer->info[skippy_iter.idx].codepoint);
+ unsigned int klass1 = (this+classDef1) (c->buffer->cur().codepoint);
+ unsigned int klass2 = (this+classDef2) (c->buffer->info[skippy_iter.idx].codepoint);
if (unlikely (klass1 >= class1Count || klass2 >= class2Count)) return TRACE_RETURN (false);
const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
@@ -754,7 +735,7 @@ struct PairPosFormat2
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!(c->check_struct (this)
&& coverage.sanitize (c, this)
&& classDef1.sanitize (c, this)
@@ -802,19 +783,31 @@ struct PairPosFormat2
struct PairPos
{
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c) const
+ friend struct PosLookupSubTable;
+
+ private:
+
+ inline const Coverage &get_coverage (void) const
+ {
+ switch (u.format) {
+ case 1: return u.format1.get_coverage ();
+ case 2: return u.format2.get_coverage ();
+ default:return Null(Coverage);
+ }
+ }
+
+ inline bool apply (hb_apply_context_t *c) const
{
- TRACE_PROCESS (this);
+ TRACE_APPLY ();
switch (u.format) {
- case 1: return TRACE_RETURN (c->process (u.format1));
- case 2: return TRACE_RETURN (c->process (u.format2));
- default:return TRACE_RETURN (c->default_return_value ());
+ case 1: return TRACE_RETURN (u.format1.apply (c));
+ case 2: return TRACE_RETURN (u.format2.apply (c));
+ default:return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -837,7 +830,7 @@ struct EntryExitRecord
friend struct CursivePosFormat1;
inline bool sanitize (hb_sanitize_context_t *c, void *base) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (entryAnchor.sanitize (c, base) && exitAnchor.sanitize (c, base));
}
@@ -856,11 +849,9 @@ struct EntryExitRecord
struct CursivePosFormat1
{
- inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
- {
- TRACE_COLLECT_GLYPHS (this);
- (this+coverage).add_coverage (&c->input);
- }
+ friend struct CursivePos;
+
+ private:
inline const Coverage &get_coverage (void) const
{
@@ -869,7 +860,7 @@ struct CursivePosFormat1
inline bool apply (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
/* We don't handle mark glyphs here. */
if (c->property & HB_OT_LAYOUT_GLYPH_PROPS_MARK) return TRACE_RETURN (false);
@@ -877,12 +868,12 @@ struct CursivePosFormat1
hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1);
if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
- const EntryExitRecord &this_record = entryExitRecord[(this+coverage).get_coverage (c->buffer->cur().codepoint)];
+ const EntryExitRecord &this_record = entryExitRecord[(this+coverage) (c->buffer->cur().codepoint)];
if (!this_record.exitAnchor) return TRACE_RETURN (false);
if (!skippy_iter.next ()) return TRACE_RETURN (false);
- const EntryExitRecord &next_record = entryExitRecord[(this+coverage).get_coverage (c->buffer->info[skippy_iter.idx].codepoint)];
+ const EntryExitRecord &next_record = entryExitRecord[(this+coverage) (c->buffer->info[skippy_iter.idx].codepoint)];
if (!next_record.entryAnchor) return TRACE_RETURN (false);
unsigned int i = c->buffer->idx;
@@ -950,7 +941,7 @@ struct CursivePosFormat1
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (coverage.sanitize (c, this) && entryExitRecord.sanitize (c, this));
}
@@ -968,18 +959,29 @@ struct CursivePosFormat1
struct CursivePos
{
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c) const
+ friend struct PosLookupSubTable;
+
+ private:
+
+ inline const Coverage &get_coverage (void) const
{
- TRACE_PROCESS (this);
switch (u.format) {
- case 1: return TRACE_RETURN (c->process (u.format1));
- default:return TRACE_RETURN (c->default_return_value ());
+ case 1: return u.format1.get_coverage ();
+ default:return Null(Coverage);
+ }
+ }
+
+ inline bool apply (hb_apply_context_t *c) const
+ {
+ TRACE_APPLY ();
+ switch (u.format) {
+ case 1: return TRACE_RETURN (u.format1.apply (c));
+ default:return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -1002,13 +1004,9 @@ typedef AnchorMatrix BaseArray; /* base-major--
struct MarkBasePosFormat1
{
- inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
- {
- TRACE_COLLECT_GLYPHS (this);
- (this+markCoverage).add_coverage (&c->input);
- (this+baseCoverage).add_coverage (&c->input);
- /* TODO only add combinations that have nonzero adjustment. */
- }
+ friend struct MarkBasePos;
+
+ private:
inline const Coverage &get_coverage (void) const
{
@@ -1017,8 +1015,8 @@ struct MarkBasePosFormat1
inline bool apply (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
- unsigned int mark_index = (this+markCoverage).get_coverage (c->buffer->cur().codepoint);
+ TRACE_APPLY ();
+ unsigned int mark_index = (this+markCoverage) (c->buffer->cur().codepoint);
if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a non-mark glyph */
@@ -1034,14 +1032,14 @@ struct MarkBasePosFormat1
/* The following assertion is too strong, so we've disabled it. */
if (!(property & HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH)) {/*return TRACE_RETURN (false);*/}
- unsigned int base_index = (this+baseCoverage).get_coverage (c->buffer->info[skippy_iter.idx].codepoint);
+ unsigned int base_index = (this+baseCoverage) (c->buffer->info[skippy_iter.idx].codepoint);
if (base_index == NOT_COVERED) return TRACE_RETURN (false);
return TRACE_RETURN ((this+markArray).apply (c, mark_index, base_index, this+baseArray, classCount, skippy_iter.idx));
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) && markCoverage.sanitize (c, this) && baseCoverage.sanitize (c, this) &&
markArray.sanitize (c, this) && baseArray.sanitize (c, this, (unsigned int) classCount));
}
@@ -1067,18 +1065,29 @@ struct MarkBasePosFormat1
struct MarkBasePos
{
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c) const
+ friend struct PosLookupSubTable;
+
+ private:
+
+ inline const Coverage &get_coverage (void) const
+ {
+ switch (u.format) {
+ case 1: return u.format1.get_coverage ();
+ default:return Null(Coverage);
+ }
+ }
+
+ inline bool apply (hb_apply_context_t *c) const
{
- TRACE_PROCESS (this);
+ TRACE_APPLY ();
switch (u.format) {
- case 1: return TRACE_RETURN (c->process (u.format1));
- default:return TRACE_RETURN (c->default_return_value ());
+ case 1: return TRACE_RETURN (u.format1.apply (c));
+ default:return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -1106,13 +1115,9 @@ typedef OffsetListOf<LigatureAttach> LigatureArray;
struct MarkLigPosFormat1
{
- inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
- {
- TRACE_COLLECT_GLYPHS (this);
- (this+markCoverage).add_coverage (&c->input);
- (this+ligatureCoverage).add_coverage (&c->input);
- /* TODO only add combinations that have nonzero adjustment. */
- }
+ friend struct MarkLigPos;
+
+ private:
inline const Coverage &get_coverage (void) const
{
@@ -1121,8 +1126,8 @@ struct MarkLigPosFormat1
inline bool apply (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
- unsigned int mark_index = (this+markCoverage).get_coverage (c->buffer->cur().codepoint);
+ TRACE_APPLY ();
+ unsigned int mark_index = (this+markCoverage) (c->buffer->cur().codepoint);
if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a non-mark glyph */
@@ -1134,7 +1139,7 @@ struct MarkLigPosFormat1
if (!(property & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE)) {/*return TRACE_RETURN (false);*/}
unsigned int j = skippy_iter.idx;
- unsigned int lig_index = (this+ligatureCoverage).get_coverage (c->buffer->info[j].codepoint);
+ unsigned int lig_index = (this+ligatureCoverage) (c->buffer->info[j].codepoint);
if (lig_index == NOT_COVERED) return TRACE_RETURN (false);
const LigatureArray& lig_array = this+ligatureArray;
@@ -1161,7 +1166,7 @@ struct MarkLigPosFormat1
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) && markCoverage.sanitize (c, this) && ligatureCoverage.sanitize (c, this) &&
markArray.sanitize (c, this) && ligatureArray.sanitize (c, this, (unsigned int) classCount));
}
@@ -1188,18 +1193,29 @@ struct MarkLigPosFormat1
struct MarkLigPos
{
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c) const
+ friend struct PosLookupSubTable;
+
+ private:
+
+ inline const Coverage &get_coverage (void) const
+ {
+ switch (u.format) {
+ case 1: return u.format1.get_coverage ();
+ default:return Null(Coverage);
+ }
+ }
+
+ inline bool apply (hb_apply_context_t *c) const
{
- TRACE_PROCESS (this);
+ TRACE_APPLY ();
switch (u.format) {
- case 1: return TRACE_RETURN (c->process (u.format1));
- default:return TRACE_RETURN (c->default_return_value ());
+ case 1: return TRACE_RETURN (u.format1.apply (c));
+ default:return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -1222,13 +1238,9 @@ typedef AnchorMatrix Mark2Array; /* mark2-major--
struct MarkMarkPosFormat1
{
- inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
- {
- TRACE_COLLECT_GLYPHS (this);
- (this+mark1Coverage).add_coverage (&c->input);
- (this+mark2Coverage).add_coverage (&c->input);
- /* TODO only add combinations that have nonzero adjustment. */
- }
+ friend struct MarkMarkPos;
+
+ private:
inline const Coverage &get_coverage (void) const
{
@@ -1237,8 +1249,8 @@ struct MarkMarkPosFormat1
inline bool apply (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
- unsigned int mark1_index = (this+mark1Coverage).get_coverage (c->buffer->cur().codepoint);
+ TRACE_APPLY ();
+ unsigned int mark1_index = (this+mark1Coverage) (c->buffer->cur().codepoint);
if (likely (mark1_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a suitable mark glyph until a non-mark glyph */
@@ -1271,14 +1283,14 @@ struct MarkMarkPosFormat1
return TRACE_RETURN (false);
good:
- unsigned int mark2_index = (this+mark2Coverage).get_coverage (c->buffer->info[j].codepoint);
+ unsigned int mark2_index = (this+mark2Coverage) (c->buffer->info[j].codepoint);
if (mark2_index == NOT_COVERED) return TRACE_RETURN (false);
return TRACE_RETURN ((this+mark1Array).apply (c, mark1_index, mark2_index, this+mark2Array, classCount, j));
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) && mark1Coverage.sanitize (c, this) &&
mark2Coverage.sanitize (c, this) && mark1Array.sanitize (c, this)
&& mark2Array.sanitize (c, this, (unsigned int) classCount));
@@ -1307,18 +1319,29 @@ struct MarkMarkPosFormat1
struct MarkMarkPos
{
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c) const
+ friend struct PosLookupSubTable;
+
+ private:
+
+ inline const Coverage &get_coverage (void) const
{
- TRACE_PROCESS (this);
switch (u.format) {
- case 1: return TRACE_RETURN (c->process (u.format1));
- default:return TRACE_RETURN (c->default_return_value ());
+ case 1: return u.format1.get_coverage ();
+ default:return Null(Coverage);
+ }
+ }
+
+ inline bool apply (hb_apply_context_t *c) const
+ {
+ TRACE_APPLY ();
+ switch (u.format) {
+ case 1: return TRACE_RETURN (u.format1.apply (c));
+ default:return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -1334,13 +1357,50 @@ struct MarkMarkPos
};
-struct ContextPos : Context {};
+static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_index);
+
+struct ContextPos : Context
+{
+ friend struct PosLookupSubTable;
+
+ private:
+ inline bool apply (hb_apply_context_t *c) const
+ {
+ TRACE_APPLY ();
+ return TRACE_RETURN (Context::apply (c, position_lookup));
+ }
+};
+
+struct ChainContextPos : ChainContext
+{
+ friend struct PosLookupSubTable;
+
+ private:
+ inline bool apply (hb_apply_context_t *c) const
+ {
+ TRACE_APPLY ();
+ return TRACE_RETURN (ChainContext::apply (c, position_lookup));
+ }
+};
-struct ChainContextPos : ChainContext {};
-struct ExtensionPos : Extension<ExtensionPos>
+struct ExtensionPos : Extension
{
- typedef struct PosLookupSubTable LookupSubTable;
+ friend struct PosLookupSubTable;
+
+ private:
+ inline const struct PosLookupSubTable& get_subtable (void) const
+ {
+ unsigned int offset = get_offset ();
+ if (unlikely (!offset)) return Null(PosLookupSubTable);
+ return StructAtOffset<PosLookupSubTable> (this, offset);
+ }
+
+ inline const Coverage &get_coverage (void) const;
+
+ inline bool apply (hb_apply_context_t *c) const;
+
+ inline bool sanitize (hb_sanitize_context_t *c);
};
@@ -1366,26 +1426,41 @@ struct PosLookupSubTable
Extension = 9
};
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c, unsigned int lookup_type) const
+ inline const Coverage &get_coverage (unsigned int lookup_type) const
+ {
+ switch (lookup_type) {
+ case Single: return u.single.get_coverage ();
+ case Pair: return u.pair.get_coverage ();
+ case Cursive: return u.cursive.get_coverage ();
+ case MarkBase: return u.markBase.get_coverage ();
+ case MarkLig: return u.markLig.get_coverage ();
+ case MarkMark: return u.markMark.get_coverage ();
+ case Context: return u.context.get_coverage ();
+ case ChainContext: return u.chainContext.get_coverage ();
+ case Extension: return u.extension.get_coverage ();
+ default: return Null(Coverage);
+ }
+ }
+
+ inline bool apply (hb_apply_context_t *c, unsigned int lookup_type) const
{
- TRACE_PROCESS (this);
+ TRACE_APPLY ();
switch (lookup_type) {
- case Single: return TRACE_RETURN (u.single.process (c));
- case Pair: return TRACE_RETURN (u.pair.process (c));
- case Cursive: return TRACE_RETURN (u.cursive.process (c));
- case MarkBase: return TRACE_RETURN (u.markBase.process (c));
- case MarkLig: return TRACE_RETURN (u.markLig.process (c));
- case MarkMark: return TRACE_RETURN (u.markMark.process (c));
- case Context: return TRACE_RETURN (u.context.process (c));
- case ChainContext: return TRACE_RETURN (u.chainContext.process (c));
- case Extension: return TRACE_RETURN (u.extension.process (c));
- default: return TRACE_RETURN (c->default_return_value ());
+ case Single: return TRACE_RETURN (u.single.apply (c));
+ case Pair: return TRACE_RETURN (u.pair.apply (c));
+ case Cursive: return TRACE_RETURN (u.cursive.apply (c));
+ case MarkBase: return TRACE_RETURN (u.markBase.apply (c));
+ case MarkLig: return TRACE_RETURN (u.markLig.apply (c));
+ case MarkMark: return TRACE_RETURN (u.markMark.apply (c));
+ case Context: return TRACE_RETURN (u.context.apply (c));
+ case ChainContext: return TRACE_RETURN (u.chainContext.apply (c));
+ case Extension: return TRACE_RETURN (u.extension.apply (c));
+ default: return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c, unsigned int lookup_type) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.header.sub_format.sanitize (c))
return TRACE_RETURN (false);
switch (lookup_type) {
@@ -1405,7 +1480,7 @@ struct PosLookupSubTable
protected:
union {
struct {
- USHORT sub_format;
+ USHORT sub_format;
} header;
SinglePos single;
PairPos pair;
@@ -1427,53 +1502,34 @@ struct PosLookup : Lookup
inline const PosLookupSubTable& get_subtable (unsigned int i) const
{ return this+CastR<OffsetArrayOf<PosLookupSubTable> > (subTable)[i]; }
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c) const
- {
- TRACE_PROCESS (this);
- unsigned int lookup_type = get_type ();
- unsigned int count = get_subtable_count ();
- for (unsigned int i = 0; i < count; i++) {
- typename context_t::return_t r = get_subtable (i).process (c, lookup_type);
- if (c->stop_sublookup_iteration (r))
- return TRACE_RETURN (r);
- }
- return TRACE_RETURN (c->default_return_value ());
- }
- template <typename context_t>
- static inline typename context_t::return_t process_recurse_func (context_t *c, unsigned int lookup_index);
-
- inline hb_collect_glyphs_context_t::return_t collect_glyphs_lookup (hb_collect_glyphs_context_t *c) const
- {
- TRACE_COLLECT_GLYPHS (this);
- c->set_recurse_func (process_recurse_func<hb_collect_glyphs_context_t>);
- return TRACE_RETURN (process (c));
- }
-
template <typename set_t>
inline void add_coverage (set_t *glyphs) const
{
- hb_get_coverage_context_t c;
const Coverage *last = NULL;
unsigned int count = get_subtable_count ();
for (unsigned int i = 0; i < count; i++) {
- const Coverage *coverage = &get_subtable (i).process (&c, get_type ());
- if (coverage != last) {
- coverage->add_coverage (glyphs);
- last = coverage;
+ const Coverage *c = &get_subtable (i).get_coverage (get_type ());
+ if (c != last) {
+ c->add_coverage (glyphs);
+ last = c;
}
}
}
inline bool apply_once (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
+ unsigned int lookup_type = get_type ();
+
if (!c->check_glyph_property (&c->buffer->cur(), c->lookup_props, &c->property))
- return TRACE_RETURN (false);
- return TRACE_RETURN (process (c));
- }
+ return false;
- static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index);
+ unsigned int count = get_subtable_count ();
+ for (unsigned int i = 0; i < count; i++)
+ if (get_subtable (i).apply (c, lookup_type))
+ return true;
+
+ return false;
+ }
inline bool apply_string (hb_apply_context_t *c, const hb_set_digest_t *digest) const
{
@@ -1482,7 +1538,6 @@ struct PosLookup : Lookup
if (unlikely (!c->buffer->len || !c->lookup_mask))
return false;
- c->set_recurse_func (apply_recurse_func);
c->set_lookup (*this);
c->buffer->idx = 0;
@@ -1501,7 +1556,7 @@ struct PosLookup : Lookup
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false);
OffsetArrayOf<PosLookupSubTable> &list = CastR<OffsetArrayOf<PosLookupSubTable> > (subTable);
return TRACE_RETURN (list.sanitize (c, this, get_type ()));
@@ -1529,7 +1584,7 @@ struct GPOS : GSUBGPOS
static inline void position_finish (hb_font_t *font, hb_buffer_t *buffer, hb_bool_t zero_width_attahced_marks);
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (unlikely (!GSUBGPOS::sanitize (c))) return TRACE_RETURN (false);
OffsetTo<PosLookupList> &list = CastR<OffsetTo<PosLookupList> > (lookupList);
return TRACE_RETURN (list.sanitize (c, this));
@@ -1618,25 +1673,38 @@ GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer, hb_bool_t
/* Out-of-class implementation for methods recursing */
-template <typename context_t>
-inline typename context_t::return_t PosLookup::process_recurse_func (context_t *c, unsigned int lookup_index)
+inline const Coverage & ExtensionPos::get_coverage (void) const
{
- const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos);
- const PosLookup &l = gpos.get_lookup (lookup_index);
- return l.process (c);
+ return get_subtable ().get_coverage (get_type ());
+}
+
+inline bool ExtensionPos::apply (hb_apply_context_t *c) const
+{
+ TRACE_APPLY ();
+ return TRACE_RETURN (get_subtable ().apply (c, get_type ()));
}
-inline bool PosLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index)
+inline bool ExtensionPos::sanitize (hb_sanitize_context_t *c)
+{
+ TRACE_SANITIZE ();
+ if (unlikely (!Extension::sanitize (c))) return TRACE_RETURN (false);
+ unsigned int offset = get_offset ();
+ if (unlikely (!offset)) return TRACE_RETURN (true);
+ return TRACE_RETURN (StructAtOffset<PosLookupSubTable> (this, offset).sanitize (c, get_type ()));
+}
+
+static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_index)
{
const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos);
const PosLookup &l = gpos.get_lookup (lookup_index);
- unsigned int saved_lookup_props = c->lookup_props;
- unsigned int saved_property = c->property;
- c->set_lookup (l);
- bool ret = l.apply_once (c);
- c->lookup_props = saved_lookup_props;
- c->property = saved_property;
- return ret;
+
+ if (unlikely (c->nesting_level_left == 0))
+ return false;
+
+ hb_apply_context_t new_c (*c);
+ new_c.nesting_level_left--;
+ new_c.set_lookup (l);
+ return l.apply_once (&new_c);
}
diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gsub-table.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gsub-table.hh
index 373cf6955d2..4acd67b3a3e 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gsub-table.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gsub-table.hh
@@ -37,9 +37,13 @@ namespace OT {
struct SingleSubstFormat1
{
+ friend struct SingleSubst;
+
+ private:
+
inline void closure (hb_closure_context_t *c) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
Coverage::Iter iter;
for (iter.init (this+coverage); iter.more (); iter.next ()) {
hb_codepoint_t glyph_id = iter.get_glyph ();
@@ -50,7 +54,6 @@ struct SingleSubstFormat1
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
- TRACE_COLLECT_GLYPHS (this);
Coverage::Iter iter;
for (iter.init (this+coverage); iter.more (); iter.next ()) {
hb_codepoint_t glyph_id = iter.get_glyph ();
@@ -64,17 +67,11 @@ struct SingleSubstFormat1
return this+coverage;
}
- inline bool would_apply (hb_would_apply_context_t *c) const
- {
- TRACE_WOULD_APPLY (this);
- return TRACE_RETURN (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) != NOT_COVERED);
- }
-
inline bool apply (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
hb_codepoint_t glyph_id = c->buffer->cur().codepoint;
- unsigned int index = (this+coverage).get_coverage (glyph_id);
+ unsigned int index = (this+coverage) (glyph_id);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
/* According to the Adobe Annotated OpenType Suite, result is always
@@ -90,7 +87,7 @@ struct SingleSubstFormat1
unsigned int num_glyphs,
int delta)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs))) return TRACE_RETURN (false);
deltaGlyphID.set (delta); /* TODO(serilaize) overflow? */
@@ -98,7 +95,7 @@ struct SingleSubstFormat1
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (coverage.sanitize (c, this) && deltaGlyphID.sanitize (c));
}
@@ -115,9 +112,13 @@ struct SingleSubstFormat1
struct SingleSubstFormat2
{
+ friend struct SingleSubst;
+
+ private:
+
inline void closure (hb_closure_context_t *c) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
Coverage::Iter iter;
for (iter.init (this+coverage); iter.more (); iter.next ()) {
if (c->glyphs->has (iter.get_glyph ()))
@@ -127,7 +128,6 @@ struct SingleSubstFormat2
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
- TRACE_COLLECT_GLYPHS (this);
Coverage::Iter iter;
for (iter.init (this+coverage); iter.more (); iter.next ()) {
c->input.add (iter.get_glyph ());
@@ -140,17 +140,11 @@ struct SingleSubstFormat2
return this+coverage;
}
- inline bool would_apply (hb_would_apply_context_t *c) const
- {
- TRACE_WOULD_APPLY (this);
- return TRACE_RETURN (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) != NOT_COVERED);
- }
-
inline bool apply (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
hb_codepoint_t glyph_id = c->buffer->cur().codepoint;
- unsigned int index = (this+coverage).get_coverage (glyph_id);
+ unsigned int index = (this+coverage) (glyph_id);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
if (unlikely (index >= substitute.len)) return TRACE_RETURN (false);
@@ -166,7 +160,7 @@ struct SingleSubstFormat2
Supplier<GlyphID> &substitutes,
unsigned int num_glyphs)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
if (unlikely (!substitute.serialize (c, substitutes, num_glyphs))) return TRACE_RETURN (false);
if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs))) return TRACE_RETURN (false);
@@ -174,7 +168,7 @@ struct SingleSubstFormat2
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (coverage.sanitize (c, this) && substitute.sanitize (c));
}
@@ -192,14 +186,47 @@ struct SingleSubstFormat2
struct SingleSubst
{
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c) const
+ friend struct SubstLookupSubTable;
+ friend struct SubstLookup;
+
+ private:
+
+ inline void closure (hb_closure_context_t *c) const
{
- TRACE_PROCESS (this);
+ TRACE_CLOSURE ();
switch (u.format) {
- case 1: return TRACE_RETURN (c->process (u.format1));
- case 2: return TRACE_RETURN (c->process (u.format2));
- default:return TRACE_RETURN (c->default_return_value ());
+ case 1: u.format1.closure (c); break;
+ case 2: u.format2.closure (c); break;
+ default: break;
+ }
+ }
+
+ inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
+ {
+ TRACE_CLOSURE ();
+ switch (u.format) {
+ case 1: u.format1.collect_glyphs (c); break;
+ case 2: u.format2.collect_glyphs (c); break;
+ default: break;
+ }
+ }
+
+ inline const Coverage &get_coverage (void) const
+ {
+ switch (u.format) {
+ case 1: return u.format1.get_coverage ();
+ case 2: return u.format2.get_coverage ();
+ default:return Null(Coverage);
+ }
+ }
+
+ inline bool apply (hb_apply_context_t *c) const
+ {
+ TRACE_APPLY ();
+ switch (u.format) {
+ case 1: return TRACE_RETURN (u.format1.apply (c));
+ case 2: return TRACE_RETURN (u.format2.apply (c));
+ default:return TRACE_RETURN (false);
}
}
@@ -208,7 +235,7 @@ struct SingleSubst
Supplier<GlyphID> &substitutes,
unsigned int num_glyphs)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false);
unsigned int format = 2;
int delta;
@@ -231,7 +258,7 @@ struct SingleSubst
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -251,9 +278,13 @@ struct SingleSubst
struct Sequence
{
+ friend struct MultipleSubstFormat1;
+
+ private:
+
inline void closure (hb_closure_context_t *c) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
unsigned int count = substitute.len;
for (unsigned int i = 0; i < count; i++)
c->glyphs->add (substitute[i]);
@@ -261,7 +292,6 @@ struct Sequence
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
- TRACE_COLLECT_GLYPHS (this);
unsigned int count = substitute.len;
for (unsigned int i = 0; i < count; i++)
c->output.add (substitute[i]);
@@ -269,7 +299,7 @@ struct Sequence
inline bool apply (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
if (unlikely (!substitute.len)) return TRACE_RETURN (false);
unsigned int klass = c->property & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE ? HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH : 0;
@@ -287,14 +317,15 @@ struct Sequence
Supplier<GlyphID> &glyphs,
unsigned int num_glyphs)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
if (unlikely (!substitute.serialize (c, glyphs, num_glyphs))) return TRACE_RETURN (false);
return TRACE_RETURN (true);
}
+ public:
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (substitute.sanitize (c));
}
@@ -307,9 +338,13 @@ struct Sequence
struct MultipleSubstFormat1
{
+ friend struct MultipleSubst;
+
+ private:
+
inline void closure (hb_closure_context_t *c) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
Coverage::Iter iter;
for (iter.init (this+coverage); iter.more (); iter.next ()) {
if (c->glyphs->has (iter.get_glyph ()))
@@ -319,7 +354,6 @@ struct MultipleSubstFormat1
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
- TRACE_COLLECT_GLYPHS (this);
(this+coverage).add_coverage (&c->input);
unsigned int count = sequence.len;
for (unsigned int i = 0; i < count; i++)
@@ -331,17 +365,11 @@ struct MultipleSubstFormat1
return this+coverage;
}
- inline bool would_apply (hb_would_apply_context_t *c) const
- {
- TRACE_WOULD_APPLY (this);
- return TRACE_RETURN (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) != NOT_COVERED);
- }
-
inline bool apply (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
- unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
+ unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
return TRACE_RETURN ((this+sequence[index]).apply (c));
@@ -353,7 +381,7 @@ struct MultipleSubstFormat1
unsigned int num_glyphs,
Supplier<GlyphID> &substitute_glyphs_list)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
if (unlikely (!sequence.serialize (c, num_glyphs))) return TRACE_RETURN (false);
for (unsigned int i = 0; i < num_glyphs; i++)
@@ -366,7 +394,7 @@ struct MultipleSubstFormat1
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (coverage.sanitize (c, this) && sequence.sanitize (c, this));
}
@@ -384,13 +412,42 @@ struct MultipleSubstFormat1
struct MultipleSubst
{
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c) const
+ friend struct SubstLookupSubTable;
+ friend struct SubstLookup;
+
+ private:
+
+ inline void closure (hb_closure_context_t *c) const
+ {
+ TRACE_CLOSURE ();
+ switch (u.format) {
+ case 1: u.format1.closure (c); break;
+ default: break;
+ }
+ }
+
+ inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
+ {
+ switch (u.format) {
+ case 1: u.format1.collect_glyphs (c); break;
+ default: break;
+ }
+ }
+
+ inline const Coverage &get_coverage (void) const
+ {
+ switch (u.format) {
+ case 1: return u.format1.get_coverage ();
+ default:return Null(Coverage);
+ }
+ }
+
+ inline bool apply (hb_apply_context_t *c) const
{
- TRACE_PROCESS (this);
+ TRACE_APPLY ();
switch (u.format) {
- case 1: return TRACE_RETURN (c->process (u.format1));
- default:return TRACE_RETURN (c->default_return_value ());
+ case 1: return TRACE_RETURN (u.format1.apply (c));
+ default:return TRACE_RETURN (false);
}
}
@@ -400,7 +457,7 @@ struct MultipleSubst
unsigned int num_glyphs,
Supplier<GlyphID> &substitute_glyphs_list)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false);
unsigned int format = 1;
u.format.set (format);
@@ -411,7 +468,7 @@ struct MultipleSubst
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -432,9 +489,13 @@ typedef ArrayOf<GlyphID> AlternateSet; /* Array of alternate GlyphIDs--in
struct AlternateSubstFormat1
{
+ friend struct AlternateSubst;
+
+ private:
+
inline void closure (hb_closure_context_t *c) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
Coverage::Iter iter;
for (iter.init (this+coverage); iter.more (); iter.next ()) {
if (c->glyphs->has (iter.get_glyph ())) {
@@ -448,7 +509,6 @@ struct AlternateSubstFormat1
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
- TRACE_COLLECT_GLYPHS (this);
Coverage::Iter iter;
for (iter.init (this+coverage); iter.more (); iter.next ()) {
c->input.add (iter.get_glyph ());
@@ -464,18 +524,12 @@ struct AlternateSubstFormat1
return this+coverage;
}
- inline bool would_apply (hb_would_apply_context_t *c) const
- {
- TRACE_WOULD_APPLY (this);
- return TRACE_RETURN (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) != NOT_COVERED);
- }
-
inline bool apply (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
hb_codepoint_t glyph_id = c->buffer->cur().codepoint;
- unsigned int index = (this+coverage).get_coverage (glyph_id);
+ unsigned int index = (this+coverage) (glyph_id);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
const AlternateSet &alt_set = this+alternateSet[index];
@@ -504,7 +558,7 @@ struct AlternateSubstFormat1
unsigned int num_glyphs,
Supplier<GlyphID> &alternate_glyphs_list)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
if (unlikely (!alternateSet.serialize (c, num_glyphs))) return TRACE_RETURN (false);
for (unsigned int i = 0; i < num_glyphs; i++)
@@ -517,7 +571,7 @@ struct AlternateSubstFormat1
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (coverage.sanitize (c, this) && alternateSet.sanitize (c, this));
}
@@ -535,13 +589,42 @@ struct AlternateSubstFormat1
struct AlternateSubst
{
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c) const
+ friend struct SubstLookupSubTable;
+ friend struct SubstLookup;
+
+ private:
+
+ inline void closure (hb_closure_context_t *c) const
+ {
+ TRACE_CLOSURE ();
+ switch (u.format) {
+ case 1: u.format1.closure (c); break;
+ default: break;
+ }
+ }
+
+ inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
- TRACE_PROCESS (this);
switch (u.format) {
- case 1: return TRACE_RETURN (c->process (u.format1));
- default:return TRACE_RETURN (c->default_return_value ());
+ case 1: u.format1.collect_glyphs (c); break;
+ default: break;
+ }
+ }
+
+ inline const Coverage &get_coverage (void) const
+ {
+ switch (u.format) {
+ case 1: return u.format1.get_coverage ();
+ default:return Null(Coverage);
+ }
+ }
+
+ inline bool apply (hb_apply_context_t *c) const
+ {
+ TRACE_APPLY ();
+ switch (u.format) {
+ case 1: return TRACE_RETURN (u.format1.apply (c));
+ default:return TRACE_RETURN (false);
}
}
@@ -551,7 +634,7 @@ struct AlternateSubst
unsigned int num_glyphs,
Supplier<GlyphID> &alternate_glyphs_list)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false);
unsigned int format = 1;
u.format.set (format);
@@ -562,7 +645,7 @@ struct AlternateSubst
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -580,9 +663,13 @@ struct AlternateSubst
struct Ligature
{
+ friend struct LigatureSet;
+
+ private:
+
inline void closure (hb_closure_context_t *c) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
unsigned int count = component.len;
for (unsigned int i = 1; i < count; i++)
if (!c->glyphs->has (component[i]))
@@ -592,7 +679,6 @@ struct Ligature
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
- TRACE_COLLECT_GLYPHS (this);
unsigned int count = component.len;
for (unsigned int i = 1; i < count; i++)
c->input.add (component[i]);
@@ -601,26 +687,25 @@ struct Ligature
inline bool would_apply (hb_would_apply_context_t *c) const
{
- TRACE_WOULD_APPLY (this);
if (c->len != component.len)
- return TRACE_RETURN (false);
+ return false;
for (unsigned int i = 1; i < c->len; i++)
if (likely (c->glyphs[i] != component[i]))
- return TRACE_RETURN (false);
+ return false;
- return TRACE_RETURN (true);
+ return true;
}
inline bool apply (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
unsigned int count = component.len;
if (unlikely (count < 1)) return TRACE_RETURN (false);
- unsigned int end_offset = 0;
- bool is_mark_ligature = false;
- unsigned int total_component_count = 0;
+ unsigned int end_offset;
+ bool is_mark_ligature;
+ unsigned int total_component_count;
if (likely (!match_input (c, count,
&component[1],
@@ -651,7 +736,7 @@ struct Ligature
Supplier<GlyphID> &components, /* Starting from second */
unsigned int num_components /* Including first component */)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
ligGlyph = ligature;
if (unlikely (!component.serialize (c, components, num_components))) return TRACE_RETURN (false);
@@ -660,7 +745,7 @@ struct Ligature
public:
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (ligGlyph.sanitize (c) && component.sanitize (c));
}
@@ -676,9 +761,13 @@ struct Ligature
struct LigatureSet
{
+ friend struct LigatureSubstFormat1;
+
+ private:
+
inline void closure (hb_closure_context_t *c) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
unsigned int num_ligs = ligature.len;
for (unsigned int i = 0; i < num_ligs; i++)
(this+ligature[i]).closure (c);
@@ -686,7 +775,6 @@ struct LigatureSet
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
- TRACE_COLLECT_GLYPHS (this);
unsigned int num_ligs = ligature.len;
for (unsigned int i = 0; i < num_ligs; i++)
(this+ligature[i]).collect_glyphs (c);
@@ -694,20 +782,19 @@ struct LigatureSet
inline bool would_apply (hb_would_apply_context_t *c) const
{
- TRACE_WOULD_APPLY (this);
unsigned int num_ligs = ligature.len;
for (unsigned int i = 0; i < num_ligs; i++)
{
const Ligature &lig = this+ligature[i];
if (lig.would_apply (c))
- return TRACE_RETURN (true);
+ return true;
}
- return TRACE_RETURN (false);
+ return false;
}
inline bool apply (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
unsigned int num_ligs = ligature.len;
for (unsigned int i = 0; i < num_ligs; i++)
{
@@ -724,7 +811,7 @@ struct LigatureSet
unsigned int num_ligatures,
Supplier<GlyphID> &component_list /* Starting from second for each ligature */)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
if (unlikely (!ligature.serialize (c, num_ligatures))) return TRACE_RETURN (false);
for (unsigned int i = 0; i < num_ligatures; i++)
@@ -737,8 +824,9 @@ struct LigatureSet
return TRACE_RETURN (true);
}
+ public:
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (ligature.sanitize (c, this));
}
@@ -752,9 +840,13 @@ struct LigatureSet
struct LigatureSubstFormat1
{
+ friend struct LigatureSubst;
+
+ private:
+
inline void closure (hb_closure_context_t *c) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
Coverage::Iter iter;
for (iter.init (this+coverage); iter.more (); iter.next ()) {
if (c->glyphs->has (iter.get_glyph ()))
@@ -764,7 +856,6 @@ struct LigatureSubstFormat1
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
- TRACE_COLLECT_GLYPHS (this);
Coverage::Iter iter;
for (iter.init (this+coverage); iter.more (); iter.next ()) {
c->input.add (iter.get_glyph ());
@@ -779,20 +870,15 @@ struct LigatureSubstFormat1
inline bool would_apply (hb_would_apply_context_t *c) const
{
- TRACE_WOULD_APPLY (this);
- unsigned int index = (this+coverage).get_coverage (c->glyphs[0]);
- if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
-
- const LigatureSet &lig_set = this+ligatureSet[index];
- return TRACE_RETURN (lig_set.would_apply (c));
+ return (this+ligatureSet[(this+coverage) (c->glyphs[0])]).would_apply (c);
}
inline bool apply (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
hb_codepoint_t glyph_id = c->buffer->cur().codepoint;
- unsigned int index = (this+coverage).get_coverage (glyph_id);
+ unsigned int index = (this+coverage) (glyph_id);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
const LigatureSet &lig_set = this+ligatureSet[index];
@@ -807,7 +893,7 @@ struct LigatureSubstFormat1
Supplier<unsigned int> &component_count_list,
Supplier<GlyphID> &component_list /* Starting from second for each ligature */)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
if (unlikely (!ligatureSet.serialize (c, num_first_glyphs))) return TRACE_RETURN (false);
for (unsigned int i = 0; i < num_first_glyphs; i++)
@@ -822,7 +908,7 @@ struct LigatureSubstFormat1
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (coverage.sanitize (c, this) && ligatureSet.sanitize (c, this));
}
@@ -840,13 +926,50 @@ struct LigatureSubstFormat1
struct LigatureSubst
{
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c) const
+ friend struct SubstLookupSubTable;
+ friend struct SubstLookup;
+
+ private:
+
+ inline void closure (hb_closure_context_t *c) const
+ {
+ TRACE_CLOSURE ();
+ switch (u.format) {
+ case 1: u.format1.closure (c); break;
+ default: break;
+ }
+ }
+
+ inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
+ {
+ switch (u.format) {
+ case 1: u.format1.collect_glyphs (c); break;
+ default: break;
+ }
+ }
+
+ inline const Coverage &get_coverage (void) const
+ {
+ switch (u.format) {
+ case 1: return u.format1.get_coverage ();
+ default:return Null(Coverage);
+ }
+ }
+
+ inline bool would_apply (hb_would_apply_context_t *c) const
+ {
+ switch (u.format) {
+ case 1: return u.format1.would_apply (c);
+ default:return false;
+ }
+ }
+
+ inline bool apply (hb_apply_context_t *c) const
{
- TRACE_PROCESS (this);
+ TRACE_APPLY ();
switch (u.format) {
- case 1: return TRACE_RETURN (c->process (u.format1));
- default:return TRACE_RETURN (c->default_return_value ());
+ case 1: return TRACE_RETURN (u.format1.apply (c));
+ default:return TRACE_RETURN (false);
}
}
@@ -858,7 +981,7 @@ struct LigatureSubst
Supplier<unsigned int> &component_count_list,
Supplier<GlyphID> &component_list /* Starting from second for each ligature */)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false);
unsigned int format = 1;
u.format.set (format);
@@ -870,7 +993,7 @@ struct LigatureSubst
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -886,13 +1009,83 @@ struct LigatureSubst
};
-struct ContextSubst : Context {};
+static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index);
+static inline void closure_lookup (hb_closure_context_t *c, unsigned int lookup_index);
+static inline void collect_glyphs_lookup (hb_collect_glyphs_context_t *c, unsigned int lookup_index);
-struct ChainContextSubst : ChainContext {};
+struct ContextSubst : Context
+{
+ friend struct SubstLookupSubTable;
-struct ExtensionSubst : Extension<ExtensionSubst>
+ private:
+
+ inline void closure (hb_closure_context_t *c) const
+ {
+ TRACE_CLOSURE ();
+ return Context::closure (c, closure_lookup);
+ }
+
+ inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
+ {
+ return Context::collect_glyphs (c, collect_glyphs_lookup);
+ }
+
+ inline bool apply (hb_apply_context_t *c) const
+ {
+ TRACE_APPLY ();
+ return TRACE_RETURN (Context::apply (c, substitute_lookup));
+ }
+};
+
+struct ChainContextSubst : ChainContext
{
- typedef struct SubstLookupSubTable LookupSubTable;
+ friend struct SubstLookupSubTable;
+
+ private:
+
+ inline void closure (hb_closure_context_t *c) const
+ {
+ TRACE_CLOSURE ();
+ return ChainContext::closure (c, closure_lookup);
+ }
+
+ inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
+ {
+ return ChainContext::collect_glyphs (c, collect_glyphs_lookup);
+ }
+
+ inline bool apply (hb_apply_context_t *c) const
+ {
+ TRACE_APPLY ();
+ return TRACE_RETURN (ChainContext::apply (c, substitute_lookup));
+ }
+};
+
+
+struct ExtensionSubst : Extension
+{
+ friend struct SubstLookupSubTable;
+ friend struct SubstLookup;
+
+ private:
+ inline const struct SubstLookupSubTable& get_subtable (void) const
+ {
+ unsigned int offset = get_offset ();
+ if (unlikely (!offset)) return Null(SubstLookupSubTable);
+ return StructAtOffset<SubstLookupSubTable> (this, offset);
+ }
+
+ inline void closure (hb_closure_context_t *c) const;
+
+ inline void collect_glyphs (hb_collect_glyphs_context_t *c) const;
+
+ inline const Coverage &get_coverage (void) const;
+
+ inline bool would_apply (hb_would_apply_context_t *c) const;
+
+ inline bool apply (hb_apply_context_t *c) const;
+
+ inline bool sanitize (hb_sanitize_context_t *c);
inline bool is_reverse (void) const;
};
@@ -900,9 +1093,13 @@ struct ExtensionSubst : Extension<ExtensionSubst>
struct ReverseChainSingleSubstFormat1
{
+ friend struct ReverseChainSingleSubst;
+
+ private:
+
inline void closure (hb_closure_context_t *c) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
unsigned int count;
@@ -927,8 +1124,6 @@ struct ReverseChainSingleSubstFormat1
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
- TRACE_COLLECT_GLYPHS (this);
-
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
unsigned int count;
@@ -954,19 +1149,13 @@ struct ReverseChainSingleSubstFormat1
return this+coverage;
}
- inline bool would_apply (hb_would_apply_context_t *c) const
- {
- TRACE_WOULD_APPLY (this);
- return TRACE_RETURN (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) != NOT_COVERED);
- }
-
inline bool apply (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
if (unlikely (c->nesting_level_left != MAX_NESTING_LEVEL))
return TRACE_RETURN (false); /* No chaining to this type */
- unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
+ unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
@@ -989,7 +1178,7 @@ struct ReverseChainSingleSubstFormat1
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!(coverage.sanitize (c, this) && backtrack.sanitize (c, this)))
return TRACE_RETURN (false);
OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
@@ -1021,18 +1210,46 @@ struct ReverseChainSingleSubstFormat1
struct ReverseChainSingleSubst
{
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c) const
+ friend struct SubstLookupSubTable;
+
+ private:
+
+ inline void closure (hb_closure_context_t *c) const
+ {
+ TRACE_CLOSURE ();
+ switch (u.format) {
+ case 1: u.format1.closure (c); break;
+ default: break;
+ }
+ }
+
+ inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
+ {
+ switch (u.format) {
+ case 1: u.format1.collect_glyphs (c); break;
+ default: break;
+ }
+ }
+
+ inline const Coverage &get_coverage (void) const
{
- TRACE_PROCESS (this);
switch (u.format) {
- case 1: return TRACE_RETURN (c->process (u.format1));
- default:return TRACE_RETURN (c->default_return_value ());
+ case 1: return u.format1.get_coverage ();
+ default:return Null(Coverage);
+ }
+ }
+
+ inline bool apply (hb_apply_context_t *c) const
+ {
+ TRACE_APPLY ();
+ switch (u.format) {
+ case 1: return TRACE_RETURN (u.format1.apply (c));
+ default:return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -1068,25 +1285,98 @@ struct SubstLookupSubTable
ReverseChainSingle = 8
};
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c, unsigned int lookup_type) const
+ inline void closure (hb_closure_context_t *c,
+ unsigned int lookup_type) const
{
- TRACE_PROCESS (this);
+ TRACE_CLOSURE ();
switch (lookup_type) {
- case Single: return TRACE_RETURN (u.single.process (c));
- case Multiple: return TRACE_RETURN (u.multiple.process (c));
- case Alternate: return TRACE_RETURN (u.alternate.process (c));
- case Ligature: return TRACE_RETURN (u.ligature.process (c));
- case Context: return TRACE_RETURN (u.context.process (c));
- case ChainContext: return TRACE_RETURN (u.chainContext.process (c));
- case Extension: return TRACE_RETURN (u.extension.process (c));
- case ReverseChainSingle: return TRACE_RETURN (u.reverseChainContextSingle.process (c));
- default: return TRACE_RETURN (c->default_return_value ());
+ case Single: u.single.closure (c); break;
+ case Multiple: u.multiple.closure (c); break;
+ case Alternate: u.alternate.closure (c); break;
+ case Ligature: u.ligature.closure (c); break;
+ case Context: u.context.closure (c); break;
+ case ChainContext: u.chainContext.closure (c); break;
+ case Extension: u.extension.closure (c); break;
+ case ReverseChainSingle: u.reverseChainContextSingle.closure (c); break;
+ default: break;
+ }
+ }
+
+ inline void collect_glyphs (hb_collect_glyphs_context_t *c,
+ unsigned int lookup_type) const
+ {
+ switch (lookup_type) {
+ case Single: u.single.collect_glyphs (c); break;
+ case Multiple: u.multiple.collect_glyphs (c); break;
+ case Alternate: u.alternate.collect_glyphs (c); break;
+ case Ligature: u.ligature.collect_glyphs (c); break;
+ case Context: u.context.collect_glyphs (c); break;
+ case ChainContext: u.chainContext.collect_glyphs (c); break;
+ case Extension: u.extension.collect_glyphs (c); break;
+ case ReverseChainSingle: u.reverseChainContextSingle.collect_glyphs (c); break;
+ default: break;
+ }
+ }
+
+ inline const Coverage &get_coverage (unsigned int lookup_type) const
+ {
+ switch (lookup_type) {
+ case Single: return u.single.get_coverage ();
+ case Multiple: return u.multiple.get_coverage ();
+ case Alternate: return u.alternate.get_coverage ();
+ case Ligature: return u.ligature.get_coverage ();
+ case Context: return u.context.get_coverage ();
+ case ChainContext: return u.chainContext.get_coverage ();
+ case Extension: return u.extension.get_coverage ();
+ case ReverseChainSingle: return u.reverseChainContextSingle.get_coverage ();
+ default: return Null(Coverage);
+ }
+ }
+
+ inline bool would_apply (hb_would_apply_context_t *c,
+ unsigned int lookup_type) const
+ {
+ TRACE_WOULD_APPLY ();
+ if (get_coverage (lookup_type).get_coverage (c->glyphs[0]) == NOT_COVERED) return false;
+ if (c->len == 1) {
+ switch (lookup_type) {
+ case Single:
+ case Multiple:
+ case Alternate:
+ case ReverseChainSingle:
+ return true;
+ }
+ }
+
+ /* Only need to look further for lookups that support substitutions
+ * of input longer than 1. */
+ switch (lookup_type) {
+ case Ligature: return u.ligature.would_apply (c);
+ case Context: return u.context.would_apply (c);
+ case ChainContext: return u.chainContext.would_apply (c);
+ case Extension: return u.extension.would_apply (c);
+ default: return false;
+ }
+ }
+
+ inline bool apply (hb_apply_context_t *c, unsigned int lookup_type) const
+ {
+ TRACE_APPLY ();
+ switch (lookup_type) {
+ case Single: return TRACE_RETURN (u.single.apply (c));
+ case Multiple: return TRACE_RETURN (u.multiple.apply (c));
+ case Alternate: return TRACE_RETURN (u.alternate.apply (c));
+ case Ligature: return TRACE_RETURN (u.ligature.apply (c));
+ case Context: return TRACE_RETURN (u.context.apply (c));
+ case ChainContext: return TRACE_RETURN (u.chainContext.apply (c));
+ case Extension: return TRACE_RETURN (u.extension.apply (c));
+ case ReverseChainSingle: return TRACE_RETURN (u.reverseChainContextSingle.apply (c));
+ default: return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c, unsigned int lookup_type) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.header.sub_format.sanitize (c))
return TRACE_RETURN (false);
switch (lookup_type) {
@@ -1137,68 +1427,63 @@ struct SubstLookup : Lookup
return lookup_type_is_reverse (type);
}
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c) const
+ inline void closure (hb_closure_context_t *c) const
{
- TRACE_PROCESS (this);
unsigned int lookup_type = get_type ();
unsigned int count = get_subtable_count ();
- for (unsigned int i = 0; i < count; i++) {
- typename context_t::return_t r = get_subtable (i).process (c, lookup_type);
- if (c->stop_sublookup_iteration (r))
- return TRACE_RETURN (r);
- }
- return TRACE_RETURN (c->default_return_value ());
- }
- template <typename context_t>
- static inline typename context_t::return_t process_recurse_func (context_t *c, unsigned int lookup_index);
-
- inline hb_closure_context_t::return_t closure (hb_closure_context_t *c) const
- {
- TRACE_CLOSURE (this);
- c->set_recurse_func (process_recurse_func<hb_closure_context_t>);
- return TRACE_RETURN (process (c));
- }
-
- inline hb_collect_glyphs_context_t::return_t collect_glyphs_lookup (hb_collect_glyphs_context_t *c) const
- {
- TRACE_COLLECT_GLYPHS (this);
- c->set_recurse_func (process_recurse_func<hb_collect_glyphs_context_t>);
- return TRACE_RETURN (process (c));
+ for (unsigned int i = 0; i < count; i++)
+ get_subtable (i).closure (c, lookup_type);
}
template <typename set_t>
inline void add_coverage (set_t *glyphs) const
{
- hb_get_coverage_context_t c;
const Coverage *last = NULL;
unsigned int count = get_subtable_count ();
for (unsigned int i = 0; i < count; i++) {
- const Coverage *coverage = &get_subtable (i).process (&c, get_type ());
- if (coverage != last) {
- coverage->add_coverage (glyphs);
- last = coverage;
+ const Coverage *c = &get_subtable (i).get_coverage (get_type ());
+ if (c != last) {
+ c->add_coverage (glyphs);
+ last = c;
}
}
}
+ inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
+ {
+ unsigned int lookup_type = get_type ();
+ unsigned int count = get_subtable_count ();
+ for (unsigned int i = 0; i < count; i++)
+ get_subtable (i).collect_glyphs (c, lookup_type);
+ }
+
inline bool would_apply (hb_would_apply_context_t *c, const hb_set_digest_t *digest) const
{
- TRACE_WOULD_APPLY (this);
- if (unlikely (!c->len)) return TRACE_RETURN (false);
- if (!digest->may_have (c->glyphs[0])) return TRACE_RETURN (false);
- return TRACE_RETURN (process (c));
+ if (unlikely (!c->len)) return false;
+ if (!digest->may_have (c->glyphs[0])) return false;
+ unsigned int lookup_type = get_type ();
+ unsigned int count = get_subtable_count ();
+ for (unsigned int i = 0; i < count; i++)
+ if (get_subtable (i).would_apply (c, lookup_type))
+ return true;
+ return false;
}
inline bool apply_once (hb_apply_context_t *c) const
{
- TRACE_APPLY (this);
+ unsigned int lookup_type = get_type ();
+
if (!c->check_glyph_property (&c->buffer->cur(), c->lookup_props, &c->property))
- return TRACE_RETURN (false);
- return TRACE_RETURN (process (c));
+ return false;
+
+ unsigned int count = get_subtable_count ();
+ for (unsigned int i = 0; i < count; i++)
+ if (get_subtable (i).apply (c, lookup_type))
+ return true;
+
+ return false;
}
- static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index);
inline bool apply_string (hb_apply_context_t *c, const hb_set_digest_t *digest) const
{
bool ret = false;
@@ -1206,7 +1491,6 @@ struct SubstLookup : Lookup
if (unlikely (!c->buffer->len || !c->lookup_mask))
return false;
- c->set_recurse_func (apply_recurse_func);
c->set_lookup (*this);
if (likely (!is_reverse ()))
@@ -1248,9 +1532,11 @@ struct SubstLookup : Lookup
return ret;
}
+ private:
inline SubstLookupSubTable& serialize_subtable (hb_serialize_context_t *c,
unsigned int i)
{ return CastR<OffsetArrayOf<SubstLookupSubTable> > (subTable)[i].serialize (c, this); }
+ public:
inline bool serialize_single (hb_serialize_context_t *c,
uint32_t lookup_props,
@@ -1258,7 +1544,7 @@ struct SubstLookup : Lookup
Supplier<GlyphID> &substitutes,
unsigned int num_glyphs)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Single, lookup_props, 1))) return TRACE_RETURN (false);
return TRACE_RETURN (serialize_subtable (c, 0).u.single.serialize (c, glyphs, substitutes, num_glyphs));
}
@@ -1270,7 +1556,7 @@ struct SubstLookup : Lookup
unsigned int num_glyphs,
Supplier<GlyphID> &substitute_glyphs_list)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Multiple, lookup_props, 1))) return TRACE_RETURN (false);
return TRACE_RETURN (serialize_subtable (c, 0).u.multiple.serialize (c, glyphs, substitute_len_list, num_glyphs,
substitute_glyphs_list));
@@ -1283,7 +1569,7 @@ struct SubstLookup : Lookup
unsigned int num_glyphs,
Supplier<GlyphID> &alternate_glyphs_list)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Alternate, lookup_props, 1))) return TRACE_RETURN (false);
return TRACE_RETURN (serialize_subtable (c, 0).u.alternate.serialize (c, glyphs, alternate_len_list, num_glyphs,
alternate_glyphs_list));
@@ -1298,7 +1584,7 @@ struct SubstLookup : Lookup
Supplier<unsigned int> &component_count_list,
Supplier<GlyphID> &component_list /* Starting from second for each ligature */)
{
- TRACE_SERIALIZE (this);
+ TRACE_SERIALIZE ();
if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Ligature, lookup_props, 1))) return TRACE_RETURN (false);
return TRACE_RETURN (serialize_subtable (c, 0).u.ligature.serialize (c, first_glyphs, ligature_per_first_glyph_count_list, num_first_glyphs,
ligatures_list, component_count_list, component_list));
@@ -1306,7 +1592,7 @@ struct SubstLookup : Lookup
inline bool sanitize (hb_sanitize_context_t *c)
{
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false);
OffsetArrayOf<SubstLookupSubTable> &list = CastR<OffsetArrayOf<SubstLookupSubTable> > (subTable);
if (unlikely (!list.sanitize (c, this, get_type ()))) return TRACE_RETURN (false);
@@ -1348,8 +1634,12 @@ struct GSUB : GSUBGPOS
static inline void substitute_start (hb_font_t *font, hb_buffer_t *buffer);
static inline void substitute_finish (hb_font_t *font, hb_buffer_t *buffer);
+ inline void closure_lookup (hb_closure_context_t *c,
+ unsigned int lookup_index) const
+ { return get_lookup (lookup_index).closure (c); }
+
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (unlikely (!GSUBGPOS::sanitize (c))) return TRACE_RETURN (false);
OffsetTo<SubstLookupList> &list = CastR<OffsetTo<SubstLookupList> > (lookupList);
return TRACE_RETURN (list.sanitize (c, this));
@@ -1382,33 +1672,83 @@ GSUB::substitute_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer HB_UNUSE
/* Out-of-class implementation for methods recursing */
+inline void ExtensionSubst::closure (hb_closure_context_t *c) const
+{
+ get_subtable ().closure (c, get_type ());
+}
+
+inline void ExtensionSubst::collect_glyphs (hb_collect_glyphs_context_t *c) const
+{
+ get_subtable ().collect_glyphs (c, get_type ());
+}
+
+inline const Coverage & ExtensionSubst::get_coverage (void) const
+{
+ return get_subtable ().get_coverage (get_type ());
+}
+
+inline bool ExtensionSubst::would_apply (hb_would_apply_context_t *c) const
+{
+ return get_subtable ().would_apply (c, get_type ());
+}
+
+inline bool ExtensionSubst::apply (hb_apply_context_t *c) const
+{
+ TRACE_APPLY ();
+ return TRACE_RETURN (get_subtable ().apply (c, get_type ()));
+}
+
+inline bool ExtensionSubst::sanitize (hb_sanitize_context_t *c)
+{
+ TRACE_SANITIZE ();
+ if (unlikely (!Extension::sanitize (c))) return TRACE_RETURN (false);
+ unsigned int offset = get_offset ();
+ if (unlikely (!offset)) return TRACE_RETURN (true);
+ return TRACE_RETURN (StructAtOffset<SubstLookupSubTable> (this, offset).sanitize (c, get_type ()));
+}
+
inline bool ExtensionSubst::is_reverse (void) const
{
unsigned int type = get_type ();
if (unlikely (type == SubstLookupSubTable::Extension))
- return CastR<ExtensionSubst> (get_subtable<SubstLookupSubTable>()).is_reverse ();
+ return CastR<ExtensionSubst> (get_subtable()).is_reverse ();
return SubstLookup::lookup_type_is_reverse (type);
}
-template <typename context_t>
-inline typename context_t::return_t SubstLookup::process_recurse_func (context_t *c, unsigned int lookup_index)
+static inline void closure_lookup (hb_closure_context_t *c, unsigned int lookup_index)
+{
+ const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub);
+ const SubstLookup &l = gsub.get_lookup (lookup_index);
+
+ if (unlikely (c->nesting_level_left == 0))
+ return;
+
+ c->nesting_level_left--;
+ l.closure (c);
+ c->nesting_level_left++;
+}
+
+static inline void collect_glyphs_lookup (hb_collect_glyphs_context_t *c, unsigned int lookup_index)
{
const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub);
const SubstLookup &l = gsub.get_lookup (lookup_index);
- return l.process (c);
+
+ /* XXX TODO */
+ l.collect_glyphs (c);
}
-inline bool SubstLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index)
+static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index)
{
const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub);
const SubstLookup &l = gsub.get_lookup (lookup_index);
- unsigned int saved_lookup_props = c->lookup_props;
- unsigned int saved_property = c->property;
- c->set_lookup (l);
- bool ret = l.apply_once (c);
- c->lookup_props = saved_lookup_props;
- c->property = saved_property;
- return ret;
+
+ if (unlikely (c->nesting_level_left == 0))
+ return false;
+
+ hb_apply_context_t new_c (*c);
+ new_c.nesting_level_left--;
+ new_c.set_lookup (l);
+ return l.apply_once (&new_c);
}
diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gsubgpos-private.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gsubgpos-private.hh
index 40e8aa9f7dd..42726811b6e 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gsubgpos-private.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout-gsubgpos-private.hh
@@ -37,83 +37,44 @@
namespace OT {
-
-#define TRACE_PROCESS(this) \
- hb_auto_trace_t<context_t::max_debug_depth, typename context_t::return_t> trace \
- (&c->debug_depth, c->get_name (), this, HB_FUNC, \
- "");
-
-
#ifndef HB_DEBUG_CLOSURE
#define HB_DEBUG_CLOSURE (HB_DEBUG+0)
#endif
-#define TRACE_CLOSURE(this) \
- hb_auto_trace_t<HB_DEBUG_CLOSURE, void_t> trace \
- (&c->debug_depth, c->get_name (), this, HB_FUNC, \
- "");
+#define TRACE_CLOSURE() \
+ hb_auto_trace_t<HB_DEBUG_CLOSURE> trace (&c->debug_depth, "CLOSURE", this, HB_FUNC, "");
+
struct hb_closure_context_t
{
- inline const char *get_name (void) { return "CLOSURE"; }
- static const unsigned int max_debug_depth = HB_DEBUG_CLOSURE;
- typedef void_t return_t;
- typedef return_t (*recurse_func_t) (hb_closure_context_t *c, unsigned int lookup_index);
- template <typename T>
- inline return_t process (const T &obj) { obj.closure (this); return VOID; }
- static return_t default_return_value (void) { return VOID; }
- bool stop_sublookup_iteration (const return_t r) const { return false; }
- return_t recurse (unsigned int lookup_index)
- {
- if (unlikely (nesting_level_left == 0 || !recurse_func))
- return default_return_value ();
-
- nesting_level_left--;
- recurse_func (this, lookup_index);
- nesting_level_left++;
- return default_return_value ();
- }
-
hb_face_t *face;
hb_set_t *glyphs;
- recurse_func_t recurse_func;
unsigned int nesting_level_left;
unsigned int debug_depth;
+
hb_closure_context_t (hb_face_t *face_,
hb_set_t *glyphs_,
unsigned int nesting_level_left_ = MAX_NESTING_LEVEL) :
face (face_),
glyphs (glyphs_),
- recurse_func (NULL),
nesting_level_left (nesting_level_left_),
debug_depth (0) {}
-
- void set_recurse_func (recurse_func_t func) { recurse_func = func; }
};
+/* TODO Add TRACE_RETURN annotation to gsub. */
#ifndef HB_DEBUG_WOULD_APPLY
#define HB_DEBUG_WOULD_APPLY (HB_DEBUG+0)
#endif
-#define TRACE_WOULD_APPLY(this) \
- hb_auto_trace_t<HB_DEBUG_WOULD_APPLY, bool> trace \
- (&c->debug_depth, c->get_name (), this, HB_FUNC, \
- "%d glyphs", c->len);
+#define TRACE_WOULD_APPLY() \
+ hb_auto_trace_t<HB_DEBUG_WOULD_APPLY> trace (&c->debug_depth, "WOULD_APPLY", this, HB_FUNC, "%d glyphs", c->len);
+
struct hb_would_apply_context_t
{
- inline const char *get_name (void) { return "WOULD_APPLY"; }
- static const unsigned int max_debug_depth = HB_DEBUG_WOULD_APPLY;
- typedef bool return_t;
- template <typename T>
- inline return_t process (const T &obj) { return obj.would_apply (this); }
- static return_t default_return_value (void) { return false; }
- bool stop_sublookup_iteration (const return_t r) const { return r; }
- return_t recurse (unsigned int lookup_index) { return true; }
-
hb_face_t *face;
const hb_codepoint_t *glyphs;
unsigned int len;
@@ -128,85 +89,40 @@ struct hb_would_apply_context_t
glyphs (glyphs_),
len (len_),
zero_context (zero_context_),
- debug_depth (0) {}
+ debug_depth (0) {};
};
+/* TODO Add TRACE_RETURN annotation to gsub. */
#ifndef HB_DEBUG_COLLECT_GLYPHS
#define HB_DEBUG_COLLECT_GLYPHS (HB_DEBUG+0)
#endif
-#define TRACE_COLLECT_GLYPHS(this) \
- hb_auto_trace_t<HB_DEBUG_COLLECT_GLYPHS, void_t> trace \
- (&c->debug_depth, c->get_name (), this, HB_FUNC, \
- "");
+#define TRACE_COLLECT_GLYPHS() \
+ hb_auto_trace_t<HB_DEBUG_COLLECT_GLYPHS> trace (&c->debug_depth, "COLLECT_GLYPHS", this, HB_FUNC, "");
+
struct hb_collect_glyphs_context_t
{
- inline const char *get_name (void) { return "COLLECT_GLYPHS"; }
- static const unsigned int max_debug_depth = HB_DEBUG_COLLECT_GLYPHS;
- typedef void_t return_t;
- typedef return_t (*recurse_func_t) (hb_collect_glyphs_context_t *c, unsigned int lookup_index);
- template <typename T>
- inline return_t process (const T &obj) { obj.collect_glyphs (this); return VOID; }
- static return_t default_return_value (void) { return VOID; }
- bool stop_sublookup_iteration (const return_t r) const { return false; }
- return_t recurse (unsigned int lookup_index)
- {
- if (unlikely (nesting_level_left == 0 || !recurse_func))
- return default_return_value ();
-
- nesting_level_left--;
- /* Only collect output glyphs in the recursion. */
- hb_collect_glyphs_context_t new_c (this->face, NULL, NULL, NULL, &output, nesting_level_left);
- recurse_func (&new_c, lookup_index);
- nesting_level_left++;
- return default_return_value ();
- }
-
hb_face_t *face;
hb_set_t &before;
hb_set_t &input;
hb_set_t &after;
hb_set_t &output;
- recurse_func_t recurse_func;
- unsigned int nesting_level_left;
unsigned int debug_depth;
hb_collect_glyphs_context_t (hb_face_t *face_,
hb_set_t *glyphs_before, /* OUT. May be NULL */
hb_set_t *glyphs_input, /* OUT. May be NULL */
hb_set_t *glyphs_after, /* OUT. May be NULL */
- hb_set_t *glyphs_output, /* OUT. May be NULL */
- unsigned int nesting_level_left_ = MAX_NESTING_LEVEL) :
+ hb_set_t *glyphs_output /* OUT. May be NULL */) :
face (face_),
before (glyphs_before ? *glyphs_before : *hb_set_get_empty ()),
input (glyphs_input ? *glyphs_input : *hb_set_get_empty ()),
after (glyphs_after ? *glyphs_after : *hb_set_get_empty ()),
output (glyphs_output ? *glyphs_output : *hb_set_get_empty ()),
- recurse_func (NULL),
- nesting_level_left (nesting_level_left_),
- debug_depth (0) {}
-
- void set_recurse_func (recurse_func_t func) { recurse_func = func; }
-};
-
-
-
-struct hb_get_coverage_context_t
-{
- inline const char *get_name (void) { return "GET_COVERAGE"; }
- static const unsigned int max_debug_depth = 0;
- typedef const Coverage &return_t;
- template <typename T>
- inline return_t process (const T &obj) { return obj.get_coverage (); }
- static return_t default_return_value (void) { return Null(Coverage); }
-
- hb_get_coverage_context_t (void) :
- debug_depth (0) {}
-
- unsigned int debug_depth;
+ debug_depth (0) {};
};
@@ -215,44 +131,23 @@ struct hb_get_coverage_context_t
#define HB_DEBUG_APPLY (HB_DEBUG+0)
#endif
-#define TRACE_APPLY(this) \
- hb_auto_trace_t<HB_DEBUG_APPLY, bool> trace \
- (&c->debug_depth, c->get_name (), this, HB_FUNC, \
- "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint);
+#define TRACE_APPLY() \
+ hb_auto_trace_t<HB_DEBUG_APPLY> trace (&c->debug_depth, "APPLY", this, HB_FUNC, "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint);
+
struct hb_apply_context_t
{
- inline const char *get_name (void) { return "APPLY"; }
- static const unsigned int max_debug_depth = HB_DEBUG_APPLY;
- typedef bool return_t;
- typedef return_t (*recurse_func_t) (hb_apply_context_t *c, unsigned int lookup_index);
- template <typename T>
- inline return_t process (const T &obj) { return obj.apply (this); }
- static return_t default_return_value (void) { return false; }
- bool stop_sublookup_iteration (const return_t r) const { return r; }
- return_t recurse (unsigned int lookup_index)
- {
- if (unlikely (nesting_level_left == 0 || !recurse_func))
- return default_return_value ();
-
- nesting_level_left--;
- recurse_func (this, lookup_index);
- nesting_level_left++;
- return default_return_value ();
- }
-
hb_font_t *font;
hb_face_t *face;
hb_buffer_t *buffer;
hb_direction_t direction;
hb_mask_t lookup_mask;
- recurse_func_t recurse_func;
unsigned int nesting_level_left;
unsigned int lookup_props;
unsigned int property; /* propety of first glyph */
+ unsigned int debug_depth;
const GDEF &gdef;
bool has_glyph_classes;
- unsigned int debug_depth;
hb_apply_context_t (hb_font_t *font_,
@@ -261,16 +156,18 @@ struct hb_apply_context_t
font (font_), face (font->face), buffer (buffer_),
direction (buffer_->props.direction),
lookup_mask (lookup_mask_),
- recurse_func (NULL),
nesting_level_left (MAX_NESTING_LEVEL),
- lookup_props (0), property (0),
+ lookup_props (0), property (0), debug_depth (0),
gdef (*hb_ot_layout_from_face (face)->gdef),
- has_glyph_classes (gdef.has_glyph_classes ()),
- debug_depth (0) {}
+ has_glyph_classes (gdef.has_glyph_classes ()) {}
+
+ void set_lookup_props (unsigned int lookup_props_) {
+ lookup_props = lookup_props_;
+ }
- void set_recurse_func (recurse_func_t func) { recurse_func = func; }
- void set_lookup_props (unsigned int lookup_props_) { lookup_props = lookup_props_; }
- void set_lookup (const Lookup &l) { lookup_props = l.get_props (); }
+ void set_lookup (const Lookup &l) {
+ lookup_props = l.get_props ();
+ }
struct mark_skipping_forward_iterator_t
{
@@ -476,23 +373,22 @@ struct hb_apply_context_t
typedef bool (*intersects_func_t) (hb_set_t *glyphs, const USHORT &value, const void *data);
-typedef void (*collect_glyphs_func_t) (hb_set_t *glyphs, const USHORT &value, const void *data);
typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const void *data);
+typedef void (*closure_lookup_func_t) (hb_closure_context_t *c, unsigned int lookup_index);
+typedef void (*collect_glyphs_lookup_func_t) (hb_collect_glyphs_context_t *c, unsigned int lookup_index);
+typedef bool (*apply_lookup_func_t) (hb_apply_context_t *c, unsigned int lookup_index);
struct ContextClosureFuncs
{
intersects_func_t intersects;
-};
-struct ContextCollectGlyphsFuncs
-{
- collect_glyphs_func_t collect;
+ closure_lookup_func_t closure;
};
struct ContextApplyFuncs
{
match_func_t match;
+ apply_lookup_func_t apply;
};
-
static inline bool intersects_glyph (hb_set_t *glyphs, const USHORT &value, const void *data HB_UNUSED)
{
return glyphs->has (value);
@@ -521,32 +417,6 @@ static inline bool intersects_array (hb_closure_context_t *c,
}
-static inline void collect_glyph (hb_set_t *glyphs, const USHORT &value, const void *data HB_UNUSED)
-{
- glyphs->add (value);
-}
-static inline void collect_class (hb_set_t *glyphs, const USHORT &value, const void *data)
-{
- const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
- class_def.add_class (glyphs, value);
-}
-static inline void collect_coverage (hb_set_t *glyphs, const USHORT &value, const void *data)
-{
- const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value;
- (data+coverage).add_coverage (glyphs);
-}
-static inline void collect_array (hb_collect_glyphs_context_t *c,
- hb_set_t *glyphs,
- unsigned int count,
- const USHORT values[],
- collect_glyphs_func_t collect_func,
- const void *collect_data)
-{
- for (unsigned int i = 0; i < count; i++)
- collect_func (glyphs, values[i], collect_data);
-}
-
-
static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const void *data HB_UNUSED)
{
return glyph_id == value;
@@ -562,6 +432,7 @@ static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value,
return (data+coverage).get_coverage (glyph_id) != NOT_COVERED;
}
+
static inline bool would_match_input (hb_would_apply_context_t *c,
unsigned int count, /* Including the first glyph (not matched) */
const USHORT input[], /* Array of input values--start with second glyph */
@@ -586,7 +457,7 @@ static inline bool match_input (hb_apply_context_t *c,
bool *p_is_mark_ligature = NULL,
unsigned int *p_total_component_count = NULL)
{
- TRACE_APPLY (NULL);
+ hb_auto_trace_t<HB_DEBUG_APPLY> trace (&c->debug_depth, "APPLY", NULL, HB_FUNC, "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint);
hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, count - 1);
if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
@@ -743,7 +614,7 @@ static inline bool match_backtrack (hb_apply_context_t *c,
match_func_t match_func,
const void *match_data)
{
- TRACE_APPLY (NULL);
+ hb_auto_trace_t<HB_DEBUG_APPLY> trace (&c->debug_depth, "APPLY", NULL, HB_FUNC, "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint);
hb_apply_context_t::mark_skipping_backward_iterator_t skippy_iter (c, c->buffer->backtrack_len (), count, true);
if (skippy_iter.has_no_chance ())
@@ -768,7 +639,7 @@ static inline bool match_lookahead (hb_apply_context_t *c,
const void *match_data,
unsigned int offset)
{
- TRACE_APPLY (NULL);
+ hb_auto_trace_t<HB_DEBUG_APPLY> trace (&c->debug_depth, "APPLY", NULL, HB_FUNC, "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint);
hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx + offset - 1, count, true);
if (skippy_iter.has_no_chance ())
@@ -791,7 +662,7 @@ static inline bool match_lookahead (hb_apply_context_t *c,
struct LookupRecord
{
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this));
}
@@ -804,22 +675,22 @@ struct LookupRecord
};
-template <typename context_t>
-static inline void recurse_lookups (context_t *c,
- unsigned int lookupCount,
- const LookupRecord lookupRecord[] /* Array of LookupRecords--in design order */)
+static inline void closure_lookup (hb_closure_context_t *c,
+ unsigned int lookupCount,
+ const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
+ closure_lookup_func_t closure_func)
{
for (unsigned int i = 0; i < lookupCount; i++)
- c->recurse (lookupRecord->lookupListIndex);
+ closure_func (c, lookupRecord->lookupListIndex);
}
static inline bool apply_lookup (hb_apply_context_t *c,
unsigned int count, /* Including the first glyph */
unsigned int lookupCount,
- const LookupRecord lookupRecord[] /* Array of LookupRecords--in design order */)
+ const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
+ apply_lookup_func_t apply_func)
{
- TRACE_APPLY (NULL);
-
+ hb_auto_trace_t<HB_DEBUG_APPLY> trace (&c->debug_depth, "APPLY", NULL, HB_FUNC, "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint);
unsigned int end = c->buffer->len;
if (unlikely (count == 0 || c->buffer->idx + count > end))
return TRACE_RETURN (false);
@@ -848,7 +719,7 @@ static inline bool apply_lookup (hb_apply_context_t *c,
unsigned int old_pos = c->buffer->idx;
/* Apply a lookup */
- bool done = c->recurse (lookupRecord->lookupListIndex);
+ bool done = apply_func (c, lookupRecord->lookupListIndex);
lookupRecord++;
lookupCount--;
@@ -882,12 +753,6 @@ struct ContextClosureLookupContext
const void *intersects_data;
};
-struct ContextCollectGlyphsLookupContext
-{
- ContextCollectGlyphsFuncs funcs;
- const void *collect_data;
-};
-
struct ContextApplyLookupContext
{
ContextApplyFuncs funcs;
@@ -904,23 +769,11 @@ static inline void context_closure_lookup (hb_closure_context_t *c,
if (intersects_array (c,
inputCount ? inputCount - 1 : 0, input,
lookup_context.funcs.intersects, lookup_context.intersects_data))
- recurse_lookups (c,
- lookupCount, lookupRecord);
+ closure_lookup (c,
+ lookupCount, lookupRecord,
+ lookup_context.funcs.closure);
}
-static inline void context_collect_glyphs_lookup (hb_collect_glyphs_context_t *c,
- unsigned int inputCount, /* Including the first glyph (not matched) */
- const USHORT input[], /* Array of input values--start with second glyph */
- unsigned int lookupCount,
- const LookupRecord lookupRecord[],
- ContextCollectGlyphsLookupContext &lookup_context)
-{
- collect_array (c, &c->input,
- inputCount ? inputCount - 1 : 0, input,
- lookup_context.funcs.collect, lookup_context.collect_data);
- recurse_lookups (c,
- lookupCount, lookupRecord);
-}
static inline bool context_would_apply_lookup (hb_would_apply_context_t *c,
unsigned int inputCount, /* Including the first glyph (not matched) */
@@ -945,14 +798,19 @@ static inline bool context_apply_lookup (hb_apply_context_t *c,
lookup_context.funcs.match, lookup_context.match_data)
&& apply_lookup (c,
inputCount,
- lookupCount, lookupRecord);
+ lookupCount, lookupRecord,
+ lookup_context.funcs.apply);
}
struct Rule
{
+ friend struct RuleSet;
+
+ private:
+
inline void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0));
context_closure_lookup (c,
inputCount, input,
@@ -960,33 +818,23 @@ struct Rule
lookup_context);
}
- inline void collect_glyphs (hb_collect_glyphs_context_t *c, ContextCollectGlyphsLookupContext &lookup_context) const
- {
- TRACE_COLLECT_GLYPHS (this);
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0));
- context_collect_glyphs_lookup (c,
- inputCount, input,
- lookupCount, lookupRecord,
- lookup_context);
- }
-
inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContext &lookup_context) const
{
- TRACE_WOULD_APPLY (this);
+ TRACE_WOULD_APPLY ();
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0));
return TRACE_RETURN (context_would_apply_lookup (c, inputCount, input, lookupCount, lookupRecord, lookup_context));
}
inline bool apply (hb_apply_context_t *c, ContextApplyLookupContext &lookup_context) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0));
return TRACE_RETURN (context_apply_lookup (c, inputCount, input, lookupCount, lookupRecord, lookup_context));
}
public:
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return inputCount.sanitize (c)
&& lookupCount.sanitize (c)
&& c->check_range (input,
@@ -1011,23 +859,15 @@ struct RuleSet
{
inline void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++)
(this+rule[i]).closure (c, lookup_context);
}
- inline void collect_glyphs (hb_collect_glyphs_context_t *c, ContextCollectGlyphsLookupContext &lookup_context) const
- {
- TRACE_COLLECT_GLYPHS (this);
- unsigned int num_rules = rule.len;
- for (unsigned int i = 0; i < num_rules; i++)
- (this+rule[i]).collect_glyphs (c, lookup_context);
- }
-
inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContext &lookup_context) const
{
- TRACE_WOULD_APPLY (this);
+ TRACE_WOULD_APPLY ();
unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++)
{
@@ -1039,7 +879,7 @@ struct RuleSet
inline bool apply (hb_apply_context_t *c, ContextApplyLookupContext &lookup_context) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++)
{
@@ -1050,7 +890,7 @@ struct RuleSet
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (rule.sanitize (c, this));
}
@@ -1065,14 +905,18 @@ struct RuleSet
struct ContextFormat1
{
- inline void closure (hb_closure_context_t *c) const
+ friend struct Context;
+
+ private:
+
+ inline void closure (hb_closure_context_t *c, closure_lookup_func_t closure_func) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
const Coverage &cov = (this+coverage);
struct ContextClosureLookupContext lookup_context = {
- {intersects_glyph},
+ {intersects_glyph, closure_func},
NULL
};
@@ -1084,55 +928,35 @@ struct ContextFormat1
}
}
- inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
- {
- TRACE_COLLECT_GLYPHS (this);
- (this+coverage).add_coverage (&c->input);
-
- struct ContextCollectGlyphsLookupContext lookup_context = {
- {collect_glyph},
- NULL
- };
-
- unsigned int count = ruleSet.len;
- for (unsigned int i = 0; i < count; i++)
- (this+ruleSet[i]).collect_glyphs (c, lookup_context);
- }
-
inline bool would_apply (hb_would_apply_context_t *c) const
{
- TRACE_WOULD_APPLY (this);
+ TRACE_WOULD_APPLY ();
- const RuleSet &rule_set = this+ruleSet[(this+coverage).get_coverage (c->glyphs[0])];
+ const RuleSet &rule_set = this+ruleSet[(this+coverage) (c->glyphs[0])];
struct ContextApplyLookupContext lookup_context = {
- {match_glyph},
+ {match_glyph, NULL},
NULL
};
return TRACE_RETURN (rule_set.would_apply (c, lookup_context));
}
- inline const Coverage &get_coverage (void) const
+ inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{
- return this+coverage;
- }
-
- inline bool apply (hb_apply_context_t *c) const
- {
- TRACE_APPLY (this);
- unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
+ TRACE_APPLY ();
+ unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED))
return TRACE_RETURN (false);
const RuleSet &rule_set = this+ruleSet[index];
struct ContextApplyLookupContext lookup_context = {
- {match_glyph},
+ {match_glyph, apply_func},
NULL
};
return TRACE_RETURN (rule_set.apply (c, lookup_context));
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (coverage.sanitize (c, this) && ruleSet.sanitize (c, this));
}
@@ -1151,16 +975,20 @@ struct ContextFormat1
struct ContextFormat2
{
- inline void closure (hb_closure_context_t *c) const
+ friend struct Context;
+
+ private:
+
+ inline void closure (hb_closure_context_t *c, closure_lookup_func_t closure_func) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
if (!(this+coverage).intersects (c->glyphs))
return;
const ClassDef &class_def = this+classDef;
struct ContextClosureLookupContext lookup_context = {
- {intersects_class},
+ {intersects_class, closure_func},
NULL
};
@@ -1172,58 +1000,38 @@ struct ContextFormat2
}
}
- inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
- {
- TRACE_COLLECT_GLYPHS (this);
- (this+coverage).add_coverage (&c->input);
-
- struct ContextCollectGlyphsLookupContext lookup_context = {
- {collect_class},
- NULL
- };
-
- unsigned int count = ruleSet.len;
- for (unsigned int i = 0; i < count; i++)
- (this+ruleSet[i]).collect_glyphs (c, lookup_context);
- }
-
inline bool would_apply (hb_would_apply_context_t *c) const
{
- TRACE_WOULD_APPLY (this);
+ TRACE_WOULD_APPLY ();
const ClassDef &class_def = this+classDef;
- unsigned int index = class_def.get_class (c->glyphs[0]);
+ unsigned int index = class_def (c->glyphs[0]);
const RuleSet &rule_set = this+ruleSet[index];
struct ContextApplyLookupContext lookup_context = {
- {match_class},
+ {match_class, NULL},
&class_def
};
return TRACE_RETURN (rule_set.would_apply (c, lookup_context));
}
- inline const Coverage &get_coverage (void) const
+ inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{
- return this+coverage;
- }
-
- inline bool apply (hb_apply_context_t *c) const
- {
- TRACE_APPLY (this);
- unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
+ TRACE_APPLY ();
+ unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
const ClassDef &class_def = this+classDef;
- index = class_def.get_class (c->buffer->cur().codepoint);
+ index = class_def (c->buffer->cur().codepoint);
const RuleSet &rule_set = this+ruleSet[index];
struct ContextApplyLookupContext lookup_context = {
- {match_class},
+ {match_class, apply_func},
&class_def
};
return TRACE_RETURN (rule_set.apply (c, lookup_context));
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (coverage.sanitize (c, this) && classDef.sanitize (c, this) && ruleSet.sanitize (c, this));
}
@@ -1245,15 +1053,19 @@ struct ContextFormat2
struct ContextFormat3
{
- inline void closure (hb_closure_context_t *c) const
+ friend struct Context;
+
+ private:
+
+ inline void closure (hb_closure_context_t *c, closure_lookup_func_t closure_func) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
if (!(this+coverage[0]).intersects (c->glyphs))
return;
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount);
struct ContextClosureLookupContext lookup_context = {
- {intersects_coverage},
+ {intersects_coverage, closure_func},
this
};
context_closure_lookup (c,
@@ -1262,56 +1074,34 @@ struct ContextFormat3
lookup_context);
}
- inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
- {
- TRACE_COLLECT_GLYPHS (this);
- (this+coverage[0]).add_coverage (&c->input);
-
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount);
- struct ContextCollectGlyphsLookupContext lookup_context = {
- {collect_coverage},
- NULL
- };
-
- context_collect_glyphs_lookup (c,
- glyphCount, (const USHORT *) (coverage + 1),
- lookupCount, lookupRecord,
- lookup_context);
- }
-
inline bool would_apply (hb_would_apply_context_t *c) const
{
- TRACE_WOULD_APPLY (this);
+ TRACE_WOULD_APPLY ();
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount);
struct ContextApplyLookupContext lookup_context = {
- {match_coverage},
+ {match_coverage, NULL},
this
};
return TRACE_RETURN (context_would_apply_lookup (c, glyphCount, (const USHORT *) (coverage + 1), lookupCount, lookupRecord, lookup_context));
}
- inline const Coverage &get_coverage (void) const
+ inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{
- return this+coverage[0];
- }
-
- inline bool apply (hb_apply_context_t *c) const
- {
- TRACE_APPLY (this);
- unsigned int index = (this+coverage[0]).get_coverage (c->buffer->cur().codepoint);
+ TRACE_APPLY ();
+ unsigned int index = (this+coverage[0]) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount);
struct ContextApplyLookupContext lookup_context = {
- {match_coverage},
+ {match_coverage, apply_func},
this
};
return TRACE_RETURN (context_apply_lookup (c, glyphCount, (const USHORT *) (coverage + 1), lookupCount, lookupRecord, lookup_context));
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!c->check_struct (this)) return TRACE_RETURN (false);
unsigned int count = glyphCount;
if (!c->check_array (coverage, coverage[0].static_size, count)) return TRACE_RETURN (false);
@@ -1337,20 +1127,63 @@ struct ContextFormat3
struct Context
{
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c) const
+ protected:
+
+ inline void closure (hb_closure_context_t *c, closure_lookup_func_t closure_func) const
{
- TRACE_PROCESS (this);
+ TRACE_CLOSURE ();
switch (u.format) {
- case 1: return TRACE_RETURN (c->process (u.format1));
- case 2: return TRACE_RETURN (c->process (u.format2));
- case 3: return TRACE_RETURN (c->process (u.format3));
- default:return TRACE_RETURN (c->default_return_value ());
+ case 1: u.format1.closure (c, closure_func); break;
+ case 2: u.format2.closure (c, closure_func); break;
+ case 3: u.format3.closure (c, closure_func); break;
+ default: break;
+ }
+ }
+
+ inline void collect_glyphs (hb_collect_glyphs_context_t *c, collect_glyphs_lookup_func_t closure_func) const
+ {
+ TRACE_CLOSURE ();
+ switch (u.format) {
+// case 1: u.format1.collect_glyphs (c); break;
+// case 2: u.format2.collect_glyphs (c); break;
+// case 3: u.format2.collect_glyphs (c); break;
+ default: break;
+ }
+ }
+
+ inline const Coverage &get_coverage (void) const
+ {
+ switch (u.format) {
+ case 1: return this + u.format1.coverage;
+ case 2: return this + u.format2.coverage;
+ case 3: return this + u.format3.coverage[0];
+ default:return Null(Coverage);
+ }
+ }
+
+ inline bool would_apply (hb_would_apply_context_t *c) const
+ {
+ switch (u.format) {
+ case 1: return u.format1.would_apply (c);
+ case 2: return u.format2.would_apply (c);
+ case 3: return u.format3.would_apply (c);
+ default:return false;
+ }
+ }
+
+ inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
+ {
+ TRACE_APPLY ();
+ switch (u.format) {
+ case 1: return TRACE_RETURN (u.format1.apply (c, apply_func));
+ case 2: return TRACE_RETURN (u.format2.apply (c, apply_func));
+ case 3: return TRACE_RETURN (u.format3.apply (c, apply_func));
+ default:return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -1378,12 +1211,6 @@ struct ChainContextClosureLookupContext
const void *intersects_data[3];
};
-struct ChainContextCollectGlyphsLookupContext
-{
- ContextCollectGlyphsFuncs funcs;
- const void *collect_data[3];
-};
-
struct ChainContextApplyLookupContext
{
ContextApplyFuncs funcs;
@@ -1410,32 +1237,9 @@ static inline void chain_context_closure_lookup (hb_closure_context_t *c,
&& intersects_array (c,
lookaheadCount, lookahead,
lookup_context.funcs.intersects, lookup_context.intersects_data[2]))
- recurse_lookups (c,
- lookupCount, lookupRecord);
-}
-
-static inline void chain_context_collect_glyphs_lookup (hb_collect_glyphs_context_t *c,
- unsigned int backtrackCount,
- const USHORT backtrack[],
- unsigned int inputCount, /* Including the first glyph (not matched) */
- const USHORT input[], /* Array of input values--start with second glyph */
- unsigned int lookaheadCount,
- const USHORT lookahead[],
- unsigned int lookupCount,
- const LookupRecord lookupRecord[],
- ChainContextCollectGlyphsLookupContext &lookup_context)
-{
- collect_array (c, &c->before,
- backtrackCount, backtrack,
- lookup_context.funcs.collect, lookup_context.collect_data[0]);
- collect_array (c, &c->input,
- inputCount ? inputCount - 1 : 0, input,
- lookup_context.funcs.collect, lookup_context.collect_data[1]);
- collect_array (c, &c->after,
- lookaheadCount, lookahead,
- lookup_context.funcs.collect, lookup_context.collect_data[2]);
- recurse_lookups (c,
- lookupCount, lookupRecord);
+ closure_lookup (c,
+ lookupCount, lookupRecord,
+ lookup_context.funcs.closure);
}
static inline bool chain_context_would_apply_lookup (hb_would_apply_context_t *c,
@@ -1466,7 +1270,7 @@ static inline bool chain_context_apply_lookup (hb_apply_context_t *c,
const LookupRecord lookupRecord[],
ChainContextApplyLookupContext &lookup_context)
{
- unsigned int lookahead_offset = 0;
+ unsigned int lookahead_offset;
return match_input (c,
inputCount, input,
lookup_context.funcs.match, lookup_context.match_data[1],
@@ -1480,14 +1284,19 @@ static inline bool chain_context_apply_lookup (hb_apply_context_t *c,
lookahead_offset)
&& apply_lookup (c,
inputCount,
- lookupCount, lookupRecord);
+ lookupCount, lookupRecord,
+ lookup_context.funcs.apply);
}
struct ChainRule
{
+ friend struct ChainRuleSet;
+
+ private:
+
inline void closure (hb_closure_context_t *c, ChainContextClosureLookupContext &lookup_context) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
@@ -1499,23 +1308,9 @@ struct ChainRule
lookup_context);
}
- inline void collect_glyphs (hb_collect_glyphs_context_t *c, ChainContextCollectGlyphsLookupContext &lookup_context) const
- {
- TRACE_COLLECT_GLYPHS (this);
- const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
- const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
- const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
- chain_context_collect_glyphs_lookup (c,
- backtrack.len, backtrack.array,
- input.len, input.array,
- lookahead.len, lookahead.array,
- lookup.len, lookup.array,
- lookup_context);
- }
-
inline bool would_apply (hb_would_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const
{
- TRACE_WOULD_APPLY (this);
+ TRACE_WOULD_APPLY ();
const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
@@ -1528,7 +1323,7 @@ struct ChainRule
inline bool apply (hb_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
@@ -1539,8 +1334,9 @@ struct ChainRule
lookup.array, lookup_context));
}
+ public:
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!backtrack.sanitize (c)) return TRACE_RETURN (false);
HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
if (!input.sanitize (c)) return TRACE_RETURN (false);
@@ -1572,23 +1368,15 @@ struct ChainRuleSet
{
inline void closure (hb_closure_context_t *c, ChainContextClosureLookupContext &lookup_context) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++)
(this+rule[i]).closure (c, lookup_context);
}
- inline void collect_glyphs (hb_collect_glyphs_context_t *c, ChainContextCollectGlyphsLookupContext &lookup_context) const
- {
- TRACE_COLLECT_GLYPHS (this);
- unsigned int num_rules = rule.len;
- for (unsigned int i = 0; i < num_rules; i++)
- (this+rule[i]).collect_glyphs (c, lookup_context);
- }
-
inline bool would_apply (hb_would_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const
{
- TRACE_WOULD_APPLY (this);
+ TRACE_WOULD_APPLY ();
unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++)
if ((this+rule[i]).would_apply (c, lookup_context))
@@ -1599,7 +1387,7 @@ struct ChainRuleSet
inline bool apply (hb_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const
{
- TRACE_APPLY (this);
+ TRACE_APPLY ();
unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++)
if ((this+rule[i]).apply (c, lookup_context))
@@ -1609,7 +1397,7 @@ struct ChainRuleSet
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (rule.sanitize (c, this));
}
@@ -1623,13 +1411,17 @@ struct ChainRuleSet
struct ChainContextFormat1
{
- inline void closure (hb_closure_context_t *c) const
+ friend struct ChainContext;
+
+ private:
+
+ inline void closure (hb_closure_context_t *c, closure_lookup_func_t closure_func) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
const Coverage &cov = (this+coverage);
struct ChainContextClosureLookupContext lookup_context = {
- {intersects_glyph},
+ {intersects_glyph, closure_func},
{NULL, NULL, NULL}
};
@@ -1641,54 +1433,34 @@ struct ChainContextFormat1
}
}
- inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
- {
- TRACE_COLLECT_GLYPHS (this);
- (this+coverage).add_coverage (&c->input);
-
- struct ChainContextCollectGlyphsLookupContext lookup_context = {
- {collect_glyph},
- {NULL, NULL, NULL}
- };
-
- unsigned int count = ruleSet.len;
- for (unsigned int i = 0; i < count; i++)
- (this+ruleSet[i]).collect_glyphs (c, lookup_context);
- }
-
inline bool would_apply (hb_would_apply_context_t *c) const
{
- TRACE_WOULD_APPLY (this);
+ TRACE_WOULD_APPLY ();
- const ChainRuleSet &rule_set = this+ruleSet[(this+coverage).get_coverage (c->glyphs[0])];
+ const ChainRuleSet &rule_set = this+ruleSet[(this+coverage) (c->glyphs[0])];
struct ChainContextApplyLookupContext lookup_context = {
- {match_glyph},
+ {match_glyph, NULL},
{NULL, NULL, NULL}
};
return TRACE_RETURN (rule_set.would_apply (c, lookup_context));
}
- inline const Coverage &get_coverage (void) const
- {
- return this+coverage;
- }
-
- inline bool apply (hb_apply_context_t *c) const
+ inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{
- TRACE_APPLY (this);
- unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
+ TRACE_APPLY ();
+ unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
const ChainRuleSet &rule_set = this+ruleSet[index];
struct ChainContextApplyLookupContext lookup_context = {
- {match_glyph},
+ {match_glyph, apply_func},
{NULL, NULL, NULL}
};
return TRACE_RETURN (rule_set.apply (c, lookup_context));
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (coverage.sanitize (c, this) && ruleSet.sanitize (c, this));
}
@@ -1706,9 +1478,13 @@ struct ChainContextFormat1
struct ChainContextFormat2
{
- inline void closure (hb_closure_context_t *c) const
+ friend struct ChainContext;
+
+ private:
+
+ inline void closure (hb_closure_context_t *c, closure_lookup_func_t closure_func) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
if (!(this+coverage).intersects (c->glyphs))
return;
@@ -1717,7 +1493,7 @@ struct ChainContextFormat2
const ClassDef &lookahead_class_def = this+lookaheadClassDef;
struct ChainContextClosureLookupContext lookup_context = {
- {intersects_class},
+ {intersects_class, closure_func},
{&backtrack_class_def,
&input_class_def,
&lookahead_class_def}
@@ -1731,55 +1507,35 @@ struct ChainContextFormat2
}
}
- inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
- {
- TRACE_COLLECT_GLYPHS (this);
- (this+coverage).add_coverage (&c->input);
-
- struct ChainContextCollectGlyphsLookupContext lookup_context = {
- {collect_class},
- {NULL, NULL, NULL}
- };
-
- unsigned int count = ruleSet.len;
- for (unsigned int i = 0; i < count; i++)
- (this+ruleSet[i]).collect_glyphs (c, lookup_context);
- }
-
inline bool would_apply (hb_would_apply_context_t *c) const
{
- TRACE_WOULD_APPLY (this);
+ TRACE_WOULD_APPLY ();
const ClassDef &input_class_def = this+inputClassDef;
- unsigned int index = input_class_def.get_class (c->glyphs[0]);
+ unsigned int index = input_class_def (c->glyphs[0]);
const ChainRuleSet &rule_set = this+ruleSet[index];
struct ChainContextApplyLookupContext lookup_context = {
- {match_class},
+ {match_class, NULL},
{NULL, &input_class_def, NULL}
};
return TRACE_RETURN (rule_set.would_apply (c, lookup_context));
}
- inline const Coverage &get_coverage (void) const
- {
- return this+coverage;
- }
-
- inline bool apply (hb_apply_context_t *c) const
+ inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{
- TRACE_APPLY (this);
- unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
+ TRACE_APPLY ();
+ unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
const ClassDef &backtrack_class_def = this+backtrackClassDef;
const ClassDef &input_class_def = this+inputClassDef;
const ClassDef &lookahead_class_def = this+lookaheadClassDef;
- index = input_class_def.get_class (c->buffer->cur().codepoint);
+ index = input_class_def (c->buffer->cur().codepoint);
const ChainRuleSet &rule_set = this+ruleSet[index];
struct ChainContextApplyLookupContext lookup_context = {
- {match_class},
+ {match_class, apply_func},
{&backtrack_class_def,
&input_class_def,
&lookahead_class_def}
@@ -1788,7 +1544,7 @@ struct ChainContextFormat2
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (coverage.sanitize (c, this) && backtrackClassDef.sanitize (c, this) &&
inputClassDef.sanitize (c, this) && lookaheadClassDef.sanitize (c, this) &&
ruleSet.sanitize (c, this));
@@ -1820,9 +1576,13 @@ struct ChainContextFormat2
struct ChainContextFormat3
{
- inline void closure (hb_closure_context_t *c) const
+ friend struct ChainContext;
+
+ private:
+
+ inline void closure (hb_closure_context_t *c, closure_lookup_func_t closure_func) const
{
- TRACE_CLOSURE (this);
+ TRACE_CLOSURE ();
const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
if (!(this+input[0]).intersects (c->glyphs))
@@ -1831,7 +1591,7 @@ struct ChainContextFormat3
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
struct ChainContextClosureLookupContext lookup_context = {
- {intersects_coverage},
+ {intersects_coverage, closure_func},
{this, this, this}
};
chain_context_closure_lookup (c,
@@ -1842,36 +1602,21 @@ struct ChainContextFormat3
lookup_context);
}
- inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
+ inline const Coverage &get_coverage (void) const
{
- TRACE_COLLECT_GLYPHS (this);
const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
-
- (this+input[0]).add_coverage (&c->input);
-
- const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
- const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
- struct ChainContextCollectGlyphsLookupContext lookup_context = {
- {collect_coverage},
- {this, this, this}
- };
- chain_context_collect_glyphs_lookup (c,
- backtrack.len, (const USHORT *) backtrack.array,
- input.len, (const USHORT *) input.array + 1,
- lookahead.len, (const USHORT *) lookahead.array,
- lookup.len, lookup.array,
- lookup_context);
+ return this+input[0];
}
inline bool would_apply (hb_would_apply_context_t *c) const
{
- TRACE_WOULD_APPLY (this);
+ TRACE_WOULD_APPLY ();
const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
struct ChainContextApplyLookupContext lookup_context = {
- {match_coverage},
+ {match_coverage, NULL},
{this, this, this}
};
return TRACE_RETURN (chain_context_would_apply_lookup (c,
@@ -1881,24 +1626,18 @@ struct ChainContextFormat3
lookup.len, lookup.array, lookup_context));
}
- inline const Coverage &get_coverage (void) const
+ inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{
+ TRACE_APPLY ();
const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
- return this+input[0];
- }
- inline bool apply (hb_apply_context_t *c) const
- {
- TRACE_APPLY (this);
- const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
-
- unsigned int index = (this+input[0]).get_coverage (c->buffer->cur().codepoint);
+ unsigned int index = (this+input[0]) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
struct ChainContextApplyLookupContext lookup_context = {
- {match_coverage},
+ {match_coverage, apply_func},
{this, this, this}
};
return TRACE_RETURN (chain_context_apply_lookup (c,
@@ -1909,7 +1648,7 @@ struct ChainContextFormat3
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!backtrack.sanitize (c, this)) return TRACE_RETURN (false);
OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
if (!input.sanitize (c, this)) return TRACE_RETURN (false);
@@ -1942,20 +1681,63 @@ struct ChainContextFormat3
struct ChainContext
{
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c) const
+ protected:
+
+ inline void closure (hb_closure_context_t *c, closure_lookup_func_t closure_func) const
+ {
+ TRACE_CLOSURE ();
+ switch (u.format) {
+ case 1: u.format1.closure (c, closure_func); break;
+ case 2: u.format2.closure (c, closure_func); break;
+ case 3: u.format3.closure (c, closure_func); break;
+ default: break;
+ }
+ }
+
+ inline void collect_glyphs (hb_collect_glyphs_context_t *c, collect_glyphs_lookup_func_t closure_func) const
+ {
+ TRACE_CLOSURE ();
+ switch (u.format) {
+// case 1: u.format1.collect_glyphs (c); break;
+// case 2: u.format2.collect_glyphs (c); break;
+// case 3: u.format2.collect_glyphs (c); break;
+ default: break;
+ }
+ }
+
+ inline const Coverage &get_coverage (void) const
+ {
+ switch (u.format) {
+ case 1: return this + u.format1.coverage;
+ case 2: return this + u.format2.coverage;
+ case 3: return u.format3.get_coverage ();
+ default:return Null(Coverage);
+ }
+ }
+
+ inline bool would_apply (hb_would_apply_context_t *c) const
+ {
+ switch (u.format) {
+ case 1: return u.format1.would_apply (c);
+ case 2: return u.format2.would_apply (c);
+ case 3: return u.format3.would_apply (c);
+ default:return false;
+ }
+ }
+
+ inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{
- TRACE_PROCESS (this);
+ TRACE_APPLY ();
switch (u.format) {
- case 1: return TRACE_RETURN (c->process (u.format1));
- case 2: return TRACE_RETURN (c->process (u.format2));
- case 3: return TRACE_RETURN (c->process (u.format3));
- default:return TRACE_RETURN (c->default_return_value ());
+ case 1: return TRACE_RETURN (u.format1.apply (c, apply_func));
+ case 2: return TRACE_RETURN (u.format2.apply (c, apply_func));
+ case 3: return TRACE_RETURN (u.format3.apply (c, apply_func));
+ default:return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -1977,11 +1759,14 @@ struct ChainContext
struct ExtensionFormat1
{
+ friend struct Extension;
+
+ protected:
inline unsigned int get_type (void) const { return extensionLookupType; }
inline unsigned int get_offset (void) const { return extensionOffset; }
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this));
}
@@ -1996,7 +1781,6 @@ struct ExtensionFormat1
DEFINE_SIZE_STATIC (8);
};
-template <typename T>
struct Extension
{
inline unsigned int get_type (void) const
@@ -2014,22 +1798,8 @@ struct Extension
}
}
- template <typename X>
- inline const X& get_subtable (void) const
- {
- unsigned int offset = get_offset ();
- if (unlikely (!offset)) return Null(typename T::LookupSubTable);
- return StructAtOffset<typename T::LookupSubTable> (this, offset);
- }
-
- template <typename context_t>
- inline typename context_t::return_t process (context_t *c) const
- {
- return get_subtable<typename T::LookupSubTable> ().process (c, get_type ());
- }
-
- inline bool sanitize_self (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ inline bool sanitize (hb_sanitize_context_t *c) {
+ TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.sanitize (c));
@@ -2037,14 +1807,6 @@ struct Extension
}
}
- inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
- if (!sanitize_self (c)) return TRACE_RETURN (false);
- unsigned int offset = get_offset ();
- if (unlikely (!offset)) return TRACE_RETURN (true);
- return TRACE_RETURN (StructAtOffset<typename T::LookupSubTable> (this, offset).sanitize (c, get_type ()));
- }
-
protected:
union {
USHORT format; /* Format identifier */
@@ -2094,7 +1856,7 @@ struct GSUBGPOS
{ return (this+lookupList)[i]; }
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (version.sanitize (c) && likely (version.major == 1) &&
scriptList.sanitize (c, this) &&
featureList.sanitize (c, this) &&
diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout.cc b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout.cc
index 2572c007359..aaef3130bf2 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout.cc
+++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout.cc
@@ -401,103 +401,6 @@ hb_ot_layout_feature_get_lookups (hb_face_t *face,
return f.get_lookup_indexes (start_offset, lookup_count, lookup_indexes);
}
-static void
-_hb_ot_layout_collect_lookups_lookups (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int feature_index,
- hb_set_t *lookup_indexes /* OUT */)
-{
- unsigned int lookup_indices[32];
- unsigned int offset, len;
-
- offset = 0;
- do {
- len = ARRAY_LENGTH (lookup_indices);
- hb_ot_layout_feature_get_lookups (face,
- table_tag,
- feature_index,
- offset, &len,
- lookup_indices);
-
- for (unsigned int i = 0; i < len; i++)
- lookup_indexes->add (lookup_indices[i]);
-
- offset += len;
- } while (len == ARRAY_LENGTH (lookup_indices));
-}
-
-static void
-_hb_ot_layout_collect_lookups_features (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- unsigned int language_index,
- const hb_tag_t *features,
- hb_set_t *lookup_indexes /* OUT */)
-{
- if (!features)
- {
- /* All features */
- unsigned int count = hb_ot_layout_language_get_feature_tags (face, table_tag, script_index, language_index, 0, NULL, NULL);
- for (unsigned int feature_index = 0; feature_index < count; feature_index++)
- _hb_ot_layout_collect_lookups_lookups (face, table_tag, feature_index, lookup_indexes);
- } else {
- for (; *features; features++)
- {
- unsigned int feature_index;
- if (hb_ot_layout_language_find_feature (face, table_tag, script_index, language_index, *features, &feature_index))
- _hb_ot_layout_collect_lookups_lookups (face, table_tag, feature_index, lookup_indexes);
- }
- }
-}
-
-static void
-_hb_ot_layout_collect_lookups_languages (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- const hb_tag_t *languages,
- const hb_tag_t *features,
- hb_set_t *lookup_indexes /* OUT */)
-{
- if (!languages)
- {
- /* All languages */
- unsigned int count = hb_ot_layout_script_get_language_tags (face, table_tag, script_index, 0, NULL, NULL);
- for (unsigned int language_index = 0; language_index < count; language_index++)
- _hb_ot_layout_collect_lookups_features (face, table_tag, script_index, language_index, features, lookup_indexes);
- } else {
- for (; *languages; languages++)
- {
- unsigned int language_index;
- if (hb_ot_layout_script_find_language (face, table_tag, script_index, *languages, &language_index))
- _hb_ot_layout_collect_lookups_features (face, table_tag, script_index, language_index, features, lookup_indexes);
- }
- }
-}
-
-void
-hb_ot_layout_collect_lookups (hb_face_t *face,
- hb_tag_t table_tag,
- const hb_tag_t *scripts,
- const hb_tag_t *languages,
- const hb_tag_t *features,
- hb_set_t *lookup_indexes /* OUT */)
-{
- if (!scripts)
- {
- /* All scripts */
- unsigned int count = hb_ot_layout_table_get_script_tags (face, table_tag, 0, NULL, NULL);
- for (unsigned int script_index = 0; script_index < count; script_index++)
- _hb_ot_layout_collect_lookups_languages (face, table_tag, script_index, languages, features, lookup_indexes);
- } else {
- for (; *scripts; scripts++)
- {
- unsigned int script_index;
- if (hb_ot_layout_table_find_script (face, table_tag, *scripts, &script_index))
- _hb_ot_layout_collect_lookups_languages (face, table_tag, script_index, languages, features, lookup_indexes);
- }
- }
-}
-
void
hb_ot_layout_lookup_collect_glyphs (hb_face_t *face,
hb_tag_t table_tag,
@@ -515,13 +418,13 @@ hb_ot_layout_lookup_collect_glyphs (hb_face_t *face,
case HB_OT_TAG_GSUB:
{
const OT::SubstLookup& l = hb_ot_layout_from_face (face)->gsub->get_lookup (lookup_index);
- l.collect_glyphs_lookup (&c);
+ l.collect_glyphs (&c);
return;
}
case HB_OT_TAG_GPOS:
{
const OT::PosLookup& l = hb_ot_layout_from_face (face)->gpos->get_lookup (lookup_index);
- l.collect_glyphs_lookup (&c);
+// l.collect_glyphs (&c);
return;
}
}
@@ -597,10 +500,7 @@ hb_ot_layout_lookup_substitute_closure (hb_face_t *face,
hb_set_t *glyphs)
{
OT::hb_closure_context_t c (face, glyphs);
-
- const OT::SubstLookup& l = _get_gsub (face).get_lookup (lookup_index);
-
- l.closure (&c);
+ _get_gsub (face).closure_lookup (&c, lookup_index);
}
/*
@@ -645,17 +545,13 @@ hb_ot_layout_position_get_size (hb_face_t *face,
uint16_t *data /* OUT, 5 items */)
{
const OT::GPOS &gpos = _get_gpos (face);
- unsigned int script_index;
- gpos.find_script_index (HB_OT_TAG_DEFAULT_SCRIPT, &script_index);
- const OT::LangSys &l = gpos.get_script (script_index).get_lang_sys (HB_OT_TAG_DEFAULT_LANGUAGE);
- unsigned int num_features = l.get_feature_count ();
+ unsigned int num_features = gpos.get_feature_count ();
for (unsigned int i = 0; i < num_features; i++) {
- unsigned int f_index = l.get_feature_index (i);
- if (HB_TAG ('s','i','z','e') == gpos.get_feature_tag (f_index))
+ if (HB_TAG ('s','i','z','e') == gpos.get_feature_tag (i))
{
- const OT::Feature &f = gpos.get_feature (f_index);
+ const OT::Feature &f = gpos.get_feature (i);
const OT::FeatureParams &params = f.get_feature_params ();
for (unsigned int i = 0; i < 5; i++)
diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout.h b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout.h
index adb483ce9df..023f0718fc8 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout.h
+++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-layout.h
@@ -179,13 +179,15 @@ hb_ot_layout_feature_get_lookups (hb_face_t *face,
unsigned int *lookup_count /* IN/OUT */,
unsigned int *lookup_indexes /* OUT */);
+#ifdef HB_NOT_IMPLEMENTED
void
-hb_ot_layout_collect_lookups (hb_face_t *face,
+Xhb_ot_layout_collect_lookups (hb_face_t *face,
hb_tag_t table_tag,
const hb_tag_t *scripts,
const hb_tag_t *languages,
const hb_tag_t *features,
hb_set_t *lookup_indexes /* OUT */);
+#endif
void
hb_ot_shape_plan_collect_lookups (hb_shape_plan_t *shape_plan,
diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-maxp-table.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-maxp-table.hh
index 0ce3ebcc2a6..ef2b9f1cc62 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-maxp-table.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-maxp-table.hh
@@ -48,7 +48,7 @@ struct maxp
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) &&
likely (version.major == 1 || (version.major == 0 && version.minor == 0x5000)));
}
diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-name-table.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-name-table.hh
index 75a1b94ea31..ab7a692ede1 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-name-table.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-ot-name-table.hh
@@ -57,7 +57,7 @@ struct NameRecord
}
inline bool sanitize (hb_sanitize_context_t *c, void *base) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
/* We can check from base all the way up to the end of string... */
return TRACE_RETURN (c->check_struct (this) && c->check_range ((char *) base, (unsigned int) length + offset));
}
@@ -99,7 +99,7 @@ struct name
}
inline bool sanitize_records (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
char *string_pool = (char *) this + stringOffset;
unsigned int _count = count;
for (unsigned int i = 0; i < _count; i++)
@@ -108,7 +108,7 @@ struct name
}
inline bool sanitize (hb_sanitize_context_t *c) {
- TRACE_SANITIZE (this);
+ TRACE_SANITIZE ();
return TRACE_RETURN (c->check_struct (this) &&
likely (format == 0 || format == 1) &&
c->check_array (nameRecord, nameRecord[0].static_size, count) &&
diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-private.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-private.hh
index 265fba15d8d..42c025909ae 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-private.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-private.hh
@@ -62,12 +62,6 @@
#endif
-/* Void! */
-struct _void_t;
-typedef const _void_t &void_t;
-#define VOID (* (const _void_t *) NULL)
-
-
/* Basics */
@@ -588,11 +582,7 @@ _hb_debug_msg_va (const char *what,
} else
fprintf (stderr, " " VRBAR LBAR);
- if (func)
- {
- /* Skip "typename" */
- if (0 == strncmp (func, "typename ", 9))
- func += 9;
+ if (func) {
/* Skip return type */
const char *space = strchr (func, ' ');
if (space)
@@ -667,39 +657,10 @@ _hb_debug_msg<0> (const char *what HB_UNUSED,
/*
- * Printer
- */
-
-template <typename T>
-struct hb_printer_t {};
-
-template <>
-struct hb_printer_t<bool> {
- const char *print (bool v) { return v ? "true" : "false"; }
-};
-
-template <>
-struct hb_printer_t<void_t> {
- const char *print (void_t v) { return ""; }
-};
-
-
-/*
* Trace
*/
-template <typename T>
-static inline void _hb_warn_no_return (bool returned)
-{
- if (unlikely (!returned)) {
- fprintf (stderr, "OUCH, returned with no call to TRACE_RETURN. This is a bug, please report.\n");
- }
-}
-template <>
-inline void _hb_warn_no_return<void_t> (bool returned)
-{}
-
-template <int max_level, typename ret_t>
+template <int max_level>
struct hb_auto_trace_t {
explicit inline hb_auto_trace_t (unsigned int *plevel_,
const char *what_,
@@ -717,23 +678,23 @@ struct hb_auto_trace_t {
}
inline ~hb_auto_trace_t (void)
{
- _hb_warn_no_return<ret_t> (returned);
- if (!returned) {
+ if (unlikely (!returned)) {
+ fprintf (stderr, "OUCH, returned with no call to TRACE_RETURN. This is a bug, please report. Level was %d.\n", plevel ? *plevel : -1);
_hb_debug_msg<max_level> (what, obj, NULL, true, plevel ? *plevel : 1, -1, " ");
+ return;
}
+
if (plevel) --*plevel;
}
- inline ret_t ret (ret_t v, unsigned int line = 0)
+ inline bool ret (bool v, unsigned int line = 0)
{
if (unlikely (returned)) {
fprintf (stderr, "OUCH, double calls to TRACE_RETURN. This is a bug, please report.\n");
return v;
}
- _hb_debug_msg<max_level> (what, obj, NULL, true, plevel ? *plevel : 1, -1,
- "return %s (line %d)",
- hb_printer_t<ret_t>().print (v), line);
+ _hb_debug_msg<max_level> (what, obj, NULL, true, plevel ? *plevel : 1, -1, "return %s (line %d)", v ? "true" : "false", line);
if (plevel) --*plevel;
plevel = NULL;
returned = true;
@@ -742,12 +703,12 @@ struct hb_auto_trace_t {
private:
unsigned int *plevel;
+ bool returned;
const char *what;
const void *obj;
- bool returned;
};
-template <typename ret_t> /* Optimize when tracing is disabled */
-struct hb_auto_trace_t<0, ret_t> {
+template <> /* Optimize when tracing is disabled */
+struct hb_auto_trace_t<0> {
explicit inline hb_auto_trace_t (unsigned int *plevel_ HB_UNUSED,
const char *what HB_UNUSED,
const void *obj HB_UNUSED,
@@ -755,7 +716,8 @@ struct hb_auto_trace_t<0, ret_t> {
const char *message HB_UNUSED,
...) {}
- inline ret_t ret (ret_t v, unsigned int line = 0) { return v; }
+ template <typename T>
+ inline T ret (T v, unsigned int line = 0) { return v; }
};
#define TRACE_RETURN(RET) trace.ret (RET, __LINE__)
diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-shape-plan.cc b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-shape-plan.cc
index 22a226f3a6c..7735d4eecab 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-shape-plan.cc
+++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.7/src/hb-shape-plan.cc
@@ -304,5 +304,4 @@ retry:
const char *
hb_shape_plan_get_shaper (hb_shape_plan_t *shape_plan)
{
- return shape_plan->shaper_name;
}