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;
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;
context->layout = layout;
context->buffer = buffer;
+ context->context_length = context_length;
context->nesting_level_left = nesting_level_left;
context->lookup_flag = get_flag ();
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);
}
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;
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 ());
context->layout = layout;
context->buffer = buffer;
+ context->context_length = context_length;
context->nesting_level_left = nesting_level_left;
context->lookup_flag = get_flag ();
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);
}
#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) */
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;
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;
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;
const LookupRecord lookupRecord[],
ContextLookupContext &lookup_context)
{
- return match_input (APPLY_ARG,
- inputCount, input,
- lookup_context.funcs.match, lookup_context.match_data,
- &context_length) &&
- apply_lookup (APPLY_ARG,
- inputCount,
- lookupCount, lookupRecord,
- lookup_context.funcs.apply);
+ unsigned int new_context_length;
+ if (!match_input (APPLY_ARG,
+ inputCount, input,
+ lookup_context.funcs.match, lookup_context.match_data,
+ &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
/* 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,
- backtrackCount, backtrack,
- lookup_context.funcs.match, lookup_context.match_data[0]) &&
- match_input (APPLY_ARG,
- inputCount, input,
- lookup_context.funcs.match, lookup_context.match_data[1],
- &offset) &&
- match_lookahead (APPLY_ARG,
- lookaheadCount, lookahead,
- lookup_context.funcs.match, lookup_context.match_data[2],
- offset) &&
- (context_length = offset, true) &&
- apply_lookup (APPLY_ARG,
- inputCount,
- lookupCount, lookupRecord,
- lookup_context.funcs.apply);
+ if (!(match_backtrack (APPLY_ARG,
+ backtrackCount, backtrack,
+ lookup_context.funcs.match, lookup_context.match_data[0]) &&
+ match_input (APPLY_ARG,
+ inputCount, input,
+ lookup_context.funcs.match, lookup_context.match_data[1],
+ &offset) &&
+ match_lookahead (APPLY_ARG,
+ lookaheadCount, lookahead,
+ lookup_context.funcs.match, lookup_context.match_data[2],
+ 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