Further cleanup of DEFINE_SIZE

This commit is contained in:
Behdad Esfahbod 2010-05-10 17:28:16 -04:00
parent 0abcc3b48c
commit bea34c7cbb
7 changed files with 37 additions and 43 deletions

View File

@ -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_STATIC (12);
DEFINE_SIZE_VAR (12, LongOffset);
};
struct TTCHeader

View File

@ -105,8 +105,7 @@ inline Type& StructAfter(TObject &X)
#define VAR 1
#define VAR0 (VAR+0)
#define DEFINE_SIZE_VAR0(size) \
_DEFINE_SIZE_ASSERTION (size); \
#define DEFINE_SIZE_MIN(size) \
static const unsigned int min_size = (size)
#define DEFINE_SIZE_VAR(size, _var_type) \
@ -140,7 +139,7 @@ template <> \
inline const Type& Null<Type> () { \
return *CastP<Type> (_Null##Type); \
} /* The following line really exists such that we end in a place needing semicolon */ \
ASSERT_STATIC (sizeof (Type) + 1 <= sizeof (_Null##Type))
ASSERT_STATIC (Type::min_size + 1 <= sizeof (_Null##Type))
/* Accessor macro. */
#define Null(Type) Null<Type>()
@ -590,9 +589,10 @@ struct GenericArrayOf
public:
LenType len;
/*Type array[VAR];*/
private:
Type arrayX[VAR];
public:
DEFINE_SIZE_VAR0 (sizeof (LenType));
DEFINE_SIZE_VAR (sizeof (LenType), Type);
};
/* An array with a USHORT number of elements. */

View File

@ -177,7 +177,7 @@ struct LangSys
* = 0xFFFF */
IndexArray featureIndex; /* Array of indices into the FeatureList */
public:
DEFINE_SIZE_STATIC (6);
DEFINE_SIZE_VAR (6, USHORT);
};
DEFINE_NULL_DATA (LangSys, "\0\0\xFF\xFF");
@ -217,7 +217,7 @@ struct Script
langSys; /* Array of LangSysRecords--listed
* alphabetically by LangSysTag */
public:
DEFINE_SIZE_STATIC (4);
DEFINE_SIZE_VAR (4, Record<LangSys>);
};
typedef RecordListOf<Script> ScriptList;
@ -248,7 +248,7 @@ struct Feature
* if not required */
IndexArray lookupIndex; /* Array of LookupList indices */
public:
DEFINE_SIZE_STATIC (4);
DEFINE_SIZE_VAR (4, USHORT);
};
typedef RecordListOf<Feature> FeatureList;
@ -307,7 +307,7 @@ struct Lookup
* structure. This field is only present if bit
* UseMarkFilteringSet of lookup flags is set. */
public:
DEFINE_SIZE_VAR (6, USHORT);
DEFINE_SIZE_VAR2 (6, Offset, USHORT);
};
typedef OffsetListOf<Lookup> LookupList;
@ -346,7 +346,7 @@ struct CoverageFormat1
ArrayOf<GlyphID>
glyphArray; /* Array of GlyphIDs--in numerical order */
public:
DEFINE_SIZE_STATIC (4);
DEFINE_SIZE_VAR (4, GlyphID);
};
struct CoverageRangeRecord
@ -407,7 +407,7 @@ struct CoverageFormat2
* Start GlyphID. rangeCount entries
* long */
public:
DEFINE_SIZE_STATIC (4);
DEFINE_SIZE_VAR (4, CoverageRangeRecord);
};
struct Coverage
@ -469,7 +469,7 @@ struct ClassDefFormat1
ArrayOf<USHORT>
classValue; /* Array of Class Values--one per GlyphID */
public:
DEFINE_SIZE_STATIC (6);
DEFINE_SIZE_VAR (6, USHORT);
};
struct ClassRangeRecord
@ -527,7 +527,7 @@ struct ClassDefFormat2
rangeRecord; /* Array of glyph ranges--ordered by
* Start GlyphID */
public:
DEFINE_SIZE_STATIC (4);
DEFINE_SIZE_VAR (4, ClassRangeRecord);
};
struct ClassDef

View File

@ -80,7 +80,7 @@ struct AttachList
attachPoint; /* Array of AttachPoint tables
* in Coverage Index order */
public:
DEFINE_SIZE_STATIC (4);
DEFINE_SIZE_VAR (4, OffsetTo<AttachPoint>);
};
/*
@ -226,7 +226,7 @@ struct LigGlyph
* --from beginning of LigGlyph table
* --in increasing coordinate order */
public:
DEFINE_SIZE_STATIC (2);
DEFINE_SIZE_VAR (2, OffsetTo<CaretValue>);
};
struct LigCaretList
@ -262,7 +262,7 @@ struct LigCaretList
ligGlyph; /* Array of LigGlyph tables
* in Coverage Index order */
public:
DEFINE_SIZE_STATIC (4);
DEFINE_SIZE_VAR (4, OffsetTo<LigGlyph>);
};
@ -282,7 +282,7 @@ struct MarkGlyphSetsFormat1
coverage; /* Array of long offsets to mark set
* coverage tables */
public:
DEFINE_SIZE_STATIC (4);
DEFINE_SIZE_VAR (4, LongOffsetTo<Coverage>);
};
struct MarkGlyphSets

View File

