From b3651231bf80bb7009214547a75ed90e21815c68 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 May 2010 16:57:29 -0400 Subject: [PATCH] Remove ASSERT_SIZE in favor of the safer DEFINE_SIZE_STATIC --- src/hb-open-file-private.hh | 3 ++- src/hb-open-type-private.hh | 20 +++++++++++++--- src/hb-ot-layout-common-private.hh | 24 ++++++++++++-------- src/hb-ot-layout-gdef-private.hh | 22 +++++++++++------- src/hb-ot-layout-gpos-private.hh | 44 ++++++++++++++++++++---------------- src/hb-ot-layout-gsub-private.hh | 32 ++++++++++++++++---------- src/hb-ot-layout-gsubgpos-private.hh | 27 ++++++++++++++-------- src/hb-private.h | 2 -- 8 files changed, 109 insertions(+), 65 deletions(-) diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh index 53e947a..d8d70e5 100644 --- a/src/hb-open-file-private.hh +++ b/src/hb-open-file-private.hh @@ -139,8 +139,9 @@ struct TTCHeaderVersion1 LongOffsetLongArrayOf table; /* Array of offsets to the OffsetTable for each font * from the beginning of the file */ + public: + DEFINE_SIZE_STATIC (12); }; -ASSERT_SIZE (TTCHeaderVersion1, 12); struct TTCHeader { diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index aab85fd..56a8bae 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -96,6 +96,15 @@ inline Type& StructAfter(TObject &X) static const unsigned int static_size = (size); \ static const unsigned int min_size = (size) +/* Size signifying variable-sized array */ +#define VAR 1 +#define VAR0 (VAR+0) + +#define DEFINE_SIZE_VAR0(size) \ + inline void _size_assertion (void) const \ + { ASSERT_STATIC (sizeof (*this) == (size)); } \ + static const unsigned int min_size = (size) + #define DEFINE_SIZE_VAR(size, _var_type) \ inline void _size_assertion (void) const \ { ASSERT_STATIC (sizeof (*this) == (size) + VAR0 * sizeof (_var_type)); } \ @@ -397,8 +406,9 @@ struct Tag : ULONG /* What the char* converters return is NOT nul-terminated. Print using "%.4s" */ inline operator const char* (void) const { return CharP(this); } inline operator char* (void) { return CharP(this); } + public: + DEFINE_SIZE_STATIC (4); }; -ASSERT_SIZE (Tag, 4); DEFINE_NULL_DATA (Tag, " "); /* Glyph index number, same as uint16 (length = 16 bits) */ @@ -423,8 +433,9 @@ struct CheckSum : ULONG Sum += *Table++; return Sum; } + public: + DEFINE_SIZE_STATIC (4); }; -ASSERT_SIZE (CheckSum, 4); /* @@ -442,8 +453,9 @@ struct FixedVersion USHORT major; USHORT minor; + public: + DEFINE_SIZE_STATIC (4); }; -ASSERT_SIZE (FixedVersion, 4); @@ -577,6 +589,8 @@ struct GenericArrayOf public: LenType len; /*Type array[VAR];*/ + public: + DEFINE_SIZE_VAR0 (sizeof (LenType)); }; /* An array with a USHORT number of elements. */ diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index 7215415..dc1229f 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -216,11 +216,11 @@ struct Script RecordArrayOf langSys; /* Array of LangSysRecords--listed * alphabetically by LangSysTag */ + public: + DEFINE_SIZE_STATIC (4); }; -ASSERT_SIZE (Script, 4); typedef RecordListOf