diff options
author | Lars Knoll <lars.knoll@qt.io> | 2019-11-11 15:00:51 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2019-12-08 18:19:58 +0100 |
commit | e58b44d557b859b7b55869f1e137aa1bc8968307 (patch) | |
tree | 5891735d0be64f341e760514b5b576b0d2fd92be /src/tools/moc/generator.cpp | |
parent | 746ab4bbd6ebf2147ce93390738c8a71d6a4a335 (diff) |
Change representation of string data in the meta object
Don't store our string data as QByteArrayLiterals anymore, but revert
back to simply storing them as an array of char* and offsets into that
array.
This is required to be able to inline size and begin into QByteArray
itself. Once that change is done, we can then avoid creating copies of
the string data again.
Change-Id: I362a54581caefdb1b3da4a7ab922d37e2e63dc02
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/tools/moc/generator.cpp')
-rw-r--r-- | src/tools/moc/generator.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index a9bf934e79..7c35af8709 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -236,7 +236,7 @@ void Generator::generateCode() // const int constCharArraySizeLimit = 65535; fprintf(out, "struct qt_meta_stringdata_%s_t {\n", qualifiedClassNameIdentifier.constData()); - fprintf(out, " QByteArrayData data[%d];\n", strings.size()); + fprintf(out, " const uint offsetsAndSize[%d];\n", strings.size()*2); { int stringDataLength = 0; int stringDataCounter = 0; @@ -259,11 +259,8 @@ void Generator::generateCode() // stringdata.stringdata member, and 2) the stringdata.data index of the // QByteArrayData being defined. This calculation relies on the // QByteArrayData::data() implementation returning simply "this + offset". - fprintf(out, "#define QT_MOC_LITERAL(idx, ofs, len) \\\n" - " Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \\\n" - " qptrdiff(offsetof(qt_meta_stringdata_%s_t, stringdata0) + ofs \\\n" - " - idx * sizeof(QByteArrayData)) \\\n" - " )\n", + fprintf(out, "#define QT_MOC_LITERAL(ofs, len) \\\n" + " uint(offsetof(qt_meta_stringdata_%s_t, stringdata0) + ofs), len \n", qualifiedClassNameIdentifier.constData()); fprintf(out, "static const qt_meta_stringdata_%s_t qt_meta_stringdata_%s = {\n", @@ -273,7 +270,7 @@ void Generator::generateCode() int idx = 0; for (int i = 0; i < strings.size(); ++i) { const QByteArray &str = strings.at(i); - fprintf(out, "QT_MOC_LITERAL(%d, %d, %d)", i, idx, str.length()); + fprintf(out, "QT_MOC_LITERAL(%d, %d)", idx, str.length()); if (i != strings.size() - 1) fputc(',', out); const QByteArray comment = str.length() > 32 ? str.left(29) + "..." : str; @@ -541,7 +538,7 @@ void Generator::generateCode() fprintf(out, " QMetaObject::SuperData::link<%s::staticMetaObject>(),\n", purestSuperClass.constData()); else fprintf(out, " nullptr,\n"); - fprintf(out, " qt_meta_stringdata_%s.data,\n" + fprintf(out, " qt_meta_stringdata_%s.offsetsAndSize,\n" " qt_meta_data_%s,\n", qualifiedClassNameIdentifier.constData(), qualifiedClassNameIdentifier.constData()); if (hasStaticMetaCall) |