[otlayout] Mark variables that are C arrays as opposed to OT::ArrayOf

This commit is contained in:
Behdad Esfahbod 2014-12-12 21:07:53 -08:00
parent 9df0a52030
commit 093c520de5
2 changed files with 42 additions and 42 deletions

View File

@ -345,8 +345,8 @@ struct AnchorMatrix
inline const Anchor& get_anchor (unsigned int row, unsigned int col, unsigned int cols, bool *found) const { inline const Anchor& get_anchor (unsigned int row, unsigned int col, unsigned int cols, bool *found) const {
*found = false; *found = false;
if (unlikely (row >= rows || col >= cols)) return Null(Anchor); if (unlikely (row >= rows || col >= cols)) return Null(Anchor);
*found = !matrix[row * cols + col].is_null (); *found = !matrixZ[row * cols + col].is_null ();
return this+matrix[row * cols + col]; return this+matrixZ[row * cols + col];
} }
inline bool sanitize (hb_sanitize_context_t *c, unsigned int cols) { inline bool sanitize (hb_sanitize_context_t *c, unsigned int cols) {
@ -354,19 +354,19 @@ struct AnchorMatrix
if (!c->check_struct (this)) return TRACE_RETURN (false); if (!c->check_struct (this)) return TRACE_RETURN (false);
if (unlikely (rows > 0 && cols >= ((unsigned int) -1) / rows)) return TRACE_RETURN (false); if (unlikely (rows > 0 && cols >= ((unsigned int) -1) / rows)) return TRACE_RETURN (false);
unsigned int count = rows * cols; unsigned int count = rows * cols;
if (!c->check_array (matrix, matrix[0].static_size, count)) return TRACE_RETURN (false); if (!c->check_array (matrixZ, matrixZ[0].static_size, count)) return TRACE_RETURN (false);
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
if (!matrix[i].sanitize (c, this)) return TRACE_RETURN (false); if (!matrixZ[i].sanitize (c, this)) return TRACE_RETURN (false);
return TRACE_RETURN (true); return TRACE_RETURN (true);
} }
USHORT rows; /* Number of rows */ USHORT rows; /* Number of rows */
protected: protected:
OffsetTo<Anchor> OffsetTo<Anchor>
matrix[VAR]; /* Matrix of offsets to Anchor tables-- matrixZ[VAR]; /* Matrix of offsets to Anchor tables--
* from beginning of AnchorMatrix table */ * from beginning of AnchorMatrix table */
public: public:
DEFINE_SIZE_ARRAY (2, matrix); DEFINE_SIZE_ARRAY (2, matrixZ);
}; };
@ -583,7 +583,7 @@ struct PairSet
unsigned int len2 = valueFormats[1].get_len (); unsigned int len2 = valueFormats[1].get_len ();
unsigned int record_size = USHORT::static_size * (1 + len1 + len2); unsigned int record_size = USHORT::static_size * (1 + len1 + len2);
const PairValueRecord *record = CastP<PairValueRecord> (array); const PairValueRecord *record = CastP<PairValueRecord> (arrayZ);
unsigned int count = len; unsigned int count = len;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
@ -602,7 +602,7 @@ struct PairSet
unsigned int len2 = valueFormats[1].get_len (); unsigned int len2 = valueFormats[1].get_len ();
unsigned int record_size = USHORT::static_size * (1 + len1 + len2); unsigned int record_size = USHORT::static_size * (1 + len1 + len2);
const PairValueRecord *record = CastP<PairValueRecord> (array); const PairValueRecord *record = CastP<PairValueRecord> (arrayZ);
unsigned int count = len; unsigned int count = len;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
@ -634,20 +634,20 @@ struct PairSet
inline bool sanitize (hb_sanitize_context_t *c, const sanitize_closure_t *closure) { inline bool sanitize (hb_sanitize_context_t *c, const sanitize_closure_t *closure) {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
if (!(c->check_struct (this) if (!(c->check_struct (this)
&& c->check_array (array, USHORT::static_size * closure->stride, len))) return TRACE_RETURN (false); && c->check_array (arrayZ, USHORT::static_size * closure->stride, len))) return TRACE_RETURN (false);
unsigned int count = len; unsigned int count = len;
PairValueRecord *record = CastP<PairValueRecord> (array); PairValueRecord *record = CastP<PairValueRecord> (arrayZ);
return TRACE_RETURN (closure->valueFormats[0].sanitize_values_stride_unsafe (c, closure->base, &record->values[0], count, closure->stride) return TRACE_RETURN (closure->valueFormats[0].sanitize_values_stride_unsafe (c, closure->base, &record->values[0], count, closure->stride)
&& closure->valueFormats[1].sanitize_values_stride_unsafe (c, closure->base, &record->values[closure->len1], count, closure->stride)); && closure->valueFormats[1].sanitize_values_stride_unsafe (c, closure->base, &record->values[closure->len1], count, closure->stride));
} }
protected: protected:
USHORT len; /* Number of PairValueRecords */ USHORT len; /* Number of PairValueRecords */
USHORT array[VAR]; /* Array of PairValueRecords--ordered USHORT arrayZ[VAR]; /* Array of PairValueRecords--ordered
* by GlyphID of the second glyph */ * by GlyphID of the second glyph */
public: public:
DEFINE_SIZE_ARRAY (2, array); DEFINE_SIZE_ARRAY (2, arrayZ);
}; };
struct PairPosFormat1 struct PairPosFormat1

