summaryrefslogtreecommitdiffstats
path: root/src/tools/moc
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-05-23 23:33:54 +0300
committerThiago Macieira <thiago.macieira@intel.com>2023-06-05 15:23:01 -0700
commit58329bbd2be6a4e7f1bf87b3c9fbaea73c8c6a66 (patch)
tree03a623d591c997df091ac78496b591ac4ff31d1d /src/tools/moc
parent4b4d384f3e8e7e762faf033ad2585e45a5a70514 (diff)
Moc: remove STRINGDATA fallback code
If QT_MOC_HAS_STRINGDATA isn't defined, just put an '#error' directive in the generated code. Since the proposal of doing ±4 versions of tool compatibility hasn't been adopted, just remove the fallback string code. Requested by Thiago in code review. Drive-by changes: - Use "STRINGDATA" in comments too - Remove a now unused static helper Change-Id: I6dbdf427b7219b8b32076a9e0a41799c0a476ff9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/tools/moc')
-rw-r--r--src/tools/moc/generator.cpp69
-rw-r--r--src/tools/moc/moc.cpp11
2 files changed, 3 insertions, 77 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index d15b6de490..25b2a4c62b 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -93,19 +93,6 @@ static inline int lengthOfEscapeSequence(const QByteArray &s, int i)
return i - startPos;
}
-static inline uint lengthOfEscapedString(const QByteArray &str)
-{
- int extra = 0;
- for (int j = 0; j < str.size(); ++j) {
- if (str.at(j) == '\\') {
- int cnt = lengthOfEscapeSequence(str, j) - 1;
- extra += cnt;
- j += cnt;
- }
- }
- return str.size() - extra;
-}
-
// Prints \a s to \a out, breaking it into lines of at most ColumnWidth. The
// opening and closing quotes are NOT included (it's up to the caller).
static void printStringWithIndentation(FILE *out, const QByteArray &s)
@@ -288,61 +275,9 @@ void Generator::generateCode()
}
}
fprintf(out, "\n);\n"
- "#else // !QT_MOC_HAS_STRING_DATA\n");
-
-#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)
+ "#else // !QT_MOC_HAS_STRINGDATA\n");
fprintf(out, "#error \"qtmochelpers.h not found or too old.\"\n");
-#else
-//
-// Build stringdata struct
-//
-
- fprintf(out, "struct qt_meta_stringdata_%s_t {\n", qualifiedClassNameIdentifier.constData());
- fprintf(out, " uint offsetsAndSizes[%d];\n", int(strings.size() * 2));
- for (int i = 0; i < strings.size(); ++i) {
- int thisLength = lengthOfEscapedString(strings.at(i)) + 1;
- fprintf(out, " char stringdata%d[%d];\n", i, thisLength);
- }
- fprintf(out, "};\n");
-
- // Macro that simplifies the string data listing. The offset is calculated
- // from the top of the stringdata object (i.e., past the uints).
- fprintf(out, "#define QT_MOC_LITERAL(ofs, len) \\\n"
- " uint(sizeof(qt_meta_stringdata_%s_t::offsetsAndSizes) + ofs), len \n",
- qualifiedClassNameIdentifier.constData());
-
- fprintf(out, "Q_CONSTINIT static const qt_meta_stringdata_%s_t qt_meta_stringdata_%s = {\n",
- qualifiedClassNameIdentifier.constData(), qualifiedClassNameIdentifier.constData());
- fprintf(out, " {");
- {
- int idx = 0;
- for (int i = 0; i < strings.size(); ++i) {
- const QByteArray &str = strings.at(i);
- const QByteArray comment = str.size() > 32 ? str.left(29) + "..." : str;
- const char *comma = (i != strings.size() - 1 ? "," : " ");
- int len = lengthOfEscapedString(str);
- fprintf(out, "\n QT_MOC_LITERAL(%d, %d)%s // \"%s\"", idx, len, comma,
- comment.constData());
-
- idx += len + 1;
- }
- fprintf(out, "\n }");
- }
-
-//
-// Build stringdata arrays
-//
- for (const QByteArray &s : std::as_const(strings)) {
- fputc(',', out);
- printStringWithIndentation(out, s);
- }
-
-// Terminate stringdata struct
- fprintf(out, "\n};\n");
- fprintf(out, "#undef QT_MOC_LITERAL\n");
-#endif // Qt 6.9
-
- fprintf(out, "#endif // !QT_MOC_HAS_STRING_DATA\n");
+ fprintf(out, "#endif // !QT_MOC_HAS_STRINGDATA\n");
fprintf(out, "} // unnamed namespace\n\n");
//
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index d4973b87ac..4a9e3463ac 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -1111,16 +1111,7 @@ void Moc::generate(FILE *out, FILE *jsonOutput)
for (const QByteArray &qtContainer : qtContainers)
fprintf(out, "#include <QtCore/%s>\n", qtContainer.constData());
- fprintf(out, "\n%s#include <QtCore/qtmochelpers.h>\n%s\n",
-#if QT_VERSION <= QT_VERSION_CHECK(6, 9, 0)
- "#if __has_include(<QtCore/qtmochelpers.h>)\n",
- "#else\n"
- "QT_BEGIN_MOC_NAMESPACE\n"
- "#endif\n"
-#else
- "", ""
-#endif
- );
+ fprintf(out, "\n#include <QtCore/qtmochelpers.h>\n");
fprintf(out, "\n#include <memory>\n\n"); // For std::addressof