From 2087f5a2a743380b36399ba8a2b4ff9e93890fcf Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 1 Dec 2018 20:04:45 -0500 Subject: [PATCH] Add casts to hb_array_t<> --- src/hb-open-type.hh | 13 ++++++++++--- src/hb-vector.hh | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 0038ad8..69cc5cc 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -374,16 +374,17 @@ struct UnsizedArrayOf return *p; } - template inline operator T * (void) { return arrayZ; } - template inline operator const T * (void) const { return arrayZ; } - inline unsigned int get_size (unsigned int len) const { return len * Type::static_size; } + template inline operator T * (void) { return arrayZ; } + template inline operator const T * (void) const { return arrayZ; } inline hb_array_t as_array (unsigned int len) { return hb_array (arrayZ, len); } inline hb_array_t as_array (unsigned int len) const { return hb_array (arrayZ, len); } + inline operator hb_array_t (void) { return as_array (); } + inline operator hb_array_t (void) const { as_array (); } template inline Type &lsearch (unsigned int len, const T &x, Type ¬_found = Crap (Type)) @@ -488,6 +489,8 @@ struct SortedUnsizedArrayOf : UnsizedArrayOf { return hb_sorted_array (this->arrayZ, len); } inline hb_sorted_array_t as_array (unsigned int len) const { return hb_sorted_array (this->arrayZ, len); } + inline operator hb_sorted_array_t (void) { return as_array (); } + inline operator hb_sorted_array_t (void) const { as_array (); } template inline Type &bsearch (unsigned int len, const T &x, Type ¬_found = Crap (Type)) @@ -533,6 +536,8 @@ struct ArrayOf { return hb_array (arrayZ, len); } inline hb_array_t as_array (void) const { return hb_array (arrayZ, len); } + inline operator hb_array_t (void) { return as_array (); } + inline operator hb_array_t (void) const { as_array (); } inline hb_array_t sub_array (unsigned int start_offset, unsigned int count) const { return as_array ().sub_array (start_offset, count);} @@ -802,6 +807,8 @@ struct SortedArrayOf : ArrayOf { return hb_sorted_array (this->arrayZ, this->len); } inline hb_sorted_array_t as_array (void) const { return hb_sorted_array (this->arrayZ, this->len); } + inline operator hb_sorted_array_t (void) { return as_array (); } + inline operator hb_sorted_array_t (void) const { as_array (); } inline hb_array_t sub_array (unsigned int start_offset, unsigned int count) const { return as_array ().sub_array (start_offset, count);} diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 953a776..4b34a38 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -105,6 +105,8 @@ struct hb_vector_t template explicit_operator inline operator T * (void) { return arrayZ(); } template explicit_operator inline operator const T * (void) const { return arrayZ(); } + inline operator hb_array_t (void) { return as_array (); } + inline operator hb_array_t (void) const { as_array (); } inline Type * operator + (unsigned int i) { return arrayZ() + i; } inline const Type * operator + (unsigned int i) const { return arrayZ() + i; } -- 2.7.4