From: Behdad Esfahbod Date: Wed, 18 Feb 2015 10:18:46 +0000 (+0300) Subject: [layout] Refactor Lookup::dispatch() X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=40c58923cbf689c465f9b65334c455a9b7f71ab0;p=platform%2Fupstream%2FlibHarfBuzzSharp.git [layout] Refactor Lookup::dispatch() --- diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index 9dfac67..e1437fc 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -37,6 +37,12 @@ namespace OT { +#define TRACE_DISPATCH(this, format) \ + hb_auto_trace_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 + 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 ()); + } + inline bool serialize (hb_serialize_context_t *c, unsigned int lookup_type, uint32_t lookup_props, diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index 63302e2..a3599a9 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1524,17 +1524,7 @@ struct PosLookup : Lookup template 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 (c); } inline bool sanitize (hb_sanitize_context_t *c) const { diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index ca79f81..66ee088 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -1284,17 +1284,7 @@ struct SubstLookup : Lookup template 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 (c); } inline bool sanitize (hb_sanitize_context_t *c) const { diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index b060a69..d891b6e 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -37,12 +37,6 @@ namespace OT { - -#define TRACE_DISPATCH(this, format) \ - hb_auto_trace_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