Core: make CLDR data constexpr

Task-number: QTBUG-100485
Pick-to: 6.3 6.2
Change-Id: Ib8c5160ca0994662a5fdc2293dc734c1bdcac4f2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Yuhang Zhao 2022-05-24 12:32:02 +08:00
parent fda8eb1741
commit 42fe677584
4 changed files with 42 additions and 42 deletions

View File

@ -30,14 +30,14 @@ struct TerritoryLanguage
quint16 territoryId;
QLocale::MeasurementSystem system;
};
static const TerritoryLanguage ImperialMeasurementSystems[] = {
static constexpr TerritoryLanguage ImperialMeasurementSystems[] = {
{ QLocale::English, QLocale::UnitedStates, QLocale::ImperialUSSystem },
{ QLocale::English, QLocale::UnitedStatesMinorOutlyingIslands, QLocale::ImperialUSSystem },
{ QLocale::Spanish, QLocale::UnitedStates, QLocale::ImperialUSSystem },
{ QLocale::Hawaiian, QLocale::UnitedStates, QLocale::ImperialUSSystem },
{ QLocale::English, QLocale::UnitedKingdom, QLocale::ImperialUKSystem }
};
static const int ImperialMeasurementSystemsCount =
static constexpr int ImperialMeasurementSystemsCount =
sizeof(ImperialMeasurementSystems)/sizeof(ImperialMeasurementSystems[0]);
/*
@ -72,7 +72,7 @@ struct LanguageCodeEntry {
edited) CLDR data; see qtbase/util/locale_database/.
*/
static const QLocaleId likely_subtags[] = {
static constexpr QLocaleId likely_subtags[] = {
{ 2, 0, 0 }, { 2, 27, 90 }, // ab -> ab_Cyrl_GE
{ 3, 0, 0 }, { 3, 66, 77 }, // aa -> aa_Latn_ET
{ 4, 0, 0 }, { 4, 66, 216 }, // af -> af_Latn_ZA
@ -806,7 +806,7 @@ static const QLocaleId likely_subtags[] = {
{ 0, 141, 0 }, { 255, 141, 50 } // und_Yiii -> ii_Yiii_CN
};
static const quint16 locale_index[] = {
static constexpr quint16 locale_index[] = {
0, // AnyLanguage
0, // C
1, // Abkhazian
@ -1140,7 +1140,7 @@ static const quint16 locale_index[] = {
0 // trailing 0
};
static const QLocaleData locale_data[] = {
static constexpr QLocaleData locale_data[] = {
// lang script terr lStrt lpMid lpEnd lPair lDelm dec group prcnt zero minus plus exp qtOpn qtEnd altQO altQE lDFmt sDFmt lTFmt sTFmt slDay lDays ssDys sDays snDay nDays am pm byte siQnt iecQn crSym crDsp crFmt crFNg ntLng ntTer currISO curDgt curRnd dow1st wknd+ wknd- grpTop grpMid grpEnd
{ 1, 0, 0, 0, 0, 0, 0, 6, 0, 1, 2, 3, 4, 5, 6, 7, 7, 8, 8, 0, 17, 0, 0, 0, 0, 56, 56, 83, 96, 0, 0, 0, 5, 22, 0, 0, 0, 0, 0, 0, 6, 6, 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 17, 10, 10, 8, 56, 56, 27, 27, 13, 13, 2, 2, 5, 17, 23, 0, 0, 4, 0, 0, 0, {0,0,0}, 2, 1, 1, 6, 7, 1, 3, 3 }, // C/AnyScript/AnyTerritory
{ 2, 27, 90, 0, 0, 0, 0, 6, 0, 1, 2, 3, 4, 5, 9, 10, 11, 12, 13, 27, 44, 0, 0, 56, 56, 56, 56, 83, 83, 0, 0, 0, 5, 22, 0, 0, 4, 0, 0, 0, 6, 6, 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 17, 10, 10, 5, 27, 27, 27, 27, 13, 13, 2, 2, 4, 17, 23, 1, 0, 5, 0, 0, 0, {71,69,76}, 2, 1, 1, 6, 7, 1, 3, 3 }, // Abkhazian/Cyrillic/Georgia
@ -1769,7 +1769,7 @@ static const QLocaleData locale_data[] = {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0,0,0}, 0, 0, 0, 0, 0, 0, 0, 0 } // trailing zeros
};
static const char16_t list_pattern_part_data[] = {
static constexpr char16_t list_pattern_part_data[] = {
0x25, 0x31, 0x2c, 0x20, 0x25, 0x32, 0x3b, 0x25, 0x31, 0x20, 0x65, 0x6e, 0x20, 0x25, 0x32, 0x25, 0x31, 0x20, 0x64, 0x68,
0x65, 0x20, 0x25, 0x32, 0x25, 0x31, 0x1363, 0x20, 0x25, 0x32, 0x25, 0x31, 0x2c, 0x20, 0x12a5, 0x1293, 0x20, 0x25, 0x32, 0x25,
0x31, 0x20, 0x12a5, 0x1293, 0x20, 0x25, 0x32, 0x25, 0x31, 0x20, 0x648, 0x25, 0x32, 0x61b, 0x25, 0x31, 0x20, 0x587, 0x20, 0x25,
@ -1835,14 +1835,14 @@ static const char16_t list_pattern_part_data[] = {
0x20, 0x25, 0x32
};
static const char16_t single_character_data[] = {
static constexpr char16_t single_character_data[] = {
0x2e, 0x2c, 0x25, 0x30, 0x2d, 0x2b, 0x65, 0x22, 0x27, 0x45, 0x201c, 0x201d, 0x2018, 0x2019, 0xa0, 0x201e, 0x201a, 0xab, 0xbb, 0x2039,
0x203a, 0x66b, 0x66c, 0x66a, 0x61c, 0x660, 0x61c, 0x2d, 0x61c, 0x2b, 0x627, 0x633, 0x200e, 0x25, 0x200e, 0x200e, 0x2d, 0x200e, 0x2b, 0x9e6,
0x2212, 0x1040, 0x300c, 0x300d, 0x300e, 0x300f, 0x200f, 0x2d, 0x200f, 0x2b, 0xd804, 0xdd36, 0xd7, 0x31, 0x30, 0x5e, 0xf20, 0x202f, 0x2e41, 0xd83a,
0xdd50, 0x6f0, 0x200e, 0x2b, 0x200e, 0xd7, 0x6f1, 0x6f0, 0x5e, 0x966, 0xb7, 0x31, 0x30, 0x5e, 0x200e, 0x2212, 0x1c50, 0x415
};
static const char16_t date_format_data[] = {
static constexpr char16_t date_format_data[] = {
0x64, 0x64, 0x64, 0x64, 0x2c, 0x20, 0x64, 0x20, 0x4d, 0x4d, 0x4d, 0x4d, 0x20, 0x79, 0x79, 0x79, 0x79, 0x64, 0x20, 0x4d,
0x4d, 0x4d, 0x20, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x20, 0x4d, 0x4d, 0x4d, 0x4d, 0x20, 0x64, 0x2c, 0x20,
0x64, 0x64, 0x64, 0x64, 0x79, 0x79, 0x79, 0x79, 0x2d, 0x4d, 0x4d, 0x2d, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x20, 0x64,
@ -1932,7 +1932,7 @@ static const char16_t date_format_data[] = {
0x4d, 0x4d, 0x4d, 0x4d, 0x2c, 0x20, 0x79, 0x79, 0x79, 0x79
};
static const char16_t time_format_data[] = {
static constexpr char16_t time_format_data[] = {
0x48, 0x48, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x20, 0x74, 0x68, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x20, 0x41, 0x50,
0x20, 0x74, 0x68, 0x3a, 0x6d, 0x6d, 0x20, 0x41, 0x50, 0x68, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x20, 0x41, 0x50, 0x2c,
0x20, 0x74, 0x41, 0x50, 0x20, 0x68, 0x2e, 0x6d, 0x6d, 0x2e, 0x73, 0x73, 0x20, 0x74, 0x48, 0x48, 0x3a, 0x6d, 0x6d, 0x3a,
@ -1960,7 +1960,7 @@ static const char16_t time_format_data[] = {
0xe35, 0x20, 0x74, 0x48, 0x3a, 0x6d, 0x6d, 0x20, 0x27, 0x68, 0x6f, 0x64, 0x17a, 0x27, 0x2e
};
static const char16_t days_data[] = {
static constexpr char16_t days_data[] = {
0x53, 0x75, 0x6e, 0x64, 0x61, 0x79, 0x3b, 0x4d, 0x6f, 0x6e, 0x64, 0x61, 0x79, 0x3b, 0x54, 0x75, 0x65, 0x73, 0x64, 0x61,
0x79, 0x3b, 0x57, 0x65, 0x64, 0x6e, 0x65, 0x73, 0x64, 0x61, 0x79, 0x3b, 0x54, 0x68, 0x75, 0x72, 0x73, 0x64, 0x61, 0x79,
0x3b, 0x46, 0x72, 0x69, 0x64, 0x61, 0x79, 0x3b, 0x53, 0x61, 0x74, 0x75, 0x72, 0x64, 0x61, 0x79, 0x53, 0x75, 0x6e, 0x3b,
@ -3073,7 +3073,7 @@ static const char16_t days_data[] = {
0x4d, 0x3b, 0x4d, 0x3b, 0x4d, 0x3b, 0x53, 0x3b, 0x59, 0x3b, 0x53
};
static const char16_t byte_unit_data[] = {
static constexpr char16_t byte_unit_data[] = {
0x62, 0x79, 0x74, 0x65, 0x73, 0x6b, 0x42, 0x3b, 0x4d, 0x42, 0x3b, 0x47, 0x42, 0x3b, 0x54, 0x42, 0x3b, 0x50, 0x42, 0x3b,
0x45, 0x42, 0x4b, 0x69, 0x42, 0x3b, 0x4d, 0x69, 0x42, 0x3b, 0x47, 0x69, 0x42, 0x3b, 0x54, 0x69, 0x42, 0x3b, 0x50, 0x69,
0x42, 0x3b, 0x45, 0x69, 0x42, 0x67, 0x72, 0x65, 0x65, 0x70, 0x62, 0x61, 0x6a, 0x74, 0x1263, 0x12ed, 0x1275, 0x12aa, 0x1263, 0x3b,
@ -3145,7 +3145,7 @@ static const char16_t byte_unit_data[] = {
0x65, 0x20, 0x61, 0x67, 0x62, 0x79, 0x74, 0x65, 0x2d, 0x69, 0x74, 0x61
};
static const char16_t am_data[] = {
static constexpr char16_t am_data[] = {
0x41, 0x4d, 0x76, 0x6d, 0x2e, 0x61, 0x2e, 0x67, 0x41, 0x4e, 0x65, 0x20, 0x70, 0x61, 0x72, 0x61, 0x64, 0x69, 0x74, 0x65,
0x73, 0x1325, 0x12cb, 0x1275, 0x635, 0x9aa, 0x9c2, 0x9f0, 0x9cd, 0x9ac, 0x9be, 0x9b9, 0x9cd, 0x9a8, 0x64, 0x65, 0x20, 0x6c, 0x61, 0x20,
0x6d, 0x61, 0xf1, 0x61, 0x6e, 0x61, 0x69, 0x63, 0x68, 0x65, 0x68, 0x65, 0x61, 0x76, 0x6f, 0x410, 0x41c, 0x73, 0xe1, 0x72,
@ -3189,7 +3189,7 @@ static const char16_t am_data[] = {
0x300
};
static const char16_t pm_data[] = {
static constexpr char16_t pm_data[] = {
0x50, 0x4d, 0x6e, 0x6d, 0x2e, 0x61, 0x2e, 0x6b, 0x45, 0x57, 0x65, 0x20, 0x70, 0x61, 0x73, 0x64, 0x69, 0x74, 0x65, 0x73,
0x12a8, 0x1230, 0x12d3, 0x1275, 0x645, 0x985, 0x9aa, 0x9f0, 0x9be, 0x9b9, 0x9cd, 0x9a8, 0x64, 0x65, 0x20, 0x6c, 0x61, 0x20, 0x74, 0x61,
0x72, 0x64, 0x65, 0x69, 0x63, 0x68, 0x61, 0x6d, 0x74, 0x68, 0x69, 0x41f, 0x41c, 0x63, 0x25b, 0x25b, 0x301, 0x6e, 0x6b, 0x6f,
@ -3234,7 +3234,7 @@ static const char16_t pm_data[] = {
0x5db, 0x5de, 0x5d9, 0x5d8, 0x5d0, 0x5b8, 0x5d2, 0x1ecc, 0x300, 0x73, 0xe1, 0x6e, 0x186, 0x300, 0x73, 0xe1, 0x6e
};
static const char16_t currency_symbol_data[] = {
static constexpr char16_t currency_symbol_data[] = {
0x20be, 0x52, 0x24, 0x46, 0x43, 0x46, 0x41, 0x47, 0x48, 0x20b5, 0x4c, 0x65, 0x6b, 0xeb, 0x20ac, 0x64, 0x65, 0x6e, 0x1265, 0x122d,
0x62c, 0x2e, 0x645, 0x2e, 0x200f, 0x62f, 0x2e, 0x62c, 0x2e, 0x200f, 0x62f, 0x2e, 0x628, 0x2e, 0x200f, 0x46, 0x64, 0x6a, 0x4e, 0x66,
0x6b, 0x62f, 0x2e, 0x639, 0x2e, 0x200f, 0x20aa, 0x62f, 0x2e, 0x623, 0x2e, 0x200f, 0x62f, 0x2e, 0x643, 0x2e, 0x200f, 0x644, 0x2e, 0x644,
@ -3255,7 +3255,7 @@ static const char16_t currency_symbol_data[] = {
0x6d, 0x441, 0x45e, 0x43c
};
static const char16_t currency_display_name_data[] = {
static constexpr char16_t currency_display_name_data[] = {
0x53, 0x75, 0x69, 0x64, 0x2d, 0x41, 0x66, 0x72, 0x69, 0x6b, 0x61, 0x61, 0x6e, 0x73, 0x65, 0x20, 0x72, 0x61, 0x6e, 0x64,
0x4e, 0x61, 0x6d, 0x69, 0x62, 0x69, 0x65, 0x73, 0x65, 0x20, 0x64, 0x6f, 0x6c, 0x6c, 0x61, 0x72, 0x43, 0x46, 0x41, 0x20,
0x46, 0xe0, 0x6c, 0xe2, 0x14b, 0x20, 0x42, 0x45, 0x41, 0x43, 0x47, 0x68, 0x61, 0x6e, 0x61, 0x20, 0x53, 0x69, 0x64, 0x69,
@ -3535,14 +3535,14 @@ static const char16_t currency_display_name_data[] = {
0x6e, 0x65, 0x73, 0x75, 0x65, 0x72, 0x61, 0x77, 0x61, 0x72, 0x61
};
static const char16_t currency_format_data[] = {
static constexpr char16_t currency_format_data[] = {
0x25, 0x31, 0x25, 0x32, 0x25, 0x32, 0xa0, 0x25, 0x31, 0x25, 0x32, 0x25, 0x31, 0x28, 0x25, 0x32, 0x25, 0x31, 0x29, 0x25,
0x31, 0xa0, 0x25, 0x32, 0x28, 0x25, 0x31, 0xa0, 0x25, 0x32, 0x29, 0x28, 0x25, 0x31, 0x25, 0x32, 0x29, 0x28, 0x25, 0x32,
0xa0, 0x25, 0x31, 0x29, 0x25, 0x32, 0x2d, 0x25, 0x31, 0x25, 0x32, 0x2212, 0x25, 0x31, 0x25, 0x32, 0x2d, 0xa0, 0x25, 0x31,
0x200e, 0x25, 0x32, 0xa0, 0x25, 0x31, 0x200e, 0x28, 0x25, 0x32, 0xa0, 0x25, 0x31, 0x29
};
static const char16_t endonyms_data[] = {
static constexpr char16_t endonyms_data[] = {
0x41, 0x66, 0x72, 0x69, 0x6b, 0x61, 0x61, 0x6e, 0x73, 0x53, 0x75, 0x69, 0x64, 0x2d, 0x41, 0x66, 0x72, 0x69, 0x6b, 0x61,
0x4e, 0x61, 0x6d, 0x69, 0x62, 0x69, 0xeb, 0x41, 0x67, 0x68, 0x65, 0x6d, 0x4b, 0xe0, 0x6d, 0xe0, 0x6c, 0xfb, 0x14b, 0x41,
0x6b, 0x61, 0x6e, 0x47, 0x61, 0x61, 0x6e, 0x61, 0x73, 0x68, 0x71, 0x69, 0x70, 0x53, 0x68, 0x71, 0x69, 0x70, 0xeb, 0x72,
@ -3856,7 +3856,7 @@ static const char16_t endonyms_data[] = {
0x75, 0x65, 0x72, 0x61
};
static const char language_name_list[] =
static constexpr char language_name_list[] =
"Default\0"
"C\0"
"Abkhazian\0"
@ -4189,7 +4189,7 @@ static const char language_name_list[] =
"Nheengatu\0"
;
static const quint16 language_name_index[] = {
static constexpr quint16 language_name_index[] = {
0, // AnyLanguage
8, // C
10, // Abkhazian
@ -4522,7 +4522,7 @@ static const quint16 language_name_index[] = {
2748, // Nheengatu
};
static const char script_name_list[] =
static constexpr char script_name_list[] =
"Default\0"
"Adlam\0"
"Ahom\0"
@ -4667,7 +4667,7 @@ static const char script_name_list[] =
"Yi\0"
;
static const quint16 script_name_index[] = {
static constexpr quint16 script_name_index[] = {
0, // AnyScript
8, // Adlam
14, // Ahom
@ -4812,7 +4812,7 @@ static const quint16 script_name_index[] = {
1312, // Yi
};
static const char territory_name_list[] =
static constexpr char territory_name_list[] =
"Default\0"
"Afghanistan\0"
"Aland Islands\0"
@ -5077,7 +5077,7 @@ static const char territory_name_list[] =
"Zimbabwe\0"
;
static const quint16 territory_name_index[] = {
static constexpr quint16 territory_name_index[] = {
0, // AnyTerritory
8, // Afghanistan
20, // Aland Islands
@ -5675,7 +5675,7 @@ constexpr std::array<LanguageCodeEntry, 330> languageCodeList {
LanguageCodeEntry {{}, {}, {}, {{'y', 'r', 'l'}}}, // Nheengatu
};
static const unsigned char script_code_list[] =
static constexpr unsigned char script_code_list[] =
"Zzzz" // AnyScript
"Adlm" // Adlam
"Ahom" // Ahom
@ -5820,7 +5820,7 @@ static const unsigned char script_code_list[] =
"Yiii" // Yi
;
static const unsigned char territory_code_list[] =
static constexpr unsigned char territory_code_list[] =
"ZZ\0" // AnyTerritory
"AF\0" // Afghanistan
"AX\0" // Aland Islands

View File

@ -99,7 +99,7 @@ struct QUtcData
*/
// Windows ID Key, Territory Enum, IANA ID Index
static const QZoneData zoneDataTable[] = {
static constexpr QZoneData zoneDataTable[] = {
{ 1, 1, 0 }, // Afghanistan Standard Time / Afghanistan
{ 2, 248, 11 }, // Alaskan Standard Time / United States
{ 3, 248, 106 }, // Aleutian Standard Time / United States
@ -470,7 +470,7 @@ static const QZoneData zoneDataTable[] = {
};
// Windows ID Key, Windows ID Index, IANA ID Index, UTC Offset
static const QWindowsData windowsDataTable[] = {
static constexpr QWindowsData windowsDataTable[] = {
{ 1, 0, 0, 16200 }, // Afghanistan Standard Time
{ 2, 26, 7303,-32400 }, // Alaskan Standard Time
{ 3, 48, 106,-36000 }, // Aleutian Standard Time
@ -613,7 +613,7 @@ static const QWindowsData windowsDataTable[] = {
};
// IANA ID Index, UTC Offset
static const QUtcData utcDataTable[] = {
static constexpr QUtcData utcDataTable[] = {
{ 7784, 0 }, // UTC
{ 7788,-50400 }, // UTC-14:00
{ 7798,-46800 }, // UTC-13:00
@ -656,7 +656,7 @@ static const QUtcData utcDataTable[] = {
{ 8168, 50400 }, // UTC+14:00
};
static const char windowsIdData[] = {
static constexpr char windowsIdData[] = {
0x41, 0x66, 0x67, 0x68, 0x61, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x20, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64,
0x20, 0x54, 0x69, 0x6d, 0x65, 0x0, 0x41, 0x6c, 0x61, 0x73, 0x6b, 0x61, 0x6e, 0x20, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61,
0x72, 0x64, 0x20, 0x54, 0x69, 0x6d, 0x65, 0x0, 0x41, 0x6c, 0x65, 0x75, 0x74, 0x69, 0x61, 0x6e, 0x20, 0x53, 0x74, 0x61,
@ -820,7 +820,7 @@ static const char windowsIdData[] = {
0x75, 0x6b, 0x6f, 0x6e, 0x20, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x20, 0x54, 0x69, 0x6d, 0x65, 0x0
};
static const char ianaIdData[] = {
static constexpr char ianaIdData[] = {
0x41, 0x73, 0x69, 0x61, 0x2f, 0x4b, 0x61, 0x62, 0x75, 0x6c, 0x0, 0x41, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x61, 0x2f, 0x41,
0x6e, 0x63, 0x68, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x20, 0x41, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x61, 0x2f, 0x4a, 0x75, 0x6e,
0x65, 0x61, 0x75, 0x20, 0x41, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x61, 0x2f, 0x4d, 0x65, 0x74, 0x6c, 0x61, 0x6b, 0x61, 0x74,

View File

@ -238,7 +238,7 @@ class ByteArrayData:
return index
def write(self, out, name):
out(f'\nstatic const char {name}[] = {{\n')
out(f'\nstatic constexpr char {name}[] = {{\n')
out(wrap_list(self.data))
out('\n};\n')
@ -269,7 +269,7 @@ class ZoneIdWriter (SourceFileEditor):
# Write Windows/IANA table
out('// Windows ID Key, Territory Enum, IANA ID Index\n')
out('static const QZoneData zoneDataTable[] = {\n')
out('static constexpr QZoneData zoneDataTable[] = {\n')
for index, data in sorted(windowsIds.items()):
out(' {{ {:6d},{:6d},{:6d} }}, // {} / {}\n'.format(
data['windowsKey'], data['territoryId'],
@ -279,7 +279,7 @@ class ZoneIdWriter (SourceFileEditor):
# Write Windows ID key table
out('// Windows ID Key, Windows ID Index, IANA ID Index, UTC Offset\n')
out('static const QWindowsData windowsDataTable[] = {\n')
out('static constexpr QWindowsData windowsDataTable[] = {\n')
for index, pair in enumerate(windowsIdList, 1):
out(' {{ {:6d},{:6d},{:6d},{:6d} }}, // {}\n'.format(
index,
@ -290,7 +290,7 @@ class ZoneIdWriter (SourceFileEditor):
# Write UTC ID key table
out('// IANA ID Index, UTC Offset\n')
out('static const QUtcData utcDataTable[] = {\n')
out('static constexpr QUtcData utcDataTable[] = {\n')
for pair in utcIdList:
out(' {{ {:6d},{:6d} }}, // {}\n'.format(
ianaIdData.append(pair[0]), pair[1], pair[0]))

View File

@ -105,7 +105,7 @@ class StringData:
if len(self.data) > 0xffff:
raise ValueError(f'Data is too big ({len(self.data)}) for quint16 index to its end!',
self.name)
fd.write(f"\nstatic const char16_t {self.name}[] = {{\n")
fd.write(f"\nstatic constexpr char16_t {self.name}[] = {{\n")
fd.write(wrap_list(self.data))
fd.write("\n};\n")
@ -150,7 +150,7 @@ class LocaleDataWriter (LocaleSourceEditor):
likely = sorted(likely, key=keyLikely)
i = 0
self.writer.write('static const QLocaleId likely_subtags[] = {\n')
self.writer.write('static constexpr QLocaleId likely_subtags[] = {\n')
for had, have, got, give in likely:
i += 1
self.writer.write(' {{ {:3d}, {:3d}, {:3d} }}'.format(*have))
@ -160,7 +160,7 @@ class LocaleDataWriter (LocaleSourceEditor):
self.writer.write('};\n\n')
def localeIndex(self, indices):
self.writer.write('static const quint16 locale_index[] = {\n')
self.writer.write('static constexpr quint16 locale_index[] = {\n')
for index, name in indices:
self.writer.write(f'{index:6d}, // {name}\n')
self.writer.write(' 0 // trailing 0\n')
@ -181,7 +181,7 @@ class LocaleDataWriter (LocaleSourceEditor):
endonyms_data = StringData('endonyms_data')
# Locale data
self.writer.write('static const QLocaleData locale_data[] = {\n')
self.writer.write('static constexpr QLocaleData locale_data[] = {\n')
# Table headings: keep each label centred in its field, matching line_format:
self.writer.write(' // '
# Width 6 + comma
@ -331,7 +331,7 @@ class LocaleDataWriter (LocaleSourceEditor):
@staticmethod
def __writeNameData(out, book, form):
out(f'static const char {form}_name_list[] =\n')
out(f'static constexpr char {form}_name_list[] =\n')
out('"Default\\0"\n')
for key, value in book.items():
if key == 0:
@ -339,7 +339,7 @@ class LocaleDataWriter (LocaleSourceEditor):
out(f'"{value[0]}\\0"\n')
out(';\n\n')
out(f'static const quint16 {form}_name_index[] = {{\n')
out(f'static constexpr quint16 {form}_name_index[] = {{\n')
out(f' 0, // Any{form.capitalize()}\n')
index = 8
for key, value in book.items():
@ -352,7 +352,7 @@ class LocaleDataWriter (LocaleSourceEditor):
@staticmethod
def __writeCodeList(out, book, form, width):
out(f'static const unsigned char {form}_code_list[] =\n')
out(f'static constexpr unsigned char {form}_code_list[] =\n')
for key, value in book.items():
code = value[1]
code += r'\0' * max(width - len(code), 0)
@ -422,7 +422,7 @@ class CalendarDataWriter (LocaleSourceEditor):
def write(self, calendar, locales, names):
months_data = StringData('months_data')
self.writer.write('static const QCalendarLocale locale_data[] = {\n')
self.writer.write('static constexpr QCalendarLocale locale_data[] = {\n')
self.writer.write(
' //'
# IDs, width 7 (6 + comma)