[HB] Add a NEXT() macro
This commit is contained in:
parent
918572fc87
commit
284899ccbe
|
@ -50,6 +50,8 @@
|
|||
#define DECONST_CAST(T,X,Ofs) (*(reinterpret_cast<T *>((char *)CONST_CHARP(&(X)) + Ofs)))
|
||||
#define CAST(T,X,Ofs) (*(reinterpret_cast<T *>(CHARP(&(X)) + Ofs)))
|
||||
|
||||
#define CONST_NEXT(T,X) (*(reinterpret_cast<const T *>(CONST_CHARP(&(X)) + (X).get_size ())))
|
||||
#define NEXT(T,X) (*(reinterpret_cast<T *>(CHARP(&(X)) + (X).get_size ())))
|
||||
|
||||
/*
|
||||
* Class features
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -578,8 +578,8 @@ struct ReverseChainSingleSubstFormat1
|
|||
if (HB_LIKELY (index == NOT_COVERED))
|
||||
return false;
|
||||
|
||||
const OffsetArrayOf<Coverage> &lookahead = CONST_CAST (OffsetArrayOf<Coverage>, backtrack, backtrack.get_size ());
|
||||
const ArrayOf<GlyphID> &substitute = CONST_CAST (ArrayOf<GlyphID>, lookahead, lookahead.get_size ());
|
||||
const OffsetArrayOf<Coverage> &lookahead = CONST_NEXT (OffsetArrayOf<Coverage>, backtrack);
|
||||
const ArrayOf<GlyphID> &substitute = CONST_NEXT (ArrayOf<GlyphID>, 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<Coverage> &lookahead = CAST (OffsetArrayOf<Coverage>, backtrack, backtrack.get_size ());
|
||||
OffsetArrayOf<Coverage> &lookahead = NEXT (OffsetArrayOf<Coverage>, backtrack);
|
||||
if (!SANITIZE_THIS (lookahead))
|
||||
return false;
|
||||
ArrayOf<GlyphID> &substitute = CAST (ArrayOf<GlyphID>, lookahead, lookahead.get_size ());
|
||||
ArrayOf<GlyphID> &substitute = NEXT (ArrayOf<GlyphID>, lookahead);
|
||||
return SANITIZE (substitute);
|
||||
}
|
||||
|
||||
|
|
|
@ -522,9 +522,9 @@ struct ChainRule
|
|||
private:
|
||||
inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
|
||||
{
|
||||
const HeadlessArrayOf<USHORT> &input = CONST_CAST (HeadlessArrayOf<USHORT>, backtrack, backtrack.get_size ());
|
||||
const ArrayOf<USHORT> &lookahead = CONST_CAST (ArrayOf<USHORT>, input, input.get_size ());
|
||||
const ArrayOf<LookupRecord> &lookup = CONST_CAST (ArrayOf<LookupRecord>, lookahead, lookahead.get_size ());
|
||||
const HeadlessArrayOf<USHORT> &input = CONST_NEXT (HeadlessArrayOf<USHORT>, backtrack);
|
||||
const ArrayOf<USHORT> &lookahead = CONST_NEXT (ArrayOf<USHORT>, input);
|
||||
const ArrayOf<LookupRecord> &lookup = CONST_NEXT (ArrayOf<LookupRecord>, 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<USHORT> &input = CAST (HeadlessArrayOf<USHORT>, backtrack, backtrack.get_size ());
|
||||
HeadlessArrayOf<USHORT> &input = NEXT (HeadlessArrayOf<USHORT>, backtrack);
|
||||
if (!SANITIZE (input)) return false;
|
||||
ArrayOf<USHORT> &lookahead = CAST (ArrayOf<USHORT>, input, input.get_size ());
|
||||
ArrayOf<USHORT> &lookahead = NEXT (ArrayOf<USHORT>, input);
|
||||
if (!SANITIZE (lookahead)) return false;
|
||||
ArrayOf<LookupRecord> &lookup = CAST (ArrayOf<LookupRecord>, lookahead, lookahead.get_size ());
|
||||
ArrayOf<LookupRecord> &lookup = NEXT (ArrayOf<LookupRecord>, 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<Coverage> &input = CONST_CAST (OffsetArrayOf<Coverage>, backtrack, backtrack.get_size ());
|
||||
const OffsetArrayOf<Coverage> &input = CONST_NEXT (OffsetArrayOf<Coverage>, backtrack);
|
||||
|
||||
unsigned int index = (this+input[0]) (IN_CURGLYPH ());
|
||||
if (HB_LIKELY (index == NOT_COVERED))
|
||||
return false;
|
||||
|
||||
const OffsetArrayOf<Coverage> &lookahead = CONST_CAST (OffsetArrayOf<Coverage>, input, input.get_size ());
|
||||
const ArrayOf<LookupRecord> &lookup = CONST_CAST (ArrayOf<LookupRecord>, lookahead, lookahead.get_size ());
|
||||
const OffsetArrayOf<Coverage> &lookahead = CONST_NEXT (OffsetArrayOf<Coverage>, input);
|
||||
const ArrayOf<LookupRecord> &lookup = CONST_NEXT (ArrayOf<LookupRecord>, 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<Coverage> &input = CAST (OffsetArrayOf<Coverage>, backtrack, backtrack.get_size ());
|
||||
OffsetArrayOf<Coverage> &input = NEXT (OffsetArrayOf<Coverage>, backtrack);
|
||||
if (!SANITIZE_THIS (input)) return false;
|
||||
OffsetArrayOf<Coverage> &lookahead = CAST (OffsetArrayOf<Coverage>, input, input.get_size ());
|
||||
OffsetArrayOf<Coverage> &lookahead = NEXT (OffsetArrayOf<Coverage>, input);
|
||||
if (!SANITIZE_THIS (lookahead)) return false;
|
||||
ArrayOf<LookupRecord> &lookup = CAST (ArrayOf<LookupRecord>, lookahead, lookahead.get_size ());
|
||||
ArrayOf<LookupRecord> &lookup = NEXT (ArrayOf<LookupRecord>, lookahead);
|
||||
return SANITIZE (lookup);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue