Remove unnecessary casts

This commit is contained in:
Behdad Esfahbod 2010-05-10 17:47:22 -04:00
parent 09766b1ec5
commit 40cbefe858
5 changed files with 43 additions and 43 deletions

View File

@ -224,7 +224,7 @@ struct hb_sanitize_context_t
fprintf (stderr, "SANITIZE(%p) %-*d-> range [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \
base,
this->debug_depth, this->debug_depth,
base, CharP(base)+len, len,
base, CharP(base) + len, len,
this->start, this->end,
ret ? "pass" : "FAIL");
@ -252,7 +252,7 @@ struct hb_sanitize_context_t
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++;
@ -261,7 +261,7 @@ struct hb_sanitize_context_t
base,
this->debug_depth, this->debug_depth,
this->edit_count,
base, base+len, len,
base, CharP(base)+len, len,
this->start, this->end,
this->writable ? "granted" : "REJECTED");
@ -496,7 +496,7 @@ struct GenericOffsetTo : OffsetType
private:
/* Set the offset to Null */
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 */
return true;
}
@ -627,12 +627,12 @@ struct OffsetListOf : OffsetArrayOf<Type>
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
return OffsetArrayOf<Type>::sanitize (context, CharP(this));
return OffsetArrayOf<Type>::sanitize (context, this);
}
template <typename T>
inline bool sanitize (hb_sanitize_context_t *context, T user_data) {
TRACE_SANITIZE ();
return OffsetArrayOf<Type>::sanitize (context, CharP(this), user_data);
return OffsetArrayOf<Type>::sanitize (context, this, user_data);
}
};

View File

@ -112,7 +112,7 @@ struct RecordListOf : RecordArrayOf<Type>
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
return RecordArrayOf<Type>::sanitize (context, CharP(this));
return RecordArrayOf<Type>::sanitize (context, this);
}
};

View File

