Remove SANITIZE macro

This commit is contained in:
Behdad Esfahbod 2010-05-06 13:30:23 -04:00
parent c2ddfd2d26
commit 4f252fedc7
7 changed files with 49 additions and 51 deletions

View File

@ -165,7 +165,7 @@ struct TTCHeader
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.header.version)) return false; if (!u.header.version.sanitize (context)) return false;
switch (u.header.version) { switch (u.header.version) {
case 2: /* version 2 is compatible with version 1 */ case 2: /* version 2 is compatible with version 1 */
case 1: return u.version1->sanitize (context); case 1: return u.version1->sanitize (context);
@ -227,7 +227,7 @@ struct OpenTypeFontFile
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.tag)) return false; if (!u.tag.sanitize (context)) return false;
switch (u.tag) { switch (u.tag) {
case CFFTag: /* All the non-collection tags */ case CFFTag: /* All the non-collection tags */
case TrueTag: case TrueTag:

View File

@ -238,8 +238,6 @@ struct hb_sanitize_context_t
}; };
#define SANITIZE(X) likely ((X).sanitize (context))
#define SANITIZE_SELF() likely(context->check_range (this, sizeof (*this))) #define SANITIZE_SELF() likely(context->check_range (this, sizeof (*this)))
@ -522,7 +520,7 @@ struct GenericArrayOf
* other structs. */ * other structs. */
unsigned int count = len; unsigned int count = len;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
if (!SANITIZE (array()[i])) if (array()[i].sanitize (context))
return false; return false;
return true; return true;
} }
@ -635,7 +633,7 @@ struct HeadlessArrayOf
unsigned int count = len ? len - 1 : 0; unsigned int count = len ? len - 1 : 0;
Type *a = array(); Type *a = array();
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
if (!SANITIZE (a[i])) if (!a[i].sanitize (context))
return false; return false;
return true; return true;
} }

View File

@ -167,7 +167,7 @@ struct LangSys
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_SELF () return SANITIZE_SELF ()
&& SANITIZE (featureIndex); && featureIndex.sanitize (context);
} }
Offset lookupOrder; /* = Null (reserved for an offset to a Offset lookupOrder; /* = Null (reserved for an offset to a
@ -236,7 +236,7 @@ struct Feature
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_SELF () return SANITIZE_SELF ()
&& SANITIZE (lookupIndex); && lookupIndex.sanitize (context);
} }
/* LONGTERMTODO: implement get_feature_parameters() */ /* LONGTERMTODO: implement get_feature_parameters() */
@ -292,7 +292,7 @@ struct Lookup
if (unlikely (lookupFlag & LookupFlag::UseMarkFilteringSet)) if (unlikely (lookupFlag & LookupFlag::UseMarkFilteringSet))
{ {
USHORT &markFilteringSet = StructAfter<USHORT> (subTable); USHORT &markFilteringSet = StructAfter<USHORT> (subTable);
if (!SANITIZE (markFilteringSet)) return false; if (!markFilteringSet.sanitize (context)) return false;
} }
return true; return true;
} }
@ -336,7 +336,7 @@ struct CoverageFormat1
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE (glyphArray); return glyphArray.sanitize (context);
} }
private: private:
@ -395,7 +395,7 @@ struct CoverageFormat2
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE (rangeRecord); return rangeRecord.sanitize (context);
} }
private: private:
@ -422,7 +422,7 @@ struct Coverage
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
case 2: return u.format2->sanitize (context); case 2: return u.format2->sanitize (context);
@ -458,7 +458,7 @@ struct ClassDefFormat1
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_SELF () return SANITIZE_SELF ()
&& SANITIZE (classValue); && classValue.sanitize (context);
} }
USHORT classFormat; /* Format identifier--format = 1 */ USHORT classFormat; /* Format identifier--format = 1 */
@ -516,7 +516,7 @@ struct ClassDefFormat2
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE (rangeRecord); return rangeRecord.sanitize (context);
} }
USHORT classFormat; /* Format identifier--format = 2 */ USHORT classFormat; /* Format identifier--format = 2 */
@ -541,7 +541,7 @@ struct ClassDef
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
case 2: return u.format2->sanitize (context); case 2: return u.format2->sanitize (context);

View File

@ -176,7 +176,7 @@ struct CaretValue
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
case 2: return u.format2->sanitize (context); case 2: return u.format2->sanitize (context);
@ -291,7 +291,7 @@ struct MarkGlyphSets
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
default:return true; default:return true;
@ -351,7 +351,7 @@ struct GDEF
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE (version) && likely (version.major == 1) return version.sanitize (context) && likely (version.major == 1)
&& glyphClassDef.sanitize (context, this) && glyphClassDef.sanitize (context, this)
&& attachList.sanitize (context, this) && attachList.sanitize (context, this)
&& ligCaretList.sanitize (context, this) && ligCaretList.sanitize (context, this)

View File

