From 6faff8e4132197ba06f0e685b82efe35b546cf64 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 28 Apr 2014 14:29:39 -0700 Subject: [PATCH] Add static storage classifier to inline functions Before we were just relying on the compiler inlining them and not leaving a trace in our public API. Try to fix. Hopefully not breaking anyone's build. --- src/hb-open-type-private.hh | 22 ++++++++++----------- src/hb-ot-layout-gpos-table.hh | 4 ++-- src/hb-ot-layout-gsub-table.hh | 6 +++--- src/hb-ot-layout-private.hh | 36 +++++++++++++++++----------------- src/hb-ot-map-private.hh | 10 +++++----- src/hb-private.hh | 2 +- 6 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 558103a8e..5a01a81d3 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -42,36 +42,36 @@ namespace OT { /* Cast to struct T, reference to reference */ template -inline const Type& CastR(const TObject &X) +static inline const Type& CastR(const TObject &X) { return reinterpret_cast (X); } template -inline Type& CastR(TObject &X) +static inline Type& CastR(TObject &X) { return reinterpret_cast (X); } /* Cast to struct T, pointer to pointer */ template -inline const Type* CastP(const TObject *X) +static inline const Type* CastP(const TObject *X) { return reinterpret_cast (X); } template -inline Type* CastP(TObject *X) +static inline Type* CastP(TObject *X) { return reinterpret_cast (X); } /* StructAtOffset(P,Ofs) returns the struct T& that is placed at memory * location pointed to by P plus Ofs bytes. */ template -inline const Type& StructAtOffset(const void *P, unsigned int offset) +static inline const Type& StructAtOffset(const void *P, unsigned int offset) { return * reinterpret_cast ((const char *) P + offset); } template -inline Type& StructAtOffset(void *P, unsigned int offset) +static inline Type& StructAtOffset(void *P, unsigned int offset) { return * reinterpret_cast ((char *) P + offset); } /* StructAfter(X) returns the struct T& that is placed after X. * Works with X of variable size also. X must implement get_size() */ template -inline const Type& StructAfter(const TObject &X) +static inline const Type& StructAfter(const TObject &X) { return StructAtOffset(&X, X.get_size()); } template -inline Type& StructAfter(TObject &X) +static inline Type& StructAfter(TObject &X) { return StructAtOffset(&X, X.get_size()); } @@ -145,7 +145,7 @@ static inline const Type& Null (void) { #define DEFINE_NULL_DATA(Type, data) \ static const char _Null##Type[sizeof (Type) + 1] = data; /* +1 is for nul-termination in data */ \ template <> \ -inline const Type& Null (void) { \ +/*static*/ inline const Type& Null (void) { \ return *CastP (_Null##Type); \ } /* The following line really exists such that we end in a place needing semicolon */ \ ASSERT_STATIC (Type::min_size + 1 <= sizeof (_Null##Type)) @@ -738,9 +738,9 @@ struct GenericOffsetTo : OffsetType } }; template -inline const Type& operator + (const Base &base, const GenericOffsetTo &offset) { return offset (base); } +static inline const Type& operator + (const Base &base, const GenericOffsetTo &offset) { return offset (base); } template -inline Type& operator + (Base &base, GenericOffsetTo &offset) { return offset (base); } +static inline Type& operator + (Base &base, GenericOffsetTo &offset) { return offset (base); } template struct OffsetTo : GenericOffsetTo {}; diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index 7c0a4ea66..91e1f8b00 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1608,14 +1608,14 @@ GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer) /* Out-of-class implementation for methods recursing */ template -inline typename context_t::return_t PosLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index) +/*static*/ inline typename context_t::return_t PosLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index) { const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos); const PosLookup &l = gpos.get_lookup (lookup_index); return l.dispatch (c); } -inline bool PosLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index) +/*static*/ inline bool PosLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index) { const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos); const PosLookup &l = gpos.get_lookup (lookup_index); diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index 76b4f33c7..3a1a0ef3d 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -1338,7 +1338,7 @@ GSUB::substitute_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer HB_UNUSE /* Out-of-class implementation for methods recursing */ -inline bool ExtensionSubst::is_reverse (void) const +/*static*/ inline bool ExtensionSubst::is_reverse (void) const { unsigned int type = get_type (); if (unlikely (type == SubstLookupSubTable::Extension)) @@ -1347,14 +1347,14 @@ inline bool ExtensionSubst::is_reverse (void) const } template -inline typename context_t::return_t SubstLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index) +/*static*/ inline typename context_t::return_t SubstLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index) { const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); const SubstLookup &l = gsub.get_lookup (lookup_index); return l.dispatch (c); } -inline bool SubstLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index) +/*static*/ inline bool SubstLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index) { const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); const SubstLookup &l = gsub.get_lookup (lookup_index); diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index 0a0a54b25..4f03e1b0e 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -182,7 +182,7 @@ enum { MASK0_GEN_CAT = 0x1Fu }; -inline void +static inline void _hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *unicode) { /* XXX This shouldn't be inlined, or at least not while is_default_ignorable() is inline. */ @@ -193,51 +193,51 @@ _hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *uni info->unicode_props1() = unicode->modified_combining_class (info->codepoint); } -inline void +static inline void _hb_glyph_info_set_general_category (hb_glyph_info_t *info, hb_unicode_general_category_t gen_cat) { info->unicode_props0() = (unsigned int) gen_cat | ((info->unicode_props0()) & ~MASK0_GEN_CAT); } -inline hb_unicode_general_category_t +static inline hb_unicode_general_category_t _hb_glyph_info_get_general_category (const hb_glyph_info_t *info) { return (hb_unicode_general_category_t) (info->unicode_props0() & MASK0_GEN_CAT); } -inline void +static inline void _hb_glyph_info_set_modified_combining_class (hb_glyph_info_t *info, unsigned int modified_class) { info->unicode_props1() = modified_class; } -inline unsigned int +static inline unsigned int _hb_glyph_info_get_modified_combining_class (const hb_glyph_info_t *info) { return info->unicode_props1(); } -inline hb_bool_t +static inline hb_bool_t _hb_glyph_info_is_default_ignorable (const hb_glyph_info_t *info) { return !!(info->unicode_props0() & MASK0_IGNORABLE); } -inline hb_bool_t +static inline hb_bool_t _hb_glyph_info_is_zwnj (const hb_glyph_info_t *info) { return !!(info->unicode_props0() & MASK0_ZWNJ); } -inline hb_bool_t +static inline hb_bool_t _hb_glyph_info_is_zwj (const hb_glyph_info_t *info) { return !!(info->unicode_props0() & MASK0_ZWJ); } -inline void +static inline void _hb_glyph_info_flip_joiners (hb_glyph_info_t *info) { info->unicode_props0() ^= MASK0_ZWNJ | MASK0_ZWJ; @@ -339,31 +339,31 @@ _hb_allocate_lig_id (hb_buffer_t *buffer) { /* glyph_props: */ -inline void +static inline void _hb_glyph_info_set_glyph_props (hb_glyph_info_t *info, unsigned int props) { info->glyph_props() = props; } -inline unsigned int +static inline unsigned int _hb_glyph_info_get_glyph_props (const hb_glyph_info_t *info) { return info->glyph_props(); } -inline bool +static inline bool _hb_glyph_info_is_base_glyph (const hb_glyph_info_t *info) { return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH); } -inline bool +static inline bool _hb_glyph_info_is_ligature (const hb_glyph_info_t *info) { return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE); } -inline bool +static inline bool _hb_glyph_info_is_mark (const hb_glyph_info_t *info) { return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MARK); @@ -383,21 +383,21 @@ _hb_glyph_info_ligated (const hb_glyph_info_t *info) /* Allocation / deallocation. */ -inline void +static inline void _hb_buffer_allocate_unicode_vars (hb_buffer_t *buffer) { HB_BUFFER_ALLOCATE_VAR (buffer, unicode_props0); HB_BUFFER_ALLOCATE_VAR (buffer, unicode_props1); } -inline void +static inline void _hb_buffer_deallocate_unicode_vars (hb_buffer_t *buffer) { HB_BUFFER_DEALLOCATE_VAR (buffer, unicode_props0); HB_BUFFER_DEALLOCATE_VAR (buffer, unicode_props1); } -inline void +static inline void _hb_buffer_allocate_gsubgpos_vars (hb_buffer_t *buffer) { HB_BUFFER_ALLOCATE_VAR (buffer, glyph_props); @@ -405,7 +405,7 @@ _hb_buffer_allocate_gsubgpos_vars (hb_buffer_t *buffer) HB_BUFFER_ALLOCATE_VAR (buffer, syllable); } -inline void +static inline void _hb_buffer_deallocate_gsubgpos_vars (hb_buffer_t *buffer) { HB_BUFFER_DEALLOCATE_VAR (buffer, syllable); diff --git a/src/hb-ot-map-private.hh b/src/hb-ot-map-private.hh index 0e718a6f1..74e2d9aca 100644 --- a/src/hb-ot-map-private.hh +++ b/src/hb-ot-map-private.hh @@ -160,19 +160,19 @@ enum hb_ot_map_feature_flags_t { }; /* Macro version for where const is desired. */ #define F_COMBINE(l,r) (hb_ot_map_feature_flags_t ((unsigned int) (l) | (unsigned int) (r))) -inline hb_ot_map_feature_flags_t +static inline hb_ot_map_feature_flags_t operator | (hb_ot_map_feature_flags_t l, hb_ot_map_feature_flags_t r) { return hb_ot_map_feature_flags_t ((unsigned int) l | (unsigned int) r); } -inline hb_ot_map_feature_flags_t +static inline hb_ot_map_feature_flags_t operator & (hb_ot_map_feature_flags_t l, hb_ot_map_feature_flags_t r) { return hb_ot_map_feature_flags_t ((unsigned int) l & (unsigned int) r); } -inline hb_ot_map_feature_flags_t +static inline hb_ot_map_feature_flags_t operator ~ (hb_ot_map_feature_flags_t r) { return hb_ot_map_feature_flags_t (~(unsigned int) r); } -inline hb_ot_map_feature_flags_t& +static inline hb_ot_map_feature_flags_t& operator |= (hb_ot_map_feature_flags_t &l, hb_ot_map_feature_flags_t r) { l = l | r; return l; } -inline hb_ot_map_feature_flags_t& +static inline hb_ot_map_feature_flags_t& operator &= (hb_ot_map_feature_flags_t& l, hb_ot_map_feature_flags_t r) { l = l & r; return l; } diff --git a/src/hb-private.hh b/src/hb-private.hh index 344c71b05..e5011e2d3 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -725,7 +725,7 @@ static inline void _hb_warn_no_return (bool returned) } } template <> -inline void _hb_warn_no_return (bool returned HB_UNUSED) +/*static*/ inline void _hb_warn_no_return (bool returned HB_UNUSED) {} template