[machinery] Remove CastR<>()

This commit is contained in:
Behdad Esfahbod 2019-12-10 13:18:32 -06:00
parent b84ceb2fcf
commit 858b627984
6 changed files with 11 additions and 19 deletions

View File

@ -41,14 +41,6 @@
* Casts
*/
/* Cast to struct T, reference to reference */
template<typename Type, typename TObject>
static inline const Type& CastR(const TObject &X)
{ return reinterpret_cast<const Type&> (X); }
template<typename Type, typename TObject>
static inline Type& CastR(TObject &X)
{ return reinterpret_cast<Type&> (X); }
/* StructAtOffset<T>(P,Ofs) returns the struct T& that is placed at memory
* location pointed to by P plus Ofs bytes. */
template<typename Type>

View File

@ -284,7 +284,7 @@ struct TTCHeader
struct ResourceRecord
{
const OpenTypeFontFace & get_face (const void *data_base) const
{ return CastR<OpenTypeFontFace> ((data_base+offset).arrayZ); }
{ return * reinterpret_cast<const OpenTypeFontFace *> ((data_base+offset).arrayZ); }
bool sanitize (hb_sanitize_context_t *c,
const void *data_base) const

View File

@ -775,10 +775,10 @@ struct Lookup
template <typename TSubTable>
const OffsetArrayOf<TSubTable>& get_subtables () const
{ return CastR<OffsetArrayOf<TSubTable>> (subTable); }
{ return reinterpret_cast<const OffsetArrayOf<TSubTable> &> (subTable); }
template <typename TSubTable>
OffsetArrayOf<TSubTable>& get_subtables ()
{ return CastR<OffsetArrayOf<TSubTable>> (subTable); }
{ return reinterpret_cast<OffsetArrayOf<TSubTable> &> (subTable); }
template <typename TSubTable>
const TSubTable& get_subtable (unsigned int i) const

View File

@ -1918,7 +1918,7 @@ struct GPOS : GSUBGPOS
static constexpr hb_tag_t tableTag = HB_OT_TAG_GPOS;
const PosLookup& get_lookup (unsigned int i) const
{ return CastR<PosLookup> (GSUBGPOS::get_lookup (i)); }
{ return static_cast<const PosLookup &> (GSUBGPOS::get_lookup (i)); }
static inline void position_start (hb_font_t *font, hb_buffer_t *buffer);
static inline void position_finish_advances (hb_font_t *font, hb_buffer_t *buffer);

View File

@ -1343,7 +1343,7 @@ struct SubstLookup : Lookup
{
unsigned int type = get_type ();
if (unlikely (type == SubTable::Extension))
return CastR<ExtensionSubst> (get_subtable(0)).is_reverse ();
return reinterpret_cast<const ExtensionSubst &> (get_subtable(0)).is_reverse ();
return lookup_type_is_reverse (type);
}
@ -1499,7 +1499,7 @@ struct GSUB : GSUBGPOS
static constexpr hb_tag_t tableTag = HB_OT_TAG_GSUB;
const SubstLookup& get_lookup (unsigned int i) const
{ return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); }
{ return static_cast<const SubstLookup &> (GSUBGPOS::get_lookup (i)); }
bool subset (hb_subset_context_t *c) const
{ return GSUBGPOS::subset<SubstLookup> (c); }
@ -1524,7 +1524,7 @@ struct GSUB_accelerator_t : GSUB::accelerator_t {};
{
unsigned int type = get_type ();
if (unlikely (type == SubTable::Extension))
return CastR<ExtensionSubst> (get_subtable<SubTable>()).is_reverse ();
return reinterpret_cast<const ExtensionSubst &> (get_subtable<SubTable>()).is_reverse ();
return SubstLookup::lookup_type_is_reverse (type);
}
template <typename context_t>

View File

@ -2741,7 +2741,7 @@ struct ExtensionFormat1
template <typename X>
const X& get_subtable () const
{ return this + CastR<LOffsetTo<typename T::SubTable>> (extensionOffset); }
{ return this + reinterpret_cast<const LOffsetTo<typename T::SubTable> &> (extensionOffset); }
template <typename context_t, typename ...Ts>
typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
@ -2913,9 +2913,9 @@ struct GSUBGPOS
typedef OffsetListOf<TLookup> TLookupList;
/* TODO Use intersects() to count how many subtables survive? */
CastR<OffsetTo<TLookupList>> (out->lookupList)
reinterpret_cast<OffsetTo<TLookupList> &> (out->lookupList)
.serialize_subset (c,
CastR<OffsetTo<TLookupList>> (lookupList),
reinterpret_cast<const OffsetTo<TLookupList> &> (lookupList),
this,
out);
@ -2942,7 +2942,7 @@ struct GSUBGPOS
likely (version.major == 1) &&
scriptList.sanitize (c, this) &&
featureList.sanitize (c, this) &&
CastR<OffsetTo<TLookupList>> (lookupList).sanitize (c, this))))
reinterpret_cast<const OffsetTo<TLookupList> &> (lookupList).sanitize (c, this))))
return_trace (false);
#ifndef HB_NO_VAR