Remove unnecessary casts
This commit is contained in:
parent
09766b1ec5
commit
40cbefe858
|
@ -224,7 +224,7 @@ struct hb_sanitize_context_t
|
||||||
fprintf (stderr, "SANITIZE(%p) %-*d-> range [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \
|
fprintf (stderr, "SANITIZE(%p) %-*d-> range [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \
|
||||||
base,
|
base,
|
||||||
this->debug_depth, this->debug_depth,
|
this->debug_depth, this->debug_depth,
|
||||||
base, CharP(base)+len, len,
|
base, CharP(base) + len, len,
|
||||||
this->start, this->end,
|
this->start, this->end,
|
||||||
ret ? "pass" : "FAIL");
|
ret ? "pass" : "FAIL");
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ struct hb_sanitize_context_t
|
||||||
return likely (this->check_range (obj, sizeof (*obj)));
|
return likely (this->check_range (obj, sizeof (*obj)));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool can_edit (const char *base HB_UNUSED, unsigned int len HB_UNUSED)
|
inline bool can_edit (const void *base HB_UNUSED, unsigned int len HB_UNUSED)
|
||||||
{
|
{
|
||||||
this->edit_count++;
|
this->edit_count++;
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ struct hb_sanitize_context_t
|
||||||
base,
|
base,
|
||||||
this->debug_depth, this->debug_depth,
|
this->debug_depth, this->debug_depth,
|
||||||
this->edit_count,
|
this->edit_count,
|
||||||
base, base+len, len,
|
base, CharP(base)+len, len,
|
||||||
this->start, this->end,
|
this->start, this->end,
|
||||||
this->writable ? "granted" : "REJECTED");
|
this->writable ? "granted" : "REJECTED");
|
||||||
|
|
||||||
|
@ -496,7 +496,7 @@ struct GenericOffsetTo : OffsetType
|
||||||
private:
|
private:
|
||||||
/* Set the offset to Null */
|
/* Set the offset to Null */
|
||||||
inline bool neuter (hb_sanitize_context_t *context) {
|
inline bool neuter (hb_sanitize_context_t *context) {
|
||||||
if (context->can_edit (CharP(this), this->static_size)) {
|
if (context->can_edit (this, this->static_size)) {
|
||||||
this->set (0); /* 0 is Null offset */
|
this->set (0); /* 0 is Null offset */
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -627,12 +627,12 @@ struct OffsetListOf : OffsetArrayOf<Type>
|
||||||
|
|
||||||
inline bool sanitize (hb_sanitize_context_t *context) {
|
inline bool sanitize (hb_sanitize_context_t *context) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
return OffsetArrayOf<Type>::sanitize (context, CharP(this));
|
return OffsetArrayOf<Type>::sanitize (context, this);
|
||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline bool sanitize (hb_sanitize_context_t *context, T user_data) {
|
inline bool sanitize (hb_sanitize_context_t *context, T user_data) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
return OffsetArrayOf<Type>::sanitize (context, CharP(this), user_data);
|
return OffsetArrayOf<Type>::sanitize (context, this, user_data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ struct RecordListOf : RecordArrayOf<Type>
|
||||||
|
|
||||||
inline bool sanitize (hb_sanitize_context_t *context) {
|
inline bool sanitize (hb_sanitize_context_t *context) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
return RecordArrayOf<Type>::sanitize (context, CharP(this));
|
return RecordArrayOf<Type>::sanitize (context, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ struct ValueFormat : USHORT
|
||||||
{ return get_len () * Value::static_size; }
|
{ return get_len () * Value::static_size; }
|
||||||
|
|
||||||
void apply_value (hb_ot_layout_context_t *layout,
|
void apply_value (hb_ot_layout_context_t *layout,
|
||||||
const char *base,
|
const void *base,
|
||||||
const Value *values,
|
const Value *values,
|
||||||
hb_internal_glyph_position_t *glyph_pos) const
|
hb_internal_glyph_position_t *glyph_pos) const
|
||||||
{
|
{
|
||||||
|
@ -436,7 +436,7 @@ struct SinglePosFormat1
|
||||||
if (likely (index == NOT_COVERED))
|
if (likely (index == NOT_COVERED))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
valueFormat.apply_value (context->layout, CharP(this), values, CURPOSITION ());
|
valueFormat.apply_value (context->layout, this, values, CURPOSITION ());
|
||||||
|
|
||||||
context->buffer->in_pos++;
|
context->buffer->in_pos++;
|
||||||
return true;
|
return true;
|
||||||
|
@ -446,7 +446,7 @@ struct SinglePosFormat1
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
return context->check_struct (this)
|
return context->check_struct (this)
|
||||||
&& coverage.sanitize (context, this)
|
&& coverage.sanitize (context, this)
|
||||||
&& valueFormat.sanitize_value (context, CharP(this), values);
|
&& valueFormat.sanitize_value (context, this, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -478,7 +478,7 @@ struct SinglePosFormat2
|
||||||
if (likely (index >= valueCount))
|
if (likely (index >= valueCount))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
valueFormat.apply_value (context->layout, CharP(this),
|
valueFormat.apply_value (context->layout, this,
|
||||||
&values[index * valueFormat.get_len ()],
|
&values[index * valueFormat.get_len ()],
|
||||||
CURPOSITION ());
|
CURPOSITION ());
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ struct SinglePosFormat2
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
return context->check_struct (this)
|
return context->check_struct (this)
|
||||||
&& coverage.sanitize (context, this)
|
&& coverage.sanitize (context, this)
|
||||||
&& valueFormat.sanitize_values (context, CharP(this), values, valueCount);
|
&& valueFormat.sanitize_values (context, this, values, valueCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -611,8 +611,8 @@ struct PairPosFormat1
|
||||||
{
|
{
|
||||||
if (IN_GLYPH (j) == record->secondGlyph)
|
if (IN_GLYPH (j) == record->secondGlyph)
|
||||||
{
|
{
|
||||||
valueFormat1.apply_value (context->layout, CharP(this), &record->values[0], CURPOSITION ());
|
valueFormat1.apply_value (context->layout, this, &record->values[0], CURPOSITION ());
|
||||||
valueFormat2.apply_value (context->layout, CharP(this), &record->values[len1], POSITION (j));
|
valueFormat2.apply_value (context->layout, this, &record->values[len1], POSITION (j));
|
||||||
if (len2)
|
if (len2)
|
||||||
j++;
|
j++;
|
||||||
context->buffer->in_pos = j;
|
context->buffer->in_pos = j;
|
||||||
|
@ -632,7 +632,7 @@ struct PairPosFormat1
|
||||||
|
|
||||||
if (!(context->check_struct (this)
|
if (!(context->check_struct (this)
|
||||||
&& coverage.sanitize (context, this)
|
&& coverage.sanitize (context, this)
|
||||||
&& likely (pairSet.sanitize (context, CharP(this), len1 + len2)))) return false;
|
&& likely (pairSet.sanitize (context, this, len1 + len2)))) return false;
|
||||||
|
|
||||||
if (!(valueFormat1.has_device () || valueFormat2.has_device ())) return true;
|
if (!(valueFormat1.has_device () || valueFormat2.has_device ())) return true;
|
||||||
|
|
||||||
|
@ -644,8 +644,8 @@ struct PairPosFormat1
|
||||||
|
|
||||||
unsigned int count2 = pair_set.len;
|
unsigned int count2 = pair_set.len;
|
||||||
PairValueRecord *record = pair_set.array;
|
PairValueRecord *record = pair_set.array;
|
||||||
if (!(valueFormat1.sanitize_values_stride_unsafe (context, CharP(this), &record->values[0], count2, stride) &&
|
if (!(valueFormat1.sanitize_values_stride_unsafe (context, this, &record->values[0], count2, stride) &&
|
||||||
valueFormat2.sanitize_values_stride_unsafe (context, CharP(this), &record->values[len1], count2, stride)))
|
valueFormat2.sanitize_values_stride_unsafe (context, this, &record->values[len1], count2, stride)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -704,8 +704,8 @@ struct PairPosFormat2
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
|
const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
|
||||||
valueFormat1.apply_value (context->layout, CharP(this), v, CURPOSITION ());
|
valueFormat1.apply_value (context->layout, this, v, CURPOSITION ());
|
||||||
valueFormat2.apply_value (context->layout, CharP(this), v + len1, POSITION (j));
|
valueFormat2.apply_value (context->layout, this, v + len1, POSITION (j));
|
||||||
|
|
||||||
if (len2)
|
if (len2)
|
||||||
j++;
|
j++;
|
||||||
|
@ -727,8 +727,8 @@ struct PairPosFormat2
|
||||||
unsigned int record_size = valueFormat1.get_size () + valueFormat2.get_size ();
|
unsigned int record_size = valueFormat1.get_size () + valueFormat2.get_size ();
|
||||||
unsigned int count = (unsigned int) class1Count * (unsigned int) class2Count;
|
unsigned int count = (unsigned int) class1Count * (unsigned int) class2Count;
|
||||||
return context->check_array (values, record_size, count) &&
|
return context->check_array (values, record_size, count) &&
|
||||||
valueFormat1.sanitize_values_stride_unsafe (context, CharP(this), &values[0], count, stride) &&
|
valueFormat1.sanitize_values_stride_unsafe (context, this, &values[0], count, stride) &&
|
||||||
valueFormat2.sanitize_values_stride_unsafe (context, CharP(this), &values[len1], count, stride);
|
valueFormat2.sanitize_values_stride_unsafe (context, this, &values[len1], count, stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1091,7 +1091,7 @@ struct MarkBasePosFormat1
|
||||||
&& markCoverage.sanitize (context, this)
|
&& markCoverage.sanitize (context, this)
|
||||||
&& baseCoverage.sanitize (context, this)
|
&& baseCoverage.sanitize (context, this)
|
||||||
&& markArray.sanitize (context, this)
|
&& markArray.sanitize (context, this)
|
||||||
&& likely (baseArray.sanitize (context, CharP(this), (unsigned int) classCount));
|
&& likely (baseArray.sanitize (context, this, (unsigned int) classCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1214,7 +1214,7 @@ struct MarkLigPosFormat1
|
||||||
&& markCoverage.sanitize (context, this)
|
&& markCoverage.sanitize (context, this)
|
||||||
&& ligatureCoverage.sanitize (context, this)
|
&& ligatureCoverage.sanitize (context, this)
|
||||||
&& markArray.sanitize (context, this)
|
&& markArray.sanitize (context, this)
|
||||||
&& likely (ligatureArray.sanitize (context, CharP(this), (unsigned int) classCount));
|
&& likely (ligatureArray.sanitize (context, this, (unsigned int) classCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1318,7 +1318,7 @@ struct MarkMarkPosFormat1
|
||||||
&& mark1Coverage.sanitize (context, this)
|
&& mark1Coverage.sanitize (context, this)
|
||||||
&& mark2Coverage.sanitize (context, this)
|
&& mark2Coverage.sanitize (context, this)
|
||||||
&& mark1Array.sanitize (context, this)
|
&& mark1Array.sanitize (context, this)
|
||||||
&& likely (mark2Array.sanitize (context, CharP(this), (unsigned int) classCount));
|
&& likely (mark2Array.sanitize (context, this, (unsigned int) classCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -617,10 +617,10 @@ struct ReverseChainSingleSubstFormat1
|
||||||
|
|
||||||
if (match_backtrack (context,
|
if (match_backtrack (context,
|
||||||
backtrack.len, (USHORT *) backtrack.array(),
|
backtrack.len, (USHORT *) backtrack.array(),
|
||||||
match_coverage, CharP(this)) &&
|
match_coverage, this) &&
|
||||||
match_lookahead (context,
|
match_lookahead (context,
|
||||||
lookahead.len, (USHORT *) lookahead.array(),
|
lookahead.len, (USHORT *) lookahead.array(),
|
||||||
match_coverage, CharP(this),
|
match_coverage, this,
|
||||||
1))
|
1))
|
||||||
{
|
{
|
||||||
IN_CURGLYPH () = substitute[index];
|
IN_CURGLYPH () = substitute[index];
|
||||||
|
|
|
@ -58,7 +58,7 @@ struct hb_apply_context_t
|
||||||
#define BUFFER context->buffer
|
#define BUFFER context->buffer
|
||||||
|
|
||||||
|
|
||||||
typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const char *data);
|
typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const void *data);
|
||||||
typedef bool (*apply_lookup_func_t) (hb_apply_context_t *context, unsigned int lookup_index);
|
typedef bool (*apply_lookup_func_t) (hb_apply_context_t *context, unsigned int lookup_index);
|
||||||
|
|
||||||
struct ContextFuncs
|
struct ContextFuncs
|
||||||
|
@ -68,18 +68,18 @@ struct ContextFuncs
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const char *data HB_UNUSED)
|
static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const void *data HB_UNUSED)
|
||||||
{
|
{
|
||||||
return glyph_id == value;
|
return glyph_id == value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool match_class (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
|
static inline bool match_class (hb_codepoint_t glyph_id, const USHORT &value, const void *data)
|
||||||
{
|
{
|
||||||
const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
|
const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
|
||||||
return class_def.get_class (glyph_id) == value;
|
return class_def.get_class (glyph_id) == value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
|
static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, const void *data)
|
||||||
{
|
{
|
||||||
const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value;
|
const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value;
|
||||||
return (data+coverage) (glyph_id) != NOT_COVERED;
|
return (data+coverage) (glyph_id) != NOT_COVERED;
|
||||||
|
@ -90,7 +90,7 @@ static inline bool match_input (hb_apply_context_t *context,
|
||||||
unsigned int count, /* Including the first glyph (not matched) */
|
unsigned int count, /* Including the first glyph (not matched) */
|
||||||
const USHORT input[], /* Array of input values--start with second glyph */
|
const USHORT input[], /* Array of input values--start with second glyph */
|
||||||
match_func_t match_func,
|
match_func_t match_func,
|
||||||
const char *match_data,
|
const void *match_data,
|
||||||
unsigned int *context_length_out)
|
unsigned int *context_length_out)
|
||||||
{
|
{
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
@ -120,7 +120,7 @@ static inline bool match_backtrack (hb_apply_context_t *context,
|
||||||
unsigned int count,
|
unsigned int count,
|
||||||
const USHORT backtrack[],
|
const USHORT backtrack[],
|
||||||
match_func_t match_func,
|
match_func_t match_func,
|
||||||
const char *match_data)
|
const void *match_data)
|
||||||
{
|
{
|
||||||
if (unlikely (context->buffer->out_pos < count))
|
if (unlikely (context->buffer->out_pos < count))
|
||||||
return false;
|
return false;
|
||||||
|
@ -145,7 +145,7 @@ static inline bool match_lookahead (hb_apply_context_t *context,
|
||||||
unsigned int count,
|
unsigned int count,
|
||||||
const USHORT lookahead[],
|
const USHORT lookahead[],
|
||||||
match_func_t match_func,
|
match_func_t match_func,
|
||||||
const char *match_data,
|
const void *match_data,
|
||||||
unsigned int offset)
|
unsigned int offset)
|
||||||
{
|
{
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
@ -247,7 +247,7 @@ static inline bool apply_lookup (hb_apply_context_t *context,
|
||||||
struct ContextLookupContext
|
struct ContextLookupContext
|
||||||
{
|
{
|
||||||
ContextFuncs funcs;
|
ContextFuncs funcs;
|
||||||
const char *match_data;
|
const void *match_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline bool context_lookup (hb_apply_context_t *context,
|
static inline bool context_lookup (hb_apply_context_t *context,
|
||||||
|
@ -392,7 +392,7 @@ struct ContextFormat2
|
||||||
*/
|
*/
|
||||||
struct ContextLookupContext lookup_context = {
|
struct ContextLookupContext lookup_context = {
|
||||||
{match_class, apply_func},
|
{match_class, apply_func},
|
||||||
CharP(&class_def)
|
&class_def
|
||||||
};
|
};
|
||||||
return rule_set.apply (context, lookup_context);
|
return rule_set.apply (context, lookup_context);
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,7 @@ struct ContextFormat3
|
||||||
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount);
|
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount);
|
||||||
struct ContextLookupContext lookup_context = {
|
struct ContextLookupContext lookup_context = {
|
||||||
{match_coverage, apply_func},
|
{match_coverage, apply_func},
|
||||||
CharP(this)
|
this
|
||||||
};
|
};
|
||||||
return context_lookup (context,
|
return context_lookup (context,
|
||||||
glyphCount, (const USHORT *) (coverage + 1),
|
glyphCount, (const USHORT *) (coverage + 1),
|
||||||
|
@ -508,7 +508,7 @@ struct Context
|
||||||
struct ChainContextLookupContext
|
struct ChainContextLookupContext
|
||||||
{
|
{
|
||||||
ContextFuncs funcs;
|
ContextFuncs funcs;
|
||||||
const char *match_data[3];
|
const void *match_data[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline bool chain_context_lookup (hb_apply_context_t *context,
|
static inline bool chain_context_lookup (hb_apply_context_t *context,
|
||||||
|
@ -685,9 +685,9 @@ struct ChainContextFormat2
|
||||||
*/
|
*/
|
||||||
struct ChainContextLookupContext lookup_context = {
|
struct ChainContextLookupContext lookup_context = {
|
||||||
{match_class, apply_func},
|
{match_class, apply_func},
|
||||||
{CharP(&backtrack_class_def),
|
{&backtrack_class_def,
|
||||||
CharP(&input_class_def),
|
&input_class_def,
|
||||||
CharP(&lookahead_class_def)}
|
&lookahead_class_def}
|
||||||
};
|
};
|
||||||
return rule_set.apply (context, lookup_context);
|
return rule_set.apply (context, lookup_context);
|
||||||
}
|
}
|
||||||
|
@ -744,7 +744,7 @@ struct ChainContextFormat3
|
||||||
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
|
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
|
||||||
struct ChainContextLookupContext lookup_context = {
|
struct ChainContextLookupContext lookup_context = {
|
||||||
{match_coverage, apply_func},
|
{match_coverage, apply_func},
|
||||||
{CharP(this), CharP(this), CharP(this)}
|
{this, this, this}
|
||||||
};
|
};
|
||||||
return chain_context_lookup (context,
|
return chain_context_lookup (context,
|
||||||
backtrack.len, (const USHORT *) backtrack.array(),
|
backtrack.len, (const USHORT *) backtrack.array(),
|
||||||
|
|
Loading…
Reference in New Issue