Cleanup DEFINE_SIZE_VAR2
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 311f74b..5194771 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh
@@ -81,13 +81,13 @@ * Size checking */ -#define _DEFINE_SIZE_ASSERTION(_compare) \ +#define _DEFINE_SIZE_ASSERTION(_assertion) \ inline void _size_assertion (void) const \ - { ASSERT_STATIC ((sizeof (*this)) _compare); } + { ASSERT_STATIC (_assertion); } #define DEFINE_SIZE_STATIC(size) \ - _DEFINE_SIZE_ASSERTION (== (size)); \ + _DEFINE_SIZE_ASSERTION (sizeof (*this) == (size)); \ static const unsigned int static_size = (size); \ static const unsigned int min_size = (size) @@ -95,16 +95,20 @@ #define VAR 1 #define VAR0 (VAR+0) +#define DEFINE_SIZE_UNION(size, _member) \ + _DEFINE_SIZE_ASSERTION (this->u._member.static_size == (size)); \ + static const unsigned int min_size = (size) + #define DEFINE_SIZE_MIN(size) \ - _DEFINE_SIZE_ASSERTION (>= (size)); \ + _DEFINE_SIZE_ASSERTION (sizeof (*this) >= (size)); \ static const unsigned int min_size = (size) #define DEFINE_SIZE_VAR(size, _var_type) \ - _DEFINE_SIZE_ASSERTION (== (size) + VAR0 * sizeof (_var_type)); \ + _DEFINE_SIZE_ASSERTION (sizeof (*this) == (size) + VAR0 * sizeof (_var_type)); \ static const unsigned int min_size = (size) -#define DEFINE_SIZE_VAR2(size, _var_type1, _var_type2) \ - _DEFINE_SIZE_ASSERTION (== (size) + VAR0 * sizeof (_var_type1) + VAR0 * sizeof (_var_type2)); \ +#define DEFINE_SIZE_VAR2(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)
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index 6542e5f..d0ab1d1 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh
@@ -307,7 +307,7 @@ * structure. This field is only present if bit * UseMarkFilteringSet of lookup flags is set. */ public: - DEFINE_SIZE_VAR2 (6, Offset, USHORT); + DEFINE_SIZE_VAR2 (6, subTable, markFilteringSetX); }; typedef OffsetListOf<Lookup> LookupList; @@ -440,7 +440,7 @@ CoverageFormat2 format2[VAR]; } u; public: - DEFINE_SIZE_MIN (2); + DEFINE_SIZE_UNION (2, format); }; @@ -562,7 +562,7 @@ ClassDefFormat2 format2[VAR]; } u; public: - DEFINE_SIZE_MIN (2); + DEFINE_SIZE_UNION (2, format); };
diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh index 456efca..85782b0 100644 --- a/src/hb-ot-layout-gdef-private.hh +++ b/src/hb-ot-layout-gdef-private.hh
@@ -196,7 +196,7 @@ CaretValueFormat3 format3[VAR]; } u; public: - DEFINE_SIZE_MIN (2); + DEFINE_SIZE_UNION (2, format); }; struct LigGlyph @@ -312,7 +312,7 @@ MarkGlyphSetsFormat1 format1[VAR]; } u; public: - DEFINE_SIZE_MIN (2); + DEFINE_SIZE_UNION (2, format); };
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh index a84210a..5a29c0a 100644 --- a/src/hb-ot-layout-gpos-private.hh +++ b/src/hb-ot-layout-gpos-private.hh
@@ -336,7 +336,7 @@ AnchorFormat3 format3[VAR]; } u; public: - DEFINE_SIZE_MIN (2); + DEFINE_SIZE_UNION (2, format); }; @@ -1490,7 +1490,7 @@ ExtensionPos extension[VAR]; } u; public: - DEFINE_SIZE_MIN (2); + DEFINE_SIZE_UNION (2, format); };
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh index 707ee61..25e2b3a 100644 --- a/src/hb-ot-layout-gsub-private.hh +++ b/src/hb-ot-layout-gsub-private.hh
@@ -759,7 +759,7 @@ ReverseChainSingleSubst reverseChainContextSingle[VAR]; } u; public: - DEFINE_SIZE_MIN (2); + DEFINE_SIZE_UNION (2, format); };
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index b3af2de..0814e21 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -303,7 +303,7 @@ LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in * design order */ public: - DEFINE_SIZE_VAR2 (4, USHORT, LookupRecord); + DEFINE_SIZE_VAR2 (4, input, lookupRecordX); }; struct RuleSet @@ -467,7 +467,7 @@ LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in * design order */ public: - DEFINE_SIZE_VAR2 (6, OffsetTo<Coverage>, LookupRecord); + DEFINE_SIZE_VAR2 (6, coverage, lookupRecordX); }; struct Context