Remove ASSERT_SIZE in favor of the safer DEFINE_SIZE_STATIC
diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index 53e947a..d8d70e5 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -139,8 +139,9 @@
LongOffsetLongArrayOf<OffsetTable>
table; /* Array of offsets to the OffsetTable for each font
* from the beginning of the file */
+ public:
+ DEFINE_SIZE_STATIC (12);
};
-ASSERT_SIZE (TTCHeaderVersion1, 12);
struct TTCHeader
{
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index aab85fd..56a8bae 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -96,6 +96,15 @@
static const unsigned int static_size = (size); \
static const unsigned int min_size = (size)
+/* Size signifying variable-sized array */
+#define VAR 1
+#define VAR0 (VAR+0)
+
+#define DEFINE_SIZE_VAR0(size) \
+ inline void _size_assertion (void) const \
+ { ASSERT_STATIC (sizeof (*this) == (size)); } \
+ static const unsigned int min_size = (size)
+
#define DEFINE_SIZE_VAR(size, _var_type) \
inline void _size_assertion (void) const \
{ ASSERT_STATIC (sizeof (*this) == (size) + VAR0 * sizeof (_var_type)); } \
@@ -397,8 +406,9 @@
/* What the char* converters return is NOT nul-terminated. Print using "%.4s" */
inline operator const char* (void) const { return CharP(this); }
inline operator char* (void) { return CharP(this); }
+ public:
+ DEFINE_SIZE_STATIC (4);
};
-ASSERT_SIZE (Tag, 4);
DEFINE_NULL_DATA (Tag, " ");
/* Glyph index number, same as uint16 (length = 16 bits) */
@@ -423,8 +433,9 @@
Sum += *Table++;
return Sum;
}
+ public:
+ DEFINE_SIZE_STATIC (4);
};
-ASSERT_SIZE (CheckSum, 4);
/*
@@ -442,8 +453,9 @@
USHORT major;
USHORT minor;
+ public:
+ DEFINE_SIZE_STATIC (4);
};
-ASSERT_SIZE (FixedVersion, 4);
@@ -577,6 +589,8 @@
public:
LenType len;
/*Type array[VAR];*/
+ public:
+ DEFINE_SIZE_VAR0 (sizeof (LenType));
};
/* An array with a USHORT number of elements. */
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 7215415..dc1229f 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -216,11 +216,11 @@
RecordArrayOf<LangSys>
langSys; /* Array of LangSysRecords--listed
* alphabetically by LangSysTag */
+ public:
+ DEFINE_SIZE_STATIC (4);
};
-ASSERT_SIZE (Script, 4);
typedef RecordListOf<Script> ScriptList;
-ASSERT_SIZE (ScriptList, 2);
struct Feature
@@ -247,11 +247,11 @@
* to the beginning of the Feature Table; = Null
* if not required */
IndexArray lookupIndex; /* Array of LookupList indices */
+ public:
+ DEFINE_SIZE_STATIC (4);
};
-ASSERT_SIZE (Feature, 4);
typedef RecordListOf<Feature> FeatureList;
-ASSERT_SIZE (FeatureList, 2);
struct LookupFlag : USHORT
@@ -266,8 +266,9 @@
Reserved = 0x00E0u,
MarkAttachmentType = 0xFF00u
};
+ public:
+ DEFINE_SIZE_STATIC (2);
};
-ASSERT_SIZE (LookupFlag, 2);
struct Lookup
{
@@ -310,7 +311,6 @@
};
typedef OffsetListOf<Lookup> LookupList;
-ASSERT_SIZE (LookupList, 2);
/*
@@ -345,8 +345,9 @@
USHORT coverageFormat; /* Format identifier--format = 1 */
ArrayOf<GlyphID>
glyphArray; /* Array of GlyphIDs--in numerical order */
+ public:
+ DEFINE_SIZE_STATIC (4);
};
-ASSERT_SIZE (CoverageFormat1, 4);
struct CoverageRangeRecord
{
@@ -405,8 +406,9 @@
rangeRecord; /* Array of glyph ranges--ordered by
* Start GlyphID. rangeCount entries
* long */
+ public:
+ DEFINE_SIZE_STATIC (4);
};
-ASSERT_SIZE (CoverageFormat2, 4);
struct Coverage
{
@@ -466,8 +468,9 @@
GlyphID startGlyph; /* First GlyphID of the classValueArray */
ArrayOf<USHORT>
classValue; /* Array of Class Values--one per GlyphID */
+ public:
+ DEFINE_SIZE_STATIC (6);
};
-ASSERT_SIZE (ClassDefFormat1, 6);
struct ClassRangeRecord
{
@@ -523,8 +526,9 @@
ArrayOf<ClassRangeRecord>
rangeRecord; /* Array of glyph ranges--ordered by
* Start GlyphID */
+ public:
+ DEFINE_SIZE_STATIC (4);
};
-ASSERT_SIZE (ClassDefFormat2, 4);
struct ClassDef
{
diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh
index e6cf7b8..4e06673 100644
--- a/src/hb-ot-layout-gdef-private.hh
+++ b/src/hb-ot-layout-gdef-private.hh
@@ -38,7 +38,6 @@
typedef ArrayOf<USHORT> AttachPoint; /* Array of contour point indices--in
* increasing numerical order */
-ASSERT_SIZE (AttachPoint, 2);
struct AttachList
{
@@ -80,8 +79,9 @@
OffsetArrayOf<AttachPoint>
attachPoint; /* Array of AttachPoint tables
* in Coverage Index order */
+ public:
+ DEFINE_SIZE_STATIC (4);
};
-ASSERT_SIZE (AttachList, 4);
/*
* Ligature Caret Table
@@ -106,8 +106,9 @@
private:
USHORT caretValueFormat; /* Format identifier--format = 1 */
SHORT coordinate; /* X or Y value, in design units */
+ public:
+ DEFINE_SIZE_STATIC (4);
};
-ASSERT_SIZE (CaretValueFormat1, 4);
struct CaretValueFormat2
{
@@ -132,8 +133,9 @@
private:
USHORT caretValueFormat; /* Format identifier--format = 2 */
USHORT caretValuePoint; /* Contour point index on glyph */
+ public:
+ DEFINE_SIZE_STATIC (4);
};
-ASSERT_SIZE (CaretValueFormat2, 4);
struct CaretValueFormat3
{
@@ -159,8 +161,9 @@
deviceTable; /* Offset to Device table for X or Y
* value--from beginning of CaretValue
* table */
+ public:
+ DEFINE_SIZE_STATIC (6);
};
-ASSERT_SIZE (CaretValueFormat3, 6);
struct CaretValue
{
@@ -222,8 +225,9 @@
carets; /* Offset array of CaretValue tables
* --from beginning of LigGlyph table
* --in increasing coordinate order */
+ public:
+ DEFINE_SIZE_STATIC (2);
};
-ASSERT_SIZE (LigGlyph, 2);
struct LigCaretList
{
@@ -257,8 +261,9 @@
OffsetArrayOf<LigGlyph>
ligGlyph; /* Array of LigGlyph tables
* in Coverage Index order */
+ public:
+ DEFINE_SIZE_STATIC (4);
};
-ASSERT_SIZE (LigCaretList, 4);
struct MarkGlyphSetsFormat1
@@ -276,8 +281,9 @@
LongOffsetArrayOf<Coverage>
coverage; /* Array of long offsets to mark set
* coverage tables */
+ public:
+ DEFINE_SIZE_STATIC (4);
};
-ASSERT_SIZE (MarkGlyphSetsFormat1, 4);
struct MarkGlyphSets
{
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index eb53ac1..65e26eb 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -202,7 +202,6 @@
return true;
}
};
-ASSERT_SIZE (ValueFormat, 2);
struct AnchorFormat1
@@ -226,8 +225,9 @@
USHORT format; /* Format identifier--format = 1 */
SHORT xCoordinate; /* Horizontal value--in design units */
SHORT yCoordinate; /* Vertical value--in design units */
+ public:
+ DEFINE_SIZE_STATIC (6);
};
-ASSERT_SIZE (AnchorFormat1, 6);
struct AnchorFormat2
{
@@ -258,8 +258,9 @@
SHORT xCoordinate; /* Horizontal value--in design units */
SHORT yCoordinate; /* Vertical value--in design units */
USHORT anchorPoint; /* Index to glyph contour point */
+ public:
+ DEFINE_SIZE_STATIC (8);
};
-ASSERT_SIZE (AnchorFormat2, 8);
struct AnchorFormat3
{
@@ -298,8 +299,9 @@
yDeviceTable; /* Offset to Device table for Y
* coordinate-- from beginning of
* Anchor table (may be NULL) */
+ public:
+ DEFINE_SIZE_STATIC (10);
};
-ASSERT_SIZE (AnchorFormat3, 10);
struct Anchor
{
@@ -421,8 +423,9 @@
private:
ArrayOf<MarkRecord>
markRecord; /* Array of MarkRecords--in Coverage order */
+ public:
+ DEFINE_SIZE_STATIC (2);
};
-ASSERT_SIZE (MarkArray, 2);
/* Lookups */
@@ -669,8 +672,9 @@
OffsetArrayOf<PairSet>
pairSet; /* Array of PairSet tables
* ordered by Coverage Index */
+ public:
+ DEFINE_SIZE_STATIC (10);
};
-ASSERT_SIZE (PairPosFormat1, 10);
struct PairPosFormat2
{
@@ -1014,8 +1018,9 @@
ArrayOf<EntryExitRecord>
entryExitRecord; /* Array of EntryExit records--in
* Coverage Index order */
+ public:
+ DEFINE_SIZE_STATIC (6);
};
-ASSERT_SIZE (CursivePosFormat1, 6);
struct CursivePos
{
@@ -1075,11 +1080,9 @@
j--;
} while (_hb_ot_layout_skip_mark (context->layout->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property));
-#if 0
- /* The following assertion is too strong. */
- if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH))
+ /* The following assertion is too strong, so we've disabled it. */
+ if (false && !(property & HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH))
return false;
-#endif
unsigned int base_index = (this+baseCoverage) (IN_GLYPH (j));
if (base_index == NOT_COVERED)
@@ -1112,8 +1115,9 @@
OffsetTo<BaseArray>
baseArray; /* Offset to BaseArray table--from
* beginning of MarkBasePos subtable */
+ public:
+ DEFINE_SIZE_STATIC (12);
};
-ASSERT_SIZE (MarkBasePosFormat1, 12);
struct MarkBasePos
{
@@ -1178,11 +1182,9 @@
j--;
} while (_hb_ot_layout_skip_mark (context->layout->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property));
-#if 0
- /* The following assertion is too strong. */
- if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE))
+ /* The following assertion is too strong, so we've disabled it. */
+ if (false && !(property & HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE))
return false;
-#endif
unsigned int lig_index = (this+ligatureCoverage) (IN_GLYPH (j));
if (lig_index == NOT_COVERED)
@@ -1237,8 +1239,9 @@
OffsetTo<LigatureArray>
ligatureArray; /* Offset to LigatureArray table--from
* beginning of MarkLigPos subtable */
+ public:
+ DEFINE_SIZE_STATIC (12);
};
-ASSERT_SIZE (MarkLigPosFormat1, 12);
struct MarkLigPos
{
@@ -1341,8 +1344,9 @@
OffsetTo<Mark2Array>
mark2Array; /* Offset to Mark2Array table--from
* beginning of MarkMarkPos subtable */
+ public:
+ DEFINE_SIZE_STATIC (12);
};
-ASSERT_SIZE (MarkMarkPosFormat1, 12);
struct MarkMarkPos
{
@@ -1567,7 +1571,6 @@
};
typedef OffsetListOf<PosLookup> PosLookupList;
-ASSERT_SIZE (PosLookupList, 2);
/*
* GPOS
@@ -1592,8 +1595,9 @@
OffsetTo<PosLookupList> &list = CastR<OffsetTo<PosLookupList> > (lookupList);
return list.sanitize (context, this);
}
+ public:
+ DEFINE_SIZE_STATIC (10);
};
-ASSERT_SIZE (GPOS, 10);
/* Out-of-class implementation for methods recursing */
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index 5585409..4a464b6 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -71,8 +71,9 @@
* beginning of Substitution table */
SHORT deltaGlyphID; /* Add to original GlyphID to get
* substitute GlyphID */
+ public:
+ DEFINE_SIZE_STATIC (6);
};
-ASSERT_SIZE (SingleSubstFormat1, 6);
struct SingleSubstFormat2
{
@@ -115,8 +116,9 @@
ArrayOf<GlyphID>
substitute; /* Array of substitute
* GlyphIDs--ordered by Coverage Index */
+ public:
+ DEFINE_SIZE_STATIC (6);
};
-ASSERT_SIZE (SingleSubstFormat2, 6);
struct SingleSubst
{
@@ -192,8 +194,9 @@
private:
ArrayOf<GlyphID>
substitute; /* String of GlyphIDs to substitute */
+ public:
+ DEFINE_SIZE_STATIC (2);
};
-ASSERT_SIZE (Sequence, 2);
struct MultipleSubstFormat1
{
@@ -226,8 +229,9 @@
OffsetArrayOf<Sequence>
sequence; /* Array of Sequence tables
* ordered by Coverage Index */
+ public:
+ DEFINE_SIZE_STATIC (6);
};
-ASSERT_SIZE (MultipleSubstFormat1, 6);
struct MultipleSubst
{
@@ -263,7 +267,6 @@
typedef ArrayOf<GlyphID> AlternateSet; /* Array of alternate GlyphIDs--in
* arbitrary order */
-ASSERT_SIZE (AlternateSet, 2);
struct AlternateSubstFormat1
{
@@ -322,8 +325,9 @@
OffsetArrayOf<AlternateSet>
alternateSet; /* Array of AlternateSet tables
* ordered by Coverage Index */
+ public:
+ DEFINE_SIZE_STATIC (6);
};
-ASSERT_SIZE (AlternateSubstFormat1, 6);
struct AlternateSubst
{
@@ -438,8 +442,9 @@
component; /* Array of component GlyphIDs--start
* with the second component--ordered
* in writing direction */
+ public:
+ DEFINE_SIZE_STATIC (4);
};
-ASSERT_SIZE (Ligature, 4);
struct LigatureSet
{
@@ -470,8 +475,9 @@
OffsetArrayOf<Ligature>
ligature; /* Array LigatureSet tables
* ordered by preference */
+ public:
+ DEFINE_SIZE_STATIC (2);
};
-ASSERT_SIZE (LigatureSet, 2);
struct LigatureSubstFormat1
{
@@ -507,8 +513,9 @@
OffsetArrayOf<LigatureSet>
ligatureSet; /* Array LigatureSet tables
* ordered by Coverage Index */
+ public:
+ DEFINE_SIZE_STATIC (6);
};
-ASSERT_SIZE (LigatureSubstFormat1, 6);
struct LigatureSubst
{
@@ -652,8 +659,9 @@
ArrayOf<GlyphID>
substituteX; /* Array of substitute
* GlyphIDs--ordered by Coverage Index */
+ public:
+ DEFINE_SIZE_STATIC (10);
};
-ASSERT_SIZE (ReverseChainSingleSubstFormat1, 10);
struct ReverseChainSingleSubst
{
@@ -865,7 +873,6 @@
};
typedef OffsetListOf<SubstLookup> SubstLookupList;
-ASSERT_SIZE (SubstLookupList, 2);
/*
* GSUB
@@ -890,8 +897,9 @@
OffsetTo<SubstLookupList> &list = CastR<OffsetTo<SubstLookupList> > (lookupList);
return list.sanitize (context, this);
}
+ public:
+ DEFINE_SIZE_STATIC (10);
};
-ASSERT_SIZE (GSUB, 10);
/* Out-of-class implementation for methods recursing */
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 0b59748..86285d1 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -367,8 +367,9 @@
OffsetArrayOf<RuleSet>
ruleSet; /* Array of RuleSet tables
* ordered by Coverage Index */
+ public:
+ DEFINE_SIZE_STATIC (6);
};
-ASSERT_SIZE (ContextFormat1, 6);
struct ContextFormat2
@@ -414,8 +415,9 @@
OffsetArrayOf<RuleSet>
ruleSet; /* Array of RuleSet tables
* ordered by class */
+ public:
+ DEFINE_SIZE_STATIC (8);
};
-ASSERT_SIZE (ContextFormat2, 8);
struct ContextFormat3
@@ -590,8 +592,9 @@
ArrayOf<LookupRecord>
lookupX; /* Array of LookupRecords--in
* design order) */
+ public:
+ DEFINE_SIZE_STATIC (8);
};
-ASSERT_SIZE (ChainRule, 8);
struct ChainRuleSet
{
@@ -617,8 +620,9 @@
OffsetArrayOf<ChainRule>
rule; /* Array of ChainRule tables
* ordered by preference */
+ public:
+ DEFINE_SIZE_STATIC (2);
};
-ASSERT_SIZE (ChainRuleSet, 2);
struct ChainContextFormat1
{
@@ -654,8 +658,9 @@
OffsetArrayOf<ChainRuleSet>
ruleSet; /* Array of ChainRuleSet tables
* ordered by Coverage Index */
+ public:
+ DEFINE_SIZE_STATIC (6);
};
-ASSERT_SIZE (ChainContextFormat1, 6);
struct ChainContextFormat2
{
@@ -716,8 +721,9 @@
OffsetArrayOf<ChainRuleSet>
ruleSet; /* Array of ChainRuleSet tables
* ordered by class */
+ public:
+ DEFINE_SIZE_STATIC (12);
};
-ASSERT_SIZE (ChainContextFormat2, 12);
struct ChainContextFormat3
{
@@ -777,8 +783,9 @@
ArrayOf<LookupRecord>
lookupX; /* Array of LookupRecords--in
* design order) */
+ public:
+ DEFINE_SIZE_STATIC (10);
};
-ASSERT_SIZE (ChainContextFormat3, 10);
struct ChainContext
{
@@ -835,8 +842,9 @@
* extension subtable). */
ULONG extensionOffset; /* Offset to the extension subtable,
* of lookup type subtable. */
+ public:
+ DEFINE_SIZE_STATIC (8);
};
-ASSERT_SIZE (ExtensionFormat1, 8);
struct Extension
{
@@ -929,8 +937,9 @@
featureList; /* FeatureList table */
OffsetTo<LookupList>
lookupList; /* LookupList table */
+ public:
+ DEFINE_SIZE_STATIC (10);
};
-ASSERT_SIZE (GSUBGPOS, 10);
#endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */
diff --git a/src/hb-private.h b/src/hb-private.h
index 3f8515b..8a323de 100644
--- a/src/hb-private.h
+++ b/src/hb-private.h
@@ -83,8 +83,6 @@
/* Misc */
-#define ASSERT_SIZE(_type, _size) ASSERT_STATIC (sizeof (_type) == (_size))
-
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
#define _HB_BOOLEAN_EXPR(expr) \