Move null data definitions to hb-static.cc

Also remove "    " null data for Tag.  Just use zeroes.
This commit is contained in:
Behdad Esfahbod 2018-08-05 21:41:52 -07:00
parent 1b4d5a2402
commit 92806ee055
4 changed files with 19 additions and 11 deletions

View File

@ -140,7 +140,6 @@ struct Tag : HBUINT32
public:
DEFINE_SIZE_STATIC (4);
};
DEFINE_NULL_DATA (OT, Tag, " ");
/* Glyph index number, same as uint16 (length = 16 bits) */
typedef HBUINT16 GlyphID;
@ -152,7 +151,7 @@ typedef HBUINT16 NameID;
struct Index : HBUINT16 {
static const unsigned int NOT_FOUND_INDEX = 0xFFFFu;
};
DEFINE_NULL_DATA (OT, Index, "\xff\xff");
DECLARE_NULL_NAMESPACE_BYTES (OT, Index);
/* Offset, Null offset = 0 */
template <typename Type>

View File

@ -173,7 +173,7 @@ struct RangeRecord
public:
DEFINE_SIZE_STATIC (6);
};
DEFINE_NULL_DATA (OT, RangeRecord, "\000\001");
DECLARE_NULL_NAMESPACE_BYTES (OT, RangeRecord);
struct IndexArray : ArrayOf<Index>
@ -240,8 +240,7 @@ struct LangSys
public:
DEFINE_SIZE_ARRAY (6, featureIndex);
};
DEFINE_NULL_DATA (OT, LangSys, "\0\0\xFF\xFF");
DECLARE_NULL_NAMESPACE_BYTES (OT, LangSys);
struct Script
{

View File

@ -391,16 +391,18 @@ static inline Type const & Null (void) {
#define Null(Type) Null<Type>()
/* Specializaiton for arbitrary-content arbitrary-sized Null objects. */
#define DEFINE_NULL_DATA(Namespace, Type, data) \
#define DECLARE_NULL_NAMESPACE_BYTES(Namespace, Type) \
} /* Close namespace. */ \
static const char _Null##Type[sizeof (Namespace::Type) + 1] = data; /* +1 is for nul-termination in data */ \
extern HB_INTERNAL const unsigned char _hb_Null_##Namespace##_##Type[sizeof (Namespace::Type)]; \
template <> \
/*static*/ inline const Namespace::Type& Null<Namespace::Type> (void) { \
return *reinterpret_cast<const Namespace::Type *> (_Null##Type); \
return *reinterpret_cast<const Namespace::Type *> (_hb_Null_##Namespace##_##Type); \
} \
namespace Namespace { \
/* The following line really exists such that we end in a place needing semicolon */ \
static_assert (Namespace::Type::min_size + 1 <= sizeof (_Null##Type), "Null pool too small. Enlarge.")
static_assert (Namespace::Type::min_size <= sizeof (Type), "Null pool too small. Enlarge."); \
#define DEFINE_NULL_NAMESPACE_BYTES(Namespace, Type) \
const unsigned char _hb_Null_##Namespace##_##Type[sizeof (Namespace::Type)]
/* Global writable pool. Enlarge as necessary. */

View File

@ -25,8 +25,11 @@
*/
#include "hb-private.hh"
#include "hb-face-private.hh"
#include "hb-open-type-private.hh"
#include "hb-ot-layout-common-private.hh"
#include "hb-face-private.hh"
#include "hb-ot-head-table.hh"
#include "hb-ot-maxp-table.hh"
@ -35,6 +38,11 @@
hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {};
/*thread_local*/ hb_vector_size_impl_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {};
DEFINE_NULL_NAMESPACE_BYTES (OT, Index) = {0xFF,0xFF};
DEFINE_NULL_NAMESPACE_BYTES (OT, LangSys) = {0x00,0x00, 0xFF,0xFF, 0x00,0x00};
DEFINE_NULL_NAMESPACE_BYTES (OT, RangeRecord) = {0x00,0x01, 0x00,0x00, 0x00, 0x00};
void
hb_face_t::load_num_glyphs (void) const
{