From bb029af943faa9905e652d58856998687e60c31d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 4 May 2010 15:28:52 -0400 Subject: [PATCH] Remove SANITIZE_THIS --- src/hb-open-file-private.hh | 2 +- src/hb-open-type-private.hh | 3 +- src/hb-ot-layout-common-private.hh | 4 +- src/hb-ot-layout-gdef-private.hh | 25 +++++++------ src/hb-ot-layout-gpos-private.hh | 55 +++++++++++++++------------- src/hb-ot-layout-gsub-private.hh | 29 ++++++++------- src/hb-ot-layout-gsubgpos-private.hh | 42 ++++++++++----------- 7 files changed, 85 insertions(+), 75 deletions(-) diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh index e09bd8076..547cef0d3 100644 --- a/src/hb-open-file-private.hh +++ b/src/hb-open-file-private.hh @@ -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: diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 82f92c1a3..75a539bcd 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -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)) diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index 1b3e27896..2c1c988f7 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -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: diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh index e5d092e36..da49fac75 100644 --- a/src/hb-ot-layout-gdef-private.hh +++ b/src/hb-ot-layout-gdef-private.hh @@ -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: diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh index 36345cbf2..5f3875186 100644 --- a/src/hb-ot-layout-gpos-private.hh +++ b/src/hb-ot-layout-gpos-private.hh @@ -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 &list = CastR > (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 &list = CastR > (lookupList); - return SANITIZE_THIS (list); + return SANITIZE_WITH_BASE (this, list); } }; ASSERT_SIZE (GPOS, 10); diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh index 170ec9636..3632c1fa8 100644 --- a/src/hb-ot-layout-gsub-private.hh +++ b/src/hb-ot-layout-gsub-private.hh @@ -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 &lookahead = StructAfter > (backtrack); - if (!SANITIZE_THIS (lookahead)) + if (!SANITIZE_WITH_BASE (this, lookahead)) return false; ArrayOf &substitute = StructAfter > (lookahead); return SANITIZE (substitute); @@ -848,7 +851,7 @@ struct SubstLookup : Lookup TRACE_SANITIZE (); if (unlikely (!Lookup::sanitize (SANITIZE_ARG))) return false; OffsetArrayOf &list = CastR > (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 &list = CastR > (lookupList); - return SANITIZE_THIS (list); + return SANITIZE_WITH_BASE (this, list); } }; ASSERT_SIZE (GSUB, 10); diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index 63239e525..c3a622b13 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -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::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 (coverage, OffsetTo::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 &input = StructAfter > (backtrack); - if (!SANITIZE_THIS (input)) return false; + if (!SANITIZE_WITH_BASE (this, input)) return false; OffsetArrayOf &lookahead = StructAfter > (input); - if (!SANITIZE_THIS (lookahead)) return false; + if (!SANITIZE_WITH_BASE (this, lookahead)) return false; ArrayOf &lookup = StructAfter > (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: