From f6c8a6eacf27fd1c509d07c85985f0367c5e475f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 18 May 2009 18:01:19 -0400 Subject: [PATCH] [HB] Simplify casts --- src/hb-ot-layout-gdef-private.h | 2 +- src/hb-ot-layout-gpos-private.h | 6 +++--- src/hb-ot-layout-gsub-private.h | 6 +++--- src/hb-ot-layout-open-private.h | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/hb-ot-layout-gdef-private.h b/src/hb-ot-layout-gdef-private.h index 8565a48..19f0e8e 100644 --- a/src/hb-ot-layout-gdef-private.h +++ b/src/hb-ot-layout-gdef-private.h @@ -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 { diff --git a/src/hb-ot-layout-gpos-private.h b/src/hb-ot-layout-gpos-private.h index 056131b..a46f73d 100644 --- a/src/hb-ot-layout-gpos-private.h +++ b/src/hb-ot-layout-gpos-private.h @@ -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) { diff --git a/src/hb-ot-layout-gsub-private.h b/src/hb-ot-layout-gsub-private.h index 2bbb81f..e1d17c8 100644 --- a/src/hb-ot-layout-gsub-private.h +++ b/src/hb-ot-layout-gsub-private.h @@ -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) { diff --git a/src/hb-ot-layout-open-private.h b/src/hb-ot-layout-open-private.h index fae2d4e..befb1d3 100644 --- a/src/hb-ot-layout-open-private.h +++ b/src/hb-ot-layout-open-private.h @@ -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 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 { \ - 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 { \ #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; \ } -- 2.7.4