From 0eb9fc6e37935707dba2bf4b3705de2161a08cb7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 May 2010 19:01:17 -0400 Subject: [PATCH] Change DEFINE_SIZE_VAR to DEFINE_SIZE_ARRAY --- src/hb-open-file-private.hh | 4 ++-- src/hb-open-type-private.hh | 10 +++++----- src/hb-ot-layout-common-private.hh | 27 +++++++++++++++------------ src/hb-ot-layout-gdef-private.hh | 10 +++++----- src/hb-ot-layout-gpos-private.hh | 25 ++++++++++++------------- src/hb-ot-layout-gsub-private.hh | 14 +++++++------- src/hb-ot-layout-gsubgpos-private.hh | 16 ++++++++-------- 7 files changed, 54 insertions(+), 52 deletions(-) diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh index ffe8ba7..f9fede3 100644 --- a/src/hb-open-file-private.hh +++ b/src/hb-open-file-private.hh @@ -112,7 +112,7 @@ typedef struct OffsetTable USHORT rangeShift; /* NumTables x 16-searchRange. */ TableDirectory tableDir[VAR]; /* TableDirectory entries. numTables items */ public: - DEFINE_SIZE_VAR (12, TableDirectory); + DEFINE_SIZE_ARRAY (12, tableDir); } OpenTypeFontFace; @@ -140,7 +140,7 @@ struct TTCHeaderVersion1 table; /* Array of offsets to the OffsetTable for each font * from the beginning of the file */ public: - DEFINE_SIZE_VAR (12, LongOffset); + DEFINE_SIZE_ARRAY (12, table); }; struct TTCHeader diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 5194771..17a037b 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -103,11 +103,11 @@ inline Type& StructAfter(TObject &X) _DEFINE_SIZE_ASSERTION (sizeof (*this) >= (size)); \ static const unsigned int min_size = (size) -#define DEFINE_SIZE_VAR(size, _var_type) \ - _DEFINE_SIZE_ASSERTION (sizeof (*this) == (size) + VAR0 * sizeof (_var_type)); \ +#define DEFINE_SIZE_ARRAY(size, array) \ + _DEFINE_SIZE_ASSERTION (sizeof (*this) == (size) + array[0].static_size); \ static const unsigned int min_size = (size) -#define DEFINE_SIZE_VAR2(size, array1, array2) \ +#define DEFINE_SIZE_ARRAY2(size, array1, array2) \ _DEFINE_SIZE_ASSERTION (sizeof (*this) == (size) + this->array1[0].static_size + this->array2[0].static_size); \ static const unsigned int min_size = (size) @@ -586,7 +586,7 @@ struct GenericArrayOf LenType len; Type array[VAR]; public: - DEFINE_SIZE_VAR (sizeof (LenType), Type); + DEFINE_SIZE_ARRAY (sizeof (LenType), array); }; /* An array with a USHORT number of elements. */ @@ -671,7 +671,7 @@ struct HeadlessArrayOf USHORT len; Type array[VAR]; public: - DEFINE_SIZE_VAR (sizeof (USHORT), Type); + DEFINE_SIZE_ARRAY (sizeof (USHORT), array); }; diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index d0ab1d1..7fadc2d 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -119,10 +119,13 @@ struct RecordListOf : RecordArrayOf struct IndexArray : ArrayOf { - inline unsigned int operator [] (unsigned int i) const + inline USHORT operator [] (unsigned int i) const { - if (unlikely (i >= this->len)) - return NO_INDEX; + if (unlikely (i >= this->len)) { + USHORT u; + u.set (NO_INDEX); + return u; + } return this->array[i]; } inline unsigned int get_indexes (unsigned int start_offset, @@ -177,7 +180,7 @@ struct LangSys * = 0xFFFF */ IndexArray featureIndex; /* Array of indices into the FeatureList */ public: - DEFINE_SIZE_VAR (6, USHORT); + DEFINE_SIZE_ARRAY (6, featureIndex); }; DEFINE_NULL_DATA (LangSys, "\0\0\xFF\xFF"); @@ -217,7 +220,7 @@ struct Script langSys; /* Array of LangSysRecords--listed * alphabetically by LangSysTag */ public: - DEFINE_SIZE_VAR (4, Record); + DEFINE_SIZE_ARRAY (4, langSys); }; typedef RecordListOf