Cleanup DEFINE_SIZE_VAR2
authorBehdad Esfahbod <behdad@behdad.org>
Mon, 10 May 2010 22:47:48 +0000 (18:47 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Mon, 10 May 2010 22:48:29 +0000 (18:48 -0400)
src/hb-open-type-private.hh
src/hb-ot-layout-common-private.hh
src/hb-ot-layout-gdef-private.hh
src/hb-ot-layout-gpos-private.hh
src/hb-ot-layout-gsub-private.hh
src/hb-ot-layout-gsubgpos-private.hh

index 311f74b..5194771 100644 (file)
@@ -81,13 +81,13 @@ inline Type& StructAfter(TObject &X)
  * 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 @@ inline Type& StructAfter(TObject &X)
 #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)
 
 
index 6542e5f..d0ab1d1 100644 (file)
@@ -307,7 +307,7 @@ struct Lookup
                                         * 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 @@ struct Coverage
   CoverageFormat2      format2[VAR];
   } u;
   public:
-  DEFINE_SIZE_MIN (2);
+  DEFINE_SIZE_UNION (2, format);
 };
 
 
@@ -562,7 +562,7 @@ struct ClassDef
   ClassDefFormat2      format2[VAR];
   } u;
   public:
-  DEFINE_SIZE_MIN (2);
+  DEFINE_SIZE_UNION (2, format);
 };
 
 
index 456efca..85782b0 100644 (file)
@@ -196,7 +196,7 @@ struct CaretValue
   CaretValueFormat3    format3[VAR];
   } u;
   public:
-  DEFINE_SIZE_MIN (2);
+  DEFINE_SIZE_UNION (2, format);
 };
 
 struct LigGlyph
@@ -312,7 +312,7 @@ struct MarkGlyphSets
   MarkGlyphSetsFormat1 format1[VAR];
   } u;
   public:
-  DEFINE_SIZE_MIN (2);
+  DEFINE_SIZE_UNION (2, format);
 };
 
 
index a84210a..5a29c0a 100644 (file)
@@ -336,7 +336,7 @@ struct Anchor
   AnchorFormat3                format3[VAR];
   } u;
   public:
-  DEFINE_SIZE_MIN (2);
+  DEFINE_SIZE_UNION (2, format);
 };
 
 
@@ -1490,7 +1490,7 @@ struct PosLookupSubTable
   ExtensionPos         extension[VAR];
   } u;
   public:
-  DEFINE_SIZE_MIN (2);
+  DEFINE_SIZE_UNION (2, format);
 };
 
 
index 707ee61..25e2b3a 100644 (file)
@@ -759,7 +759,7 @@ struct SubstLookupSubTable
   ReverseChainSingleSubst      reverseChainContextSingle[VAR];
   } u;
   public:
-  DEFINE_SIZE_MIN (2);
+  DEFINE_SIZE_UNION (2, format);
 };
 
 
index b3af2de..0814e21 100644 (file)
@@ -303,7 +303,7 @@ struct Rule
   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 @@ struct ContextFormat3
   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