Move context_length into apply_context
This commit is contained in:
parent
94a23aaeca
commit
969c9705ae
|
@ -577,7 +577,7 @@ struct PairPosFormat1
|
|||
inline bool apply (APPLY_ARG_DEF) const
|
||||
{
|
||||
TRACE_APPLY ();
|
||||
unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context_length);
|
||||
unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context->context_length);
|
||||
if (unlikely (context->buffer->in_pos + 2 > end))
|
||||
return false;
|
||||
|
||||
|
@ -670,7 +670,7 @@ struct PairPosFormat2
|
|||
inline bool apply (APPLY_ARG_DEF) const
|
||||
{
|
||||
TRACE_APPLY ();
|
||||
unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context_length);
|
||||
unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context->context_length);
|
||||
if (unlikely (context->buffer->in_pos + 2 > end))
|
||||
return false;
|
||||
|
||||
|
@ -1495,6 +1495,7 @@ struct PosLookup : Lookup
|
|||
|
||||
context->layout = layout;
|
||||
context->buffer = buffer;
|
||||
context->context_length = context_length;
|
||||
context->nesting_level_left = nesting_level_left;
|
||||
context->lookup_flag = get_flag ();
|
||||
|
||||
|
@ -1608,10 +1609,10 @@ static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
|
|||
if (unlikely (context->nesting_level_left == 0))
|
||||
return false;
|
||||
|
||||
if (unlikely (context_length < 1))
|
||||
if (unlikely (context->context_length < 1))
|
||||
return false;
|
||||
|
||||
return l.apply_once (context->layout, context->buffer, context_length, context->nesting_level_left - 1, apply_depth + 1);
|
||||
return l.apply_once (context->layout, context->buffer, context->context_length, context->nesting_level_left - 1, apply_depth + 1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -367,7 +367,7 @@ struct Ligature
|
|||
TRACE_APPLY ();
|
||||
unsigned int i, j;
|
||||
unsigned int count = component.len;
|
||||
unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context_length);
|
||||
unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context->context_length);
|
||||
if (unlikely (context->buffer->in_pos + count > end))
|
||||
return false;
|
||||
|
||||
|
@ -597,7 +597,7 @@ struct ReverseChainSingleSubstFormat1
|
|||
inline bool apply (APPLY_ARG_DEF) const
|
||||
{
|
||||
TRACE_APPLY ();
|
||||
if (unlikely (context_length != NO_CONTEXT))
|
||||
if (unlikely (context->context_length != NO_CONTEXT))
|
||||
return false; /* No chaining to this type */
|
||||
|
||||
unsigned int index = (this+coverage) (IN_CURGLYPH ());
|
||||
|
@ -780,6 +780,7 @@ struct SubstLookup : Lookup
|
|||
|
||||
context->layout = layout;
|
||||
context->buffer = buffer;
|
||||
context->context_length = context_length;
|
||||
context->nesting_level_left = nesting_level_left;
|
||||
context->lookup_flag = get_flag ();
|
||||
|
||||
|
@ -927,10 +928,10 @@ static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
|
|||
if (unlikely (context->nesting_level_left == 0))
|
||||
return false;
|
||||
|
||||
if (unlikely (context_length < 1))
|
||||
if (unlikely (context->context_length < 1))
|
||||
return false;
|
||||
|
||||
return l.apply_once (context->layout, context->buffer, context_length, context->nesting_level_left - 1, apply_depth + 1);
|
||||
return l.apply_once (context->layout, context->buffer, context->context_length, context->nesting_level_left - 1, apply_depth + 1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,17 +44,16 @@
|
|||
|
||||
#define APPLY_ARG_DEF \
|
||||
hb_apply_context_t *context, \
|
||||
unsigned int context_length HB_UNUSED, \
|
||||
unsigned int apply_depth HB_UNUSED
|
||||
#define APPLY_ARG \
|
||||
context, \
|
||||
context_length, \
|
||||
(HB_DEBUG_APPLY ? apply_depth + 1 : 0)
|
||||
|
||||
struct hb_apply_context_t
|
||||
{
|
||||
hb_ot_layout_context_t *layout;
|
||||
hb_buffer_t *buffer;
|
||||
unsigned int context_length;
|
||||
unsigned int nesting_level_left;
|
||||
unsigned int lookup_flag;
|
||||
unsigned int property; /* propety of first glyph (TODO remove) */
|
||||
|
@ -103,7 +102,7 @@ static inline bool match_input (APPLY_ARG_DEF,
|
|||
unsigned int *context_length_out)
|
||||
{
|
||||
unsigned int i, j;
|
||||
unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context_length);
|
||||
unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context->context_length);
|
||||
if (unlikely (context->buffer->in_pos + count > end))
|
||||
return false;
|
||||
|
||||
|
@ -158,7 +157,7 @@ static inline bool match_lookahead (APPLY_ARG_DEF,
|
|||
unsigned int offset)
|
||||
{
|
||||
unsigned int i, j;
|
||||
unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context_length);
|
||||
unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context->context_length);
|
||||
if (unlikely (context->buffer->in_pos + offset + count > end))
|
||||
return false;
|
||||
|
||||
|
@ -201,7 +200,7 @@ static inline bool apply_lookup (APPLY_ARG_DEF,
|
|||
const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
|
||||
apply_lookup_func_t apply_func)
|
||||
{
|
||||
unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context_length);
|
||||
unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context->context_length);
|
||||
if (unlikely (context->buffer->in_pos + count > end))
|
||||
return false;
|
||||
|
||||
|
@ -267,14 +266,20 @@ static inline bool context_lookup (APPLY_ARG_DEF,
|
|||
const LookupRecord lookupRecord[],
|
||||
ContextLookupContext &lookup_context)
|
||||
{
|
||||
return match_input (APPLY_ARG,
|
||||
unsigned int new_context_length;
|
||||
if (!match_input (APPLY_ARG,
|
||||
inputCount, input,
|
||||
lookup_context.funcs.match, lookup_context.match_data,
|
||||
&context_length) &&
|
||||
apply_lookup (APPLY_ARG,
|
||||
&new_context_length)) return false;
|
||||
unsigned int old_context_length;
|
||||
old_context_length = context->context_length;
|
||||
context->context_length = new_context_length;
|
||||
bool ret = apply_lookup (APPLY_ARG,
|
||||
inputCount,
|
||||
lookupCount, lookupRecord,
|
||||
lookup_context.funcs.apply);
|
||||
context->context_length = old_context_length;
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct Rule
|
||||
|
@ -529,11 +534,11 @@ static inline bool chain_context_lookup (APPLY_ARG_DEF,
|
|||
/* First guess */
|
||||
if (unlikely (context->buffer->out_pos < backtrackCount ||
|
||||
context->buffer->in_pos + inputCount + lookaheadCount > context->buffer->in_length ||
|
||||
inputCount + lookaheadCount > context_length))
|
||||
inputCount + lookaheadCount > context->context_length))
|
||||
return false;
|
||||
|
||||
unsigned int offset;
|
||||
return match_backtrack (APPLY_ARG,
|
||||
if (!(match_backtrack (APPLY_ARG,
|
||||
backtrackCount, backtrack,
|
||||
lookup_context.funcs.match, lookup_context.match_data[0]) &&
|
||||
match_input (APPLY_ARG,
|
||||
|
@ -543,12 +548,17 @@ static inline bool chain_context_lookup (APPLY_ARG_DEF,
|
|||
match_lookahead (APPLY_ARG,
|
||||
lookaheadCount, lookahead,
|
||||
lookup_context.funcs.match, lookup_context.match_data[2],
|
||||
offset) &&
|
||||
(context_length = offset, true) &&
|
||||
apply_lookup (APPLY_ARG,
|
||||
offset))) return false;
|
||||
|
||||
unsigned int old_context_length;
|
||||
old_context_length = context->context_length;
|
||||
context->context_length = offset;
|
||||
bool ret = apply_lookup (APPLY_ARG,
|
||||
inputCount,
|
||||
lookupCount, lookupRecord,
|
||||
lookup_context.funcs.apply);
|
||||
context->context_length = old_context_length;
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct ChainRule
|
||||
|
|
Loading…
Reference in New Issue