diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 29e231ebc..7fd96a00b 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -50,6 +50,8 @@ #define DECONST_CAST(T,X,Ofs) (*(reinterpret_cast((char *)CONST_CHARP(&(X)) + Ofs))) #define CAST(T,X,Ofs) (*(reinterpret_cast(CHARP(&(X)) + Ofs))) +#define CONST_NEXT(T,X) (*(reinterpret_cast(CONST_CHARP(&(X)) + (X).get_size ()))) +#define NEXT(T,X) (*(reinterpret_cast(CHARP(&(X)) + (X).get_size ()))) /* * Class features diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index c0d1df933..a4032d9a9 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -269,7 +269,7 @@ struct Lookup unsigned int flag = lookupFlag; if (HB_UNLIKELY (flag & LookupFlag::UseMarkFilteringSet)) { - const USHORT &markFilteringSet = CONST_CAST (USHORT, subTable, subTable.get_size ()); + const USHORT &markFilteringSet = CONST_NEXT (USHORT, subTable); flag += (markFilteringSet << 16); } return flag; @@ -280,7 +280,7 @@ struct Lookup if (!(SANITIZE_SELF () && SANITIZE_THIS (subTable))) return false; if (HB_UNLIKELY (lookupFlag & LookupFlag::UseMarkFilteringSet)) { - USHORT &markFilteringSet = CAST (USHORT, subTable, subTable.get_size ()); + USHORT &markFilteringSet = NEXT (USHORT, subTable); if (!SANITIZE (markFilteringSet)) return false; } return true; diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh index 20431aedc..7539bc22f 100644 --- a/src/hb-ot-layout-gsub-private.hh +++ b/src/hb-ot-layout-gsub-private.hh @@ -578,8 +578,8 @@ struct ReverseChainSingleSubstFormat1 if (HB_LIKELY (index == NOT_COVERED)) return false; - const OffsetArrayOf &lookahead = CONST_CAST (OffsetArrayOf, backtrack, backtrack.get_size ()); - const ArrayOf &substitute = CONST_CAST (ArrayOf, lookahead, lookahead.get_size ()); + const OffsetArrayOf &lookahead = CONST_NEXT (OffsetArrayOf, backtrack); + const ArrayOf &substitute = CONST_NEXT (ArrayOf, lookahead); if (match_backtrack (APPLY_ARG, backtrack.len, (USHORT *) backtrack.array, @@ -601,10 +601,10 @@ struct ReverseChainSingleSubstFormat1 SANITIZE_DEBUG (); if (!SANITIZE_THIS2 (coverage, backtrack)) return false; - OffsetArrayOf &lookahead = CAST (OffsetArrayOf, backtrack, backtrack.get_size ()); + OffsetArrayOf &lookahead = NEXT (OffsetArrayOf, backtrack); if (!SANITIZE_THIS (lookahead)) return false; - ArrayOf &substitute = CAST (ArrayOf, lookahead, lookahead.get_size ()); + ArrayOf &substitute = NEXT (ArrayOf, lookahead); return SANITIZE (substitute); } diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index dcfaa910a..c322dfb09 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -522,9 +522,9 @@ struct ChainRule private: inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const { - const HeadlessArrayOf &input = CONST_CAST (HeadlessArrayOf, backtrack, backtrack.get_size ()); - const ArrayOf &lookahead = CONST_CAST (ArrayOf, input, input.get_size ()); - const ArrayOf &lookup = CONST_CAST (ArrayOf, lookahead, lookahead.get_size ()); + const HeadlessArrayOf &input = CONST_NEXT (HeadlessArrayOf, backtrack); + const ArrayOf &lookahead = CONST_NEXT (ArrayOf, input); + const ArrayOf &lookup = CONST_NEXT (ArrayOf, lookahead); return chain_context_lookup (APPLY_ARG, backtrack.len, backtrack.array, input.len, input.array + 1, @@ -538,11 +538,11 @@ struct ChainRule inline bool sanitize (SANITIZE_ARG_DEF) { SANITIZE_DEBUG (); if (!SANITIZE (backtrack)) return false; - HeadlessArrayOf &input = CAST (HeadlessArrayOf, backtrack, backtrack.get_size ()); + HeadlessArrayOf &input = NEXT (HeadlessArrayOf, backtrack); if (!SANITIZE (input)) return false; - ArrayOf &lookahead = CAST (ArrayOf, input, input.get_size ()); + ArrayOf &lookahead = NEXT (ArrayOf, input); if (!SANITIZE (lookahead)) return false; - ArrayOf &lookup = CAST (ArrayOf, lookahead, lookahead.get_size ()); + ArrayOf &lookup = NEXT (ArrayOf, lookahead); return SANITIZE (lookup); } @@ -691,14 +691,14 @@ struct ChainContextFormat3 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const { - const OffsetArrayOf &input = CONST_CAST (OffsetArrayOf, backtrack, backtrack.get_size ()); + const OffsetArrayOf &input = CONST_NEXT (OffsetArrayOf, backtrack); unsigned int index = (this+input[0]) (IN_CURGLYPH ()); if (HB_LIKELY (index == NOT_COVERED)) return false; - const OffsetArrayOf &lookahead = CONST_CAST (OffsetArrayOf, input, input.get_size ()); - const ArrayOf &lookup = CONST_CAST (ArrayOf, lookahead, lookahead.get_size ()); + const OffsetArrayOf &lookahead = CONST_NEXT (OffsetArrayOf, input); + const ArrayOf &lookup = CONST_NEXT (ArrayOf, lookahead); struct ChainContextLookupContext lookup_context = { {match_coverage, apply_func}, {DECONST_CHARP(this), DECONST_CHARP(this), DECONST_CHARP(this)} @@ -715,11 +715,11 @@ struct ChainContextFormat3 inline bool sanitize (SANITIZE_ARG_DEF) { SANITIZE_DEBUG (); if (!SANITIZE_THIS (backtrack)) return false; - OffsetArrayOf &input = CAST (OffsetArrayOf, backtrack, backtrack.get_size ()); + OffsetArrayOf &input = NEXT (OffsetArrayOf, backtrack); if (!SANITIZE_THIS (input)) return false; - OffsetArrayOf &lookahead = CAST (OffsetArrayOf, input, input.get_size ()); + OffsetArrayOf &lookahead = NEXT (OffsetArrayOf, input); if (!SANITIZE_THIS (lookahead)) return false; - ArrayOf &lookup = CAST (ArrayOf, lookahead, lookahead.get_size ()); + ArrayOf &lookup = NEXT (ArrayOf, lookahead); return SANITIZE (lookup); }