Change DEFINE_SIZE_VAR to DEFINE_SIZE_ARRAY

This commit is contained in:
Behdad Esfahbod 2010-05-10 19:01:17 -04:00
parent 596e471aa5
commit 0eb9fc6e37
7 changed files with 54 additions and 52 deletions

View File

@ -112,7 +112,7 @@ typedef struct OffsetTable
USHORT rangeShift; /* NumTables x 16-searchRange. */ USHORT rangeShift; /* NumTables x 16-searchRange. */
TableDirectory tableDir[VAR]; /* TableDirectory entries. numTables items */ TableDirectory tableDir[VAR]; /* TableDirectory entries. numTables items */
public: public:
DEFINE_SIZE_VAR (12, TableDirectory); DEFINE_SIZE_ARRAY (12, tableDir);
} OpenTypeFontFace; } OpenTypeFontFace;
@ -140,7 +140,7 @@ struct TTCHeaderVersion1
table; /* Array of offsets to the OffsetTable for each font table; /* Array of offsets to the OffsetTable for each font
* from the beginning of the file */ * from the beginning of the file */
public: public:
DEFINE_SIZE_VAR (12, LongOffset); DEFINE_SIZE_ARRAY (12, table);
}; };
struct TTCHeader struct TTCHeader

View File

@ -103,11 +103,11 @@ inline Type& StructAfter(TObject &X)
_DEFINE_SIZE_ASSERTION (sizeof (*this) >= (size)); \ _DEFINE_SIZE_ASSERTION (sizeof (*this) >= (size)); \
static const unsigned int min_size = (size) static const unsigned int min_size = (size)
#define DEFINE_SIZE_VAR(size, _var_type) \ #define DEFINE_SIZE_ARRAY(size, array) \
_DEFINE_SIZE_ASSERTION (sizeof (*this) == (size) + VAR0 * sizeof (_var_type)); \ _DEFINE_SIZE_ASSERTION (sizeof (*this) == (size) + array[0].static_size); \
static const unsigned int min_size = (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); \ _DEFINE_SIZE_ASSERTION (sizeof (*this) == (size) + this->array1[0].static_size + this->array2[0].static_size); \
static const unsigned int min_size = (size) static const unsigned int min_size = (size)
@ -586,7 +586,7 @@ struct GenericArrayOf
LenType len; LenType len;
Type array[VAR]; Type array[VAR];
public: public:
DEFINE_SIZE_VAR (sizeof (LenType), Type); DEFINE_SIZE_ARRAY (sizeof (LenType), array);
}; };
/* An array with a USHORT number of elements. */ /* An array with a USHORT number of elements. */
@ -671,7 +671,7 @@ struct HeadlessArrayOf
USHORT len; USHORT len;
Type array[VAR]; Type array[VAR];
public: public:
DEFINE_SIZE_VAR (sizeof (USHORT), Type); DEFINE_SIZE_ARRAY (sizeof (USHORT), array);
}; };

View File