@ -385,7 +385,7 @@ struct MarkRecord
DEFINE_SIZE_STATIC (4);
};
struct MarkArray
struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage order */
{
inline bool apply (hb_apply_context_t *context,
unsigned int mark_index, unsigned int glyph_index,
@ -393,7 +393,7 @@ struct MarkArray
unsigned int glyph_pos) const
{
TRACE_APPLY ();
const MarkRecord &record = markRecord[mark_index];
const MarkRecord &record = ArrayOf<MarkRecord>::operator[](mark_index);
unsigned int mark_class = record.klass;
const Anchor& mark_anchor = this + record.markAnchor;
@ -417,14 +417,8 @@ struct MarkArray
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
return markRecord.sanitize (context, this);
return ArrayOf<MarkRecord>::sanitize (context, this);
}
private:
ArrayOf<MarkRecord>
markRecord; /* Array of MarkRecords--in Coverage order */
public:
DEFINE_SIZE_STATIC (2);
};
@ -673,7 +667,7 @@ struct PairPosFormat1
pairSet; /* Array of PairSet tables
* ordered by Coverage Index */
public:
DEFINE_SIZE_STATIC (10);
DEFINE_SIZE_VAR (10, OffsetTo<PairSet>);
};
struct PairPosFormat2
@ -1019,7 +1013,7 @@ struct CursivePosFormat1
entryExitRecord; /* Array of EntryExit records--in
* Coverage Index order */
public:
DEFINE_SIZE_STATIC (6);
DEFINE_SIZE_VAR (6, EntryExitRecord);
};
struct CursivePos

View File

@ -117,7 +117,7 @@ struct SingleSubstFormat2
substitute; /* Array of substitute
* GlyphIDs--ordered by Coverage Index */
public:
DEFINE_SIZE_STATIC (6);
DEFINE_SIZE_VAR (6, GlyphID);
};
struct SingleSubst
@ -195,7 +195,7 @@ struct Sequence
ArrayOf<GlyphID>
substitute; /* String of GlyphIDs to substitute */
public:
DEFINE_SIZE_STATIC (2);
DEFINE_SIZE_VAR (2, GlyphID);
};
struct MultipleSubstFormat1
@ -230,7 +230,7 @@ struct MultipleSubstFormat1
sequence; /* Array of Sequence tables
* ordered by Coverage Index */
public:
DEFINE_SIZE_STATIC (6);
DEFINE_SIZE_VAR (6, OffsetTo<Sequence>);
};
struct MultipleSubst
@ -326,7 +326,7 @@ struct AlternateSubstFormat1
alternateSet; /* Array of AlternateSet tables
* ordered by Coverage Index */
public:
DEFINE_SIZE_STATIC (6);
DEFINE_SIZE_VAR (6, OffsetTo<AlternateSet>);
};
struct AlternateSubst
@ -476,7 +476,7 @@ struct LigatureSet
ligature; /* Array LigatureSet tables
* ordered by preference */
public:
DEFINE_SIZE_STATIC (2);
DEFINE_SIZE_VAR (2, OffsetTo<Ligature>);
};
struct LigatureSubstFormat1
@ -514,7 +514,7 @@ struct LigatureSubstFormat1
ligatureSet; /* Array LigatureSet tables
* ordered by Coverage Index */
public:
DEFINE_SIZE_STATIC (6);
DEFINE_SIZE_VAR (6, OffsetTo<LigatureSet>);
};
struct LigatureSubst
@ -660,7 +660,7 @@ struct ReverseChainSingleSubstFormat1
substituteX; /* Array of substitute
* GlyphIDs--ordered by Coverage Index */
public:
DEFINE_SIZE_STATIC (10);
DEFINE_SIZE_MIN (10);
};
struct ReverseChainSingleSubst

View File

@ -368,7 +368,7 @@ struct ContextFormat1
ruleSet; /* Array of RuleSet tables
* ordered by Coverage Index */
public:
DEFINE_SIZE_STATIC (6);
DEFINE_SIZE_VAR (6, OffsetTo<RuleSet>);
};
@ -416,7 +416,7 @@ struct ContextFormat2
ruleSet; /* Array of RuleSet tables
* ordered by class */
public:
DEFINE_SIZE_STATIC (8);
DEFINE_SIZE_VAR (8, OffsetTo<RuleSet>);
};
@ -593,7 +593,7 @@ struct ChainRule
lookupX; /* Array of LookupRecords--in
* design order) */
public:
DEFINE_SIZE_STATIC (8);
DEFINE_SIZE_MIN (8);
};
struct ChainRuleSet
@ -621,7 +621,7 @@ struct ChainRuleSet
rule; /* Array of ChainRule tables
* ordered by preference */
public:
DEFINE_SIZE_STATIC (2);
DEFINE_SIZE_VAR (2, OffsetTo<ChainRule>);
};
struct ChainContextFormat1
@ -659,7 +659,7 @@ struct ChainContextFormat1
ruleSet; /* Array of ChainRuleSet tables
* ordered by Coverage Index */
public:
DEFINE_SIZE_STATIC (6);
DEFINE_SIZE_VAR (6, OffsetTo<ChainRuleSet>);
};
struct ChainContextFormat2
@ -722,7 +722,7 @@ struct ChainContextFormat2
ruleSet; /* Array of ChainRuleSet tables
* ordered by class */
public:
DEFINE_SIZE_STATIC (12);
DEFINE_SIZE_VAR (12, OffsetTo<ChainRuleSet>);
};
struct ChainContextFormat3
@ -784,7 +784,7 @@ struct ChainContextFormat3
lookupX; /* Array of LookupRecords--in
* design order) */
public:
DEFINE_SIZE_STATIC (10);
DEFINE_SIZE_MIN (10);
};
struct ChainContext