View File

@ -1136,9 +1136,9 @@ struct Rule
inline void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const inline void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const
{ {
TRACE_CLOSURE (this); TRACE_CLOSURE (this);
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0)); const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (inputZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
context_closure_lookup (c, context_closure_lookup (c,
inputCount, input, inputCount, inputZ,
lookupCount, lookupRecord, lookupCount, lookupRecord,
lookup_context); lookup_context);
} }
@ -1146,9 +1146,9 @@ struct Rule
inline void collect_glyphs (hb_collect_glyphs_context_t *c, ContextCollectGlyphsLookupContext &lookup_context) const inline void collect_glyphs (hb_collect_glyphs_context_t *c, ContextCollectGlyphsLookupContext &lookup_context) const
{ {
TRACE_COLLECT_GLYPHS (this); TRACE_COLLECT_GLYPHS (this);
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0)); const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (inputZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
context_collect_glyphs_lookup (c, context_collect_glyphs_lookup (c,
inputCount, input, inputCount, inputZ,
lookupCount, lookupRecord, lookupCount, lookupRecord,
lookup_context); lookup_context);
} }
@ -1156,15 +1156,15 @@ struct Rule
inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContext &lookup_context) const inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContext &lookup_context) const
{ {
TRACE_WOULD_APPLY (this); TRACE_WOULD_APPLY (this);
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0)); const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (inputZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
return TRACE_RETURN (context_would_apply_lookup (c, inputCount, input, lookupCount, lookupRecord, lookup_context)); return TRACE_RETURN (context_would_apply_lookup (c, inputCount, inputZ, lookupCount, lookupRecord, lookup_context));
} }
inline bool apply (hb_apply_context_t *c, ContextApplyLookupContext &lookup_context) const inline bool apply (hb_apply_context_t *c, ContextApplyLookupContext &lookup_context) const
{ {
TRACE_APPLY (this); TRACE_APPLY (this);
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0)); const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (inputZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
return TRACE_RETURN (context_apply_lookup (c, inputCount, input, lookupCount, lookupRecord, lookup_context)); return TRACE_RETURN (context_apply_lookup (c, inputCount, inputZ, lookupCount, lookupRecord, lookup_context));
} }
public: public:
@ -1172,8 +1172,8 @@ struct Rule
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
return inputCount.sanitize (c) return inputCount.sanitize (c)
&& lookupCount.sanitize (c) && lookupCount.sanitize (c)
&& c->check_range (input, && c->check_range (inputZ,
input[0].static_size * inputCount inputZ[0].static_size * inputCount
+ lookupRecordX[0].static_size * lookupCount); + lookupRecordX[0].static_size * lookupCount);
} }
@ -1182,12 +1182,12 @@ struct Rule
* glyph sequence--includes the first * glyph sequence--includes the first
* glyph */ * glyph */
USHORT lookupCount; /* Number of LookupRecords */ USHORT lookupCount; /* Number of LookupRecords */
USHORT input[VAR]; /* Array of match inputs--start with USHORT inputZ[VAR]; /* Array of match inputs--start with
* second glyph */ * second glyph */
LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
* design order */ * design order */
public: public:
DEFINE_SIZE_ARRAY2 (4, input, lookupRecordX); DEFINE_SIZE_ARRAY2 (4, inputZ, lookupRecordX);
}; };
struct RuleSet struct RuleSet
@ -1432,16 +1432,16 @@ struct ContextFormat3
inline void closure (hb_closure_context_t *c) const inline void closure (hb_closure_context_t *c) const
{ {
TRACE_CLOSURE (this); TRACE_CLOSURE (this);
if (!(this+coverage[0]).intersects (c->glyphs)) if (!(this+coverageZ[0]).intersects (c->glyphs))
return; return;
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount); const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ, coverageZ[0].static_size * glyphCount);
struct ContextClosureLookupContext lookup_context = { struct ContextClosureLookupContext lookup_context = {
{intersects_coverage}, {intersects_coverage},
this this
}; };
context_closure_lookup (c, context_closure_lookup (c,
glyphCount, (const USHORT *) (coverage + 1), glyphCount, (const USHORT *) (coverageZ + 1),
lookupCount, lookupRecord, lookupCount, lookupRecord,
lookup_context); lookup_context);
} }
@ -1449,16 +1449,16 @@ struct ContextFormat3
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ {
TRACE_COLLECT_GLYPHS (this); TRACE_COLLECT_GLYPHS (this);
(this+coverage[0]).add_coverage (c->input); (this+coverageZ[0]).add_coverage (c->input);
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount); const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ, coverageZ[0].static_size * glyphCount);
struct ContextCollectGlyphsLookupContext lookup_context = { struct ContextCollectGlyphsLookupContext lookup_context = {
{collect_coverage}, {collect_coverage},
this this
}; };
context_collect_glyphs_lookup (c, context_collect_glyphs_lookup (c,
glyphCount, (const USHORT *) (coverage + 1), glyphCount, (const USHORT *) (coverageZ + 1),
lookupCount, lookupRecord, lookupCount, lookupRecord,
lookup_context); lookup_context);
} }
@ -1467,42 +1467,42 @@ struct ContextFormat3
{ {
TRACE_WOULD_APPLY (this); TRACE_WOULD_APPLY (this);
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount); const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ, coverageZ[0].static_size * glyphCount);
struct ContextApplyLookupContext lookup_context = { struct ContextApplyLookupContext lookup_context = {
{match_coverage}, {match_coverage},
this this
}; };
return TRACE_RETURN (context_would_apply_lookup (c, glyphCount, (const USHORT *) (coverage + 1), lookupCount, lookupRecord, lookup_context)); return TRACE_RETURN (context_would_apply_lookup (c, glyphCount, (const USHORT *) (coverageZ + 1), lookupCount, lookupRecord, lookup_context));
} }
inline const Coverage &get_coverage (void) const inline const Coverage &get_coverage (void) const
{ {
return this+coverage[0]; return this+coverageZ[0];
} }
inline bool apply (hb_apply_context_t *c) const inline bool apply (hb_apply_context_t *c) const
{ {
TRACE_APPLY (this); TRACE_APPLY (this);
unsigned int index = (this+coverage[0]).get_coverage (c->buffer->cur().codepoint); unsigned int index = (this+coverageZ[0]).get_coverage (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount); const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ, coverageZ[0].static_size * glyphCount);
struct ContextApplyLookupContext lookup_context = { struct ContextApplyLookupContext lookup_context = {
{match_coverage}, {match_coverage},
this this
}; };
return TRACE_RETURN (context_apply_lookup (c, glyphCount, (const USHORT *) (coverage + 1), lookupCount, lookupRecord, lookup_context)); return TRACE_RETURN (context_apply_lookup (c, glyphCount, (const USHORT *) (coverageZ + 1), lookupCount, lookupRecord, lookup_context));
} }
inline bool sanitize (hb_sanitize_context_t *c) { inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
if (!c->check_struct (this)) return TRACE_RETURN (false); if (!c->check_struct (this)) return TRACE_RETURN (false);
unsigned int count = glyphCount; unsigned int count = glyphCount;
if (!count) return TRACE_RETURN (false); /* We want to access coverage[0] freely. */ if (!count) return TRACE_RETURN (false); /* We want to access coverageZ[0] freely. */
if (!c->check_array (coverage, coverage[0].static_size, count)) return TRACE_RETURN (false); if (!c->check_array (coverageZ, coverageZ[0].static_size, count)) return TRACE_RETURN (false);
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
if (!coverage[i].sanitize (c, this)) return TRACE_RETURN (false); if (!coverageZ[i].sanitize (c, this)) return TRACE_RETURN (false);
LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * count); LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ, coverageZ[0].static_size * count);
return TRACE_RETURN (c->check_array (lookupRecord, lookupRecord[0].static_size, lookupCount)); return TRACE_RETURN (c->check_array (lookupRecord, lookupRecord[0].static_size, lookupCount));
} }
@ -1512,12 +1512,12 @@ struct ContextFormat3
* sequence */ * sequence */
USHORT lookupCount; /* Number of LookupRecords */ USHORT lookupCount; /* Number of LookupRecords */
OffsetTo<Coverage> OffsetTo<Coverage>
coverage[VAR]; /* Array of offsets to Coverage coverageZ[VAR]; /* Array of offsets to Coverage
* table in glyph sequence order */ * table in glyph sequence order */
LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
* design order */ * design order */
public: public:
DEFINE_SIZE_ARRAY2 (6, coverage, lookupRecordX); DEFINE_SIZE_ARRAY2 (6, coverageZ, lookupRecordX);
}; };
struct Context struct Context