@ -92,7 +92,7 @@ struct ValueFormat : USHORT
{ return get_len () * Value::static_size; }
void apply_value (hb_ot_layout_context_t *layout,
const char *base,
const void *base,
const Value *values,
hb_internal_glyph_position_t *glyph_pos) const
{
@ -436,7 +436,7 @@ struct SinglePosFormat1
if (likely (index == NOT_COVERED))
return false;
valueFormat.apply_value (context->layout, CharP(this), values, CURPOSITION ());
valueFormat.apply_value (context->layout, this, values, CURPOSITION ());
context->buffer->in_pos++;
return true;
@ -446,7 +446,7 @@ struct SinglePosFormat1
TRACE_SANITIZE ();
return context->check_struct (this)
&& coverage.sanitize (context, this)
&& valueFormat.sanitize_value (context, CharP(this), values);
&& valueFormat.sanitize_value (context, this, values);
}
private:
@ -478,7 +478,7 @@ struct SinglePosFormat2
if (likely (index >= valueCount))
return false;
valueFormat.apply_value (context->layout, CharP(this),
valueFormat.apply_value (context->layout, this,
&values[index * valueFormat.get_len ()],
CURPOSITION ());
@ -490,7 +490,7 @@ struct SinglePosFormat2
TRACE_SANITIZE ();
return context->check_struct (this)
&& coverage.sanitize (context, this)
&& valueFormat.sanitize_values (context, CharP(this), values, valueCount);
&& valueFormat.sanitize_values (context, this, values, valueCount);
}
private:
@ -611,8 +611,8 @@ struct PairPosFormat1
{
if (IN_GLYPH (j) == record->secondGlyph)
{
valueFormat1.apply_value (context->layout, CharP(this), &record->values[0], CURPOSITION ());
valueFormat2.apply_value (context->layout, CharP(this), &record->values[len1], POSITION (j));
valueFormat1.apply_value (context->layout, this, &record->values[0], CURPOSITION ());
valueFormat2.apply_value (context->layout, this, &record->values[len1], POSITION (j));
if (len2)
j++;
context->buffer->in_pos = j;
@ -632,7 +632,7 @@ struct PairPosFormat1
if (!(context->check_struct (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;
@ -644,8 +644,8 @@ struct PairPosFormat1
unsigned int count2 = pair_set.len;
PairValueRecord *record = pair_set.array;
if (!(valueFormat1.sanitize_values_stride_unsafe (context, CharP(this), &record->values[0], count2, stride) &&
valueFormat2.sanitize_values_stride_unsafe (context, CharP(this), &record->values[len1], count2, stride)))
if (!(valueFormat1.sanitize_values_stride_unsafe (context, this, &record->values[0], count2, stride) &&
valueFormat2.sanitize_values_stride_unsafe (context, this, &record->values[len1], count2, stride)))
return false;
}
@ -704,8 +704,8 @@ struct PairPosFormat2
return false;
const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
valueFormat1.apply_value (context->layout, CharP(this), v, CURPOSITION ());
valueFormat2.apply_value (context->layout, CharP(this), v + len1, POSITION (j));
valueFormat1.apply_value (context->layout, this, v, CURPOSITION ());
valueFormat2.apply_value (context->layout, this, v + len1, POSITION (j));
if (len2)
j++;
@ -727,8 +727,8 @@ struct PairPosFormat2
unsigned int record_size = valueFormat1.get_size () + valueFormat2.get_size ();
unsigned int count = (unsigned int) class1Count * (unsigned int) class2Count;
return context->check_array (values, record_size, count) &&
valueFormat1.sanitize_values_stride_unsafe (context, CharP(this), &values[0], count, stride) &&
valueFormat2.sanitize_values_stride_unsafe (context, CharP(this), &values[len1], count, stride);
valueFormat1.sanitize_values_stride_unsafe (context, this, &values[0], count, stride) &&
valueFormat2.sanitize_values_stride_unsafe (context, this, &values[len1], count, stride);
}
private:
@ -1091,7 +1091,7 @@ struct MarkBasePosFormat1
&& markCoverage.sanitize (context, this)
&& baseCoverage.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:
@ -1214,7 +1214,7 @@ struct MarkLigPosFormat1
&& markCoverage.sanitize (context, this)
&& ligatureCoverage.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:
@ -1318,7 +1318,7 @@ struct MarkMarkPosFormat1
&& mark1Coverage.sanitize (context, this)
&& mark2Coverage.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:

View File

@ -617,10 +617,10 @@ struct ReverseChainSingleSubstFormat1
if (match_backtrack (context,
backtrack.len, (USHORT *) backtrack.array(),
match_coverage, CharP(this)) &&
match_coverage, this) &&
match_lookahead (context,
lookahead.len, (USHORT *) lookahead.array(),
match_coverage, CharP(this),
match_coverage, this,
1))
{
IN_CURGLYPH () = substitute[index];

View File

@ -58,7 +58,7 @@ struct hb_apply_context_t
#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);
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;
}
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);
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;
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) */
const USHORT input[], /* Array of input values--start with second glyph */
match_func_t match_func,
const char *match_data,
const void *match_data,
unsigned int *context_length_out)
{
unsigned int i, j;
@ -120,7 +120,7 @@ static inline bool match_backtrack (hb_apply_context_t *context,
unsigned int count,
const USHORT backtrack[],
match_func_t match_func,
const char *match_data)
const void *match_data)
{
if (unlikely (context->buffer->out_pos < count))
return false;
@ -145,7 +145,7 @@ static inline bool match_lookahead (hb_apply_context_t *context,
unsigned int count,
const USHORT lookahead[],
match_func_t match_func,
const char *match_data,
const void *match_data,
unsigned int offset)
{
unsigned int i, j;
@ -247,7 +247,7 @@ static inline bool apply_lookup (hb_apply_context_t *context,
struct ContextLookupContext
{
ContextFuncs funcs;
const char *match_data;
const void *match_data;
};
static inline bool context_lookup (hb_apply_context_t *context,
@ -391,8 +391,8 @@ struct ContextFormat2
* them across subrule lookups. Not sure it's worth it.
*/
struct ContextLookupContext lookup_context = {
{match_class, apply_func},
CharP(&class_def)
{match_class, apply_func},
&class_def
};
return rule_set.apply (context, lookup_context);
}
@ -435,7 +435,7 @@ struct ContextFormat3
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount);
struct ContextLookupContext lookup_context = {
{match_coverage, apply_func},
CharP(this)
this
};
return context_lookup (context,
glyphCount, (const USHORT *) (coverage + 1),
@ -508,7 +508,7 @@ struct Context
struct ChainContextLookupContext
{
ContextFuncs funcs;
const char *match_data[3];
const void *match_data[3];
};
static inline bool chain_context_lookup (hb_apply_context_t *context,
@ -684,10 +684,10 @@ struct ChainContextFormat2
* them across subrule lookups. Not sure it's worth it.
*/
struct ChainContextLookupContext lookup_context = {
{match_class, apply_func},
{CharP(&backtrack_class_def),
CharP(&input_class_def),
CharP(&lookahead_class_def)}
{match_class, apply_func},
{&backtrack_class_def,
&input_class_def,
&lookahead_class_def}
};
return rule_set.apply (context, lookup_context);
}
@ -744,7 +744,7 @@ struct ChainContextFormat3
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
struct ChainContextLookupContext lookup_context = {
{match_coverage, apply_func},
{CharP(this), CharP(this), CharP(this)}
{this, this, this}
};
return chain_context_lookup (context,
backtrack.len, (const USHORT *) backtrack.array(),