summaryrefslogtreecommitdiff
path: root/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh')
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh69
1 files changed, 32 insertions, 37 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh
index 95d6b312ab5..27ade28fe19 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh
@@ -77,7 +77,7 @@ struct LookupFormat0
template <typename T>
struct LookupSegmentSingle
{
- enum { TerminationWordCount = 2 };
+ static constexpr unsigned TerminationWordCount = 2u;
int cmp (hb_codepoint_t g) const
{ return g < first ? -1 : g <= last ? 0 : +1 ; }
@@ -136,7 +136,7 @@ struct LookupFormat2
template <typename T>
struct LookupSegmentArray
{
- enum { TerminationWordCount = 2 };
+ static constexpr unsigned TerminationWordCount = 2u;
const T* get_value (hb_codepoint_t glyph_id, const void *base) const
{
@@ -164,7 +164,7 @@ struct LookupSegmentArray
GlyphID last; /* Last GlyphID in this segment */
GlyphID first; /* First GlyphID in this segment */
- OffsetTo<UnsizedArrayOf<T>, HBUINT16, false>
+ NNOffsetTo<UnsizedArrayOf<T> >
valuesZ; /* A 16-bit offset from the start of
* the table to the data. */
public:
@@ -207,7 +207,7 @@ struct LookupFormat4
template <typename T>
struct LookupSingle
{
- enum { TerminationWordCount = 1 };
+ static constexpr unsigned TerminationWordCount = 1u;
int cmp (hb_codepoint_t g) const { return glyph.cmp (g); }
@@ -394,7 +394,7 @@ struct Lookup
case 4: return_trace (u.format4.sanitize (c, base));
case 6: return_trace (u.format6.sanitize (c, base));
case 8: return_trace (u.format8.sanitize (c, base));
- case 10: return_trace (false); /* No need to support format10 apparently */
+ case 10: return_trace (false); /* We don't support format10 here currently. */
default:return_trace (true);
}
}
@@ -511,9 +511,10 @@ struct StateTable
const Entry<Extra> *get_entries () const
{ return (this+entryTable).arrayZ; }
- const Entry<Extra> *get_entryZ (int state, unsigned int klass) const
+ const Entry<Extra> &get_entry (int state, unsigned int klass) const
{
- if (unlikely (klass >= nClasses)) return nullptr;
+ if (unlikely (klass >= nClasses))
+ klass = StateTable<Types, Entry<Extra> >::CLASS_OUT_OF_BOUNDS;
const HBUSHORT *states = (this+stateArrayTable).arrayZ;
const Entry<Extra> *entries = (this+entryTable).arrayZ;
@@ -521,7 +522,7 @@ struct StateTable
unsigned int entry = states[state * nClasses + klass];
DEBUG_MSG (APPLY, nullptr, "e%u", entry);
- return &entries[entry];
+ return entries[entry];
}
bool sanitize (hb_sanitize_context_t *c,
@@ -529,6 +530,7 @@ struct StateTable
{
TRACE_SANITIZE (this);
if (unlikely (!(c->check_struct (this) &&
+ nClasses >= 4 /* Ensure pre-defined classes fit. */ &&
classTable.sanitize (c, this)))) return_trace (false);
const HBUSHORT *states = (this+stateArrayTable).arrayZ;
@@ -571,7 +573,7 @@ struct StateTable
-min_state,
row_stride)))
return_trace (false);
- if ((c->max_ops -= state_neg - min_state) < 0)
+ if ((c->max_ops -= state_neg - min_state) <= 0)
return_trace (false);
{ /* Sweep new states. */
const HBUSHORT *stop = &states[min_state * num_classes];
@@ -590,7 +592,7 @@ struct StateTable
max_state + 1,
row_stride)))
return_trace (false);
- if ((c->max_ops -= max_state - state_pos + 1) < 0)
+ if ((c->max_ops -= max_state - state_pos + 1) <= 0)
return_trace (false);
{ /* Sweep new states. */
if (unlikely (hb_unsigned_mul_overflows ((max_state + 1), num_classes)))
@@ -606,7 +608,7 @@ struct StateTable
if (unlikely (!c->check_array (entries, num_entries)))
return_trace (false);
- if ((c->max_ops -= num_entries - entry) < 0)
+ if ((c->max_ops -= num_entries - entry) <= 0)
return_trace (false);
{ /* Sweep new entries. */
const Entry<Extra> *stop = &entries[num_entries];
@@ -629,11 +631,11 @@ struct StateTable
protected:
HBUINT nClasses; /* Number of classes, which is the number of indices
* in a single line in the state array. */
- OffsetTo<ClassType, HBUINT, false>
+ NNOffsetTo<ClassType, HBUINT>
classTable; /* Offset to the class table. */
- OffsetTo<UnsizedArrayOf<HBUSHORT>, HBUINT, false>
+ NNOffsetTo<UnsizedArrayOf<HBUSHORT>, HBUINT>
stateArrayTable;/* Offset to the state array. */
- OffsetTo<UnsizedArrayOf<Entry<Extra> >, HBUINT, false>
+ NNOffsetTo<UnsizedArrayOf<Entry<Extra> >, HBUINT>
entryTable; /* Offset to the entry array. */
public:
@@ -669,7 +671,7 @@ struct ClassTable
struct ObsoleteTypes
{
- enum { extended = false };
+ static constexpr bool extended = false;
typedef HBUINT16 HBUINT;
typedef HBUINT8 HBUSHORT;
typedef ClassTable<HBUINT8> ClassTypeNarrow;
@@ -699,7 +701,7 @@ struct ObsoleteTypes
};
struct ExtendedTypes
{
- enum { extended = true };
+ static constexpr bool extended = true;
typedef HBUINT32 HBUINT;
typedef HBUINT16 HBUSHORT;
typedef Lookup<HBUINT16> ClassTypeNarrow;
@@ -707,22 +709,22 @@ struct ExtendedTypes
template <typename T>
static unsigned int offsetToIndex (unsigned int offset,
- const void *base,
- const T *array)
+ const void *base HB_UNUSED,
+ const T *array HB_UNUSED)
{
return offset;
}
template <typename T>
static unsigned int byteOffsetToIndex (unsigned int offset,
- const void *base,
- const T *array)
+ const void *base HB_UNUSED,
+ const T *array HB_UNUSED)
{
return offset / 2;
}
template <typename T>
static unsigned int wordOffsetToIndex (unsigned int offset,
- const void *base,
- const T *array)
+ const void *base HB_UNUSED,
+ const T *array HB_UNUSED)
{
return offset;
}
@@ -745,16 +747,13 @@ struct StateTableDriver
buffer->clear_output ();
int state = StateTable<Types, EntryData>::STATE_START_OF_TEXT;
- bool last_was_dont_advance = false;
for (buffer->idx = 0; buffer->successful;)
{
unsigned int klass = buffer->idx < buffer->len ?
machine.get_class (buffer->info[buffer->idx].codepoint, num_glyphs) :
(unsigned) StateTable<Types, EntryData>::CLASS_END_OF_TEXT;
DEBUG_MSG (APPLY, nullptr, "c%u at %u", klass, buffer->idx);
- const Entry<EntryData> *entry = machine.get_entryZ (state, klass);
- if (unlikely (!entry))
- break;
+ const Entry<EntryData> &entry = machine.get_entry (state, klass);
/* Unsafe-to-break before this if not in state 0, as things might
* go differently if we start from state 0 here.
@@ -765,31 +764,28 @@ struct StateTableDriver
/* If there's no action and we're just epsilon-transitioning to state 0,
* safe to break. */
if (c->is_actionable (this, entry) ||
- !(entry->newState == StateTable<Types, EntryData>::STATE_START_OF_TEXT &&
- entry->flags == context_t::DontAdvance))
+ !(entry.newState == StateTable<Types, EntryData>::STATE_START_OF_TEXT &&
+ entry.flags == context_t::DontAdvance))
buffer->unsafe_to_break_from_outbuffer (buffer->backtrack_len () - 1, buffer->idx + 1);
}
/* Unsafe-to-break if end-of-text would kick in here. */
if (buffer->idx + 2 <= buffer->len)
{
- const Entry<EntryData> *end_entry = machine.get_entryZ (state, 0);
+ const Entry<EntryData> &end_entry = machine.get_entry (state, StateTable<Types, EntryData>::CLASS_END_OF_TEXT);
if (c->is_actionable (this, end_entry))
buffer->unsafe_to_break (buffer->idx, buffer->idx + 2);
}
- if (unlikely (!c->transition (this, entry)))
- break;
-
- last_was_dont_advance = (entry->flags & context_t::DontAdvance) && buffer->max_ops-- > 0;
+ c->transition (this, entry);
- state = machine.new_state (entry->newState);
+ state = machine.new_state (entry.newState);
DEBUG_MSG (APPLY, nullptr, "s%d", state);
if (buffer->idx == buffer->len)
break;
- if (!last_was_dont_advance)
+ if (!(entry.flags & context_t::DontAdvance) || buffer->max_ops-- <= 0)
buffer->next_glyph ();
}
@@ -825,7 +821,6 @@ struct hb_aat_apply_context_t :
hb_buffer_t *buffer;
hb_sanitize_context_t sanitizer;
const ankr *ankr_table;
- const char *ankr_end;
/* Unused. For debug tracing only. */
unsigned int lookup_index;
@@ -838,7 +833,7 @@ struct hb_aat_apply_context_t :
HB_INTERNAL ~hb_aat_apply_context_t ();
- HB_INTERNAL void set_ankr_table (const AAT::ankr *ankr_table_, const char *ankr_end_);
+ HB_INTERNAL void set_ankr_table (const AAT::ankr *ankr_table_);
void set_lookup_index (unsigned int i) { lookup_index = i; }
};