Remove SANITIZE_THIS

This commit is contained in:
Behdad Esfahbod 2010-05-04 15:28:52 -04:00
parent 2226fc93d1
commit bb029af943
7 changed files with 85 additions and 75 deletions

View File

@ -126,7 +126,7 @@ struct TTCHeaderVersion1
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (table);
return SANITIZE_WITH_BASE (this, table);
}
private:

View File

@ -229,8 +229,7 @@ _hb_sanitize_edit (SANITIZE_ARG_DEF,
#define SANITIZE(X) likely ((X).sanitize (SANITIZE_ARG))
#define SANITIZE_THIS(X) likely ((X).sanitize (SANITIZE_ARG, CharP(this)))
#define SANITIZE_WITH_BASE(B,X) likely ((X).sanitize (SANITIZE_ARG, (B)))
#define SANITIZE_WITH_BASE(B,X) likely ((X).sanitize (SANITIZE_ARG, CharP(B)))
#define SANITIZE_SELF() SANITIZE_MEM(this, sizeof (*this))

View File

@ -203,8 +203,8 @@ struct Script
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (defaultLangSys)
&& SANITIZE_THIS (langSys);
return SANITIZE_WITH_BASE (this, defaultLangSys)
&& SANITIZE_WITH_BASE (this, langSys);
}
private:

View File

@ -69,8 +69,8 @@ struct AttachList
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (coverage)
&& SANITIZE_THIS (attachPoint);
return SANITIZE_WITH_BASE (this, coverage)
&& SANITIZE_WITH_BASE (this, attachPoint);
}
private:
@ -148,7 +148,8 @@ struct CaretValueFormat3
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_SELF () && SANITIZE_THIS (deviceTable);
return SANITIZE_SELF ()
&& SANITIZE_WITH_BASE (this, deviceTable);
}
private:
@ -213,7 +214,7 @@ struct LigGlyph
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (carets);
return SANITIZE_WITH_BASE (this, carets);
}
private:
@ -245,8 +246,8 @@ struct LigCaretList
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (coverage)
&& SANITIZE_THIS (ligGlyph);
return SANITIZE_WITH_BASE (this, coverage)
&& SANITIZE_WITH_BASE (this, ligGlyph);
}
private:
@ -267,7 +268,7 @@ struct MarkGlyphSetsFormat1
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (coverage);
return SANITIZE_WITH_BASE (this, coverage);
}
private:
@ -350,10 +351,12 @@ struct GDEF
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE (version) && likely (version.major == 1) &&
SANITIZE_THIS (glyphClassDef) && SANITIZE_THIS (attachList) &&
SANITIZE_THIS (ligCaretList) && SANITIZE_THIS (markAttachClassDef) &&
(version < 0x00010002 || SANITIZE_THIS (markGlyphSetsDef[0]));
return SANITIZE (version) && likely (version.major == 1)
&& SANITIZE_WITH_BASE (this, glyphClassDef)
&& SANITIZE_WITH_BASE (this, attachList)
&& SANITIZE_WITH_BASE (this, ligCaretList)
&& SANITIZE_WITH_BASE (this, markAttachClassDef)
&& (version < 0x00010002 || SANITIZE_WITH_BASE (this, markGlyphSetsDef[0]));
}
private:

View File

