[OTLayout] More templatizing Extension

This commit is contained in:
Behdad Esfahbod 2012-11-23 17:04:55 -05:00
parent 653eeb2645
commit 7dddd4e72b
3 changed files with 12 additions and 14 deletions

View File

@ -1248,12 +1248,7 @@ struct ChainContextPos : ChainContext {};
struct ExtensionPos : Extension<ExtensionPos>
{
inline const struct PosLookupSubTable& get_subtable (void) const
{
unsigned int offset = get_offset ();
if (unlikely (!offset)) return Null(PosLookupSubTable);
return StructAtOffset<PosLookupSubTable> (this, offset);
}
typedef struct PosLookupSubTable LookupSubTable;
inline bool sanitize (hb_sanitize_context_t *c);
};

View File

@ -880,12 +880,7 @@ struct ChainContextSubst : ChainContext {};
struct ExtensionSubst : Extension<ExtensionSubst>
{
inline const struct SubstLookupSubTable& get_subtable (void) const
{
unsigned int offset = get_offset ();
if (unlikely (!offset)) return Null(SubstLookupSubTable);
return StructAtOffset<SubstLookupSubTable> (this, offset);
}
typedef struct SubstLookupSubTable LookupSubTable;
inline bool sanitize (hb_sanitize_context_t *c);
@ -1390,7 +1385,7 @@ inline bool ExtensionSubst::is_reverse (void) const
{
unsigned int type = get_type ();
if (unlikely (type == SubstLookupSubTable::Extension))
return CastR<ExtensionSubst> (get_subtable()).is_reverse ();
return CastR<ExtensionSubst> (get_subtable<SubstLookupSubTable>()).is_reverse ();
return SubstLookup::lookup_type_is_reverse (type);
}

View File

@ -1783,10 +1783,18 @@ 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 CastP<T>(this)->get_subtable ().process (c, get_type ());
return CastP<T>(this)->get_subtable<typename T::LookupSubTable> ().process (c, get_type ());
}
inline bool sanitize (hb_sanitize_context_t *c) {