summaryrefslogtreecommitdiff
path: root/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh')
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh34
1 files changed, 28 insertions, 6 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh
index 7e06ff17010..eb15c089eb6 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh
@@ -29,6 +29,8 @@
#include "hb.hh"
+#include "hb-null.hh"
+
/* Void! For when we need a expression-type of void. */
typedef const struct _hb_void_t *hb_void_t;
@@ -507,20 +509,40 @@ struct hb_auto_t : Type
void fini (void) {}
};
+template <typename T>
+struct hb_array_t
+{
+ inline hb_array_t (void) : arrayZ (nullptr), len (0) {}
+ inline hb_array_t (const T *array_, unsigned int len_) : arrayZ (array_), len (len_) {}
+
+ inline const T& operator [] (unsigned int i) const
+ {
+ if (unlikely (i >= len)) return Null(T);
+ return arrayZ[i];
+ }
+
+ inline void free (void) { ::free ((void *) arrayZ); arrayZ = nullptr; len = 0; }
+
+ const T *arrayZ;
+ unsigned int len;
+};
+
struct hb_bytes_t
{
- inline hb_bytes_t (void) : bytes (nullptr), len (0) {}
- inline hb_bytes_t (const char *bytes_, unsigned int len_) : bytes (bytes_), len (len_) {}
- inline hb_bytes_t (const void *bytes_, unsigned int len_) : bytes ((const char *) bytes_), len (len_) {}
+ inline hb_bytes_t (void) : arrayZ (nullptr), len (0) {}
+ inline hb_bytes_t (const char *bytes_, unsigned int len_) : arrayZ (bytes_), len (len_) {}
+ inline hb_bytes_t (const void *bytes_, unsigned int len_) : arrayZ ((const char *) bytes_), len (len_) {}
+ template <typename T>
+ inline hb_bytes_t (const T& array) : arrayZ ((const char *) array.arrayZ), len (array.len) {}
- inline void free (void) { ::free ((void *) bytes); bytes = nullptr; len = 0; }
+ inline void free (void) { ::free ((void *) arrayZ); arrayZ = nullptr; len = 0; }
inline int cmp (const hb_bytes_t &a) const
{
if (len != a.len)
return (int) a.len - (int) len;
- return memcmp (a.bytes, bytes, len);
+ return memcmp (a.arrayZ, arrayZ, len);
}
static inline int cmp (const void *pa, const void *pb)
{
@@ -529,7 +551,7 @@ struct hb_bytes_t
return b->cmp (*a);
}
- const char *bytes;
+ const char *arrayZ;
unsigned int len;
};