diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2018-11-02 11:46:24 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2018-11-02 11:46:42 -0400 |
commit | 72462eb76584a2892f1d961c90fd289240ea9380 (patch) | |
tree | 39f03c278764a4a2b862682531cc71e75c058fd2 | |
parent | 1cf075ecb674cc0c7043bffe2fef5ef187c15335 (diff) |
Add UnsizedArrayOf::as_array() instead of hb_array() template
-rw-r--r-- | src/hb-aat-layout-trak-table.hh | 2 | ||||
-rw-r--r-- | src/hb-dsalgs.hh | 2 | ||||
-rw-r--r-- | src/hb-open-file.hh | 2 | ||||
-rw-r--r-- | src/hb-open-type.hh | 11 | ||||
-rw-r--r-- | src/hb-ot-color-cpal-table.hh | 6 |
5 files changed, 8 insertions, 15 deletions
diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh index de2071ad..c579c119 100644 --- a/src/hb-aat-layout-trak-table.hh +++ b/src/hb-aat-layout-trak-table.hh @@ -55,7 +55,7 @@ struct TrackTableEntry unsigned int index, unsigned int nSizes) const { - return hb_array (base+valuesZ, nSizes)[index]; + return (base+valuesZ).as_array (nSizes)[index]; } public: diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index 59df860d..0940dc53 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -572,8 +572,6 @@ struct hb_array_t T *arrayZ; unsigned int len; }; -template <typename T> static inline -hb_array_t<T> hb_array (T *array, unsigned int len) { return hb_array_t<T> (array, len); } struct HbOpOr diff --git a/src/hb-open-file.hh b/src/hb-open-file.hh index 80dc5e61..2ef6d775 100644 --- a/src/hb-open-file.hh +++ b/src/hb-open-file.hh @@ -330,7 +330,7 @@ struct ResourceTypeRecord inline const ResourceRecord& get_resource_record (unsigned int i, const void *type_base) const { - return hb_array (type_base+resourcesZ, get_resource_count ())[i]; + return (type_base+resourcesZ).as_array (get_resource_count ())[i]; } inline bool sanitize (hb_sanitize_context_t *c, diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 06257603..7bce7ead 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -346,6 +346,9 @@ struct UnsizedArrayOf inline unsigned int get_size (unsigned int len) const { return len * Type::static_size; } + inline hb_array_t<Type> as_array (unsigned int len) { return hb_array_t<Type> (arrayZ, len); } + inline hb_array_t<const Type> as_array (unsigned int len) const { return hb_array_t<const Type> (arrayZ, len); } + inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const { TRACE_SANITIZE (this); @@ -393,14 +396,6 @@ struct UnsizedArrayOf public: DEFINE_SIZE_ARRAY (0, arrayZ); }; -} /* namespace OT */ -template <typename T> static inline -hb_array_t<T> hb_array (OT::UnsizedArrayOf<T> &array, unsigned int len) -{ return hb_array (array.arrayZ, len); } -template <typename T> static inline -hb_array_t<const T> hb_array (const OT::UnsizedArrayOf<T> &array, unsigned int len) -{ return hb_array (array.arrayZ, len); } -namespace OT { /* Unsized array of offset's */ template <typename Type, typename OffsetType, bool has_null=true> diff --git a/src/hb-ot-color-cpal-table.hh b/src/hb-ot-color-cpal-table.hh index df4d9b4e..332f0dd7 100644 --- a/src/hb-ot-color-cpal-table.hh +++ b/src/hb-ot-color-cpal-table.hh @@ -55,7 +55,7 @@ struct CPALV1Tail { if (!paletteFlagsZ) return HB_OT_COLOR_PALETTE_FLAG_DEFAULT; return (hb_ot_color_palette_flags_t) (uint32_t) - hb_array (base+paletteFlagsZ, palette_count)[palette_index]; + (base+paletteFlagsZ).as_array (palette_count)[palette_index]; } inline hb_ot_name_id_t @@ -64,7 +64,7 @@ struct CPALV1Tail unsigned int palette_count) const { if (!paletteLabelsZ) return HB_OT_NAME_ID_INVALID; - return hb_array (base+paletteLabelsZ, palette_count)[palette_index]; + return (base+paletteLabelsZ).as_array (palette_count)[palette_index]; } inline hb_ot_name_id_t @@ -73,7 +73,7 @@ struct CPALV1Tail unsigned int color_count) const { if (!colorLabelsZ) return HB_OT_NAME_ID_INVALID; - return hb_array (base+colorLabelsZ, color_count)[color_index]; + return (base+colorLabelsZ).as_array (color_count)[color_index]; } public: |