From 90657f9236889524a9d27a136e49d12feb46d2a3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 13 Jul 2012 10:55:38 +0200 Subject: Simplify the moc code related to private signals a bit. Change-Id: I0e9bae82c7c6d313e4161c35d0b988f633d5ae60 Reviewed-by: Olivier Goffart --- src/tools/moc/generator.cpp | 27 ++++++++++++++++++--------- src/tools/moc/moc.cpp | 4 +++- 2 files changed, 21 insertions(+), 10 deletions(-) (limited to 'src/tools/moc') diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 09a4603753..39bd528008 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -540,7 +540,7 @@ void Generator::registerFunctionStrings(const QList& list) strreg(f.normalizedType); strreg(f.tag); - int argsCount = f.arguments.count() - (f.isPrivateSignal ? 1 : 0); + int argsCount = f.arguments.count(); for (int j = 0; j < argsCount; ++j) { const ArgumentDef &a = f.arguments.at(j); if (!isBuiltinType(a.normalizedType)) @@ -581,7 +581,7 @@ void Generator::generateFunctions(const QList& list, const char *fu if (f.revision > 0) flags |= MethodRevisioned; - int argc = f.arguments.count() - (f.isPrivateSignal ? 1 : 0); + int argc = f.arguments.count(); fprintf(out, " %4d, %4d, %4d, %4d, 0x%02x,\n", stridx(f.name), argc, paramsIndex, stridx(f.tag), flags); @@ -609,7 +609,7 @@ void Generator::generateFunctionParameters(const QList& list, const fprintf(out, " "); // Types - int argsCount = f.arguments.count() - (f.isPrivateSignal ? 1 : 0); + int argsCount = f.arguments.count(); for (int j = -1; j < argsCount; ++j) { if (j > -1) fputc(' ', out); @@ -1059,7 +1059,7 @@ void Generator::generateStaticMetacall() const FunctionDef &f = cdef->constructorList.at(ctorindex); int offset = 1; - int argsCount = f.arguments.count() - (f.isPrivateSignal ? 1 : 0); + int argsCount = f.arguments.count(); for (int j = 0; j < argsCount; ++j) { const ArgumentDef &a = f.arguments.at(j); if (j) @@ -1069,7 +1069,7 @@ void Generator::generateStaticMetacall() if (f.isPrivateSignal) { if (argsCount > 0) fprintf(out, ", "); - fprintf(out, "%s", QByteArray(f.arguments.last().normalizedType + "()").constData()); + fprintf(out, "%s", QByteArray("QPrivateSignal()").constData()); } fprintf(out, ");\n"); fprintf(out, " if (_a[0]) *reinterpret_cast(_a[0]) = _r; } break;\n"); @@ -1108,7 +1108,7 @@ void Generator::generateStaticMetacall() fprintf(out, "%s(", f.name.constData()); int offset = 1; - int argsCount = f.arguments.count() - (f.isPrivateSignal ? 1 : 0); + int argsCount = f.arguments.count(); for (int j = 0; j < argsCount; ++j) { const ArgumentDef &a = f.arguments.at(j); if (j) @@ -1119,7 +1119,7 @@ void Generator::generateStaticMetacall() if (f.isPrivateSignal) { if (argsCount > 0) fprintf(out, ", "); - fprintf(out, "%s", QByteArray(f.arguments.last().normalizedType + "()").constData()); + fprintf(out, "%s", "QPrivateSignal()"); } fprintf(out, ");"); if (f.normalizedType != "void") { @@ -1148,7 +1148,7 @@ void Generator::generateStaticMetacall() fprintf(out, " {\n"); fprintf(out, " typedef %s (%s::*_t)(",f.type.rawName.constData() , cdef->classname.constData()); - int argsCount = f.arguments.count() - (f.isPrivateSignal ? 1 : 0); + int argsCount = f.arguments.count(); for (int j = 0; j < argsCount; ++j) { const ArgumentDef &a = f.arguments.at(j); if (j) @@ -1158,7 +1158,7 @@ void Generator::generateStaticMetacall() if (f.isPrivateSignal) { if (argsCount > 0) fprintf(out, ", "); - fprintf(out, "%s", f.arguments.last().normalizedType.constData()); + fprintf(out, "%s", "QPrivateSignal"); } if (f.isConst) fprintf(out, ") const;\n"); @@ -1210,6 +1210,9 @@ void Generator::generateSignal(FunctionDef *def,int index) Q_ASSERT(!def->normalizedType.isEmpty()); if (def->arguments.isEmpty() && def->normalizedType == "void") { + if (def->isPrivateSignal) + fprintf(out, "QPrivateSignal"); + fprintf(out, ")%s\n{\n" " QMetaObject::activate(%s, &staticMetaObject, %d, 0);\n" "}\n", constQualifier, thisPtr.constData(), index); @@ -1223,6 +1226,12 @@ void Generator::generateSignal(FunctionDef *def,int index) fprintf(out, ", "); fprintf(out, "%s _t%d%s", a.type.name.constData(), offset++, a.rightType.constData()); } + if (def->isPrivateSignal) { + if (!def->arguments.isEmpty()) + fprintf(out, ", "); + fprintf(out, "QPrivateSignal"); + } + fprintf(out, ")%s\n{\n", constQualifier); if (def->type.name.size() && def->normalizedType != "void") { QByteArray returnType = noRef(def->normalizedType); diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 0caa124e79..e76f2c1776 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -311,8 +311,10 @@ void Moc::parseFunctionArguments(FunctionDef *def) } if (!def->arguments.isEmpty() - && def->arguments.last().normalizedType == "QPrivateSignal") + && def->arguments.last().normalizedType == "QPrivateSignal") { + def->arguments.removeLast(); def->isPrivateSignal = true; + } } bool Moc::testFunctionAttribute(FunctionDef *def) -- cgit v1.2.3