@ -119,10 +119,13 @@ struct RecordListOf : RecordArrayOf<Type>
struct IndexArray : ArrayOf<USHORT> struct IndexArray : ArrayOf<USHORT>
{ {
inline unsigned int operator [] (unsigned int i) const inline USHORT operator [] (unsigned int i) const
{ {
if (unlikely (i >= this->len)) if (unlikely (i >= this->len)) {
return NO_INDEX; USHORT u;
u.set (NO_INDEX);
return u;
}
return this->array[i]; return this->array[i];
} }
inline unsigned int get_indexes (unsigned int start_offset, inline unsigned int get_indexes (unsigned int start_offset,
@ -177,7 +180,7 @@ struct LangSys
* = 0xFFFF */ * = 0xFFFF */
IndexArray featureIndex; /* Array of indices into the FeatureList */ IndexArray featureIndex; /* Array of indices into the FeatureList */
public: public:
DEFINE_SIZE_VAR (6, USHORT); DEFINE_SIZE_ARRAY (6, featureIndex);
}; };
DEFINE_NULL_DATA (LangSys, "\0\0\xFF\xFF"); DEFINE_NULL_DATA (LangSys, "\0\0\xFF\xFF");
@ -217,7 +220,7 @@ struct Script
langSys; /* Array of LangSysRecords--listed langSys; /* Array of LangSysRecords--listed
* alphabetically by LangSysTag */ * alphabetically by LangSysTag */
public: public:
DEFINE_SIZE_VAR (4, Record<LangSys>); DEFINE_SIZE_ARRAY (4, langSys);
}; };
typedef RecordListOf<Script> ScriptList; typedef RecordListOf<Script> ScriptList;
@ -248,7 +251,7 @@ struct Feature
* if not required */ * if not required */
IndexArray lookupIndex; /* Array of LookupList indices */ IndexArray lookupIndex; /* Array of LookupList indices */
public: public:
DEFINE_SIZE_VAR (4, USHORT); DEFINE_SIZE_ARRAY (4, lookupIndex);
}; };
typedef RecordListOf<Feature> FeatureList; typedef RecordListOf<Feature> FeatureList;
@ -307,7 +310,7 @@ struct Lookup
* structure. This field is only present if bit * structure. This field is only present if bit
* UseMarkFilteringSet of lookup flags is set. */ * UseMarkFilteringSet of lookup flags is set. */
public: public:
DEFINE_SIZE_VAR2 (6, subTable, markFilteringSetX); DEFINE_SIZE_ARRAY2 (6, subTable, markFilteringSetX);
}; };
typedef OffsetListOf<Lookup> LookupList; typedef OffsetListOf<Lookup> LookupList;
@ -346,7 +349,7 @@ struct CoverageFormat1
ArrayOf<GlyphID> ArrayOf<GlyphID>
glyphArray; /* Array of GlyphIDs--in numerical order */ glyphArray; /* Array of GlyphIDs--in numerical order */
public: public:
DEFINE_SIZE_VAR (4, GlyphID); DEFINE_SIZE_ARRAY (4, glyphArray);
}; };
struct CoverageRangeRecord struct CoverageRangeRecord
@ -407,7 +410,7 @@ struct CoverageFormat2
* Start GlyphID. rangeCount entries * Start GlyphID. rangeCount entries
* long */ * long */
public: public:
DEFINE_SIZE_VAR (4, CoverageRangeRecord); DEFINE_SIZE_ARRAY (4, rangeRecord);
}; };
struct Coverage struct Coverage
@ -471,7 +474,7 @@ struct ClassDefFormat1
ArrayOf<USHORT> ArrayOf<USHORT>
classValue; /* Array of Class Values--one per GlyphID */ classValue; /* Array of Class Values--one per GlyphID */
public: public:
DEFINE_SIZE_VAR (6, USHORT); DEFINE_SIZE_ARRAY (6, classValue);
}; };
struct ClassRangeRecord struct ClassRangeRecord
@ -529,7 +532,7 @@ struct ClassDefFormat2
rangeRecord; /* Array of glyph ranges--ordered by rangeRecord; /* Array of glyph ranges--ordered by
* Start GlyphID */ * Start GlyphID */
public: public:
DEFINE_SIZE_VAR (4, ClassRangeRecord); DEFINE_SIZE_ARRAY (4, rangeRecord);
}; };
struct ClassDef struct ClassDef
@ -620,7 +623,7 @@ struct Device
*/ */
USHORT deltaValue[VAR]; /* Array of compressed data */ USHORT deltaValue[VAR]; /* Array of compressed data */
public: public:
DEFINE_SIZE_VAR (6, USHORT); DEFINE_SIZE_ARRAY (6, deltaValue);
}; };

View File

