提交 2737aa81 编写于 作者: B Behdad Esfahbod
上级 fffea5af
...@@ -40,16 +40,22 @@ ...@@ -40,16 +40,22 @@
/* Use SFINAE to sniff whether T has min_size; in which case return T::null_size, /* Use SFINAE to sniff whether T has min_size; in which case return T::null_size,
* otherwise return sizeof(T). */ * otherwise return sizeof(T). */
template <typename T, bool b>
/* The hard way...
* https://stackoverflow.com/questions/7776448/sfinae-tried-with-bool-gives-compiler-error-template-argument-tvalue-invol
*/
template<bool> struct _hb_bool_type {};
template <typename T, typename B>
struct _hb_null_size struct _hb_null_size
{ enum { value = sizeof (T) }; }; { enum { value = sizeof (T) }; };
template <typename T> template <typename T>
struct _hb_null_size<T, T::min_size ? false : false> struct _hb_null_size<T, _hb_bool_type<(bool) T::min_size> >
{ enum { value = T::null_size }; }; { enum { value = T::null_size }; };
template <typename T> template <typename T>
struct hb_null_size struct hb_null_size
{ enum { value = _hb_null_size<T, false>::value }; }; { enum { value = _hb_null_size<T, _hb_bool_type<true> >::value }; };
extern HB_INTERNAL extern HB_INTERNAL
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)]; 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)];
......
...@@ -231,14 +231,9 @@ struct FixedVersion ...@@ -231,14 +231,9 @@ struct FixedVersion
* Use: (base+offset) * Use: (base+offset)
*/ */
template <typename Type, bool has_null_> struct assert_has_null_size { static_assert (Type::null_size > 0, ""); };
template <typename Type> struct assert_has_null_size<Type, false> {};
template <typename Type, typename OffsetType=HBUINT16, bool has_null=true> template <typename Type, typename OffsetType=HBUINT16, bool has_null=true>
struct OffsetTo : Offset<OffsetType, has_null> struct OffsetTo : Offset<OffsetType, has_null>
{ {
static_assert (sizeof (assert_has_null_size<Type, has_null>) || true, "");
inline const Type& operator () (const void *base) const inline const Type& operator () (const void *base) const
{ {
if (unlikely (this->is_null ())) return Null (Type); if (unlikely (this->is_null ())) return Null (Type);
......
...@@ -56,7 +56,7 @@ struct loca ...@@ -56,7 +56,7 @@ struct loca
protected: protected:
UnsizedArrayOf<HBUINT8> dataZ; /* Location data. */ UnsizedArrayOf<HBUINT8> dataZ; /* Location data. */
public: public:
DEFINE_SIZE_ARRAY (0, dataZ); DEFINE_SIZE_UNBOUNDED (0);
}; };
...@@ -465,7 +465,7 @@ struct glyf ...@@ -465,7 +465,7 @@ struct glyf
protected: protected:
UnsizedArrayOf<HBUINT8> dataZ; /* Glyphs data. */ UnsizedArrayOf<HBUINT8> dataZ; /* Glyphs data. */
public: public:
DEFINE_SIZE_ARRAY (0, dataZ); DEFINE_SIZE_UNBOUNDED (0);
}; };
struct glyf_accelerator_t : glyf::accelerator_t {}; struct glyf_accelerator_t : glyf::accelerator_t {};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册