提交 6d08c7f1 编写于 作者: B Behdad Esfahbod

Revert "Towards templatizing common Lookup types"

This reverts commit 727135f3.

This is work-in-progress.  Didn't mean to push it out just yet.
上级 552bf3a9
...@@ -1268,7 +1268,7 @@ struct ChainContextPos : ChainContext ...@@ -1268,7 +1268,7 @@ struct ChainContextPos : ChainContext
}; };
struct ExtensionPos : Extension<struct GPOS> struct ExtensionPos : Extension
{ {
friend struct PosLookupSubTable; friend struct PosLookupSubTable;
...@@ -1382,10 +1382,8 @@ struct PosLookupSubTable ...@@ -1382,10 +1382,8 @@ struct PosLookupSubTable
struct PosLookup : Lookup struct PosLookup : Lookup
{ {
typedef struct PosLookupSubTable SubTable; inline const PosLookupSubTable& get_subtable (unsigned int i) const
{ return this+CastR<OffsetArrayOf<PosLookupSubTable> > (subTable)[i]; }
inline const SubTable& get_subtable (unsigned int i) const
{ return this+CastR<OffsetArrayOf<SubTable> > (subTable)[i]; }
inline bool apply_once (hb_apply_context_t *c) const inline bool apply_once (hb_apply_context_t *c) const
{ {
...@@ -1426,7 +1424,7 @@ struct PosLookup : Lookup ...@@ -1426,7 +1424,7 @@ struct PosLookup : Lookup
inline bool sanitize (hb_sanitize_context_t *c) { inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false); if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false);
OffsetArrayOf<SubTable> &list = CastR<OffsetArrayOf<SubTable> > (subTable); OffsetArrayOf<PosLookupSubTable> &list = CastR<OffsetArrayOf<PosLookupSubTable> > (subTable);
return TRACE_RETURN (list.sanitize (c, this, get_type ())); return TRACE_RETURN (list.sanitize (c, this, get_type ()));
} }
}; };
...@@ -1439,8 +1437,6 @@ typedef OffsetListOf<PosLookup> PosLookupList; ...@@ -1439,8 +1437,6 @@ typedef OffsetListOf<PosLookup> PosLookupList;
struct GPOS : GSUBGPOS struct GPOS : GSUBGPOS
{ {
typedef struct PosLookup Lookup;
static const hb_tag_t Tag = HB_OT_TAG_GPOS; static const hb_tag_t Tag = HB_OT_TAG_GPOS;
inline const PosLookup& get_lookup (unsigned int i) const inline const PosLookup& get_lookup (unsigned int i) const
...@@ -1549,10 +1545,10 @@ inline bool ExtensionPos::apply (hb_apply_context_t *c) const ...@@ -1549,10 +1545,10 @@ inline bool ExtensionPos::apply (hb_apply_context_t *c) const
inline bool ExtensionPos::sanitize (hb_sanitize_context_t *c) inline bool ExtensionPos::sanitize (hb_sanitize_context_t *c)
{ {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (unlikely (!Extension<GPOS>::sanitize (c))) return TRACE_RETURN (false); if (unlikely (!Extension::sanitize (c))) return TRACE_RETURN (false);
unsigned int offset = get_offset (); unsigned int offset = get_offset ();
if (unlikely (!offset)) return TRACE_RETURN (true); if (unlikely (!offset)) return TRACE_RETURN (true);
return TRACE_RETURN (StructAtOffset<PosLookup::SubTable> (this, offset).sanitize (c, get_type ())); 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) static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_index)
......
...@@ -750,7 +750,7 @@ struct ChainContextSubst : ChainContext ...@@ -750,7 +750,7 @@ struct ChainContextSubst : ChainContext
}; };
struct ExtensionSubst : Extension<struct GSUB> struct ExtensionSubst : Extension
{ {
friend struct SubstLookupSubTable; friend struct SubstLookupSubTable;
friend struct SubstLookup; friend struct SubstLookup;
...@@ -1037,18 +1037,16 @@ struct SubstLookupSubTable ...@@ -1037,18 +1037,16 @@ struct SubstLookupSubTable
struct SubstLookup : Lookup struct SubstLookup : Lookup
{ {
typedef struct SubstLookupSubTable SubTable; inline const SubstLookupSubTable& get_subtable (unsigned int i) const
{ return this+CastR<OffsetArrayOf<SubstLookupSubTable> > (subTable)[i]; }
inline const SubTable& get_subtable (unsigned int i) const
{ return this+CastR<OffsetArrayOf<SubTable> > (subTable)[i]; }
inline static bool lookup_type_is_reverse (unsigned int lookup_type) inline static bool lookup_type_is_reverse (unsigned int lookup_type)
{ return lookup_type == SubTable::ReverseChainSingle; } { return lookup_type == SubstLookupSubTable::ReverseChainSingle; }
inline bool is_reverse (void) const inline bool is_reverse (void) const
{ {
unsigned int type = get_type (); unsigned int type = get_type ();
if (unlikely (type == SubTable::Extension)) if (unlikely (type == SubstLookupSubTable::Extension))
return CastR<ExtensionSubst> (get_subtable(0)).is_reverse (); return CastR<ExtensionSubst> (get_subtable(0)).is_reverse ();
return lookup_type_is_reverse (type); return lookup_type_is_reverse (type);
} }
...@@ -1089,7 +1087,7 @@ struct SubstLookup : Lookup ...@@ -1089,7 +1087,7 @@ struct SubstLookup : Lookup
/* TODO: For the most common case this can move out of the main /* TODO: For the most common case this can move out of the main
* loop, but it's not a big deal for now. */ * loop, but it's not a big deal for now. */
if (unlikely (lookup_type == SubTable::Extension)) if (unlikely (lookup_type == SubstLookupSubTable::Extension))
{ {
/* The spec says all subtables should have the same type. /* The spec says all subtables should have the same type.
* This is specially important if one has a reverse type! * This is specially important if one has a reverse type!
...@@ -1157,7 +1155,7 @@ struct SubstLookup : Lookup ...@@ -1157,7 +1155,7 @@ struct SubstLookup : Lookup
inline bool sanitize (hb_sanitize_context_t *c) { inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false); if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false);
OffsetArrayOf<SubTable> &list = CastR<OffsetArrayOf<SubTable> > (subTable); OffsetArrayOf<SubstLookupSubTable> &list = CastR<OffsetArrayOf<SubstLookupSubTable> > (subTable);
return TRACE_RETURN (list.sanitize (c, this, get_type ())); return TRACE_RETURN (list.sanitize (c, this, get_type ()));
} }
}; };
...@@ -1170,8 +1168,6 @@ typedef OffsetListOf<SubstLookup> SubstLookupList; ...@@ -1170,8 +1168,6 @@ typedef OffsetListOf<SubstLookup> SubstLookupList;
struct GSUB : GSUBGPOS struct GSUB : GSUBGPOS
{ {
typedef struct SubstLookup Lookup;
static const hb_tag_t Tag = HB_OT_TAG_GSUB; static const hb_tag_t Tag = HB_OT_TAG_GSUB;
inline const SubstLookup& get_lookup (unsigned int i) const inline const SubstLookup& get_lookup (unsigned int i) const
...@@ -1242,16 +1238,16 @@ inline bool ExtensionSubst::apply (hb_apply_context_t *c) const ...@@ -1242,16 +1238,16 @@ inline bool ExtensionSubst::apply (hb_apply_context_t *c) const
inline bool ExtensionSubst::sanitize (hb_sanitize_context_t *c) inline bool ExtensionSubst::sanitize (hb_sanitize_context_t *c)
{ {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (unlikely (!Extension<GSUB>::sanitize (c))) return TRACE_RETURN (false); if (unlikely (!Extension::sanitize (c))) return TRACE_RETURN (false);
unsigned int offset = get_offset (); unsigned int offset = get_offset ();
if (unlikely (!offset)) return TRACE_RETURN (true); if (unlikely (!offset)) return TRACE_RETURN (true);
return TRACE_RETURN (StructAtOffset<GSUB::Lookup::SubTable> (this, offset).sanitize (c, get_type ())); return TRACE_RETURN (StructAtOffset<SubstLookupSubTable> (this, offset).sanitize (c, get_type ()));
} }
inline bool ExtensionSubst::is_reverse (void) const inline bool ExtensionSubst::is_reverse (void) const
{ {
unsigned int type = get_type (); unsigned int type = get_type ();
if (unlikely (type == SubstLookup::SubTable::Extension)) if (unlikely (type == SubstLookupSubTable::Extension))
return CastR<ExtensionSubst> (get_subtable()).is_reverse (); return CastR<ExtensionSubst> (get_subtable()).is_reverse ();
return SubstLookup::lookup_type_is_reverse (type); return SubstLookup::lookup_type_is_reverse (type);
} }
......
...@@ -298,27 +298,6 @@ static inline bool intersects_array (hb_closure_context_t *c, ...@@ -298,27 +298,6 @@ static inline bool intersects_array (hb_closure_context_t *c,
} }
struct match_glyph_t {
inline bool operator() (hb_codepoint_t glyph_id, const USHORT &value, const void *data)
{
return glyph_id == value;
}
};
struct match_class_t {
inline bool operator() (hb_codepoint_t glyph_id, const USHORT &value, const void *data)
{
const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
return class_def.get_class (glyph_id) == value;
}
};
struct match_coverage_t {
inline bool operator() (hb_codepoint_t glyph_id, const USHORT &value, const void *data)
{
const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value;
return (data+coverage).get_coverage (glyph_id) != NOT_COVERED;
}
};
static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const void *data HB_UNUSED) static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const void *data HB_UNUSED)
{ {
return glyph_id == value; return glyph_id == value;
...@@ -335,7 +314,6 @@ static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, ...@@ -335,7 +314,6 @@ static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value,
} }
template <typename match_func_t>
static inline bool match_input (hb_apply_context_t *c, static inline bool match_input (hb_apply_context_t *c,
unsigned int count, /* Including the first glyph (not matched) */ unsigned int count, /* Including the first glyph (not matched) */
const USHORT input[], /* Array of input values--start with second glyph */ const USHORT input[], /* Array of input values--start with second glyph */
...@@ -362,7 +340,6 @@ static inline bool match_input (hb_apply_context_t *c, ...@@ -362,7 +340,6 @@ static inline bool match_input (hb_apply_context_t *c,
return true; return true;
} }
template <typename match_func_t>
static inline bool match_backtrack (hb_apply_context_t *c, static inline bool match_backtrack (hb_apply_context_t *c,
unsigned int count, unsigned int count,
const USHORT backtrack[], const USHORT backtrack[],
...@@ -385,7 +362,6 @@ static inline bool match_backtrack (hb_apply_context_t *c, ...@@ -385,7 +362,6 @@ static inline bool match_backtrack (hb_apply_context_t *c,
return true; return true;
} }
template <typename match_func_t>
static inline bool match_lookahead (hb_apply_context_t *c, static inline bool match_lookahead (hb_apply_context_t *c,
unsigned int count, unsigned int count,
const USHORT lookahead[], const USHORT lookahead[],
...@@ -1286,12 +1262,9 @@ struct ChainContext ...@@ -1286,12 +1262,9 @@ struct ChainContext
}; };
template <typename Table> struct Extension;
template <typename Table>
struct ExtensionFormat1 struct ExtensionFormat1
{ {
friend struct Extension<Table>; friend struct Extension;
protected: protected:
inline unsigned int get_type (void) const { return extensionLookupType; } inline unsigned int get_type (void) const { return extensionLookupType; }
...@@ -1313,7 +1286,6 @@ struct ExtensionFormat1 ...@@ -1313,7 +1286,6 @@ struct ExtensionFormat1
DEFINE_SIZE_STATIC (8); DEFINE_SIZE_STATIC (8);
}; };
template <typename Table>
struct Extension struct Extension
{ {
inline unsigned int get_type (void) const inline unsigned int get_type (void) const
...@@ -1343,8 +1315,7 @@ struct Extension ...@@ -1343,8 +1315,7 @@ struct Extension
private: private:
union { union {
USHORT format; /* Format identifier */ USHORT format; /* Format identifier */
ExtensionFormat1<Table> ExtensionFormat1 format1;
format1;
} u; } u;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册