@ -80,7 +80,7 @@ struct AttachList
attachPoint; /* Array of AttachPoint tables attachPoint; /* Array of AttachPoint tables
* in Coverage Index order */ * in Coverage Index order */
public: public:
DEFINE_SIZE_VAR (4, OffsetTo<AttachPoint>); DEFINE_SIZE_ARRAY (4, attachPoint);
}; };
/* /*
@ -228,7 +228,7 @@ struct LigGlyph
* --from beginning of LigGlyph table * --from beginning of LigGlyph table
* --in increasing coordinate order */ * --in increasing coordinate order */
public: public:
DEFINE_SIZE_VAR (2, OffsetTo<CaretValue>); DEFINE_SIZE_ARRAY (2, carets);
}; };
struct LigCaretList struct LigCaretList
@ -264,7 +264,7 @@ struct LigCaretList
ligGlyph; /* Array of LigGlyph tables ligGlyph; /* Array of LigGlyph tables
* in Coverage Index order */ * in Coverage Index order */
public: public:
DEFINE_SIZE_VAR (4, OffsetTo<LigGlyph>); DEFINE_SIZE_ARRAY (4, ligGlyph);
}; };
@ -284,7 +284,7 @@ struct MarkGlyphSetsFormat1
coverage; /* Array of long offsets to mark set coverage; /* Array of long offsets to mark set
* coverage tables */ * coverage tables */
public: public:
DEFINE_SIZE_VAR (4, LongOffsetTo<Coverage>); DEFINE_SIZE_ARRAY (4, coverage);
}; };
struct MarkGlyphSets struct MarkGlyphSets
@ -394,7 +394,7 @@ struct GDEF
* header (may be NULL). Introduced * header (may be NULL). Introduced
* in version 00010002. */ * in version 00010002. */
public: public:
DEFINE_SIZE_VAR (12, OffsetTo<MarkGlyphSets>); DEFINE_SIZE_ARRAY (12, markGlyphSetsDef);
}; };

View File

@ -40,7 +40,7 @@
typedef USHORT Value; typedef USHORT Value;
typedef Value ValueRecord[VAR0]; typedef Value ValueRecord[VAR];
struct ValueFormat : USHORT struct ValueFormat : USHORT
{ {
@ -364,7 +364,7 @@ struct AnchorMatrix
matrix[VAR]; /* Matrix of offsets to Anchor tables-- matrix[VAR]; /* Matrix of offsets to Anchor tables--
* from beginning of AnchorMatrix table */ * from beginning of AnchorMatrix table */
public: public:
DEFINE_SIZE_VAR (2, OffsetTo<Anchor>); DEFINE_SIZE_ARRAY (2, matrix);
}; };
@ -462,7 +462,7 @@ struct SinglePosFormat1
* value(s)--applied to all glyphs in * value(s)--applied to all glyphs in
* the Coverage table */ * the Coverage table */
public: public:
DEFINE_SIZE_VAR (6, Value); DEFINE_SIZE_ARRAY (6, values);
}; };
struct SinglePosFormat2 struct SinglePosFormat2
@ -506,7 +506,7 @@ struct SinglePosFormat2
ValueRecord values; /* Array of ValueRecords--positioning ValueRecord values; /* Array of ValueRecords--positioning
* values applied to glyphs */ * values applied to glyphs */
public: public:
DEFINE_SIZE_VAR (8, Value); DEFINE_SIZE_ARRAY (8, values);
}; };
struct SinglePos struct SinglePos
@ -554,7 +554,7 @@ struct PairValueRecord
ValueRecord values; /* Positioning data for the first glyph ValueRecord values; /* Positioning data for the first glyph
* followed by for second glyph */ * followed by for second glyph */
public: public:
DEFINE_SIZE_VAR (2, Value); DEFINE_SIZE_ARRAY (2, values);
}; };
struct PairSet struct PairSet
@ -571,11 +571,10 @@ struct PairSet
private: private:
USHORT len; /* Number of PairValueRecords */ USHORT len; /* Number of PairValueRecords */
PairValueRecord USHORT array[VAR]; /* Array of PairValueRecords--ordered
array[VAR]; /* Array of PairValueRecords--ordered
* by GlyphID of the second glyph */ * by GlyphID of the second glyph */
public: public:
DEFINE_SIZE_VAR (2, PairValueRecord); DEFINE_SIZE_ARRAY (2, array);
}; };
struct PairPosFormat1 struct PairPosFormat1
@ -608,7 +607,7 @@ struct PairPosFormat1
const PairSet &pair_set = this+pairSet[index]; const PairSet &pair_set = this+pairSet[index];
unsigned int count = pair_set.len; unsigned int count = pair_set.len;
const PairValueRecord *record = pair_set.array; const PairValueRecord *record = CastP<PairValueRecord> (pair_set.array);
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
if (IN_GLYPH (j) == record->secondGlyph) if (IN_GLYPH (j) == record->secondGlyph)
@ -645,7 +644,7 @@ struct PairPosFormat1
PairSet &pair_set = const_cast<PairSet &> (this+pairSet[i]); /* XXX clean this up */ PairSet &pair_set = const_cast<PairSet &> (this+pairSet[i]); /* XXX clean this up */
unsigned int count2 = pair_set.len; unsigned int count2 = pair_set.len;
PairValueRecord *record = pair_set.array; PairValueRecord *record = CastP<PairValueRecord> (pair_set.array);
if (!(valueFormat1.sanitize_values_stride_unsafe (context, this, &record->values[0], count2, stride) && if (!(valueFormat1.sanitize_values_stride_unsafe (context, this, &record->values[0], count2, stride) &&
valueFormat2.sanitize_values_stride_unsafe (context, this, &record->values[len1], count2, stride))) valueFormat2.sanitize_values_stride_unsafe (context, this, &record->values[len1], count2, stride)))
return false; return false;
@ -669,7 +668,7 @@ struct PairPosFormat1
pairSet; /* Array of PairSet tables pairSet; /* Array of PairSet tables
* ordered by Coverage Index */ * ordered by Coverage Index */
public: public:
DEFINE_SIZE_VAR (10, OffsetTo<PairSet>); DEFINE_SIZE_ARRAY (10, pairSet);
}; };
struct PairPosFormat2 struct PairPosFormat2
@ -760,7 +759,7 @@ struct PairPosFormat2
* class1-major, class2-minor, * class1-major, class2-minor,
* Each entry has value1 and value2 */ * Each entry has value1 and value2 */
public: public:
DEFINE_SIZE_VAR (16, ValueRecord); DEFINE_SIZE_ARRAY (16, values);
}; };
struct PairPos struct PairPos
@ -1015,7 +1014,7 @@ struct CursivePosFormat1
entryExitRecord; /* Array of EntryExit records--in entryExitRecord; /* Array of EntryExit records--in
* Coverage Index order */ * Coverage Index order */
public: public:
DEFINE_SIZE_VAR (6, EntryExitRecord); DEFINE_SIZE_ARRAY (6, entryExitRecord);
}; };
struct CursivePos struct CursivePos