@ -318,7 +318,7 @@ struct Anchor
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
case 2: return u.format2->sanitize (context); case 2: return u.format2->sanitize (context);
@ -526,7 +526,7 @@ struct SinglePos
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
case 2: return u.format2->sanitize (context); case 2: return u.format2->sanitize (context);
@ -776,7 +776,7 @@ struct PairPos
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
case 2: return u.format2->sanitize (context); case 2: return u.format2->sanitize (context);
@ -1027,7 +1027,7 @@ struct CursivePos
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
default:return true; default:return true;
@ -1125,7 +1125,7 @@ struct MarkBasePos
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
default:return true; default:return true;
@ -1250,7 +1250,7 @@ struct MarkLigPos
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
default:return true; default:return true;
@ -1354,7 +1354,7 @@ struct MarkMarkPos
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
default:return true; default:return true;
@ -1455,7 +1455,7 @@ struct PosLookupSubTable
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case Single: return u.single->sanitize (context); case Single: return u.single->sanitize (context);
case Pair: return u.pair->sanitize (context); case Pair: return u.pair->sanitize (context);
@ -1604,7 +1604,7 @@ inline bool ExtensionPos::sanitize (hb_sanitize_context_t *context)
if (unlikely (!Extension::sanitize (context))) return false; if (unlikely (!Extension::sanitize (context))) return false;
unsigned int offset = get_offset (); unsigned int offset = get_offset ();
if (unlikely (!offset)) return true; if (unlikely (!offset)) return true;
return SANITIZE (StructAtOffset<PosLookupSubTable> (*this, offset)); return StructAtOffset<PosLookupSubTable> (*this, offset).sanitize (context);
} }
static inline bool position_lookup (hb_apply_context_t *context, unsigned int lookup_index) static inline bool position_lookup (hb_apply_context_t *context, unsigned int lookup_index)

View File

@ -61,7 +61,7 @@ struct SingleSubstFormat1
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return coverage.sanitize (context, this) return coverage.sanitize (context, this)
&& SANITIZE (deltaGlyphID); && deltaGlyphID.sanitize (context);
} }
private: private:
@ -104,7 +104,7 @@ struct SingleSubstFormat2
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return coverage.sanitize (context, this) return coverage.sanitize (context, this)
&& SANITIZE (substitute); && substitute.sanitize (context);
} }
private: private:
@ -136,7 +136,7 @@ struct SingleSubst
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
case 2: return u.format2->sanitize (context); case 2: return u.format2->sanitize (context);
@ -186,7 +186,7 @@ struct Sequence
public: public:
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE (substitute); return substitute.sanitize (context);
} }
private: private:
@ -246,7 +246,7 @@ struct MultipleSubst
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
default:return true; default:return true;
@ -342,7 +342,7 @@ struct AlternateSubst
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
default:return true; default:return true;
@ -428,8 +428,8 @@ struct Ligature
public: public:
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE (ligGlyph) return ligGlyph.sanitize (context)
&& SANITIZE (component); && component.sanitize (context);
} }
private: private:
@ -526,7 +526,7 @@ struct LigatureSubst
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
default:return true; default:return true;
@ -633,7 +633,7 @@ struct ReverseChainSingleSubstFormat1
if (!lookahead.sanitize (context, this)) if (!lookahead.sanitize (context, this))
return false; return false;
ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead); ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
return SANITIZE (substitute); return substitute.sanitize (context);
} }
private: private:
@ -671,7 +671,7 @@ struct ReverseChainSingleSubst
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
default:return true; default:return true;
@ -724,7 +724,7 @@ struct SubstLookupSubTable
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case Single: return u.single->sanitize (context); case Single: return u.single->sanitize (context);
case Multiple: return u.multiple->sanitize (context); case Multiple: return u.multiple->sanitize (context);
@ -908,7 +908,7 @@ inline bool ExtensionSubst::sanitize (hb_sanitize_context_t *context)
if (unlikely (!Extension::sanitize (context))) return false; if (unlikely (!Extension::sanitize (context))) return false;
unsigned int offset = get_offset (); unsigned int offset = get_offset ();
if (unlikely (!offset)) return true; if (unlikely (!offset)) return true;
return SANITIZE (StructAtOffset<SubstLookupSubTable> (*this, offset)); return StructAtOffset<SubstLookupSubTable> (*this, offset).sanitize (context);
} }
inline bool ExtensionSubst::is_reverse (void) const inline bool ExtensionSubst::is_reverse (void) const

View File

@ -287,8 +287,8 @@ struct Rule
public: public:
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE (inputCount) return inputCount.sanitize (context)
&& SANITIZE (lookupCount) && lookupCount.sanitize (context)
&& context->check_range (input, && context->check_range (input,
input[0].get_size () * inputCount input[0].get_size () * inputCount
+ lookupRecordX[0].get_size () * lookupCount); + lookupRecordX[0].get_size () * lookupCount);
@ -481,7 +481,7 @@ struct Context
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
case 2: return u.format2->sanitize (context); case 2: return u.format2->sanitize (context);
@ -566,13 +566,13 @@ struct ChainRule
public: public:
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (backtrack)) return false; if (!backtrack.sanitize (context)) return false;
HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack); HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
if (!SANITIZE (input)) return false; if (!input.sanitize (context)) return false;
ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input); ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
if (!SANITIZE (lookahead)) return false; if (!lookahead.sanitize (context)) return false;
ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
return SANITIZE (lookup); return lookup.sanitize (context);
} }
private: private:
@ -756,7 +756,7 @@ struct ChainContextFormat3
OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input); OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
if (!lookahead.sanitize (context, this)) return false; if (!lookahead.sanitize (context, this)) return false;
ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
return SANITIZE (lookup); return lookup.sanitize (context);
} }
private: private:
@ -795,7 +795,7 @@ struct ChainContext
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
case 2: return u.format2->sanitize (context); case 2: return u.format2->sanitize (context);
@ -856,7 +856,7 @@ struct Extension
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (u.format)) return false; if (!u.format.sanitize (context)) return false;
switch (u.format) { switch (u.format) {
case 1: return u.format1->sanitize (context); case 1: return u.format1->sanitize (context);
default:return true; default:return true;
@ -913,7 +913,7 @@ struct GSUBGPOS
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE (version) && likely (version.major == 1) return version.sanitize (context) && likely (version.major == 1)
&& scriptList.sanitize (context, this) && scriptList.sanitize (context, this)
&& featureList.sanitize (context, this) && featureList.sanitize (context, this)
&& lookupList.sanitize (context, this); && lookupList.sanitize (context, this);