@ -271,8 +271,8 @@ struct AnchorFormat3
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_SELF ()
&& SANITIZE_THIS (xDeviceTable)
&& SANITIZE_THIS (yDeviceTable);
&& SANITIZE_WITH_BASE (this, xDeviceTable)
&& SANITIZE_WITH_BASE (this, yDeviceTable);
}
private:
@ -339,7 +339,7 @@ struct AnchorMatrix
unsigned int count = rows * cols;
if (!SANITIZE_ARRAY (matrix, matrix[0].get_size (), count)) return false;
for (unsigned int i = 0; i < count; i++)
if (!SANITIZE_THIS (matrix[i])) return false;
if (!SANITIZE_WITH_BASE (this, matrix[i])) return false;
return true;
}
@ -404,7 +404,7 @@ struct MarkArray
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (markRecord);
return SANITIZE_WITH_BASE (this, markRecord);
}
private:
@ -436,8 +436,9 @@ struct SinglePosFormat1
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
valueFormat.sanitize_value (SANITIZE_ARG, CharP(this), values);
return SANITIZE_SELF ()
&& SANITIZE_WITH_BASE (this, coverage)
&& valueFormat.sanitize_value (SANITIZE_ARG, CharP(this), values);
}
private:
@ -478,8 +479,9 @@ struct SinglePosFormat2
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
valueFormat.sanitize_values (SANITIZE_ARG, CharP(this), values, valueCount);
return SANITIZE_SELF ()
&& SANITIZE_WITH_BASE (this, coverage)
&& valueFormat.sanitize_values (SANITIZE_ARG, CharP(this), values, valueCount);
}
private:
@ -616,8 +618,9 @@ struct PairPosFormat1
unsigned int len1 = valueFormat1.get_len ();
unsigned int len2 = valueFormat2.get_len ();
if (!(SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
likely (pairSet.sanitize (SANITIZE_ARG, CharP(this), len1 + len2)))) return false;
if (!(SANITIZE_SELF ()
&& SANITIZE_WITH_BASE (this, coverage)
&& likely (pairSet.sanitize (SANITIZE_ARG, CharP(this), len1 + len2)))) return false;
if (!(valueFormat1.has_device () || valueFormat2.has_device ())) return true;
@ -700,8 +703,10 @@ struct PairPosFormat2
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
if (!(SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
SANITIZE_THIS (classDef1) && SANITIZE_THIS (classDef2))) return false;
if (!(SANITIZE_SELF ()
&& SANITIZE_WITH_BASE (this, coverage)
&& SANITIZE_WITH_BASE (this, classDef1)
&& SANITIZE_WITH_BASE (this, classDef2))) return false;
unsigned int len1 = valueFormat1.get_len ();
unsigned int len2 = valueFormat2.get_len ();
@ -979,8 +984,8 @@ struct CursivePosFormat1
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (coverage)
&& SANITIZE_THIS (entryExitRecord);
return SANITIZE_WITH_BASE (this, coverage)
&& SANITIZE_WITH_BASE (this, entryExitRecord);
}
private:
@ -1068,9 +1073,9 @@ struct MarkBasePosFormat1
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_SELF ()
&& SANITIZE_THIS (markCoverage)
&& SANITIZE_THIS (baseCoverage)
&& SANITIZE_THIS (markArray)
&& SANITIZE_WITH_BASE (this, markCoverage)
&& SANITIZE_WITH_BASE (this, baseCoverage)
&& SANITIZE_WITH_BASE (this, markArray)
&& likely (baseArray.sanitize (SANITIZE_ARG, CharP(this), classCount));
}
@ -1192,9 +1197,9 @@ struct MarkLigPosFormat1
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_SELF ()
&& SANITIZE_THIS (markCoverage)
&& SANITIZE_THIS (ligatureCoverage)
&& SANITIZE_THIS (markArray)
&& SANITIZE_WITH_BASE (this, markCoverage)
&& SANITIZE_WITH_BASE (this, ligatureCoverage)
&& SANITIZE_WITH_BASE (this, markArray)
&& likely (ligatureArray.sanitize (SANITIZE_ARG, CharP(this), classCount));
}
@ -1295,9 +1300,9 @@ struct MarkMarkPosFormat1
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_SELF ()
&& SANITIZE_THIS (mark1Coverage)
&& SANITIZE_THIS (mark2Coverage)
&& SANITIZE_THIS (mark1Array)
&& SANITIZE_WITH_BASE (this, mark1Coverage)
&& SANITIZE_WITH_BASE (this, mark2Coverage)
&& SANITIZE_WITH_BASE (this, mark1Array)
&& likely (mark2Array.sanitize (SANITIZE_ARG, CharP(this), classCount));
}
@ -1535,7 +1540,7 @@ struct PosLookup : Lookup
TRACE_SANITIZE ();
if (unlikely (!Lookup::sanitize (SANITIZE_ARG))) return false;
OffsetArrayOf<PosLookupSubTable> &list = CastR<OffsetArrayOf<PosLookupSubTable> > (subTable);
return SANITIZE_THIS (list);
return SANITIZE_WITH_BASE (this, list);
}
};
@ -1563,7 +1568,7 @@ struct GPOS : GSUBGPOS
TRACE_SANITIZE ();
if (unlikely (!GSUBGPOS::sanitize (SANITIZE_ARG))) return false;
OffsetTo<PosLookupList> &list = CastR<OffsetTo<PosLookupList> > (lookupList);
return SANITIZE_THIS (list);
return SANITIZE_WITH_BASE (this, list);
}
};
ASSERT_SIZE (GPOS, 10);

View File