View File

@ -117,7 +117,7 @@ struct SingleSubstFormat2
substitute; /* Array of substitute substitute; /* Array of substitute
* GlyphIDs--ordered by Coverage Index */ * GlyphIDs--ordered by Coverage Index */
public: public:
DEFINE_SIZE_VAR (6, GlyphID); DEFINE_SIZE_ARRAY (6, substitute);
}; };
struct SingleSubst struct SingleSubst
@ -195,7 +195,7 @@ struct Sequence
ArrayOf<GlyphID> ArrayOf<GlyphID>
substitute; /* String of GlyphIDs to substitute */ substitute; /* String of GlyphIDs to substitute */
public: public:
DEFINE_SIZE_VAR (2, GlyphID); DEFINE_SIZE_ARRAY (2, substitute);
}; };
struct MultipleSubstFormat1 struct MultipleSubstFormat1
@ -230,7 +230,7 @@ struct MultipleSubstFormat1
sequence; /* Array of Sequence tables sequence; /* Array of Sequence tables
* ordered by Coverage Index */ * ordered by Coverage Index */
public: public:
DEFINE_SIZE_VAR (6, OffsetTo<Sequence>); DEFINE_SIZE_ARRAY (6, sequence);
}; };
struct MultipleSubst struct MultipleSubst
@ -326,7 +326,7 @@ struct AlternateSubstFormat1
alternateSet; /* Array of AlternateSet tables alternateSet; /* Array of AlternateSet tables
* ordered by Coverage Index */ * ordered by Coverage Index */
public: public:
DEFINE_SIZE_VAR (6, OffsetTo<AlternateSet>); DEFINE_SIZE_ARRAY (6, alternateSet);
}; };
struct AlternateSubst struct AlternateSubst
@ -443,7 +443,7 @@ struct Ligature
* with the second component--ordered * with the second component--ordered
* in writing direction */ * in writing direction */
public: public:
DEFINE_SIZE_VAR (4, GlyphID); DEFINE_SIZE_ARRAY (4, component);
}; };
struct LigatureSet struct LigatureSet
@ -476,7 +476,7 @@ struct LigatureSet
ligature; /* Array LigatureSet tables ligature; /* Array LigatureSet tables
* ordered by preference */ * ordered by preference */
public: public:
DEFINE_SIZE_VAR (2, OffsetTo<Ligature>); DEFINE_SIZE_ARRAY (2, ligature);
}; };
struct LigatureSubstFormat1 struct LigatureSubstFormat1
@ -514,7 +514,7 @@ struct LigatureSubstFormat1
ligatureSet; /* Array LigatureSet tables ligatureSet; /* Array LigatureSet tables
* ordered by Coverage Index */ * ordered by Coverage Index */
public: public:
DEFINE_SIZE_VAR (6, OffsetTo<LigatureSet>); DEFINE_SIZE_ARRAY (6, ligatureSet);
}; };
struct LigatureSubst struct LigatureSubst

