From 7dddd4e72bc35be962d93dc1b76c7e26c63aaa6d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 23 Nov 2012 17:04:55 -0500 Subject: [PATCH] [OTLayout] More templatizing Extension --- src/hb-ot-layout-gpos-table.hh | 7 +------ src/hb-ot-layout-gsub-table.hh | 9 ++------- src/hb-ot-layout-gsubgpos-private.hh | 10 +++++++++- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index 38cf967ae..1a75880f0 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1248,12 +1248,7 @@ struct ChainContextPos : ChainContext {}; struct ExtensionPos : Extension { - inline const struct PosLookupSubTable& get_subtable (void) const - { - unsigned int offset = get_offset (); - if (unlikely (!offset)) return Null(PosLookupSubTable); - return StructAtOffset (this, offset); - } + typedef struct PosLookupSubTable LookupSubTable; inline bool sanitize (hb_sanitize_context_t *c); }; diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index 7cf1e1b41..997187504 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -880,12 +880,7 @@ struct ChainContextSubst : ChainContext {}; struct ExtensionSubst : Extension { - inline const struct SubstLookupSubTable& get_subtable (void) const - { - unsigned int offset = get_offset (); - if (unlikely (!offset)) return Null(SubstLookupSubTable); - return StructAtOffset (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 (get_subtable()).is_reverse (); + return CastR (get_subtable()).is_reverse (); return SubstLookup::lookup_type_is_reverse (type); } diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index 300ba7c13..4ff894031 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -1783,10 +1783,18 @@ struct Extension } } + template + inline const X& get_subtable (void) const + { + unsigned int offset = get_offset (); + if (unlikely (!offset)) return Null(typename T::LookupSubTable); + return StructAtOffset (this, offset); + } + template inline typename context_t::return_t process (context_t *c) const { - return CastP(this)->get_subtable ().process (c, get_type ()); + return CastP(this)->get_subtable ().process (c, get_type ()); } inline bool sanitize (hb_sanitize_context_t *c) {