From 5d4b0377b99ddc4112b8ffb2b787eac0b383081c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 22 Jan 2019 12:11:24 +0100 Subject: [PATCH] Convert unsigned enum class consts to static constexpr Part of https://github.com/harfbuzz/harfbuzz/issues/1553 --- src/hb-aat-layout-common.hh | 6 +++--- src/hb-aat-layout-kerx-table.hh | 2 +- src/hb-buffer.hh | 2 +- src/hb-open-type.hh | 2 +- src/hb-ot-kern-table.hh | 4 ++-- src/hb-ot-layout-common.hh | 2 +- src/hb-ot-layout.cc | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh index 133e8731a..df41741f5 100644 --- a/src/hb-aat-layout-common.hh +++ b/src/hb-aat-layout-common.hh @@ -77,7 +77,7 @@ struct LookupFormat0 template struct LookupSegmentSingle { - enum { TerminationWordCount = 2u }; + static constexpr unsigned TerminationWordCount = 2u; int cmp (hb_codepoint_t g) const { return g < first ? -1 : g <= last ? 0 : +1 ; } @@ -136,7 +136,7 @@ struct LookupFormat2 template struct LookupSegmentArray { - enum { TerminationWordCount = 2u }; + static constexpr unsigned TerminationWordCount = 2u; const T* get_value (hb_codepoint_t glyph_id, const void *base) const { @@ -207,7 +207,7 @@ struct LookupFormat4 template struct LookupSingle { - enum { TerminationWordCount = 1u }; + static constexpr unsigned TerminationWordCount = 1u; int cmp (hb_codepoint_t g) const { return glyph.cmp (g); } diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh index cbb305bd8..ac562e408 100644 --- a/src/hb-aat-layout-kerx-table.hh +++ b/src/hb-aat-layout-kerx-table.hh @@ -980,7 +980,7 @@ struct kerx : KerxTable friend struct KerxTable; static constexpr hb_tag_t tableTag = HB_AAT_TAG_kerx; - enum { minVersion = 2u }; + static constexpr unsigned minVersion = 2u; typedef KerxSubTableHeader SubTableHeader; typedef SubTableHeader::Types Types; diff --git a/src/hb-buffer.hh b/src/hb-buffer.hh index ab963a5fb..330f88bac 100644 --- a/src/hb-buffer.hh +++ b/src/hb-buffer.hh @@ -119,7 +119,7 @@ struct hb_buffer_t /* Text before / after the main buffer contents. * Always in Unicode, and ordered outward. * Index 0 is for "pre-context", 1 for "post-context". */ - enum { CONTEXT_LENGTH = 5u }; + static constexpr unsigned CONTEXT_LENGTH = 5u; hb_codepoint_t context[2][CONTEXT_LENGTH]; unsigned int context_len[2]; diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 6dad1e4e0..67af16fcb 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -159,7 +159,7 @@ typedef HBUINT16 GlyphID; /* Script/language-system/feature index */ struct Index : HBUINT16 { - enum { NOT_FOUND_INDEX = 0xFFFFu }; + static constexpr unsigned NOT_FOUND_INDEX = 0xFFFFu; }; DECLARE_NULL_NAMESPACE_BYTES (OT, Index); diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh index bb563bf50..ec6a3c84c 100644 --- a/src/hb-ot-kern-table.hh +++ b/src/hb-ot-kern-table.hh @@ -198,7 +198,7 @@ struct KernOT : AAT::KerxTable friend struct AAT::KerxTable; static constexpr hb_tag_t tableTag = HB_OT_TAG_kern; - enum { minVersion = 0u }; + static constexpr unsigned minVersion = 0u; typedef KernOTSubTableHeader SubTableHeader; typedef SubTableHeader::Types Types; @@ -253,7 +253,7 @@ struct KernAAT : AAT::KerxTable friend struct AAT::KerxTable; static constexpr hb_tag_t tableTag = HB_OT_TAG_kern; - enum { minVersion = 0x00010000u }; + static constexpr unsigned minVersion = 0x00010000u; typedef KernAATSubTableHeader SubTableHeader; typedef SubTableHeader::Types Types; diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 4818a8b88..39a8bbabd 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -1949,7 +1949,7 @@ struct FeatureVariationRecord struct FeatureVariations { - enum { NOT_FOUND_INDEX = 0xFFFFFFFFu }; + static constexpr unsigned NOT_FOUND_INDEX = 0xFFFFFFFFu; bool find_index (const int *coords, unsigned int coord_len, unsigned int *index) const diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 3ded3ada1..d32be04a8 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -1299,7 +1299,7 @@ hb_ot_layout_feature_get_characters (hb_face_t *face, struct GSUBProxy { - enum { table_index = 0u }; + static constexpr unsigned table_index = 0u; static constexpr bool inplace = false; typedef OT::SubstLookup Lookup; @@ -1313,7 +1313,7 @@ struct GSUBProxy struct GPOSProxy { - enum { table_index = 1u }; + static constexpr unsigned table_index = 1u; static constexpr bool inplace = true; typedef OT::PosLookup Lookup;