Use static_assert instead of custom ASSERT_STATIC
This commit is contained in:
parent
76dcbf8b23
commit
c3448e8d21
|
@ -45,8 +45,8 @@
|
|||
#define HB_BUFFER_MAX_LEN_DEFAULT 0x3FFFFFFF /* Shaping more than a billion chars? Let us know! */
|
||||
#endif
|
||||
|
||||
ASSERT_STATIC (sizeof (hb_glyph_info_t) == 20);
|
||||
ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t));
|
||||
static_assert ((sizeof (hb_glyph_info_t) == 20), "");
|
||||
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_serialize_flags_t);
|
||||
|
|
|
@ -130,7 +130,7 @@ hb_buffer_t::enlarge (unsigned int size)
|
|||
while (size >= new_allocated)
|
||||
new_allocated += (new_allocated >> 1) + 32;
|
||||
|
||||
ASSERT_STATIC (sizeof (info[0]) == sizeof (pos[0]));
|
||||
static_assert ((sizeof (info[0]) == sizeof (pos[0])), "");
|
||||
if (unlikely (_hb_unsigned_int_mul_overflows (new_allocated, sizeof (info[0]))))
|
||||
goto done;
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@
|
|||
template <unsigned int key_bits, unsigned int value_bits, unsigned int cache_bits>
|
||||
struct hb_cache_t
|
||||
{
|
||||
ASSERT_STATIC (key_bits >= cache_bits);
|
||||
ASSERT_STATIC (key_bits + value_bits - cache_bits < 8 * sizeof (unsigned int));
|
||||
static_assert ((key_bits >= cache_bits), "");
|
||||
static_assert ((key_bits + value_bits - cache_bits < 8 * sizeof (unsigned int)), "");
|
||||
|
||||
inline void clear (void)
|
||||
{
|
||||
|
|
|
@ -678,7 +678,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.setting)
|
||||
};
|
||||
ASSERT_STATIC (ARRAY_LENGTH (keys) == ARRAY_LENGTH (values));
|
||||
static_assert ((ARRAY_LENGTH (keys) == ARRAY_LENGTH (values)), "");
|
||||
CFDictionaryRef dict = CFDictionaryCreate (kCFAllocatorDefault,
|
||||
(const void **) keys,
|
||||
(const void **) values,
|
||||
|
|
|
@ -85,7 +85,7 @@ static inline Type& StructAfter(TObject &X)
|
|||
#define _DEFINE_INSTANCE_ASSERTION1(_line, _assertion) \
|
||||
inline void _instance_assertion_on_line_##_line (void) const \
|
||||
{ \
|
||||
ASSERT_STATIC (_assertion); \
|
||||
static_assert ((_assertion), ""); \
|
||||
ASSERT_INSTANCE_POD (*this); /* Make sure it's POD. */ \
|
||||
}
|
||||
# define _DEFINE_INSTANCE_ASSERTION0(_line, _assertion) _DEFINE_INSTANCE_ASSERTION1 (_line, _assertion)
|
||||
|
@ -136,7 +136,7 @@ static const void *_NullPool[(256+8) / sizeof (void *)];
|
|||
/* Generic nul-content Null objects. */
|
||||
template <typename Type>
|
||||
static inline const Type& Null (void) {
|
||||
ASSERT_STATIC (sizeof (Type) <= sizeof (_NullPool));
|
||||
static_assert ((sizeof (Type) <= sizeof (_NullPool)), "");
|
||||
return *CastP<Type> (_NullPool);
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ template <> \
|
|||
/*static*/ inline const Type& Null<Type> (void) { \
|
||||
return *CastP<Type> (_Null##Type); \
|
||||
} /* The following line really exists such that we end in a place needing semicolon */ \
|
||||
ASSERT_STATIC (Type::min_size + 1 <= sizeof (_Null##Type))
|
||||
static_assert (Type::min_size + 1 <= sizeof (_Null##Type), "Null pool too small. Enlarge.")
|
||||
|
||||
/* Accessor macro. */
|
||||
#define Null(Type) Null<Type>()
|
||||
|
|
|
@ -690,7 +690,7 @@ struct CoverageFormat1
|
|||
inline unsigned int get_coverage (hb_codepoint_t glyph_id) const
|
||||
{
|
||||
int i = glyphArray.bsearch (glyph_id);
|
||||
ASSERT_STATIC (((unsigned int) -1) == NOT_COVERED);
|
||||
static_assert ((((unsigned int) -1) == NOT_COVERED), "");
|
||||
return i;
|
||||
}
|
||||
|
||||
|
|
|
@ -404,9 +404,9 @@ struct GDEF
|
|||
{
|
||||
unsigned int klass = get_glyph_class (glyph);
|
||||
|
||||
ASSERT_STATIC ((unsigned int) HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH == (unsigned int) LookupFlag::IgnoreBaseGlyphs);
|
||||
ASSERT_STATIC ((unsigned int) HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE == (unsigned int) LookupFlag::IgnoreLigatures);
|
||||
ASSERT_STATIC ((unsigned int) HB_OT_LAYOUT_GLYPH_PROPS_MARK == (unsigned int) LookupFlag::IgnoreMarks);
|
||||
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_MARK == (unsigned int) LookupFlag::IgnoreMarks), "");
|
||||
|
||||
switch (klass) {
|
||||
default: return 0;
|
||||
|
|
|
@ -321,7 +321,7 @@ hb_ot_layout_table_find_script (hb_face_t *face,
|
|||
hb_tag_t script_tag,
|
||||
unsigned int *script_index)
|
||||
{
|
||||
ASSERT_STATIC (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);
|
||||
|
||||
if (g.find_script_index (script_tag, script_index))
|
||||
|
@ -352,7 +352,7 @@ hb_ot_layout_table_choose_script (hb_face_t *face,
|
|||
unsigned int *script_index,
|
||||
hb_tag_t *chosen_script)
|
||||
{
|
||||
ASSERT_STATIC (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);
|
||||
|
||||
while (*script_tags)
|
||||
|
@ -411,7 +411,7 @@ hb_ot_layout_table_find_feature (hb_face_t *face,
|
|||
hb_tag_t feature_tag,
|
||||
unsigned int *feature_index)
|
||||
{
|
||||
ASSERT_STATIC (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);
|
||||
|
||||
unsigned int num_features = g.get_feature_count ();
|
||||
|
@ -448,7 +448,7 @@ hb_ot_layout_script_find_language (hb_face_t *face,
|
|||
hb_tag_t language_tag,
|
||||
unsigned int *language_index)
|
||||
{
|
||||
ASSERT_STATIC (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);
|
||||
|
||||
if (s.find_lang_sys_index (language_tag, language_index))
|
||||
|
@ -527,7 +527,7 @@ hb_ot_layout_language_get_feature_tags (hb_face_t *face,
|
|||
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
||||
const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
|
||||
|
||||
ASSERT_STATIC (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);
|
||||
|
||||
if (feature_tags) {
|
||||
|
@ -548,7 +548,7 @@ hb_ot_layout_language_find_feature (hb_face_t *face,
|
|||
hb_tag_t feature_tag,
|
||||
unsigned int *feature_index)
|
||||
{
|
||||
ASSERT_STATIC (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::LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
|
||||
|
||||
|
@ -859,7 +859,7 @@ hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face,
|
|||
unsigned int *lookup_count /* IN/OUT */,
|
||||
unsigned int *lookup_indexes /* OUT */)
|
||||
{
|
||||
ASSERT_STATIC (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::Feature &f = g.get_feature_variation (feature_index, variations_index);
|
||||
|
|
|
@ -138,7 +138,7 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m,
|
|||
const int *coords,
|
||||
unsigned int num_coords)
|
||||
{
|
||||
ASSERT_STATIC (!(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_shift = _hb_popcount32 (HB_GLYPH_FLAG_DEFINED);
|
||||
|
||||
|
|
|
@ -463,8 +463,8 @@ struct MathGlyphPartRecord
|
|||
out.end_connector_length = font->em_scale (endConnectorLength, scale);
|
||||
out.full_advance = font->em_scale (fullAdvance, scale);
|
||||
|
||||
ASSERT_STATIC ((unsigned int) HB_MATH_GLYPH_PART_FLAG_EXTENDER ==
|
||||
(unsigned int) PartFlags::Extender);
|
||||
static_assert ((unsigned int) HB_MATH_GLYPH_PART_FLAG_EXTENDER ==
|
||||
(unsigned int) PartFlags::Extender, "");
|
||||
|
||||
out.flags = (hb_ot_math_glyph_part_flags_t)
|
||||
(unsigned int)
|
||||
|
|
|
@ -237,8 +237,8 @@ arabic_fallback_plan_init_win1256 (arabic_fallback_plan_t *fallback_plan,
|
|||
return false;
|
||||
|
||||
const Manifest &manifest = reinterpret_cast<const Manifest&> (arabic_win1256_gsub_lookups.manifest);
|
||||
ASSERT_STATIC (sizeof (arabic_win1256_gsub_lookups.manifestData) / sizeof (ManifestLookup)
|
||||
<= ARABIC_FALLBACK_MAX_LOOKUPS);
|
||||
static_assert (sizeof (arabic_win1256_gsub_lookups.manifestData) / sizeof (ManifestLookup)
|
||||
<= ARABIC_FALLBACK_MAX_LOOKUPS, "");
|
||||
/* TODO sanitize the table? */
|
||||
|
||||
unsigned j = 0;
|
||||
|
@ -271,7 +271,7 @@ arabic_fallback_plan_init_unicode (arabic_fallback_plan_t *fallback_plan,
|
|||
const hb_ot_shape_plan_t *plan,
|
||||
hb_font_t *font)
|
||||
{
|
||||
ASSERT_STATIC (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;
|
||||
for (unsigned int i = 0; i < ARRAY_LENGTH(arabic_fallback_features) ; i++)
|
||||
{
|
||||
|
|
|
@ -198,7 +198,7 @@ set_indic_properties (hb_glyph_info_t &info)
|
|||
0x1CEEu, 0x1CF1u)))
|
||||
{
|
||||
cat = OT_Symbol;
|
||||
ASSERT_STATIC ((int) INDIC_SYLLABIC_CATEGORY_AVAGRAHA == OT_Symbol);
|
||||
static_assert (((int) INDIC_SYLLABIC_CATEGORY_AVAGRAHA == OT_Symbol), "");
|
||||
}
|
||||
else if (unlikely (hb_in_range<hb_codepoint_t> (u, 0x17CDu, 0x17D1u) ||
|
||||
u == 0x17CBu || u == 0x17D3u || u == 0x17DDu)) /* Khmer Various signs */
|
||||
|
|
|
@ -292,7 +292,7 @@ setup_topographical_masks (const hb_ot_shape_plan_t *plan,
|
|||
if (use_plan->arabic_plan)
|
||||
return;
|
||||
|
||||
ASSERT_STATIC (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;
|
||||
for (unsigned int i = 0; i < 4; i++)
|
||||
{
|
||||
|
|
|
@ -100,7 +100,7 @@ private:
|
|||
#define _PASTE1(a,b) a##b
|
||||
#define _PASTE(a,b) _PASTE1(a,b)
|
||||
#define static_assert(e, msg) \
|
||||
HB_UNUSED typedef char _PASTE(assertion_failed_at_line_, __LINE__) [(e) ? 1 : -1]
|
||||
HB_UNUSED typedef int _PASTE(static_assertion_failed_at_line_, __LINE__) [(e) ? 1 : -1]
|
||||
#endif // static_assert
|
||||
|
||||
#endif // __cplusplus < 201103L
|
||||
|
@ -267,10 +267,6 @@ static inline unsigned int ARRAY_LENGTH (const Type (&)[n]) { return n; }
|
|||
#define HB_STMT_START do
|
||||
#define HB_STMT_END while (0)
|
||||
|
||||
#define _ASSERT_STATIC1(_line, _cond) HB_UNUSED typedef int _static_assert_on_line_##_line##_failed[(_cond)?1:-1]
|
||||
#define _ASSERT_STATIC0(_line, _cond) _ASSERT_STATIC1 (_line, (_cond))
|
||||
#define ASSERT_STATIC(_cond) _ASSERT_STATIC0 (__LINE__, (_cond))
|
||||
|
||||
template <unsigned int cond> class hb_assert_constant_t;
|
||||
template <> class hb_assert_constant_t<1> {};
|
||||
|
||||
|
@ -278,19 +274,19 @@ template <> class hb_assert_constant_t<1> {};
|
|||
|
||||
/* Lets assert int types. Saves trouble down the road. */
|
||||
|
||||
ASSERT_STATIC (sizeof (int8_t) == 1);
|
||||
ASSERT_STATIC (sizeof (uint8_t) == 1);
|
||||
ASSERT_STATIC (sizeof (int16_t) == 2);
|
||||
ASSERT_STATIC (sizeof (uint16_t) == 2);
|
||||
ASSERT_STATIC (sizeof (int32_t) == 4);
|
||||
ASSERT_STATIC (sizeof (uint32_t) == 4);
|
||||
ASSERT_STATIC (sizeof (int64_t) == 8);
|
||||
ASSERT_STATIC (sizeof (uint64_t) == 8);
|
||||
static_assert ((sizeof (int8_t) == 1), "");
|
||||
static_assert ((sizeof (uint8_t) == 1), "");
|
||||
static_assert ((sizeof (int16_t) == 2), "");
|
||||
static_assert ((sizeof (uint16_t) == 2), "");
|
||||
static_assert ((sizeof (int32_t) == 4), "");
|
||||
static_assert ((sizeof (uint32_t) == 4), "");
|
||||
static_assert ((sizeof (int64_t) == 8), "");
|
||||
static_assert ((sizeof (uint64_t) == 8), "");
|
||||
|
||||
ASSERT_STATIC (sizeof (hb_codepoint_t) == 4);
|
||||
ASSERT_STATIC (sizeof (hb_position_t) == 4);
|
||||
ASSERT_STATIC (sizeof (hb_mask_t) == 4);
|
||||
ASSERT_STATIC (sizeof (hb_var_int_t) == 4);
|
||||
static_assert ((sizeof (hb_codepoint_t) == 4), "");
|
||||
static_assert ((sizeof (hb_position_t) == 4), "");
|
||||
static_assert ((sizeof (hb_mask_t) == 4), "");
|
||||
static_assert ((sizeof (hb_var_int_t) == 4), "");
|
||||
|
||||
|
||||
/* We like our types POD */
|
||||
|
@ -912,7 +908,7 @@ hb_in_range (T u, T lo, T hi)
|
|||
* one right now. Declaring a variable won't work as HB_UNUSED
|
||||
* is unusable on some platforms and unused types are less likely
|
||||
* to generate a warning than unused variables. */
|
||||
ASSERT_STATIC (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 subtract results will become a signed int! */
|
||||
|
@ -1027,7 +1023,7 @@ union hb_options_union_t {
|
|||
unsigned int i;
|
||||
hb_options_t opts;
|
||||
};
|
||||
ASSERT_STATIC (sizeof (int) == sizeof (hb_options_union_t));
|
||||
static_assert ((sizeof (int) == sizeof (hb_options_union_t)), "");
|
||||
|
||||
HB_INTERNAL void
|
||||
_hb_options_init (void);
|
||||
|
|
|
@ -62,8 +62,8 @@ struct hb_set_digest_lowest_bits_t
|
|||
+ (mask_bytes >= 16? 1 : 0)
|
||||
+ 0;
|
||||
|
||||
ASSERT_STATIC (shift < sizeof (hb_codepoint_t) * 8);
|
||||
ASSERT_STATIC (shift + num_bits <= sizeof (hb_codepoint_t) * 8);
|
||||
static_assert ((shift < sizeof (hb_codepoint_t) * 8), "");
|
||||
static_assert ((shift + num_bits <= sizeof (hb_codepoint_t) * 8), "");
|
||||
|
||||
inline void init (void) {
|
||||
mask = 0;
|
||||
|
@ -341,8 +341,8 @@ struct hb_set_t
|
|||
|
||||
elt_t elts[ELTS]; /* XXX 8kb */
|
||||
|
||||
ASSERT_STATIC (sizeof (elt_t) * 8 == BITS);
|
||||
ASSERT_STATIC (sizeof (elt_t) * 8 * ELTS > MAX_G);
|
||||
static_assert ((sizeof (elt_t) * 8 == BITS), "");
|
||||
static_assert ((sizeof (elt_t) * 8 * ELTS > MAX_G), "");
|
||||
};
|
||||
|
||||
struct hb_frozen_set_t
|
||||
|
|
|
@ -316,7 +316,7 @@ _hb_generate_unique_face_name (wchar_t *face_name, unsigned int *plen)
|
|||
const char *enc = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-";
|
||||
UUID id;
|
||||
UuidCreate ((UUID*) &id);
|
||||
ASSERT_STATIC (2 + 3 * (16/2) < LF_FACESIZE);
|
||||
static_assert ((2 + 3 * (16/2) < LF_FACESIZE), "");
|
||||
unsigned int name_str_len = 0;
|
||||
face_name[name_str_len++] = 'F';
|
||||
face_name[name_str_len++] = '_';
|
||||
|
|
|
@ -486,7 +486,8 @@ font_options_t::add_options (option_parser_t *parser)
|
|||
char *text = NULL;
|
||||
|
||||
{
|
||||
ASSERT_STATIC (ARRAY_LENGTH_CONST (supported_font_funcs) > 0);
|
||||
static_assert ((ARRAY_LENGTH_CONST (supported_font_funcs) > 0),
|
||||
"No supported font-funcs found.");
|
||||
GString *s = g_string_new (NULL);
|
||||
g_string_printf (s, "Set font functions implementation to use (default: %s)\n\n Supported font function implementations are: %s",
|
||||
supported_font_funcs[0].name,
|
||||
|
|
Loading…
Reference in New Issue