@ -56,7 +56,8 @@ struct SingleSubstFormat1
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (coverage) && SANITIZE (deltaGlyphID);
return SANITIZE_WITH_BASE (this, coverage)
&& SANITIZE (deltaGlyphID);
}
private:
@ -98,7 +99,8 @@ struct SingleSubstFormat2
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (coverage) && SANITIZE (substitute);
return SANITIZE_WITH_BASE (this, coverage)
&& SANITIZE (substitute);
}
private:
@ -208,8 +210,8 @@ struct MultipleSubstFormat1
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (coverage)
&& SANITIZE_THIS (sequence);
return SANITIZE_WITH_BASE (this, coverage)
&& SANITIZE_WITH_BASE (this, sequence);
}
private:
@ -304,8 +306,8 @@ struct AlternateSubstFormat1
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (coverage)
&& SANITIZE_THIS (alternateSet);
return SANITIZE_WITH_BASE (this, coverage)
&& SANITIZE_WITH_BASE (this, alternateSet);
}
private:
@ -456,7 +458,7 @@ struct LigatureSet
public:
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (ligature);
return SANITIZE_WITH_BASE (this, ligature);
}
private:
@ -488,8 +490,8 @@ struct LigatureSubstFormat1
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (coverage)
&& SANITIZE_THIS (ligatureSet);
return SANITIZE_WITH_BASE (this, coverage)
&& SANITIZE_WITH_BASE (this, ligatureSet);
}
private:
@ -619,10 +621,11 @@ struct ReverseChainSingleSubstFormat1
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
if (!(SANITIZE_THIS (coverage) && SANITIZE_THIS (backtrack)))
if (!(SANITIZE_WITH_BASE (this, coverage)
&& SANITIZE_WITH_BASE (this, backtrack)))
return false;
OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
if (!SANITIZE_THIS (lookahead))
if (!SANITIZE_WITH_BASE (this, lookahead))
return false;
ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
return SANITIZE (substitute);
@ -848,7 +851,7 @@ struct SubstLookup : Lookup
TRACE_SANITIZE ();
if (unlikely (!Lookup::sanitize (SANITIZE_ARG))) return false;
OffsetArrayOf<SubstLookupSubTable> &list = CastR<OffsetArrayOf<SubstLookupSubTable> > (subTable);
return SANITIZE_THIS (list);
return SANITIZE_WITH_BASE (this, list);
}
};
@ -877,7 +880,7 @@ struct GSUB : GSUBGPOS
TRACE_SANITIZE ();
if (unlikely (!GSUBGPOS::sanitize (SANITIZE_ARG))) return false;
OffsetTo<SubstLookupList> &list = CastR<OffsetTo<SubstLookupList> > (lookupList);
return SANITIZE_THIS (list);
return SANITIZE_WITH_BASE (this, list);
}
};
ASSERT_SIZE (GSUB, 10);

View File

@ -326,7 +326,7 @@ struct RuleSet
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (rule);
return SANITIZE_WITH_BASE (this, rule);
}
private:
@ -358,8 +358,8 @@ struct ContextFormat1
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (coverage)
&& SANITIZE_THIS (ruleSet);
return SANITIZE_WITH_BASE (this, coverage)
&& SANITIZE_WITH_BASE (this, ruleSet);
}
private:
@ -401,9 +401,9 @@ struct ContextFormat2
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (coverage)
&& SANITIZE_THIS (classDef)
&& SANITIZE_THIS (ruleSet);
return SANITIZE_WITH_BASE (this, coverage)
&& SANITIZE_WITH_BASE (this, classDef)
&& SANITIZE_WITH_BASE (this, ruleSet);
}
private:
@ -450,7 +450,7 @@ struct ContextFormat3
unsigned int count = glyphCount;
if (!SANITIZE_ARRAY (coverage, OffsetTo<Coverage>::get_size (), glyphCount)) return false;
for (unsigned int i = 0; i < count; i++)
if (!SANITIZE_THIS (coverage[i])) return false;
if (!SANITIZE_WITH_BASE (this, coverage[i])) return false;
LookupRecord &lookupRecord = StructAtOffset<LookupRecord> (coverage, OffsetTo<Coverage>::get_size () * glyphCount);
return SANITIZE_ARRAY (&lookupRecord, LookupRecord::get_size (), lookupCount);
}
@ -613,7 +613,7 @@ struct ChainRuleSet
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (rule);
return SANITIZE_WITH_BASE (this, rule);
}
private:
@ -645,8 +645,8 @@ struct ChainContextFormat1
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (coverage)
&& SANITIZE_THIS (ruleSet);
return SANITIZE_WITH_BASE (this, coverage)
&& SANITIZE_WITH_BASE (this, ruleSet);
}
private:
@ -692,11 +692,11 @@ struct ChainContextFormat2
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_THIS (coverage)
&& SANITIZE_THIS (backtrackClassDef)
&& SANITIZE_THIS (inputClassDef)
&& SANITIZE_THIS (lookaheadClassDef)
&& SANITIZE_THIS (ruleSet);
return SANITIZE_WITH_BASE (this, coverage)
&& SANITIZE_WITH_BASE (this, backtrackClassDef)
&& SANITIZE_WITH_BASE (this, inputClassDef)
&& SANITIZE_WITH_BASE (this, lookaheadClassDef)
&& SANITIZE_WITH_BASE (this, ruleSet);
}
private:
@ -754,11 +754,11 @@ struct ChainContextFormat3
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
if (!SANITIZE_THIS (backtrack)) return false;
if (!SANITIZE_WITH_BASE (this, backtrack)) return false;
OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
if (!SANITIZE_THIS (input)) return false;
if (!SANITIZE_WITH_BASE (this, input)) return false;
OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
if (!SANITIZE_THIS (lookahead)) return false;
if (!SANITIZE_WITH_BASE (this, lookahead)) return false;
ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
return SANITIZE (lookup);
}
@ -918,9 +918,9 @@ struct GSUBGPOS
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE (version) && likely (version.major == 1)
&& SANITIZE_THIS (scriptList)
&& SANITIZE_THIS (featureList)
&& SANITIZE_THIS (lookupList);
&& SANITIZE_WITH_BASE (this, scriptList)
&& SANITIZE_WITH_BASE (this, featureList)
&& SANITIZE_WITH_BASE (this, lookupList);
}
protected: