src/hb-aat-layout-trak-table.hh |    2 +-
 src/hb-dsalgs.hh                |    2 ++
 src/hb-open-file.hh             |    3 +--
 src/hb-open-type.hh             |    8 ++++++++
 src/hb-ot-color-cpal-table.hh   |    6 +++---
 5 files changed, 15 insertions(+), 6 deletions(-)

New commits:
commit 8d689f8a7bccda861bcb286d52f1a90fca52df0f
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Mon Oct 22 21:33:18 2018 -0700

    Add hb_array<>() specialization for UnsizedArrayOf
    
    Related https://github.com/harfbuzz/harfbuzz/issues/1301

diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh
index 823991f2..8cfc8bc3 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).arrayZ, nSizes)[index];
+    return hb_array (base+valuesZ, nSizes)[index];
   }
 
   public:
diff --git a/src/hb-open-file.hh b/src/hb-open-file.hh
index 3b742ea7..80dc5e61 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).arrayZ, get_resource_count ())[i];
+    return hb_array (type_base+resourcesZ, 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 19081447..a76b111e 100644
--- a/src/hb-open-type.hh
+++ b/src/hb-open-type.hh
@@ -385,6 +385,14 @@ struct UnsizedArrayOf
   public:
   DEFINE_SIZE_ARRAY (0, arrayZ);
 };
+} /* namespace OT */
+template <typename T>
+hb_array_t<T> hb_array (OT::UnsizedArrayOf<T> &array, unsigned int len)
+{ return hb_array (array.arrayZ, len); }
+template <typename T>
+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 4b09d3a5..7d3733d3 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).arrayZ, palette_count)[palette_index];
+          hb_array (base+paletteFlagsZ, palette_count)[palette_index];
   }
 
   inline unsigned int
@@ -64,7 +64,7 @@ struct CPALV1Tail
                       unsigned int palette_count) const
   {
     if (!paletteLabelsZ) return HB_NAME_ID_INVALID;
-    return hb_array ((base+paletteLabelsZ).arrayZ, 
palette_count)[palette_index];
+    return hb_array (base+paletteLabelsZ, palette_count)[palette_index];
   }
 
   inline unsigned int
@@ -73,7 +73,7 @@ struct CPALV1Tail
                     unsigned int color_count) const
   {
     if (!colorLabelsZ) return HB_NAME_ID_INVALID;
-    return hb_array ((base+colorLabelsZ).arrayZ, color_count)[color_index];
+    return hb_array (base+colorLabelsZ, color_count)[color_index];
   }
 
   public:
commit abfbba191141c3e3cf2a391f365b5323f9dc37c0
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Mon Oct 22 21:27:45 2018 -0700

    Add hb_array<>()
    
    Simplifies transient object creation.
    
    Fixes https://github.com/harfbuzz/harfbuzz/issues/1301

diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh
index c2c50bbb..823991f2 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_t<const FWORD> ((base+valuesZ).arrayZ, nSizes)[index];
+    return hb_array ((base+valuesZ).arrayZ, nSizes)[index];
   }
 
   public:
diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh
index 27c1a96e..11a05506 100644
--- a/src/hb-dsalgs.hh
+++ b/src/hb-dsalgs.hh
@@ -537,6 +537,8 @@ struct hb_array_t
   T *arrayZ;
   unsigned int len;
 };
+template <typename T>
+hb_array_t<T> hb_array (T *array, unsigned int len) { return hb_array_t<T> 
(array, len); }
 
 struct hb_bytes_t
 {
diff --git a/src/hb-open-file.hh b/src/hb-open-file.hh
index a973455d..3b742ea7 100644
--- a/src/hb-open-file.hh
+++ b/src/hb-open-file.hh
@@ -330,8 +330,7 @@ struct ResourceTypeRecord
   inline const ResourceRecord& get_resource_record (unsigned int i,
                                                    const void *type_base) const
   {
-    return hb_array_t<const ResourceRecord> ((type_base+resourcesZ).arrayZ,
-                                            get_resource_count ()) [i];
+    return hb_array ((type_base+resourcesZ).arrayZ, get_resource_count ())[i];
   }
 
   inline bool sanitize (hb_sanitize_context_t *c,
diff --git a/src/hb-ot-color-cpal-table.hh b/src/hb-ot-color-cpal-table.hh
index 7dd0c0f9..4b09d3a5 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_t<const HBUINT32> ((base+paletteFlagsZ).arrayZ, 
palette_count)[palette_index];
+          hb_array ((base+paletteFlagsZ).arrayZ, palette_count)[palette_index];
   }
 
   inline unsigned int
@@ -64,7 +64,7 @@ struct CPALV1Tail
                       unsigned int palette_count) const
   {
     if (!paletteLabelsZ) return HB_NAME_ID_INVALID;
-    return hb_array_t<const NameID> ((base+paletteLabelsZ).arrayZ, 
palette_count)[palette_index];
+    return hb_array ((base+paletteLabelsZ).arrayZ, 
palette_count)[palette_index];
   }
 
   inline unsigned int
@@ -73,7 +73,7 @@ struct CPALV1Tail
                     unsigned int color_count) const
   {
     if (!colorLabelsZ) return HB_NAME_ID_INVALID;
-    return hb_array_t<const NameID> ((base+colorLabelsZ).arrayZ, 
color_count)[color_index];
+    return hb_array ((base+colorLabelsZ).arrayZ, color_count)[color_index];
   }
 
   public:
_______________________________________________
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/harfbuzz

Reply via email to