diff --git a/src/hb-ot-layout-open-private.h b/src/hb-ot-layout-open-private.h index b9715ed60..53a401f41 100644 --- a/src/hb-ot-layout-open-private.h +++ b/src/hb-ot-layout-open-private.h @@ -112,18 +112,12 @@ * List types */ -#define DEFINE_LIST_ARRAY(Type, name) \ - inline const Type##List& get_##name##_list (void) const { \ - if (HB_UNLIKELY (!name##List)) return Null(Type##List); \ - return *(const Type##List *)((const char*)this + name##List); \ - } - #define DEFINE_LIST_INTERFACE(Type, name) \ inline const Type& get_##name (unsigned int i) const { \ - return get_##name##_list ()[i]; \ + return (this+name##List)[i]; \ } \ inline unsigned int get_##name##_count (void) const { \ - return get_##name##_list ().get_len (); \ + return (this+name##List).len; \ } /* @@ -138,7 +132,7 @@ #define DEFINE_TAG_LIST_INTERFACE(Type, name) \ DEFINE_LIST_INTERFACE (Type, name); \ inline const Tag& get_##name##_tag (unsigned int i) const { \ - return get_##name##_list ().get_tag (i); \ + return (this+name##List).get_tag (i); \ } #define DEFINE_TAG_FIND_INTERFACE(Type, name) \ @@ -544,16 +538,45 @@ ASSERT_SIZE (OpenTypeFontFile, 4); * Script, ScriptList, LangSys, Feature, FeatureList, Lookup, LookupList */ -typedef struct Record { +template +struct Record { Tag tag; /* 4-byte Tag identifier */ - Offset offset; /* Offset from beginning of object holding + OffsetTo + offset; /* Offset from beginning of object holding * the Record */ -} ScriptRecord, LangSysRecord, FeatureRecord; -ASSERT_SIZE (Record, 6); +}; + +template +struct RecordListOf : ArrayOf > { + inline const Type& operator [] (unsigned int i) const { + if (HB_UNLIKELY (i >= this->len)) return Null(Type); + return this+this->array[i].offset; + } + inline const Tag& get_tag (unsigned int i) const { + if (HB_UNLIKELY (i >= this->len)) return Null(Tag); + return this->array[i].tag; + } +}; + + +struct Script; +typedef Record