[layout] Refactor Lookup::dispatch()

This commit is contained in:
Behdad Esfahbod 2015-02-18 13:18:46 +03:00
parent 70366f5d19
commit 40c58923cb
4 changed files with 22 additions and 28 deletions

View File

@ -37,6 +37,12 @@
namespace OT {
#define TRACE_DISPATCH(this, format) \
hb_auto_trace_t<context_t::max_debug_depth, typename context_t::return_t> trace \
(&c->debug_depth, c->get_name (), this, HB_FUNC, \
"format %d", (int) format);
#define NOT_COVERED ((unsigned int) -1)
#define MAX_NESTING_LEVEL 8
#define MAX_CONTEXT_LENGTH 64
@ -598,6 +604,20 @@ struct Lookup
return flag;
}
template <typename SubTableType, typename context_t>
inline typename context_t::return_t dispatch (context_t *c) const
{
unsigned int lookup_type = get_type ();
TRACE_DISPATCH (this, lookup_type);
unsigned int count = get_subtable_count ();
for (unsigned int i = 0; i < count; i++) {
typename context_t::return_t r = get_subtable<SubTableType> (i).dispatch (c, lookup_type);
if (c->stop_sublookup_iteration (r))
return TRACE_RETURN (r);
}
return TRACE_RETURN (c->default_return_value ());
}
inline bool serialize (hb_serialize_context_t *c,
unsigned int lookup_type,
uint32_t lookup_props,

View File

@ -1524,17 +1524,7 @@ struct PosLookup : Lookup
template <typename context_t>
inline typename context_t::return_t dispatch (context_t *c) const
{
unsigned int lookup_type = get_type ();
TRACE_DISPATCH (this, lookup_type);
unsigned int count = get_subtable_count ();
for (unsigned int i = 0; i < count; i++) {
typename context_t::return_t r = get_subtable (i).dispatch (c, lookup_type);
if (c->stop_sublookup_iteration (r))
return TRACE_RETURN (r);
}
return TRACE_RETURN (c->default_return_value ());
}
{ return Lookup::dispatch<PosLookupSubTable> (c); }
inline bool sanitize (hb_sanitize_context_t *c) const
{

View File

@ -1284,17 +1284,7 @@ struct SubstLookup : Lookup
template <typename context_t>
inline typename context_t::return_t dispatch (context_t *c) const
{
unsigned int lookup_type = get_type ();
TRACE_DISPATCH (this, lookup_type);
unsigned int count = get_subtable_count ();
for (unsigned int i = 0; i < count; i++) {
typename context_t::return_t r = get_subtable (i).dispatch (c, lookup_type);
if (c->stop_sublookup_iteration (r))
return TRACE_RETURN (r);
}
return TRACE_RETURN (c->default_return_value ());
}
{ return Lookup::dispatch<SubstLookupSubTable> (c); }
inline bool sanitize (hb_sanitize_context_t *c) const
{

View File

@ -37,12 +37,6 @@
namespace OT {
#define TRACE_DISPATCH(this, format) \
hb_auto_trace_t<context_t::max_debug_depth, typename context_t::return_t> trace \
(&c->debug_depth, c->get_name (), this, HB_FUNC, \
"format %d", (int) format);
#ifndef HB_DEBUG_CLOSURE
#define HB_DEBUG_CLOSURE (HB_DEBUG+0)
#endif