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. */
TableDirectory tableDir[VAR]; /* TableDirectory entries. numTables items */
public:
DEFINE_SIZE_VAR (12, TableDirectory);
DEFINE_SIZE_ARRAY (12, tableDir);
} OpenTypeFontFace;
@ -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_VAR (12, LongOffset);
DEFINE_SIZE_ARRAY (12, table);
};
struct TTCHeader

View File

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

View File

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

View File

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

View File

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

View File

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