Make Extension a template

This commit is contained in:
Behdad Esfahbod 2012-11-23 16:57:36 -05:00
parent 08f1eede1b
commit 653eeb2645
3 changed files with 9 additions and 20 deletions

View File

@ -1246,7 +1246,7 @@ struct ContextPos : Context {};
struct ChainContextPos : ChainContext {};
struct ExtensionPos : Extension
struct ExtensionPos : Extension<ExtensionPos>
{
inline const struct PosLookupSubTable& get_subtable (void) const
{
@ -1255,9 +1255,6 @@ struct ExtensionPos : Extension
return StructAtOffset<PosLookupSubTable> (this, offset);
}
template <typename context_t>
inline typename context_t::return_t process (context_t *c) const;
inline bool sanitize (hb_sanitize_context_t *c);
};
@ -1525,12 +1522,6 @@ 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 ExtensionPos::process (context_t *c) const
{
return get_subtable ().process (c, get_type ());
}
inline bool ExtensionPos::sanitize (hb_sanitize_context_t *c)
{
TRACE_SANITIZE (this);

View File

@ -878,7 +878,7 @@ struct ContextSubst : Context {};
struct ChainContextSubst : ChainContext {};
struct ExtensionSubst : Extension
struct ExtensionSubst : Extension<ExtensionSubst>
{
inline const struct SubstLookupSubTable& get_subtable (void) const
{
@ -887,9 +887,6 @@ struct ExtensionSubst : Extension
return StructAtOffset<SubstLookupSubTable> (this, offset);
}
template <typename context_t>
inline typename context_t::return_t process (context_t *c) const;
inline bool sanitize (hb_sanitize_context_t *c);
inline bool is_reverse (void) const;
@ -1380,12 +1377,6 @@ GSUB::substitute_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer HB_UNUSE
/* Out-of-class implementation for methods recursing */
template <typename context_t>
inline typename context_t::return_t ExtensionSubst::process (context_t *c) const
{
return get_subtable ().process (c, get_type ());
}
inline bool ExtensionSubst::sanitize (hb_sanitize_context_t *c)
{
TRACE_SANITIZE (this);

View File

@ -1765,6 +1765,7 @@ struct ExtensionFormat1
DEFINE_SIZE_STATIC (8);
};
template <typename T>
struct Extension
{
inline unsigned int get_type (void) const
@ -1782,6 +1783,12 @@ struct Extension
}
}
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 ());
}
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE (this);
if (!u.format.sanitize (c)) return TRACE_RETURN (false);