src/hb-open-file-private.hh | 2 - src/hb-open-type-private.hh | 74 +++++++++---------------------------- src/hb-ot-cmap-table.hh | 6 +-- src/hb-ot-layout-common-private.hh | 10 ++--- src/hb-ot-layout-gdef-table.hh | 2 - src/hb-private.hh | 9 ++-- 6 files changed, 33 insertions(+), 70 deletions(-)
New commits: commit 586b60622c33878f9ca4826b4ef07369d32bf039 Author: Behdad Esfahbod <[email protected]> Date: Fri Jun 27 15:39:47 2014 -0400 Minor: final bits of cleanup diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index b63daee..5f4cd42 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -728,6 +728,7 @@ struct OffsetTo : Offset<OffsetType> inline bool neuter (hb_sanitize_context_t *c) { return c->try_set (this, 0); } + DEFINE_SIZE_STATIC (sizeof(OffsetType)); }; template <typename Base, typename OffsetType, typename Type> static inline const Type& operator + (const Base &base, const OffsetTo<Type, OffsetType> &offset) { return offset (base); } diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index 2ed14a2..82e0fb7 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -502,7 +502,7 @@ struct Feature * Adobe tools, only the 'size' feature had FeatureParams defined. */ - Offset<> orig_offset = featureParams; + OffsetTo<FeatureParams> orig_offset = featureParams; if (unlikely (!featureParams.sanitize (c, this, closure ? closure->tag : HB_TAG_NONE))) return TRACE_RETURN (false); @@ -516,7 +516,7 @@ struct Feature unsigned int new_offset_int = (unsigned int) orig_offset - (((char *) this) - ((char *) closure->list_base)); - Offset<> new_offset; + OffsetTo<FeatureParams> new_offset; /* Check that it did not overflow. */ new_offset.set (new_offset_int); if (new_offset == new_offset_int && commit 51d9ba09bc78188ec87218aef5232e80568c1712 Author: Behdad Esfahbod <[email protected]> Date: Fri Jun 27 15:27:15 2014 -0400 Minor diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index e995dc0..b63daee 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -873,9 +873,8 @@ struct OffsetListOf : OffsetArrayOf<Type> }; -/* An array with a USHORT number of elements, - * starting at second element. */ -template <typename Type> +/* An array starting at second element. */ +template <typename Type, typename LenType=USHORT> struct HeadlessArrayOf { inline const Type& operator [] (unsigned int i) const @@ -922,10 +921,10 @@ struct HeadlessArrayOf return TRACE_RETURN (true); } - USHORT len; + LenType len; Type array[VAR]; public: - DEFINE_SIZE_ARRAY (sizeof (USHORT), array); + DEFINE_SIZE_ARRAY (sizeof (LenType), array); }; commit 3084767e92483c669f38319f153c498e9a6b92c7 Author: Behdad Esfahbod <[email protected]> Date: Fri Jun 27 15:24:35 2014 -0400 Minor: Remove LongArrayOf diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh index b583aa1..f7e80a3 100644 --- a/src/hb-open-file-private.hh +++ b/src/hb-open-file-private.hh @@ -139,7 +139,7 @@ struct TTCHeaderVersion1 Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */ FixedVersion version; /* Version of the TTC Header (1.0), * 0x00010000 */ - LongArrayOf<OffsetTo<OffsetTable, ULONG> > + ArrayOf<OffsetTo<OffsetTable, ULONG>, ULONG> table; /* Array of offsets to the OffsetTable for each font * from the beginning of the file */ public: diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index ef4ceb7..e995dc0 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -847,10 +847,6 @@ struct ArrayOf DEFINE_SIZE_ARRAY (sizeof (LenType), array); }; -/* An array with a ULONG number of elements. */ -template <typename Type> -struct LongArrayOf : ArrayOf<Type, ULONG> {}; - /* Array of Offset's */ template <typename Type> struct OffsetArrayOf : ArrayOf<OffsetTo<Type> > {}; commit 41ea59495032e712fa6f801350ee00d5f00b5724 Author: Behdad Esfahbod <[email protected]> Date: Fri Jun 27 15:23:18 2014 -0400 Minor: Remove LongSortedArrayOf diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 2fba736..ef4ceb7 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -957,10 +957,6 @@ struct SortedArrayOf : ArrayOf<Type, LenType> } }; -/* A sorted array with a ULONG number of elements. */ -template <typename Type> -struct LongSortedArrayOf : SortedArrayOf<Type, ULONG> {}; - } /* namespace OT */ diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index abdd8db..8cc2ab7 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -264,7 +264,7 @@ struct CmapSubtableLongSegmented USHORT reserved; /* Reserved; set to 0. */ ULONG length; /* Byte length of this subtable. */ ULONG language; /* Ignore. */ - LongSortedArrayOf<CmapSubtableLongGroup> + SortedArrayOf<CmapSubtableLongGroup, ULONG> groups; /* Groupings. */ public: DEFINE_SIZE_ARRAY (16, groups); commit bb6ecf2ce5c2679c298741af17836a22e1d68121 Author: Behdad Esfahbod <[email protected]> Date: Fri Jun 27 15:13:44 2014 -0400 Minor: Remove LongOffsetArrayOf and LongOffsetLongArrayOf diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh index 250504a..b583aa1 100644 --- a/src/hb-open-file-private.hh +++ b/src/hb-open-file-private.hh @@ -139,7 +139,7 @@ struct TTCHeaderVersion1 Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */ FixedVersion version; /* Version of the TTC Header (1.0), * 0x00010000 */ - LongOffsetLongArrayOf<OffsetTable> + LongArrayOf<OffsetTo<OffsetTable, ULONG> > table; /* Array of offsets to the OffsetTable for each font * from the beginning of the file */ public: diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 84e4aa2..2fba736 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -855,14 +855,6 @@ struct LongArrayOf : ArrayOf<Type, ULONG> {}; template <typename Type> struct OffsetArrayOf : ArrayOf<OffsetTo<Type> > {}; -/* Array of LongOffset's */ -template <typename Type> -struct LongOffsetArrayOf : ArrayOf<OffsetTo<Type, ULONG> > {}; - -/* LongArray of LongOffset's */ -template <typename Type> -struct LongOffsetLongArrayOf : LongArrayOf<OffsetTo<Type, ULONG> > {}; - /* Array of offsets relative to the beginning of the array itself. */ template <typename Type> struct OffsetListOf : OffsetArrayOf<Type> diff --git a/src/hb-ot-layout-gdef-table.hh b/src/hb-ot-layout-gdef-table.hh index 389cbb9..bb8a4b9 100644 --- a/src/hb-ot-layout-gdef-table.hh +++ b/src/hb-ot-layout-gdef-table.hh @@ -282,7 +282,7 @@ struct MarkGlyphSetsFormat1 protected: USHORT format; /* Format identifier--format = 1 */ - LongOffsetArrayOf<Coverage> + ArrayOf<OffsetTo<Coverage, ULONG> > coverage; /* Array of long offsets to mark set * coverage tables */ public: commit 99d281712390fd54e523b2f0580d10445457ec2f Author: Behdad Esfahbod <[email protected]> Date: Fri Jun 27 15:12:52 2014 -0400 Minor: Remove GenericOffset diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 0b17eff..84e4aa2 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -630,18 +630,15 @@ struct Index : USHORT { }; DEFINE_NULL_DATA (Index, "\xff\xff"); -/* GenericOffset, Null offset = 0 */ -template <typename Type> -struct GenericOffset : Type +/* Offset, Null offset = 0 */ +template <typename Type=USHORT> +struct Offset : Type { inline bool is_null (void) const { return 0 == *this; } public: DEFINE_SIZE_STATIC (sizeof(Type)); }; -typedef GenericOffset<USHORT> Offset; -typedef GenericOffset<ULONG> LongOffset; - /* CheckSum */ struct CheckSum : ULONG @@ -688,12 +685,12 @@ struct FixedVersion /* - * Template subclasses of Offset and LongOffset that do the dereferencing. + * Template subclasses of Offset that do the dereferencing. * Use: (base+offset) */ template <typename Type, typename OffsetType=USHORT> -struct OffsetTo : GenericOffset<OffsetType> +struct OffsetTo : Offset<OffsetType> { inline const Type& operator () (const void *base) const { diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index 479fb26..2ed14a2 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -204,7 +204,7 @@ struct LangSys return TRACE_RETURN (c->check_struct (this) && featureIndex.sanitize (c)); } - Offset lookupOrder; /* = Null (reserved for an offset to a + Offset<> lookupOrder; /* = Null (reserved for an offset to a * reordering table) */ USHORT reqFeatureIndex;/* Index of a feature required for this * language system--if no required features @@ -502,7 +502,7 @@ struct Feature * Adobe tools, only the 'size' feature had FeatureParams defined. */ - Offset orig_offset = featureParams; + Offset<> orig_offset = featureParams; if (unlikely (!featureParams.sanitize (c, this, closure ? closure->tag : HB_TAG_NONE))) return TRACE_RETURN (false); @@ -516,7 +516,7 @@ struct Feature unsigned int new_offset_int = (unsigned int) orig_offset - (((char *) this) - ((char *) closure->list_base)); - Offset new_offset; + Offset<> new_offset; /* Check that it did not overflow. */ new_offset.set (new_offset_int); if (new_offset == new_offset_int && @@ -609,7 +609,7 @@ struct Lookup USHORT lookupType; /* Different enumerations for GSUB and GPOS */ USHORT lookupFlag; /* Lookup qualifiers */ - ArrayOf<Offset> + ArrayOf<Offset<> > subTable; /* Array of SubTables */ USHORT markFilteringSetX[VAR]; /* Index (base 0) into GDEF mark glyph sets * structure. This field is only present if bit commit 9da552dcc5b89b3bbbe5a55fb7c543222382e12a Author: Behdad Esfahbod <[email protected]> Date: Fri Jun 27 15:09:42 2014 -0400 Minor: Remove some GenericXXX templates diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index f6081f0..0b17eff 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -692,8 +692,8 @@ struct FixedVersion * Use: (base+offset) */ -template <typename Type, typename OffsetType=Offset> -struct OffsetTo : OffsetType +template <typename Type, typename OffsetType=USHORT> +struct OffsetTo : GenericOffset<OffsetType> { inline const Type& operator () (const void *base) const { @@ -737,16 +737,14 @@ static inline const Type& operator + (const Base &base, const OffsetTo<Type, Off template <typename Base, typename OffsetType, typename Type> static inline Type& operator + (Base &base, OffsetTo<Type, OffsetType> &offset) { return offset (base); } -template <typename Type> -struct LongOffsetTo : OffsetTo<Type, LongOffset> {}; - /* * Array Types */ -template <typename Type, typename LenType> -struct GenericArrayOf +/* An array with a number of elements. */ +template <typename Type, typename LenType=USHORT> +struct ArrayOf { const Type *sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const { @@ -852,13 +850,9 @@ struct GenericArrayOf DEFINE_SIZE_ARRAY (sizeof (LenType), array); }; -/* An array with a USHORT number of elements. */ -template <typename Type> -struct ArrayOf : GenericArrayOf<Type, USHORT> {}; - /* An array with a ULONG number of elements. */ template <typename Type> -struct LongArrayOf : GenericArrayOf<Type, ULONG> {}; +struct LongArrayOf : ArrayOf<Type, ULONG> {}; /* Array of Offset's */ template <typename Type> @@ -866,11 +860,11 @@ struct OffsetArrayOf : ArrayOf<OffsetTo<Type> > {}; /* Array of LongOffset's */ template <typename Type> -struct LongOffsetArrayOf : ArrayOf<LongOffsetTo<Type> > {}; +struct LongOffsetArrayOf : ArrayOf<OffsetTo<Type, ULONG> > {}; /* LongArray of LongOffset's */ template <typename Type> -struct LongOffsetLongArrayOf : LongArrayOf<LongOffsetTo<Type> > {}; +struct LongOffsetLongArrayOf : LongArrayOf<OffsetTo<Type, ULONG> > {}; /* Array of offsets relative to the beginning of the array itself. */ template <typename Type> @@ -951,8 +945,8 @@ struct HeadlessArrayOf /* An array with sorted elements. Supports binary searching. */ -template <typename Type, typename LenType> -struct GenericSortedArrayOf : GenericArrayOf<Type, LenType> +template <typename Type, typename LenType=USHORT> +struct SortedArrayOf : ArrayOf<Type, LenType> { template <typename SearchType> inline int bsearch (const SearchType &x) const @@ -974,13 +968,9 @@ struct GenericSortedArrayOf : GenericArrayOf<Type, LenType> } }; -/* A sorted array with a USHORT number of elements. */ -template <typename Type> -struct SortedArrayOf : GenericSortedArrayOf<Type, USHORT> {}; - /* A sorted array with a ULONG number of elements. */ template <typename Type> -struct LongSortedArrayOf : GenericSortedArrayOf<Type, ULONG> {}; +struct LongSortedArrayOf : SortedArrayOf<Type, ULONG> {}; } /* namespace OT */ diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index a50dca6..abdd8db 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -229,7 +229,7 @@ struct CmapSubtableTrimmed UINT length; /* Byte length of this subtable. */ UINT language; /* Ignore. */ UINT startCharCode; /* First character code covered. */ - GenericArrayOf<GlyphID, UINT> + ArrayOf<GlyphID, UINT> glyphIdArray; /* Array of glyph index values for character * codes in the range. */ public: @@ -350,7 +350,7 @@ struct EncodingRecord USHORT platformID; /* Platform ID. */ USHORT encodingID; /* Platform-specific encoding ID. */ - LongOffsetTo<CmapSubtable> + OffsetTo<CmapSubtable, ULONG> subtable; /* Byte offset from beginning of table to the subtable for this encoding. */ public: DEFINE_SIZE_STATIC (8); diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index 3904c2d..479fb26 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -506,7 +506,7 @@ struct Feature if (unlikely (!featureParams.sanitize (c, this, closure ? closure->tag : HB_TAG_NONE))) return TRACE_RETURN (false); - if (likely (!orig_offset)) + if (likely (orig_offset.is_null ())) return TRACE_RETURN (true); if (featureParams == 0 && closure && commit 36073ede5b52bd1231622cbacd1bee6b82696d81 Author: Behdad Esfahbod <[email protected]> Date: Fri Jun 27 14:48:54 2014 -0400 Minor: Reorder template parameter order diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index d3e2bee..f6081f0 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -745,7 +745,7 @@ struct LongOffsetTo : OffsetTo<Type, LongOffset> {}; * Array Types */ -template <typename LenType, typename Type> +template <typename Type, typename LenType> struct GenericArrayOf { const Type *sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const @@ -854,11 +854,11 @@ struct GenericArrayOf /* An array with a USHORT number of elements. */ template <typename Type> -struct ArrayOf : GenericArrayOf<USHORT, Type> {}; +struct ArrayOf : GenericArrayOf<Type, USHORT> {}; /* An array with a ULONG number of elements. */ template <typename Type> -struct LongArrayOf : GenericArrayOf<ULONG, Type> {}; +struct LongArrayOf : GenericArrayOf<Type, ULONG> {}; /* Array of Offset's */ template <typename Type> @@ -951,8 +951,8 @@ struct HeadlessArrayOf /* An array with sorted elements. Supports binary searching. */ -template <typename LenType, typename Type> -struct GenericSortedArrayOf : GenericArrayOf<LenType, Type> +template <typename Type, typename LenType> +struct GenericSortedArrayOf : GenericArrayOf<Type, LenType> { template <typename SearchType> inline int bsearch (const SearchType &x) const @@ -976,11 +976,11 @@ struct GenericSortedArrayOf : GenericArrayOf<LenType, Type> /* A sorted array with a USHORT number of elements. */ template <typename Type> -struct SortedArrayOf : GenericSortedArrayOf<USHORT, Type> {}; +struct SortedArrayOf : GenericSortedArrayOf<Type, USHORT> {}; /* A sorted array with a ULONG number of elements. */ template <typename Type> -struct LongSortedArrayOf : GenericSortedArrayOf<ULONG, Type> {}; +struct LongSortedArrayOf : GenericSortedArrayOf<Type, ULONG> {}; } /* namespace OT */ diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index b182b53..a50dca6 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -229,7 +229,7 @@ struct CmapSubtableTrimmed UINT length; /* Byte length of this subtable. */ UINT language; /* Ignore. */ UINT startCharCode; /* First character code covered. */ - GenericArrayOf<UINT, GlyphID> + GenericArrayOf<GlyphID, UINT> glyphIdArray; /* Array of glyph index values for character * codes in the range. */ public: commit 0394ec1bfbd7806cbe9fc809b34f96f8d12ffbf2 Author: Behdad Esfahbod <[email protected]> Date: Fri Jun 27 14:40:35 2014 -0400 Minor: Introduce GenericOffset diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index c4ec0ed..d3e2bee 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -630,21 +630,17 @@ struct Index : USHORT { }; DEFINE_NULL_DATA (Index, "\xff\xff"); -/* Offset to a table, same as uint16 (length = 16 bits), Null offset = 0x0000 */ -struct Offset : USHORT +/* GenericOffset, Null offset = 0 */ +template <typename Type> +struct GenericOffset : Type { inline bool is_null (void) const { return 0 == *this; } public: - DEFINE_SIZE_STATIC (2); + DEFINE_SIZE_STATIC (sizeof(Type)); }; -/* LongOffset to a table, same as uint32 (length = 32 bits), Null offset = 0x00000000 */ -struct LongOffset : ULONG -{ - inline bool is_null (void) const { return 0 == *this; } - public: - DEFINE_SIZE_STATIC (4); -}; +typedef GenericOffset<USHORT> Offset; +typedef GenericOffset<ULONG> LongOffset; /* CheckSum */ commit 0d1b3419a7bbfd18ab8fed1abd3a41dec11e8d97 Author: Behdad Esfahbod <[email protected]> Date: Thu Jun 26 19:13:34 2014 -0400 Minor: Use template parameter default values for OffsetTo diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index a95afc2..c4ec0ed 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -696,8 +696,8 @@ struct FixedVersion * Use: (base+offset) */ -template <typename OffsetType, typename Type> -struct GenericOffsetTo : OffsetType +template <typename Type, typename OffsetType=Offset> +struct OffsetTo : OffsetType { inline const Type& operator () (const void *base) const { @@ -737,15 +737,12 @@ struct GenericOffsetTo : OffsetType } }; template <typename Base, typename OffsetType, typename Type> -static inline const Type& operator + (const Base &base, const GenericOffsetTo<OffsetType, Type> &offset) { return offset (base); } +static inline const Type& operator + (const Base &base, const OffsetTo<Type, OffsetType> &offset) { return offset (base); } template <typename Base, typename OffsetType, typename Type> -static inline Type& operator + (Base &base, GenericOffsetTo<OffsetType, Type> &offset) { return offset (base); } +static inline Type& operator + (Base &base, OffsetTo<Type, OffsetType> &offset) { return offset (base); } template <typename Type> -struct OffsetTo : GenericOffsetTo<Offset, Type> {}; - -template <typename Type> -struct LongOffsetTo : GenericOffsetTo<LongOffset, Type> {}; +struct LongOffsetTo : OffsetTo<Type, LongOffset> {}; /* commit 546b1adcdce2d3592843938b0b81ff32e67b0b83 Author: Behdad Esfahbod <[email protected]> Date: Thu Jun 26 19:10:21 2014 -0400 Minor: Use template parameter default values for hb_prealloced_array_t diff --git a/src/hb-private.hh b/src/hb-private.hh index 5179912..f2f580a 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -272,7 +272,7 @@ typedef int (*hb_compare_func_t) (const void *, const void *); #define HB_PREALLOCED_ARRAY_INIT {0} -template <typename Type, unsigned int StaticSize> +template <typename Type, unsigned int StaticSize=16> struct hb_prealloced_array_t { unsigned int len; @@ -383,12 +383,11 @@ struct hb_prealloced_array_t } }; -#define HB_AUTO_ARRAY_PREALLOCED 16 template <typename Type> -struct hb_auto_array_t : hb_prealloced_array_t <Type, HB_AUTO_ARRAY_PREALLOCED> +struct hb_auto_array_t : hb_prealloced_array_t <Type> { - hb_auto_array_t (void) { hb_prealloced_array_t<Type, HB_AUTO_ARRAY_PREALLOCED>::init (); } - ~hb_auto_array_t (void) { hb_prealloced_array_t<Type, HB_AUTO_ARRAY_PREALLOCED>::finish (); } + hb_auto_array_t (void) { hb_prealloced_array_t<Type>::init (); } + ~hb_auto_array_t (void) { hb_prealloced_array_t<Type>::finish (); } }; _______________________________________________ HarfBuzz mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/harfbuzz
