diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh index f58050da0..f8f1a5b57 100644 --- a/src/hb-machinery.hh +++ b/src/hb-machinery.hh @@ -110,17 +110,17 @@ static inline Type& StructAfter(TObject &X) static const unsigned int min_size = (size) #define DEFINE_SIZE_ARRAY(size, array) \ - DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + VAR * sizeof (array[0])); \ - DEFINE_COMPILES_ASSERTION ((void) array[0].static_size) \ + DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + VAR * (array).item_size); \ + DEFINE_COMPILES_ASSERTION ((void) (array)[0].static_size) \ enum { min_size = (size) } #define DEFINE_SIZE_ARRAY_SIZED(size, array) \ - inline unsigned int get_size (void) const { return (size - array.min_size + array.get_size ()); } \ + inline unsigned int get_size (void) const { return (size - (array).min_size + (array).get_size ()); } \ DEFINE_SIZE_ARRAY(size, array) #define DEFINE_SIZE_ARRAY2(size, array1, array2) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + sizeof (this->array1[0]) + sizeof (this->array2[0])); \ - DEFINE_COMPILES_ASSERTION ((void) array1[0].static_size; (void) array2[0].static_size) \ + DEFINE_COMPILES_ASSERTION ((void) (array1)[0].static_size; (void) (array2)[0].static_size) \ static const unsigned int min_size = (size) diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 56fa43345..14506180f 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -335,6 +335,8 @@ static inline Type& operator + (Base &base, OffsetTo template struct UnsizedArrayOf { + enum { item_size = Type::static_size }; + HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type); /* Unlikely other places, use "int i" instead of "unsigned int i" for our @@ -435,6 +437,8 @@ struct UnsizedOffsetListOf : UnsizedOffsetArrayOf template struct ArrayOf { + enum { item_size = Type::static_size }; + HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (ArrayOf, Type, LenType); inline const Type *sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const @@ -603,6 +607,8 @@ struct OffsetListOf : OffsetArrayOf template struct HeadlessArrayOf { + enum { item_size = Type::static_size }; + HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (HeadlessArrayOf, Type, LenType); inline const Type& operator [] (unsigned int i) const @@ -801,6 +807,8 @@ struct VarSizedBinSearchHeader template struct VarSizedBinSearchArrayOf { + enum { item_size = Type::static_size }; + HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (VarSizedBinSearchArrayOf, Type); inline const Type& operator [] (unsigned int i) const diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index 399c46bfc..c0e08666a 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -636,7 +636,7 @@ struct DefaultUVS : SortedArrayOf } public: - DEFINE_SIZE_ARRAY (4, arrayZ); + DEFINE_SIZE_ARRAY (4, *this); }; struct UVSMapping @@ -668,7 +668,7 @@ struct NonDefaultUVS : SortedArrayOf } public: - DEFINE_SIZE_ARRAY (4, arrayZ); + DEFINE_SIZE_ARRAY (4, *this); }; struct VariationSelectorRecord diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index fc74af47a..cf735c301 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -53,7 +53,7 @@ enum attach_type_t { typedef HBUINT16 Value; -typedef Value ValueRecord[VAR]; +typedef UnsizedArrayOf ValueRecord; struct ValueFormat : HBUINT16 { @@ -879,7 +879,7 @@ struct PairPosFormat2 unsigned int stride = len1 + len2; unsigned int record_size = valueFormat1.get_size () + valueFormat2.get_size (); unsigned int count = (unsigned int) class1Count * (unsigned int) class2Count; - return_trace (c->check_array (values, count, record_size) && + return_trace (c->check_array ((const void *) values, count, record_size) && valueFormat1.sanitize_values_stride_unsafe (c, this, &values[0], count, stride) && valueFormat2.sanitize_values_stride_unsafe (c, this, &values[len1], count, stride)); } diff --git a/src/hb-ot-var-avar-table.hh b/src/hb-ot-var-avar-table.hh index d100ca21e..c2b110a21 100644 --- a/src/hb-ot-var-avar-table.hh +++ b/src/hb-ot-var-avar-table.hh @@ -94,7 +94,7 @@ struct SegmentMaps : ArrayOf } public: - DEFINE_SIZE_ARRAY (2, arrayZ); + DEFINE_SIZE_ARRAY (2, *this); }; struct avar @@ -109,7 +109,7 @@ struct avar c->check_struct (this)))) return_trace (false); - const SegmentMaps *map = axisSegmentMapsZ.arrayZ; + const SegmentMaps *map = &firstAxisSegmentMaps; unsigned int count = axisCount; for (unsigned int i = 0; i < count; i++) { @@ -125,7 +125,7 @@ struct avar { unsigned int count = MIN (coords_length, axisCount); - const SegmentMaps *map = axisSegmentMapsZ.arrayZ; + const SegmentMaps *map = &firstAxisSegmentMaps; for (unsigned int i = 0; i < count; i++) { coords[i] = map->map (coords[i]); @@ -140,8 +140,7 @@ struct avar HBUINT16 axisCount; /* The number of variation axes in the font. This * must be the same number as axisCount in the * 'fvar' table. */ - UnsizedArrayOf - axisSegmentMapsZ; + SegmentMaps firstAxisSegmentMaps; public: DEFINE_SIZE_MIN (8);