src/hb-aat-layout.cc | 12 ++++++------ src/hb-atomic.hh | 3 +++ src/hb-common.cc | 6 +++--- src/hb-dsalgs.hh | 6 ++---- src/hb-face.cc | 2 +- src/hb-graphite2.cc | 8 ++++---- src/hb-machinery.hh | 1 + src/hb-null.hh | 18 ++++++------------ src/hb-ot-color.cc | 10 +++++----- src/hb-ot-font.cc | 18 +++++++++--------- src/hb-ot-layout.cc | 2 +- src/hb-ot-math.cc | 2 +- src/hb-ot-name.cc | 2 +- src/hb-ot-shape-complex-arabic.cc | 4 ++-- src/hb-ot-var.cc | 6 ++---- src/hb-shape-plan.cc | 2 +- 16 files changed, 48 insertions(+), 54 deletions(-)
New commits: commit f6fc5574d3dae177a54b10195e0d1f368a74f768 Author: Behdad Esfahbod <[email protected]> Date: Mon Nov 5 13:23:54 2018 -0500 Add pointer magic operators to hb_atomic_ptr_t diff --git a/src/hb-atomic.hh b/src/hb-atomic.hh index 697de19c..49c2809e 100644 --- a/src/hb-atomic.hh +++ b/src/hb-atomic.hh @@ -290,6 +290,9 @@ struct hb_atomic_ptr_t inline T *get (void) const { return (T *) hb_atomic_ptr_impl_get ((void **) &v); } inline bool cmpexch (const T *old, T *new_) const { return hb_atomic_ptr_impl_cmpexch ((void **) &v, (void *) old, (void *) new_); } + inline T * operator -> (void) const { return get (); } + template <typename C> inline operator C * (void) const { return get (); } + mutable T *v; }; diff --git a/src/hb-common.cc b/src/hb-common.cc index d7c1921f..37be8a34 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -281,7 +281,7 @@ static void free_langs (void) { retry: - hb_language_item_t *first_lang = langs.get (); + hb_language_item_t *first_lang = langs; if (unlikely (!langs.cmpexch (first_lang, nullptr))) goto retry; @@ -298,7 +298,7 @@ static hb_language_item_t * lang_find_or_insert (const char *key) { retry: - hb_language_item_t *first_lang = langs.get (); + hb_language_item_t *first_lang = langs; for (hb_language_item_t *lang = first_lang; lang; lang = lang->next) if (*lang == key) @@ -408,7 +408,7 @@ hb_language_get_default (void) { static hb_atomic_ptr_t <hb_language_t> default_language; - hb_language_t language = default_language.get (); + hb_language_t language = default_language; if (unlikely (language == HB_LANGUAGE_INVALID)) { language = hb_language_from_string (setlocale (LC_CTYPE, nullptr), -1); diff --git a/src/hb-face.cc b/src/hb-face.cc index 50ab10e3..a0f8047f 100644 --- a/src/hb-face.cc +++ b/src/hb-face.cc @@ -263,7 +263,7 @@ hb_face_destroy (hb_face_t *face) { if (!hb_object_destroy (face)) return; - for (hb_face_t::plan_node_t *node = face->shape_plans.get (); node; ) + for (hb_face_t::plan_node_t *node = face->shape_plans; node; ) { hb_face_t::plan_node_t *next = node->next; hb_shape_plan_destroy (node->shape_plan); diff --git a/src/hb-graphite2.cc b/src/hb-graphite2.cc index 971241f9..24ee3d50 100644 --- a/src/hb-graphite2.cc +++ b/src/hb-graphite2.cc @@ -71,7 +71,7 @@ struct hb_graphite2_face_data_t static const void *hb_graphite2_get_table (const void *data, unsigned int tag, size_t *len) { hb_graphite2_face_data_t *face_data = (hb_graphite2_face_data_t *) data; - hb_graphite2_tablelist_t *tlist = face_data->tlist.get (); + hb_graphite2_tablelist_t *tlist = face_data->tlist; hb_blob_t *blob = nullptr; @@ -94,7 +94,7 @@ static const void *hb_graphite2_get_table (const void *data, unsigned int tag, s p->tag = tag; retry: - hb_graphite2_tablelist_t *tlist = face_data->tlist.get (); + hb_graphite2_tablelist_t *tlist = face_data->tlist; p->next = tlist; if (unlikely (!face_data->tlist.cmpexch (tlist, p))) @@ -110,7 +110,7 @@ retry: static void hb_graphite2_release_table(const void *data, const void *table_buffer) { hb_graphite2_face_data_t *face_data = (hb_graphite2_face_data_t *) data; - hb_graphite2_tablelist_t *tlist = face_data->tlist.get(); + hb_graphite2_tablelist_t *tlist = face_data->tlist; hb_graphite2_tablelist_t *prev = nullptr; hb_graphite2_tablelist_t *curr = tlist; @@ -164,7 +164,7 @@ _hb_graphite2_shaper_face_data_create (hb_face_t *face) void _hb_graphite2_shaper_face_data_destroy (hb_graphite2_face_data_t *data) { - hb_graphite2_tablelist_t *tlist = data->tlist.get (); + hb_graphite2_tablelist_t *tlist = data->tlist; while (tlist) { diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh index 465bbb14..f58050da 100644 --- a/src/hb-machinery.hh +++ b/src/hb-machinery.hh @@ -795,6 +795,7 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData> inline const Returned * operator -> (void) const { return get (); } inline const Returned & operator * (void) const { return *get (); } + template <typename C> inline operator const C * (void) const { return get (); } inline Data * get_data (void) const { diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index 8e56dde3..50a52136 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -279,7 +279,7 @@ data_destroy_arabic (void *data) { arabic_shape_plan_t *arabic_plan = (arabic_shape_plan_t *) data; - arabic_fallback_plan_destroy (arabic_plan->fallback_plan.get ()); + arabic_fallback_plan_destroy (arabic_plan->fallback_plan); free (data); } @@ -389,7 +389,7 @@ arabic_fallback_shape (const hb_ot_shape_plan_t *plan, return; retry: - arabic_fallback_plan_t *fallback_plan = arabic_plan->fallback_plan.get (); + arabic_fallback_plan_t *fallback_plan = arabic_plan->fallback_plan; if (unlikely (!fallback_plan)) { /* This sucks. We need a font to build the fallback plan... */ diff --git a/src/hb-shape-plan.cc b/src/hb-shape-plan.cc index 8d002f8a..f2f21019 100644 --- a/src/hb-shape-plan.cc +++ b/src/hb-shape-plan.cc @@ -532,7 +532,7 @@ hb_shape_plan_create_cached2 (hb_face_t *face, retry: - hb_face_t::plan_node_t *cached_plan_nodes = face->shape_plans.get (); + hb_face_t::plan_node_t *cached_plan_nodes = face->shape_plans; /* Don't look for plan in the cache if there were variation coordinates XXX Fix me. */ if (!hb_coords_present (coords, num_coords)) commit f6e7cb51b13aabb447dc97a59602d65eb42edc4b Author: Behdad Esfahbod <[email protected]> Date: Mon Nov 5 13:23:07 2018 -0500 Fix const-confusion in hb_array_t as well diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index f2bff063..9ccd7f25 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -553,11 +553,9 @@ struct hb_array_t inline unsigned int get_size (void) const { return len * sizeof (Type); } - template <typename T> inline operator T * (void) { return arrayZ; } - template <typename T> inline operator const T * (void) const { return arrayZ; } + template <typename T> inline operator T * (void) const { return arrayZ; } - inline Type * operator & (void) { return arrayZ; } - inline const Type * operator & (void) const { return arrayZ; } + inline Type * operator & (void) const { return arrayZ; } inline hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int seg_count) const { commit 0da22fb0ada8a54fc59739057f281a406a993212 Author: Behdad Esfahbod <[email protected]> Date: Mon Nov 5 13:13:39 2018 -0500 [null] Tweak hb_nonnull_ptr_t some more diff --git a/src/hb-null.hh b/src/hb-null.hh index c91af163..25a24f05 100644 --- a/src/hb-null.hh +++ b/src/hb-null.hh @@ -114,20 +114,14 @@ struct hb_nonnull_ptr_t inline hb_nonnull_ptr_t (T *v_ = nullptr) : v (v_) {} inline T * operator = (T *v_) { return v = v_; } - inline T * operator -> (void) { return get (); } - inline const T * operator -> (void) const { return get (); } - inline T & operator * (void) { return *get (); } - inline const T & operator * (void) const { return *get (); } - inline T ** operator & (void) { return &v; } - inline const T ** operator & (void) const { return &v; } - template <typename C> inline operator C * (void) { return get (); } + inline T * operator -> (void) const { return get (); } + inline T & operator * (void) const { return *get (); } + inline T ** operator & (void) const { return &v; } + /* Only auto-cast to const types. */ template <typename C> inline operator const C * (void) const { return get (); } - inline operator char * (void) { return (char *) get (); } inline operator const char * (void) const { return (const char *) get (); } - inline T * get (void) { return v ? v : const_cast<T *> (&Null(T)); } - inline const T * get (void) const { return v ? v : const_cast<T *> (&Null(T)); } - inline T * get_raw (void) { return v; } - inline const T * get_raw (void) const { return v; } + inline T * get (void) const { return v ? v : const_cast<T *> (&Null(T)); } + inline T * get_raw (void) const { return v; } T *v; }; commit 03348ce0051cfae7172ac0d09b83ed5f82fa842a Author: Behdad Esfahbod <[email protected]> Date: Mon Nov 5 12:59:32 2018 -0500 Minor diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc index 80bf2d76..9e0eb92f 100644 --- a/src/hb-aat-layout.cc +++ b/src/hb-aat-layout.cc @@ -181,7 +181,7 @@ _get_mort (hb_face_t *face, hb_blob_t **blob = nullptr) *blob = hb_blob_get_empty (); return Null(AAT::mort); } - const AAT::mort& mort = *(hb_ot_face_data (face)->mort.get ()); + const AAT::mort& mort = *(hb_ot_face_data (face)->mort); if (blob) *blob = hb_ot_face_data (face)->mort.get_blob (); return mort; @@ -195,7 +195,7 @@ _get_morx (hb_face_t *face, hb_blob_t **blob = nullptr) *blob = hb_blob_get_empty (); return Null(AAT::morx); } - const AAT::morx& morx = *(hb_ot_face_data (face)->morx.get ()); + const AAT::morx& morx = *(hb_ot_face_data (face)->morx); if (blob) *blob = hb_ot_face_data (face)->morx.get_blob (); return morx; @@ -209,7 +209,7 @@ _get_kerx (hb_face_t *face, hb_blob_t **blob = nullptr) *blob = hb_blob_get_empty (); return Null(AAT::kerx); } - const AAT::kerx& kerx = *(hb_ot_face_data (face)->kerx.get ()); + const AAT::kerx& kerx = *(hb_ot_face_data (face)->kerx); if (blob) *blob = hb_ot_face_data (face)->kerx.get_blob (); return kerx; @@ -223,7 +223,7 @@ _get_ankr (hb_face_t *face, hb_blob_t **blob = nullptr) *blob = hb_blob_get_empty (); return Null(AAT::ankr); } - const AAT::ankr& ankr = *(hb_ot_face_data (face)->ankr.get ()); + const AAT::ankr& ankr = *(hb_ot_face_data (face)->ankr); if (blob) *blob = hb_ot_face_data (face)->ankr.get_blob (); return ankr; @@ -232,13 +232,13 @@ static inline const AAT::trak& _get_trak (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(AAT::trak); - return *(hb_ot_face_data (face)->trak.get ()); + return *(hb_ot_face_data (face)->trak); } static inline const AAT::ltag& _get_ltag (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(AAT::ltag); - return *(hb_ot_face_data (face)->ltag.get ()); + return *(hb_ot_face_data (face)->ltag); } diff --git a/src/hb-ot-color.cc b/src/hb-ot-color.cc index b87ed56f..853f65dc 100644 --- a/src/hb-ot-color.cc +++ b/src/hb-ot-color.cc @@ -54,35 +54,35 @@ static inline const OT::COLR& _get_colr (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::COLR); - return *(hb_ot_face_data (face)->COLR.get ()); + return *(hb_ot_face_data (face)->COLR); } static inline const OT::CBDT_accelerator_t& _get_cbdt (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::CBDT_accelerator_t); - return *(hb_ot_face_data (face)->CBDT.get ()); + return *(hb_ot_face_data (face)->CBDT); } static inline const OT::CPAL& _get_cpal (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::CPAL); - return *(hb_ot_face_data (face)->CPAL.get ()); + return *(hb_ot_face_data (face)->CPAL); } static inline const OT::sbix_accelerator_t& _get_sbix (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::sbix_accelerator_t); - return *(hb_ot_face_data (face)->sbix.get ()); + return *(hb_ot_face_data (face)->sbix); } static inline const OT::SVG_accelerator_t& _get_svg (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::SVG_accelerator_t); - return *(hb_ot_face_data (face)->SVG.get ()); + return *(hb_ot_face_data (face)->SVG); } diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index 33a4388c..41bea140 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -62,7 +62,7 @@ hb_ot_get_nominal_glyph (hb_font_t *font HB_UNUSED, void *user_data HB_UNUSED) { const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; - return ot_face->cmap.get ()->get_nominal_glyph (unicode, glyph); + return ot_face->cmap->get_nominal_glyph (unicode, glyph); } static unsigned int @@ -76,7 +76,7 @@ hb_ot_get_nominal_glyphs (hb_font_t *font HB_UNUSED, void *user_data HB_UNUSED) { const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; - const OT::cmap_accelerator_t &cmap = *ot_face->cmap.get (); + const OT::cmap_accelerator_t &cmap = *ot_face->cmap; unsigned int done; for (done = 0; done < count && cmap.get_nominal_glyph (*first_unicode, first_glyph); @@ -97,7 +97,7 @@ hb_ot_get_variation_glyph (hb_font_t *font HB_UNUSED, void *user_data HB_UNUSED) { const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; - return ot_face->cmap.get ()->get_variation_glyph (unicode, variation_selector, glyph); + return ot_face->cmap->get_variation_glyph (unicode, variation_selector, glyph); } static void @@ -110,7 +110,7 @@ hb_ot_get_glyph_h_advances (hb_font_t* font, void* font_data, void *user_data HB_UNUSED) { const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; - const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx.get (); + const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx; for (unsigned int i = 0; i < count; i++) { @@ -130,7 +130,7 @@ hb_ot_get_glyph_v_advances (hb_font_t* font, void* font_data, void *user_data HB_UNUSED) { const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; - const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx.get (); + const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx; for (unsigned int i = 0; i < count; i++) { @@ -152,7 +152,7 @@ hb_ot_get_glyph_v_origin (hb_font_t *font, *x = font->get_glyph_h_advance (glyph) / 2; - const OT::VORG &VORG = *ot_face->VORG.get (); + const OT::VORG &VORG = *ot_face->VORG; if (VORG.has_data ()) { *y = font->em_scale_y (VORG.get_y_origin (glyph)); @@ -162,7 +162,7 @@ hb_ot_get_glyph_v_origin (hb_font_t *font, hb_glyph_extents_t extents = {0}; if (ot_face->glyf->get_extents (glyph, &extents)) { - const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx.get (); + const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx; hb_position_t tsb = vmtx.get_side_bearing (glyph); *y = font->em_scale_y (extents.y_bearing + tsb); return true; @@ -225,7 +225,7 @@ hb_ot_get_font_h_extents (hb_font_t *font, void *user_data HB_UNUSED) { const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; - const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx.get (); + const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx; metrics->ascender = font->em_scale_y (hmtx.ascender); metrics->descender = font->em_scale_y (hmtx.descender); metrics->line_gap = font->em_scale_y (hmtx.line_gap); @@ -240,7 +240,7 @@ hb_ot_get_font_v_extents (hb_font_t *font, void *user_data HB_UNUSED) { const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; - const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx.get (); + const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx; metrics->ascender = font->em_scale_x (vmtx.ascender); metrics->descender = font->em_scale_x (vmtx.descender); metrics->line_gap = font->em_scale_x (vmtx.line_gap); diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index f1f09c76..fcdc79ee 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -62,7 +62,7 @@ _get_kern (hb_face_t *face, hb_blob_t **blob = nullptr) *blob = hb_blob_get_empty (); return Null(OT::kern); } - const OT::kern& kern = *(hb_ot_face_data (face)->kern.get ()); + const OT::kern& kern = *(hb_ot_face_data (face)->kern); if (blob) *blob = hb_ot_face_data (face)->kern.get_blob (); return kern; diff --git a/src/hb-ot-math.cc b/src/hb-ot-math.cc index 92c29480..3fb720b2 100644 --- a/src/hb-ot-math.cc +++ b/src/hb-ot-math.cc @@ -45,7 +45,7 @@ _get_math (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::MATH); hb_ot_face_data_t * data = hb_ot_face_data (face); - return *(data->MATH.get ()); + return *(data->MATH); } /* diff --git a/src/hb-ot-name.cc b/src/hb-ot-name.cc index f5ac18d7..f2d1f0c2 100644 --- a/src/hb-ot-name.cc +++ b/src/hb-ot-name.cc @@ -46,7 +46,7 @@ static inline const OT::name_accelerator_t& _get_name (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::name_accelerator_t); - return *(hb_ot_face_data (face)->name.get ()); + return *(hb_ot_face_data (face)->name); } /** diff --git a/src/hb-ot-var.cc b/src/hb-ot-var.cc index 64087be8..4363f85e 100644 --- a/src/hb-ot-var.cc +++ b/src/hb-ot-var.cc @@ -51,15 +51,13 @@ static inline const OT::fvar& _get_fvar (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::fvar); - hb_ot_face_data_t *layout = hb_ot_face_data (face); - return *(layout->fvar.get ()); + return *(hb_ot_face_data (face)->fvar); } static inline const OT::avar& _get_avar (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::avar); - hb_ot_face_data_t *layout = hb_ot_face_data (face); - return *(layout->avar.get ()); + return *(hb_ot_face_data (face)->avar); } /** _______________________________________________ HarfBuzz mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/harfbuzz
