summaryrefslogtreecommitdiffstats
path: root/util/unicode/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'util/unicode/main.cpp')
-rw-r--r--util/unicode/main.cpp146
1 files changed, 60 insertions, 86 deletions
diff --git a/util/unicode/main.cpp b/util/unicode/main.cpp
index 22a4405ca9..26cdab87d6 100644
--- a/util/unicode/main.cpp
+++ b/util/unicode/main.cpp
@@ -789,6 +789,15 @@ static void initScriptMap()
// Keep this one in sync with the code in createPropertyInfo
static const char *property_string =
+ "enum Case {\n"
+ " LowerCase,\n"
+ " UpperCase,\n"
+ " TitleCase,\n"
+ " CaseFold,\n"
+ "\n"
+ " NumCases\n"
+ "};\n"
+ "\n"
"struct Properties {\n"
" ushort category : 8; /* 5 used */\n"
" ushort direction : 8; /* 5 used */\n"
@@ -796,84 +805,51 @@ static const char *property_string =
" ushort joining : 3;\n"
" signed short digitValue : 5;\n"
" signed short mirrorDiff : 16;\n"
- " ushort lowerCaseSpecial : 1;\n"
- " signed short lowerCaseDiff : 15;\n"
+ " ushort unicodeVersion : 8; /* 5 used */\n"
+ " ushort nfQuickCheck : 8;\n" // could be narrowed
"#ifdef Q_OS_WASM\n"
" unsigned char : 0; //wasm 64 packing trick\n"
"#endif\n"
- " ushort upperCaseSpecial : 1;\n"
- " signed short upperCaseDiff : 15;\n"
- " ushort titleCaseSpecial : 1;\n"
- " signed short titleCaseDiff : 15;\n"
- " ushort caseFoldSpecial : 1;\n"
- " signed short caseFoldDiff : 15;\n"
- " ushort unicodeVersion : 8; /* 5 used */\n"
- " ushort nfQuickCheck : 8;\n" // could be narrowed
+ " struct {\n"
+ " ushort special : 1;\n"
+ " signed short diff : 15;\n"
+ " } cases[NumCases];\n"
"#ifdef Q_OS_WASM\n"
" unsigned char : 0; //wasm 64 packing trick\n"
"#endif\n"
" ushort graphemeBreakClass : 5; /* 5 used */\n"
" ushort wordBreakClass : 5; /* 5 used */\n"
- " ushort sentenceBreakClass : 8; /* 4 used */\n"
" ushort lineBreakClass : 6; /* 6 used */\n"
+ " ushort sentenceBreakClass : 8; /* 4 used */\n"
" ushort script : 8;\n"
"};\n\n"
- "Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) Q_DECL_NOTHROW;\n"
- "Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) Q_DECL_NOTHROW;\n"
- "\n"
- "struct LowercaseTraits\n"
- "{\n"
- " static inline signed short caseDiff(const Properties *prop)\n"
- " { return prop->lowerCaseDiff; }\n"
- " static inline bool caseSpecial(const Properties *prop)\n"
- " { return prop->lowerCaseSpecial; }\n"
- "};\n"
- "\n"
- "struct UppercaseTraits\n"
- "{\n"
- " static inline signed short caseDiff(const Properties *prop)\n"
- " { return prop->upperCaseDiff; }\n"
- " static inline bool caseSpecial(const Properties *prop)\n"
- " { return prop->upperCaseSpecial; }\n"
- "};\n"
- "\n"
- "struct TitlecaseTraits\n"
- "{\n"
- " static inline signed short caseDiff(const Properties *prop)\n"
- " { return prop->titleCaseDiff; }\n"
- " static inline bool caseSpecial(const Properties *prop)\n"
- " { return prop->titleCaseSpecial; }\n"
- "};\n"
- "\n"
- "struct CasefoldTraits\n"
- "{\n"
- " static inline signed short caseDiff(const Properties *prop)\n"
- " { return prop->caseFoldDiff; }\n"
- " static inline bool caseSpecial(const Properties *prop)\n"
- " { return prop->caseFoldSpecial; }\n"
- "};\n"
+ "Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) noexcept;\n"
+ "Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) noexcept;\n"
"\n";
static const char *methods =
- "Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) Q_DECL_NOTHROW;\n"
- "inline GraphemeBreakClass graphemeBreakClass(QChar ch) Q_DECL_NOTHROW\n"
+ "Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) noexcept;\n"
+ "inline GraphemeBreakClass graphemeBreakClass(QChar ch) noexcept\n"
"{ return graphemeBreakClass(ch.unicode()); }\n"
"\n"
- "Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) Q_DECL_NOTHROW;\n"
- "inline WordBreakClass wordBreakClass(QChar ch) Q_DECL_NOTHROW\n"
+ "Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) noexcept;\n"
+ "inline WordBreakClass wordBreakClass(QChar ch) noexcept\n"
"{ return wordBreakClass(ch.unicode()); }\n"
"\n"
- "Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) Q_DECL_NOTHROW;\n"
- "inline SentenceBreakClass sentenceBreakClass(QChar ch) Q_DECL_NOTHROW\n"
+ "Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) noexcept;\n"
+ "inline SentenceBreakClass sentenceBreakClass(QChar ch) noexcept\n"
"{ return sentenceBreakClass(ch.unicode()); }\n"
"\n"
- "Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) Q_DECL_NOTHROW;\n"
- "inline LineBreakClass lineBreakClass(QChar ch) Q_DECL_NOTHROW\n"
+ "Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) noexcept;\n"
+ "inline LineBreakClass lineBreakClass(QChar ch) noexcept\n"
"{ return lineBreakClass(ch.unicode()); }\n"
"\n";
static const int SizeOfPropertiesStruct = 20;
+static const QByteArray sizeOfPropertiesStructCheck =
+ "Q_STATIC_ASSERT(sizeof(Properties) == " + QByteArray::number(SizeOfPropertiesStruct) + ");\n\n";
+
struct PropertyFlags {
bool operator==(const PropertyFlags &o) const {
return (combiningClass == o.combiningClass
@@ -2470,48 +2446,45 @@ static QByteArray createPropertyInfo()
// " signed short mirrorDiff : 16;\n"
out += QByteArray::number( p.mirrorDiff );
out += ", ";
-// " ushort lowerCaseSpecial : 1;\n"
-// " signed short lowerCaseDiff : 15;\n"
+// " ushort unicodeVersion : 8; /* 5 used */\n"
+ out += QByteArray::number( p.age );
+ out += ", ";
+// " ushort nfQuickCheck : 8;\n"
+ out += QByteArray::number( p.nfQuickCheck );
+ out += ", ";
+// " struct {\n"
+// " ushort special : 1;\n"
+// " signed short diff : 15;\n"
+// " } cases[NumCases];\n"
+ out += " { {";
out += QByteArray::number( p.lowerCaseSpecial );
out += ", ";
out += QByteArray::number( p.lowerCaseDiff );
- out += ", ";
-// " ushort upperCaseSpecial : 1;\n"
-// " signed short upperCaseDiff : 15;\n"
+ out += "}, {";
out += QByteArray::number( p.upperCaseSpecial );
out += ", ";
out += QByteArray::number( p.upperCaseDiff );
- out += ", ";
-// " ushort titleCaseSpecial : 1;\n"
-// " signed short titleCaseDiff : 15;\n"
+ out += "}, {";
out += QByteArray::number( p.titleCaseSpecial );
out += ", ";
out += QByteArray::number( p.titleCaseDiff );
- out += ", ";
-// " ushort caseFoldSpecial : 1;\n"
-// " signed short caseFoldDiff : 15;\n"
+ out += "}, {";
out += QByteArray::number( p.caseFoldSpecial );
out += ", ";
out += QByteArray::number( p.caseFoldDiff );
- out += ", ";
-// " ushort unicodeVersion : 8; /* 5 used */\n"
- out += QByteArray::number( p.age );
- out += ", ";
-// " ushort nfQuickCheck : 8;\n"
- out += QByteArray::number( p.nfQuickCheck );
- out += ", ";
+ out += "} }, ";
// " ushort graphemeBreakClass : 5; /* 5 used */\n"
// " ushort wordBreakClass : 5; /* 5 used */\n"
-// " ushort sentenceBreakClass : 8; /* 4 used */\n"
// " ushort lineBreakClass : 6; /* 6 used */\n"
out += QByteArray::number( p.graphemeBreakClass );
out += ", ";
out += QByteArray::number( p.wordBreakClass );
out += ", ";
- out += QByteArray::number( p.sentenceBreakClass );
- out += ", ";
out += QByteArray::number( p.lineBreakClass );
out += ", ";
+// " ushort sentenceBreakClass : 8; /* 4 used */\n"
+ out += QByteArray::number( p.sentenceBreakClass );
+ out += ", ";
// " ushort script : 8;\n"
out += QByteArray::number( p.script );
out += " },";
@@ -2521,42 +2494,42 @@ static QByteArray createPropertyInfo()
out += "\n};\n\n";
- out += "Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(uint ucs4) Q_DECL_NOTHROW\n"
+ out += "Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(uint ucs4) noexcept\n"
"{\n"
" return uc_properties + GET_PROP_INDEX(ucs4);\n"
"}\n"
"\n"
- "Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(ushort ucs2) Q_DECL_NOTHROW\n"
+ "Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(ushort ucs2) noexcept\n"
"{\n"
" return uc_properties + GET_PROP_INDEX_UCS2(ucs2);\n"
"}\n"
"\n"
- "Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) Q_DECL_NOTHROW\n"
+ "Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) noexcept\n"
"{\n"
" return qGetProp(ucs4);\n"
"}\n"
"\n"
- "Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) Q_DECL_NOTHROW\n"
+ "Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) noexcept\n"
"{\n"
" return qGetProp(ucs2);\n"
"}\n\n";
- out += "Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) Q_DECL_NOTHROW\n"
+ out += "Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) noexcept\n"
"{\n"
" return static_cast<GraphemeBreakClass>(qGetProp(ucs4)->graphemeBreakClass);\n"
"}\n"
"\n"
- "Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) Q_DECL_NOTHROW\n"
+ "Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) noexcept\n"
"{\n"
" return static_cast<WordBreakClass>(qGetProp(ucs4)->wordBreakClass);\n"
"}\n"
"\n"
- "Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) Q_DECL_NOTHROW\n"
+ "Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) noexcept\n"
"{\n"
" return static_cast<SentenceBreakClass>(qGetProp(ucs4)->sentenceBreakClass);\n"
"}\n"
"\n"
- "Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) Q_DECL_NOTHROW\n"
+ "Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) noexcept\n"
"{\n"
" return static_cast<LineBreakClass>(qGetProp(ucs4)->lineBreakClass);\n"
"}\n"
@@ -2832,7 +2805,7 @@ static QByteArray createLigatureInfo()
QList<Ligature> l = ligatureHashes.value(uc);
if (!l.isEmpty()) {
Q_ASSERT(!QChar::requiresSurrogates(uc));
- qSort(l); // needed for bsearch in ligatureHelper code
+ std::sort(l.begin(), l.end()); // needed for bsearch in ligatureHelper code
ligatures.append(l.size());
for (int j = 0; j < l.size(); ++j) {
@@ -2864,7 +2837,7 @@ static QByteArray createLigatureInfo()
QList<Ligature> l = ligatureHashes.value(uc);
if (!l.isEmpty()) {
Q_ASSERT(QChar::requiresSurrogates(uc));
- qSort(l); // needed for bsearch in ligatureHelper code
+ std::sort(l.begin(), l.end()); // needed for bsearch in ligatureHelper code
ligatures.append(l.size());
for (int j = 0; j < l.size(); ++j) {
@@ -3096,7 +3069,7 @@ int main(int, char **)
"// We mean it.\n"
"//\n\n";
- QFile f("../../src/corelib/tools/qunicodetables.cpp");
+ QFile f("../../src/corelib/text/qunicodetables.cpp");
f.open(QFile::WriteOnly|QFile::Truncate);
f.write(header);
f.write(note);
@@ -3116,7 +3089,7 @@ int main(int, char **)
f.write("QT_END_NAMESPACE\n");
f.close();
- f.setFileName("../../src/corelib/tools/qunicodetables_p.h");
+ f.setFileName("../../src/corelib/text/qunicodetables_p.h");
f.open(QFile::WriteOnly | QFile::Truncate);
f.write(header);
f.write(note);
@@ -3129,6 +3102,7 @@ int main(int, char **)
f.write("#define UNICODE_DATA_VERSION " DATA_VERSION_STR "\n\n");
f.write("namespace QUnicodeTables {\n\n");
f.write(property_string);
+ f.write(sizeOfPropertiesStructCheck);
f.write(grapheme_break_class_string);
f.write(word_break_class_string);
f.write(sentence_break_class_string);