View File

@ -303,7 +303,7 @@ struct Rule
LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
* design order */ * design order */
public: public:
DEFINE_SIZE_VAR2 (4, input, lookupRecordX); DEFINE_SIZE_ARRAY2 (4, input, lookupRecordX);
}; };
struct RuleSet struct RuleSet
@ -331,7 +331,7 @@ struct RuleSet
rule; /* Array of Rule tables rule; /* Array of Rule tables
* ordered by preference */ * ordered by preference */
public: public:
DEFINE_SIZE_VAR (2, OffsetTo<Rule>); DEFINE_SIZE_ARRAY (2, rule);
}; };
@ -370,7 +370,7 @@ struct ContextFormat1
ruleSet; /* Array of RuleSet tables ruleSet; /* Array of RuleSet tables
* ordered by Coverage Index */ * ordered by Coverage Index */
public: public:
DEFINE_SIZE_VAR (6, OffsetTo<RuleSet>); DEFINE_SIZE_ARRAY (6, ruleSet);
}; };
@ -418,7 +418,7 @@ struct ContextFormat2
ruleSet; /* Array of RuleSet tables ruleSet; /* Array of RuleSet tables
* ordered by class */ * ordered by class */
public: public:
DEFINE_SIZE_VAR (8, OffsetTo<RuleSet>); DEFINE_SIZE_ARRAY (8, ruleSet);
}; };
@ -467,7 +467,7 @@ struct ContextFormat3
LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
* design order */ * design order */
public: public:
DEFINE_SIZE_VAR2 (6, coverage, lookupRecordX); DEFINE_SIZE_ARRAY2 (6, coverage, lookupRecordX);
}; };
struct Context struct Context
@ -623,7 +623,7 @@ struct ChainRuleSet
rule; /* Array of ChainRule tables rule; /* Array of ChainRule tables
* ordered by preference */ * ordered by preference */
public: public:
DEFINE_SIZE_VAR (2, OffsetTo<ChainRule>); DEFINE_SIZE_ARRAY (2, rule);
}; };
struct ChainContextFormat1 struct ChainContextFormat1
@ -661,7 +661,7 @@ struct ChainContextFormat1
ruleSet; /* Array of ChainRuleSet tables ruleSet; /* Array of ChainRuleSet tables
* ordered by Coverage Index */ * ordered by Coverage Index */
public: public:
DEFINE_SIZE_VAR (6, OffsetTo<ChainRuleSet>); DEFINE_SIZE_ARRAY (6, ruleSet);
}; };
struct ChainContextFormat2 struct ChainContextFormat2
@ -724,7 +724,7 @@ struct ChainContextFormat2
ruleSet; /* Array of ChainRuleSet tables ruleSet; /* Array of ChainRuleSet tables
* ordered by class */ * ordered by class */
public: public:
DEFINE_SIZE_VAR (12, OffsetTo<ChainRuleSet>); DEFINE_SIZE_ARRAY (12, ruleSet);
}; };
struct ChainContextFormat3 struct ChainContextFormat3