summaryrefslogtreecommitdiffstats
path: root/src/tools/moc/generator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/moc/generator.cpp')
-rw-r--r--src/tools/moc/generator.cpp54
1 files changed, 24 insertions, 30 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index 8d4fb2efc6..93bc4d8c4e 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -194,7 +194,6 @@ static bool qualifiedNameEquals(const QByteArray &qualifiedName, const QByteArra
void Generator::generateCode()
{
- bool isQt = (cdef->classname == "Qt");
bool isQObject = (cdef->classname == "QObject");
bool isConstructible = !cdef->constructorList.isEmpty();
@@ -237,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;
@@ -260,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",
@@ -274,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;
@@ -452,7 +448,7 @@ void Generator::generateCode()
//
// Generate internal qt_static_metacall() function
//
- const bool hasStaticMetaCall = !isQt &&
+ const bool hasStaticMetaCall =
(cdef->hasQObject || !cdef->methodList.isEmpty()
|| !cdef->propertyList.isEmpty() || !cdef->constructorList.isEmpty());
if (hasStaticMetaCall)
@@ -480,7 +476,7 @@ void Generator::generateCode()
QByteArray unqualifiedScope = p.type.left(s);
// The scope may be a namespace for example, so it's only safe to include scopes that are known QObjects (QTBUG-2151)
- QHash<QByteArray, QByteArray>::ConstIterator scopeIt;
+ QMultiHash<QByteArray, QByteArray>::ConstIterator scopeIt;
QByteArray thisScope = cdef->qualified;
do {
@@ -534,10 +530,7 @@ void Generator::generateCode()
//
// Finally create and initialize the static meta object
//
- if (isQt)
- fprintf(out, "QT_INIT_METAOBJECT const QMetaObject QObject::staticQtMetaObject = { {\n");
- else
- fprintf(out, "QT_INIT_METAOBJECT const QMetaObject %s::staticMetaObject = { {\n", cdef->qualified.constData());
+ fprintf(out, "QT_INIT_METAOBJECT const QMetaObject %s::staticMetaObject = { {\n", cdef->qualified.constData());
if (isQObject)
fprintf(out, " nullptr,\n");
@@ -547,7 +540,7 @@ void Generator::generateCode()
fprintf(out, " QtPrivate::MetaObjectForType<%s>::value(),\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)
@@ -561,9 +554,6 @@ void Generator::generateCode()
fprintf(out, " qt_meta_extradata_%s,\n", qualifiedClassNameIdentifier.constData());
fprintf(out, " nullptr\n} };\n\n");
- if(isQt)
- return;
-
if (!cdef->hasQObject)
return;
@@ -1221,18 +1211,22 @@ void Generator::generateStaticMetacall()
fprintf(out, "%s(", f.name.constData());
int offset = 1;
- int argsCount = f.arguments.count();
- for (int j = 0; j < argsCount; ++j) {
- const ArgumentDef &a = f.arguments.at(j);
- if (j)
- fprintf(out, ",");
- fprintf(out, "(*reinterpret_cast< %s>(_a[%d]))",a.typeNameForCast.constData(), offset++);
- isUsed_a = true;
- }
- if (f.isPrivateSignal) {
- if (argsCount > 0)
- fprintf(out, ", ");
- fprintf(out, "%s", "QPrivateSignal()");
+ if (f.isRawSlot) {
+ fprintf(out, "QMethodRawArguments{ _a }");
+ } else {
+ int argsCount = f.arguments.count();
+ for (int j = 0; j < argsCount; ++j) {
+ const ArgumentDef &a = f.arguments.at(j);
+ if (j)
+ fprintf(out, ",");
+ fprintf(out, "(*reinterpret_cast< %s>(_a[%d]))",a.typeNameForCast.constData(), offset++);
+ isUsed_a = true;
+ }
+ if (f.isPrivateSignal) {
+ if (argsCount > 0)
+ fprintf(out, ", ");
+ fprintf(out, "%s", "QPrivateSignal()");
+ }
}
fprintf(out, ");");
if (f.normalizedType != "void") {