From c72589f13f24ca24a0613f7d9bc28b7fe1ef25c0 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 29 Aug 2019 15:45:21 -0700 Subject: [PATCH] [iter] Change item_size to get_item_size() By moving access to hb_static_size(Type) into a function instead of a class-const, we can refer to iter types of incomplete types, which come handy when a method of hb_array_t wants to return iterator of hb_array_t. That kind of stuff. Next commit needs this to build on clang... --- src/hb-array.hh | 8 ++++---- src/hb-iter.hh | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hb-array.hh b/src/hb-array.hh index 51994947e..6efaf5fa5 100644 --- a/src/hb-array.hh +++ b/src/hb-array.hh @@ -141,13 +141,13 @@ struct hb_array_t : hb_iter_with_fallback_t, Type&> hb_sorted_array_t qsort (int (*cmp_)(const void*, const void*)) { if (likely (length)) - hb_qsort (arrayZ, length, this->item_size, cmp_); + hb_qsort (arrayZ, length, this->get_item_size (), cmp_); return hb_sorted_array_t (*this); } hb_sorted_array_t qsort () { if (likely (length)) - hb_qsort (arrayZ, length, this->item_size, Type::cmp); + hb_qsort (arrayZ, length, this->get_item_size (), Type::cmp); return hb_sorted_array_t (*this); } void qsort (unsigned int start, unsigned int end) @@ -155,14 +155,14 @@ struct hb_array_t : hb_iter_with_fallback_t, Type&> end = hb_min (end, length); assert (start <= end); if (likely (start < end)) - hb_qsort (arrayZ + start, end - start, this->item_size, Type::cmp); + hb_qsort (arrayZ + start, end - start, this->get_item_size (), Type::cmp); } /* * Other methods. */ - unsigned int get_size () const { return length * this->item_size; } + unsigned int get_size () const { return length * this->get_item_size (); } hb_array_t sub_array (unsigned int start_offset = 0, unsigned int *seg_count = nullptr /* IN/OUT */) const { diff --git a/src/hb-iter.hh b/src/hb-iter.hh index 238663e8a..c14fee907 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -64,7 +64,7 @@ template struct hb_iter_t { typedef Item item_t; - static constexpr unsigned item_size = hb_static_size (Item); + constexpr unsigned get_item_size () const { return hb_static_size (Item); } static constexpr bool is_iterator = true; static constexpr bool is_random_access_iterator = false; static constexpr bool is_sorted_iterator = false; @@ -130,7 +130,7 @@ struct hb_iter_t using item_t = typename Name::item_t; \ using Name::begin; \ using Name::end; \ - using Name::item_size; \ + using Name::get_item_size; \ using Name::is_iterator; \ using Name::iter; \ using Name::operator bool; \