提交 4e626278 编写于 作者: B Behdad Esfahbod

Enforce single-param static_assert() only

So we don't accidentally break it again.
上级 f1a86e1e
...@@ -107,7 +107,7 @@ static inline void _hb_memory_barrier (void) ...@@ -107,7 +107,7 @@ static inline void _hb_memory_barrier (void)
#define _hb_memory_barrier() _hb_memory_barrier () #define _hb_memory_barrier() _hb_memory_barrier ()
#define hb_atomic_int_impl_add(AI, V) InterlockedExchangeAdd ((LONG *) (AI), (V)) #define hb_atomic_int_impl_add(AI, V) InterlockedExchangeAdd ((LONG *) (AI), (V))
static_assert ((sizeof (LONG) == sizeof (int)), ""); static_assert ((sizeof (LONG) == sizeof (int)));
#define hb_atomic_ptr_impl_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((void **) (P), (void *) (N), (void *) (O)) == (void *) (O)) #define hb_atomic_ptr_impl_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((void **) (P), (void *) (N), (void *) (O)) == (void *) (O))
...@@ -198,7 +198,7 @@ static inline bool _hb_compare_and_swaplp (long *P, long O, long N) ...@@ -198,7 +198,7 @@ static inline bool _hb_compare_and_swaplp (long *P, long O, long N)
#define hb_atomic_int_impl_add(AI, V) _hb_fetch_and_add ((AI), (V)) #define hb_atomic_int_impl_add(AI, V) _hb_fetch_and_add ((AI), (V))
#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_compare_and_swaplp ((long *) (P), (long) (O), (long) (N)) #define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_compare_and_swaplp ((long *) (P), (long) (O), (long) (N))
static_assert ((sizeof (long) == sizeof (void *)), ""); static_assert ((sizeof (long) == sizeof (void *)));
#elif !defined(HB_NO_MT) #elif !defined(HB_NO_MT)
......
...@@ -130,7 +130,7 @@ hb_buffer_t::enlarge (unsigned int size) ...@@ -130,7 +130,7 @@ hb_buffer_t::enlarge (unsigned int size)
while (size >= new_allocated) while (size >= new_allocated)
new_allocated += (new_allocated >> 1) + 32; new_allocated += (new_allocated >> 1) + 32;
static_assert ((sizeof (info[0]) == sizeof (pos[0])), ""); static_assert ((sizeof (info[0]) == sizeof (pos[0])));
if (unlikely (hb_unsigned_mul_overflows (new_allocated, sizeof (info[0])))) if (unlikely (hb_unsigned_mul_overflows (new_allocated, sizeof (info[0]))))
goto done; goto done;
......
...@@ -54,8 +54,8 @@ ...@@ -54,8 +54,8 @@
#define HB_BUFFER_MAX_OPS_DEFAULT 0x1FFFFFFF /* Shaping more than a billion operations? Let us know! */ #define HB_BUFFER_MAX_OPS_DEFAULT 0x1FFFFFFF /* Shaping more than a billion operations? Let us know! */
#endif #endif
static_assert ((sizeof (hb_glyph_info_t) == 20), ""); static_assert ((sizeof (hb_glyph_info_t) == 20));
static_assert ((sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t)), ""); static_assert ((sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t)));
HB_MARK_AS_FLAG_T (hb_buffer_flags_t); HB_MARK_AS_FLAG_T (hb_buffer_flags_t);
HB_MARK_AS_FLAG_T (hb_buffer_serialize_flags_t); HB_MARK_AS_FLAG_T (hb_buffer_serialize_flags_t);
......
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
template <unsigned int key_bits, unsigned int value_bits, unsigned int cache_bits> template <unsigned int key_bits, unsigned int value_bits, unsigned int cache_bits>
struct hb_cache_t struct hb_cache_t
{ {
static_assert ((key_bits >= cache_bits), ""); static_assert ((key_bits >= cache_bits));
static_assert ((key_bits + value_bits - cache_bits <= 8 * sizeof (unsigned int)), ""); static_assert ((key_bits + value_bits - cache_bits <= 8 * sizeof (unsigned int)));
inline void init (void) { clear (); } inline void init (void) { clear (); }
inline void fini (void) {} inline void fini (void) {}
......
...@@ -720,7 +720,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan, ...@@ -720,7 +720,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &active_features[j].rec.feature), CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &active_features[j].rec.feature),
CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &active_features[j].rec.setting) CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &active_features[j].rec.setting)
}; };
static_assert ((ARRAY_LENGTH_CONST (keys) == ARRAY_LENGTH_CONST (values)), ""); static_assert ((ARRAY_LENGTH_CONST (keys) == ARRAY_LENGTH_CONST (values)));
CFDictionaryRef dict = CFDictionaryCreate (kCFAllocatorDefault, CFDictionaryRef dict = CFDictionaryCreate (kCFAllocatorDefault,
(const void **) keys, (const void **) keys,
(const void **) values, (const void **) values,
......
...@@ -52,7 +52,7 @@ union hb_options_union_t { ...@@ -52,7 +52,7 @@ union hb_options_union_t {
int i; int i;
hb_options_t opts; hb_options_t opts;
}; };
static_assert ((sizeof (hb_atomic_int_t) >= sizeof (hb_options_union_t)), ""); static_assert ((sizeof (hb_atomic_int_t) >= sizeof (hb_options_union_t)));
HB_INTERNAL void HB_INTERNAL void
_hb_options_init (void); _hb_options_init (void);
......
...@@ -290,7 +290,7 @@ hb_in_range (T u, T lo, T hi) ...@@ -290,7 +290,7 @@ hb_in_range (T u, T lo, T hi)
* one right now. Declaring a variable won't work as HB_UNUSED * one right now. Declaring a variable won't work as HB_UNUSED
* is unusable on some platforms and unused types are less likely * is unusable on some platforms and unused types are less likely
* to generate a warning than unused variables. */ * to generate a warning than unused variables. */
static_assert ((sizeof (hb_assert_unsigned_t<T>) >= 0), ""); static_assert ((sizeof (hb_assert_unsigned_t<T>) >= 0));
/* The casts below are important as if T is smaller than int, /* The casts below are important as if T is smaller than int,
* the subtract results will become a signed int! */ * the subtract results will become a signed int! */
...@@ -628,7 +628,7 @@ struct hb_vector_size_t ...@@ -628,7 +628,7 @@ struct hb_vector_size_t
} }
private: private:
static_assert (byte_size / sizeof (elt_t) * sizeof (elt_t) == byte_size, ""); static_assert (byte_size / sizeof (elt_t) * sizeof (elt_t) == byte_size);
union { union {
elt_t v[byte_size / sizeof (elt_t)]; elt_t v[byte_size / sizeof (elt_t)];
#if HB_VECTOR_SIZE #if HB_VECTOR_SIZE
......
...@@ -83,7 +83,7 @@ static inline Type& StructAfter(TObject &X) ...@@ -83,7 +83,7 @@ static inline Type& StructAfter(TObject &X)
#define _DEFINE_INSTANCE_ASSERTION1(_line, _assertion) \ #define _DEFINE_INSTANCE_ASSERTION1(_line, _assertion) \
inline void _instance_assertion_on_line_##_line (void) const \ inline void _instance_assertion_on_line_##_line (void) const \
{ \ { \
static_assert ((_assertion), ""); \ static_assert ((_assertion)); \
ASSERT_INSTANCE_POD (*this); /* Make sure it's POD. */ \ ASSERT_INSTANCE_POD (*this); /* Make sure it's POD. */ \
} }
# define _DEFINE_INSTANCE_ASSERTION0(_line, _assertion) _DEFINE_INSTANCE_ASSERTION1 (_line, _assertion) # define _DEFINE_INSTANCE_ASSERTION0(_line, _assertion) _DEFINE_INSTANCE_ASSERTION1 (_line, _assertion)
...@@ -704,7 +704,7 @@ struct BEInt<Type, 4> ...@@ -704,7 +704,7 @@ struct BEInt<Type, 4>
template <typename Data, unsigned int WheresData> template <typename Data, unsigned int WheresData>
struct hb_data_wrapper_t struct hb_data_wrapper_t
{ {
static_assert (WheresData > 0, ""); static_assert (WheresData > 0);
inline Data * get_data (void) const inline Data * get_data (void) const
{ {
......
...@@ -44,7 +44,7 @@ hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_ ...@@ -44,7 +44,7 @@ hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_
/* Generic nul-content Null objects. */ /* Generic nul-content Null objects. */
template <typename Type> template <typename Type>
static inline Type const & Null (void) { static inline Type const & Null (void) {
static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE."); static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE);
return *reinterpret_cast<Type const *> (_hb_NullPool); return *reinterpret_cast<Type const *> (_hb_NullPool);
} }
#define Null(Type) Null<Type>() #define Null(Type) Null<Type>()
...@@ -58,7 +58,7 @@ static inline Type const & Null (void) { ...@@ -58,7 +58,7 @@ static inline Type const & Null (void) {
return *reinterpret_cast<const Namespace::Type *> (_hb_Null_##Namespace##_##Type); \ return *reinterpret_cast<const Namespace::Type *> (_hb_Null_##Namespace##_##Type); \
} \ } \
namespace Namespace { \ namespace Namespace { \
static_assert (true, "Just so we take semicolon after.") static_assert (true) /* Just so we take semicolon after. */
#define DEFINE_NULL_NAMESPACE_BYTES(Namespace, Type) \ #define DEFINE_NULL_NAMESPACE_BYTES(Namespace, Type) \
const unsigned char _hb_Null_##Namespace##_##Type[Namespace::Type::min_size] const unsigned char _hb_Null_##Namespace##_##Type[Namespace::Type::min_size]
...@@ -69,7 +69,7 @@ static inline Type const & Null (void) { ...@@ -69,7 +69,7 @@ static inline Type const & Null (void) {
/*static*/ inline const Type& Null<Type> (void) { \ /*static*/ inline const Type& Null<Type> (void) { \
return _hb_Null_##Type; \ return _hb_Null_##Type; \
} \ } \
static_assert (true, "Just so we take semicolon after.") static_assert (true) /* Just so we take semicolon after. */
#define DEFINE_NULL_INSTANCE(Type) \ #define DEFINE_NULL_INSTANCE(Type) \
const Type _hb_Null_##Type const Type _hb_Null_##Type
...@@ -85,7 +85,7 @@ extern HB_INTERNAL ...@@ -85,7 +85,7 @@ extern HB_INTERNAL
/* CRAP pool: Common Region for Access Protection. */ /* CRAP pool: Common Region for Access Protection. */
template <typename Type> template <typename Type>
static inline Type& Crap (void) { static inline Type& Crap (void) {
static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE."); static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE);
Type *obj = reinterpret_cast<Type *> (_hb_CrapPool); Type *obj = reinterpret_cast<Type *> (_hb_CrapPool);
*obj = Null(Type); *obj = Null(Type);
return *obj; return *obj;
......
...@@ -226,13 +226,13 @@ struct FixedVersion ...@@ -226,13 +226,13 @@ struct FixedVersion
* Use: (base+offset) * Use: (base+offset)
*/ */
template <typename Type, bool has_null_> struct assert_has_min_size { static_assert (Type::min_size > 0, ""); }; template <typename Type, bool has_null_> struct assert_has_min_size { static_assert (Type::min_size > 0); };
template <typename Type> struct assert_has_min_size<Type, false> {}; template <typename Type> struct assert_has_min_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_min_size<Type, has_null>) || true, ""); static_assert (sizeof (assert_has_min_size<Type, has_null>) || true);
inline const Type& operator () (const void *base) const inline const Type& operator () (const void *base) const
{ {
......
...@@ -800,7 +800,7 @@ struct CoverageFormat1 ...@@ -800,7 +800,7 @@ struct CoverageFormat1
inline unsigned int get_coverage (hb_codepoint_t glyph_id) const inline unsigned int get_coverage (hb_codepoint_t glyph_id) const
{ {
int i = glyphArray.bsearch (glyph_id); int i = glyphArray.bsearch (glyph_id);
static_assert ((((unsigned int) -1) == NOT_COVERED), ""); static_assert ((((unsigned int) -1) == NOT_COVERED));
return i; return i;
} }
......
...@@ -394,9 +394,9 @@ struct GDEF ...@@ -394,9 +394,9 @@ struct GDEF
{ {
unsigned int klass = get_glyph_class (glyph); unsigned int klass = get_glyph_class (glyph);
static_assert (((unsigned int) HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH == (unsigned int) LookupFlag::IgnoreBaseGlyphs), ""); static_assert (((unsigned int) HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH == (unsigned int) LookupFlag::IgnoreBaseGlyphs));
static_assert (((unsigned int) HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE == (unsigned int) LookupFlag::IgnoreLigatures), ""); static_assert (((unsigned int) HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE == (unsigned int) LookupFlag::IgnoreLigatures));
static_assert (((unsigned int) HB_OT_LAYOUT_GLYPH_PROPS_MARK == (unsigned int) LookupFlag::IgnoreMarks), ""); static_assert (((unsigned int) HB_OT_LAYOUT_GLYPH_PROPS_MARK == (unsigned int) LookupFlag::IgnoreMarks));
switch (klass) { switch (klass) {
default: return 0; default: return 0;
......
...@@ -320,7 +320,7 @@ hb_ot_layout_table_find_script (hb_face_t *face, ...@@ -320,7 +320,7 @@ hb_ot_layout_table_find_script (hb_face_t *face,
hb_tag_t script_tag, hb_tag_t script_tag,
unsigned int *script_index) unsigned int *script_index)
{ {
static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX), ""); static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX));
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
if (g.find_script_index (script_tag, script_index)) if (g.find_script_index (script_tag, script_index))
...@@ -351,7 +351,7 @@ hb_ot_layout_table_choose_script (hb_face_t *face, ...@@ -351,7 +351,7 @@ hb_ot_layout_table_choose_script (hb_face_t *face,
unsigned int *script_index, unsigned int *script_index,
hb_tag_t *chosen_script) hb_tag_t *chosen_script)
{ {
static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX), ""); static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX));
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
while (*script_tags) while (*script_tags)
...@@ -410,7 +410,7 @@ hb_ot_layout_table_find_feature (hb_face_t *face, ...@@ -410,7 +410,7 @@ hb_ot_layout_table_find_feature (hb_face_t *face,
hb_tag_t feature_tag, hb_tag_t feature_tag,
unsigned int *feature_index) unsigned int *feature_index)
{ {
static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_FEATURE_INDEX), ""); static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_FEATURE_INDEX));
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
unsigned int num_features = g.get_feature_count (); unsigned int num_features = g.get_feature_count ();
...@@ -447,7 +447,7 @@ hb_ot_layout_script_find_language (hb_face_t *face, ...@@ -447,7 +447,7 @@ hb_ot_layout_script_find_language (hb_face_t *face,
hb_tag_t language_tag, hb_tag_t language_tag,
unsigned int *language_index) unsigned int *language_index)
{ {
static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX), ""); static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX));
const OT::Script &s = get_gsubgpos_table (face, table_tag).get_script (script_index); const OT::Script &s = get_gsubgpos_table (face, table_tag).get_script (script_index);
if (s.find_lang_sys_index (language_tag, language_index)) if (s.find_lang_sys_index (language_tag, language_index))
...@@ -539,7 +539,7 @@ hb_ot_layout_language_get_feature_tags (hb_face_t *face, ...@@ -539,7 +539,7 @@ hb_ot_layout_language_get_feature_tags (hb_face_t *face,
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index); const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
static_assert ((sizeof (unsigned int) == sizeof (hb_tag_t)), ""); static_assert ((sizeof (unsigned int) == sizeof (hb_tag_t)));
unsigned int ret = l.get_feature_indexes (start_offset, feature_count, (unsigned int *) feature_tags); unsigned int ret = l.get_feature_indexes (start_offset, feature_count, (unsigned int *) feature_tags);
if (feature_tags) { if (feature_tags) {
...@@ -560,7 +560,7 @@ hb_ot_layout_language_find_feature (hb_face_t *face, ...@@ -560,7 +560,7 @@ hb_ot_layout_language_find_feature (hb_face_t *face,
hb_tag_t feature_tag, hb_tag_t feature_tag,
unsigned int *feature_index) unsigned int *feature_index)
{ {
static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_FEATURE_INDEX), ""); static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_FEATURE_INDEX));
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index); const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
...@@ -869,7 +869,7 @@ hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face, ...@@ -869,7 +869,7 @@ hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face,
unsigned int *lookup_count /* IN/OUT */, unsigned int *lookup_count /* IN/OUT */,
unsigned int *lookup_indexes /* OUT */) unsigned int *lookup_indexes /* OUT */)
{ {
static_assert ((OT::FeatureVariations::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_VARIATIONS_INDEX), ""); static_assert ((OT::FeatureVariations::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_VARIATIONS_INDEX));
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
const OT::Feature &f = g.get_feature_variation (feature_index, variations_index); const OT::Feature &f = g.get_feature_variation (feature_index, variations_index);
......
...@@ -145,7 +145,7 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, ...@@ -145,7 +145,7 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m,
const int *coords, const int *coords,
unsigned int num_coords) unsigned int num_coords)
{ {
static_assert ((!(HB_GLYPH_FLAG_DEFINED & (HB_GLYPH_FLAG_DEFINED + 1))), ""); static_assert ((!(HB_GLYPH_FLAG_DEFINED & (HB_GLYPH_FLAG_DEFINED + 1))));
unsigned int global_bit_mask = HB_GLYPH_FLAG_DEFINED + 1; unsigned int global_bit_mask = HB_GLYPH_FLAG_DEFINED + 1;
unsigned int global_bit_shift = hb_popcount (HB_GLYPH_FLAG_DEFINED); unsigned int global_bit_shift = hb_popcount (HB_GLYPH_FLAG_DEFINED);
......
...@@ -463,7 +463,7 @@ struct MathGlyphPartRecord ...@@ -463,7 +463,7 @@ struct MathGlyphPartRecord
out.full_advance = font->em_scale (fullAdvance, scale); out.full_advance = font->em_scale (fullAdvance, scale);
static_assert ((unsigned int) HB_MATH_GLYPH_PART_FLAG_EXTENDER == static_assert ((unsigned int) HB_MATH_GLYPH_PART_FLAG_EXTENDER ==
(unsigned int) PartFlags::Extender, ""); (unsigned int) PartFlags::Extender);
out.flags = (hb_ot_math_glyph_part_flags_t) out.flags = (hb_ot_math_glyph_part_flags_t)
(unsigned int) (unsigned int)
......
...@@ -269,7 +269,7 @@ arabic_fallback_plan_init_unicode (arabic_fallback_plan_t *fallback_plan, ...@@ -269,7 +269,7 @@ arabic_fallback_plan_init_unicode (arabic_fallback_plan_t *fallback_plan,
const hb_ot_shape_plan_t *plan, const hb_ot_shape_plan_t *plan,
hb_font_t *font) hb_font_t *font)
{ {
static_assert ((ARRAY_LENGTH_CONST(arabic_fallback_features) <= ARABIC_FALLBACK_MAX_LOOKUPS), ""); static_assert ((ARRAY_LENGTH_CONST(arabic_fallback_features) <= ARABIC_FALLBACK_MAX_LOOKUPS));
unsigned int j = 0; unsigned int j = 0;
for (unsigned int i = 0; i < ARRAY_LENGTH(arabic_fallback_features) ; i++) for (unsigned int i = 0; i < ARRAY_LENGTH(arabic_fallback_features) ; i++)
{ {
......
...@@ -349,7 +349,7 @@ set_indic_properties (hb_glyph_info_t &info) ...@@ -349,7 +349,7 @@ set_indic_properties (hb_glyph_info_t &info)
0x1CEEu, 0x1CF1u))) 0x1CEEu, 0x1CF1u)))
{ {
cat = OT_Symbol; cat = OT_Symbol;
static_assert (((int) INDIC_SYLLABIC_CATEGORY_AVAGRAHA == OT_Symbol), ""); static_assert (((int) INDIC_SYLLABIC_CATEGORY_AVAGRAHA == OT_Symbol));
} }
else if (unlikely (u == 0x0A51u)) else if (unlikely (u == 0x0A51u))
{ {
......
...@@ -292,7 +292,7 @@ setup_topographical_masks (const hb_ot_shape_plan_t *plan, ...@@ -292,7 +292,7 @@ setup_topographical_masks (const hb_ot_shape_plan_t *plan,
if (use_plan->arabic_plan) if (use_plan->arabic_plan)
return; return;
static_assert ((INIT < 4 && ISOL < 4 && MEDI < 4 && FINA < 4), ""); static_assert ((INIT < 4 && ISOL < 4 && MEDI < 4 && FINA < 4));
hb_mask_t masks[4], all_masks = 0; hb_mask_t masks[4], all_masks = 0;
for (unsigned int i = 0; i < 4; i++) for (unsigned int i = 0; i < 4; i++)
{ {
......
...@@ -60,8 +60,8 @@ struct hb_set_digest_lowest_bits_t ...@@ -60,8 +60,8 @@ struct hb_set_digest_lowest_bits_t
+ (mask_bytes >= 16? 1 : 0) + (mask_bytes >= 16? 1 : 0)
+ 0; + 0;
static_assert ((shift < sizeof (hb_codepoint_t) * 8), ""); static_assert ((shift < sizeof (hb_codepoint_t) * 8));
static_assert ((shift + num_bits <= sizeof (hb_codepoint_t) * 8), ""); static_assert ((shift + num_bits <= sizeof (hb_codepoint_t) * 8));
inline void init (void) { inline void init (void) {
mask = 0; mask = 0;
......
...@@ -158,7 +158,7 @@ struct hb_set_t ...@@ -158,7 +158,7 @@ struct hb_set_t
typedef unsigned long long elt_t; typedef unsigned long long elt_t;
enum { PAGE_BITS = 512 }; enum { PAGE_BITS = 512 };
static_assert ((PAGE_BITS & ((PAGE_BITS) - 1)) == 0, ""); static_assert ((PAGE_BITS & ((PAGE_BITS) - 1)) == 0);
static inline unsigned int elt_get_min (const elt_t &elt) { return hb_ctz (elt); } static inline unsigned int elt_get_min (const elt_t &elt) { return hb_ctz (elt); }
static inline unsigned int elt_get_max (const elt_t &elt) { return hb_bit_storage (elt) - 1; } static inline unsigned int elt_get_max (const elt_t &elt) { return hb_bit_storage (elt) - 1; }
...@@ -169,7 +169,7 @@ struct hb_set_t ...@@ -169,7 +169,7 @@ struct hb_set_t
enum { ELT_MASK = ELT_BITS - 1 }; enum { ELT_MASK = ELT_BITS - 1 };
enum { BITS = sizeof (vector_t) * 8 }; enum { BITS = sizeof (vector_t) * 8 };
enum { MASK = BITS - 1 }; enum { MASK = BITS - 1 };
static_assert ((unsigned) PAGE_BITS == (unsigned) BITS, ""); static_assert ((unsigned) PAGE_BITS == (unsigned) BITS);
elt_t &elt (hb_codepoint_t g) { return v[(g & MASK) / ELT_BITS]; } elt_t &elt (hb_codepoint_t g) { return v[(g & MASK) / ELT_BITS]; }
elt_t const &elt (hb_codepoint_t g) const { return v[(g & MASK) / ELT_BITS]; } elt_t const &elt (hb_codepoint_t g) const { return v[(g & MASK) / ELT_BITS]; }
...@@ -177,7 +177,7 @@ struct hb_set_t ...@@ -177,7 +177,7 @@ struct hb_set_t
vector_t v; vector_t v;
}; };
static_assert (page_t::PAGE_BITS == sizeof (page_t) * 8, ""); static_assert (page_t::PAGE_BITS == sizeof (page_t) * 8);
hb_object_header_t header; hb_object_header_t header;
bool successful; /* Allocations successful */ bool successful; /* Allocations successful */
......
...@@ -327,7 +327,7 @@ _hb_generate_unique_face_name (wchar_t *face_name, unsigned int *plen) ...@@ -327,7 +327,7 @@ _hb_generate_unique_face_name (wchar_t *face_name, unsigned int *plen)
const char *enc = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-"; const char *enc = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-";
UUID id; UUID id;
UuidCreate ((UUID*) &id); UuidCreate ((UUID*) &id);
static_assert ((2 + 3 * (16/2) < LF_FACESIZE), ""); static_assert ((2 + 3 * (16/2) < LF_FACESIZE));
unsigned int name_str_len = 0; unsigned int name_str_len = 0;
face_name[name_str_len++] = 'F'; face_name[name_str_len++] = 'F';
face_name[name_str_len++] = '_'; face_name[name_str_len++] = '_';
......
...@@ -99,7 +99,7 @@ extern "C" int hb_memalign_impl(void **memptr, size_t alignment, size_t size); ...@@ -99,7 +99,7 @@ extern "C" int hb_memalign_impl(void **memptr, size_t alignment, size_t size);
#endif #endif
#ifndef static_assert #ifndef static_assert
#define static_assert(e, msg) \ #define static_assert(e) \
HB_UNUSED typedef int HB_PASTE(static_assertion_failed_at_line_, __LINE__) [(e) ? 1 : -1] HB_UNUSED typedef int HB_PASTE(static_assertion_failed_at_line_, __LINE__) [(e) ? 1 : -1]
#endif // static_assert #endif // static_assert
...@@ -137,6 +137,10 @@ struct _hb_alignof ...@@ -137,6 +137,10 @@ struct _hb_alignof
#define explicit_operator explicit #define explicit_operator explicit
#endif #endif
#if __cplusplus < 201703L || true /* Only allow single-arg form. */
#define static_assert(x) static_assert(x, "")
#endif
#endif /* __cplusplus < 201103L */ #endif /* __cplusplus < 201103L */
...@@ -304,18 +308,18 @@ template <> class hb_assert_constant_t<1> {}; ...@@ -304,18 +308,18 @@ template <> class hb_assert_constant_t<1> {};
#define ASSERT_STATIC_EXPR_ZERO(_cond) (0 * (unsigned int) sizeof (hb_assert_constant_t<_cond>)) #define ASSERT_STATIC_EXPR_ZERO(_cond) (0 * (unsigned int) sizeof (hb_assert_constant_t<_cond>))
/* Lets assert int types. Saves trouble down the road. */ /* Lets assert int types. Saves trouble down the road. */
static_assert ((sizeof (int8_t) == 1), ""); static_assert ((sizeof (int8_t) == 1));
static_assert ((sizeof (uint8_t) == 1), ""); static_assert ((sizeof (uint8_t) == 1));
static_assert ((sizeof (int16_t) == 2), ""); static_assert ((sizeof (int16_t) == 2));
static_assert ((sizeof (uint16_t) == 2), ""); static_assert ((sizeof (uint16_t) == 2));
static_assert ((sizeof (int32_t) == 4), ""); static_assert ((sizeof (int32_t) == 4));
static_assert ((sizeof (uint32_t) == 4), ""); static_assert ((sizeof (uint32_t) == 4));
static_assert ((sizeof (int64_t) == 8), ""); static_assert ((sizeof (int64_t) == 8));
static_assert ((sizeof (uint64_t) == 8), ""); static_assert ((sizeof (uint64_t) == 8));
static_assert ((sizeof (hb_codepoint_t) == 4), ""); static_assert ((sizeof (hb_codepoint_t) == 4));
static_assert ((sizeof (hb_position_t) == 4), ""); static_assert ((sizeof (hb_position_t) == 4));
static_assert ((sizeof (hb_mask_t) == 4), ""); static_assert ((sizeof (hb_mask_t) == 4));
static_assert ((sizeof (hb_var_int_t) == 4), ""); static_assert ((sizeof (hb_var_int_t) == 4));
/* We like our types POD */ /* We like our types POD */
...@@ -372,8 +376,8 @@ static_assert ((sizeof (hb_var_int_t) == 4), ""); ...@@ -372,8 +376,8 @@ static_assert ((sizeof (hb_var_int_t) == 4), "");
# define HB_VECTOR_SIZE 0 # define HB_VECTOR_SIZE 0
# endif # endif
#endif #endif
static_assert (0 == (HB_VECTOR_SIZE & (HB_VECTOR_SIZE - 1)), "HB_VECTOR_SIZE is not power of 2."); static_assert (0 == (HB_VECTOR_SIZE & (HB_VECTOR_SIZE - 1)));
static_assert (0 == (HB_VECTOR_SIZE % 64), "HB_VECTOR_SIZE is not multiple of 64."); static_assert (0 == (HB_VECTOR_SIZE % 64));
#if HB_VECTOR_SIZE #if HB_VECTOR_SIZE
typedef uint64_t hb_vector_size_impl_t __attribute__((vector_size (HB_VECTOR_SIZE / 8))); typedef uint64_t hb_vector_size_impl_t __attribute__((vector_size (HB_VECTOR_SIZE / 8)));
#else #else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册