[HB] Simplify casts
This commit is contained in:
parent
9c42f05a5c
commit
f6c8a6eacf
|
@ -110,7 +110,7 @@ struct CaretValueFormat3 {
|
|||
private:
|
||||
inline const Device& get_device (void) const {
|
||||
if (HB_UNLIKELY (!deviceTable)) return Null(Device);
|
||||
return *(const Device*)((const char*)this + deviceTable);
|
||||
return (const Device&)*((const char*)this + deviceTable);
|
||||
}
|
||||
|
||||
inline int get_caret_value (int ppem) const {
|
||||
|
|
|
@ -787,7 +787,7 @@ ASSERT_SIZE (PosLookupSubTable, 2);
|
|||
struct PosLookup : Lookup {
|
||||
|
||||
inline const PosLookupSubTable& get_subtable (unsigned int i) const {
|
||||
return *(PosLookupSubTable*)&(((Lookup *)this)->get_subtable (i));
|
||||
return (const PosLookupSubTable&) Lookup::get_subtable (i);
|
||||
}
|
||||
|
||||
/* Like get_type(), but looks through extension lookups.
|
||||
|
@ -880,7 +880,7 @@ struct GPOS : GSUBGPOS {
|
|||
/* XXX check version here? */
|
||||
|
||||
inline const PosLookup& get_lookup (unsigned int i) const {
|
||||
return *(PosLookup*)&(((GSUBGPOS *)this)->get_lookup (i));
|
||||
return (PosLookup&)(((GSUBGPOS *)this)->get_lookup (i));
|
||||
}
|
||||
|
||||
inline bool position_lookup (hb_ot_layout_t *layout,
|
||||
|
@ -902,7 +902,7 @@ inline bool ExtensionPosFormat1::position (LOOKUP_ARGS_DEF) const {
|
|||
if (HB_UNLIKELY (lookup_type == GPOS_Extension))
|
||||
return false;
|
||||
|
||||
return (*(PosLookupSubTable *)(((char *) this) + get_offset ())).position (LOOKUP_ARGS, lookup_type);
|
||||
return ((PosLookupSubTable&)*(((char *) this) + get_offset ())).position (LOOKUP_ARGS, lookup_type);
|
||||
}
|
||||
|
||||
static inline bool position_lookup (LOOKUP_ARGS_DEF, unsigned int lookup_index) {
|
||||
|
|
|
@ -667,7 +667,7 @@ ASSERT_SIZE (SubstLookupSubTable, 2);
|
|||
struct SubstLookup : Lookup {
|
||||
|
||||
inline const SubstLookupSubTable& get_subtable (unsigned int i) const {
|
||||
return *(SubstLookupSubTable*)&(((Lookup *)this)->get_subtable (i));
|
||||
return (const SubstLookupSubTable&) Lookup::get_subtable (i);
|
||||
}
|
||||
|
||||
/* Like get_type(), but looks through extension lookups.
|
||||
|
@ -779,7 +779,7 @@ struct GSUB : GSUBGPOS {
|
|||
/* XXX check version here? */
|
||||
|
||||
inline const SubstLookup& get_lookup (unsigned int i) const {
|
||||
return *(SubstLookup*)&(((GSUBGPOS *)this)->get_lookup (i));
|
||||
return (SubstLookup&)(((GSUBGPOS *)this)->get_lookup (i));
|
||||
}
|
||||
|
||||
inline bool substitute_lookup (hb_ot_layout_t *layout,
|
||||
|
@ -801,7 +801,7 @@ inline bool ExtensionSubstFormat1::substitute (LOOKUP_ARGS_DEF) const {
|
|||
if (HB_UNLIKELY (lookup_type == GSUB_Extension))
|
||||
return false;
|
||||
|
||||
return (*(SubstLookupSubTable *)(((char *) this) + get_offset ())).substitute (LOOKUP_ARGS, lookup_type);
|
||||
return ((SubstLookupSubTable&)*(((char *) this) + get_offset ())).substitute (LOOKUP_ARGS, lookup_type);
|
||||
}
|
||||
|
||||
static inline bool substitute_lookup (LOOKUP_ARGS_DEF, unsigned int lookup_index) {
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
inline const Type& operator[] (unsigned int i) const { \
|
||||
if (HB_UNLIKELY (i >= num)) return Null(Type); \
|
||||
if (HB_UNLIKELY (!array[i])) return Null(Type); \
|
||||
return *(const Type *)((const char*)this + array[i]); \
|
||||
return (const Type&)*((const char*)this + array[i]); \
|
||||
}
|
||||
|
||||
|
||||
|
@ -152,14 +152,14 @@ static const char NullPool[16] = "";
|
|||
template <typename Type>
|
||||
struct Null {
|
||||
ASSERT_STATIC (sizeof (Type) <= sizeof (NullPool));
|
||||
static inline const Type &get () { return (const Type&) *(const Type*) NullPool; }
|
||||
static inline const Type &get () { return (const Type&) *NullPool; }
|
||||
};
|
||||
|
||||
/* Specializaiton for arbitrary-content arbitrary-sized Null objects. */
|
||||
#define DEFINE_NULL_DATA(Type, size, data) \
|
||||
template <> \
|
||||
struct Null <Type> { \
|
||||
static inline const Type &get () { static const char bytes[size] = data; return (const Type&) *(const Type*) bytes; } \
|
||||
static inline const Type &get () { static const char bytes[size] = data; return (const Type&) *bytes; /* XXX */ } \
|
||||
}
|
||||
|
||||
/* Accessor macro. */
|
||||
|
@ -176,10 +176,10 @@ struct Null <Type> { \
|
|||
#define STATIC_DEFINE_GET_FOR_DATA(Type) \
|
||||
static inline const Type& get_for_data (const char *data) { \
|
||||
if (HB_UNLIKELY (data == NULL)) return Null(Type); \
|
||||
return *(const Type*)data; \
|
||||
return (const Type&)*data; \
|
||||
} \
|
||||
static inline Type& get_for_data (char *data) { \
|
||||
return *(Type*)data; \
|
||||
return (Type&)*data; \
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue