moc: Only generate IndexOfMethod for signals.

moc is currently generating code to convert from a pointer to member
function of a slot or signal to its index.

The idea was that it could be usefull for slots to have the new syntax
do the same as the old one (connecting signal index to slot index). But
in practice, the new syntax do not use the IndexOfMethod for slots.

Also, it does not work for all the slots (no Q_PRIVATE_SLOT,
no static slots)

So since it is not used, and that it would take room in the binaries to
generate all the code to get the index of slots, we remove it.

If ever we need it, we can still add it later.

Change-Id: Ia417e3e524d7915ca86433ea86c66ac2b299c81a
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
This commit is contained in:
Olivier Goffart 2012-02-25 20:48:56 +01:00 committed by Qt by Nokia
parent 457606d12b
commit 0d9714f445
2 changed files with 13 additions and 8 deletions

View File

@ -951,13 +951,17 @@ void Generator::generateStaticMetacall()
}
fprintf(out, " default: ;\n");
fprintf(out, " }\n");
fprintf(out, " } else if (_c == QMetaObject::IndexOfMethod) {\n");
fprintf(out, " }");
needElse = true;
}
if (!cdef->signalList.isEmpty()) {
Q_ASSERT(needElse); // if there is signal, there was method.
fprintf(out, " else if (_c == QMetaObject::IndexOfMethod) {\n");
fprintf(out, " int *result = reinterpret_cast<int *>(_a[0]);\n");
fprintf(out, " void **func = reinterpret_cast<void **>(_a[1]);\n");
bool anythingUsed = false;
for (int methodindex = 0; methodindex < methodList.size(); ++methodindex) {
const FunctionDef &f = methodList.at(methodindex);
for (int methodindex = 0; methodindex < cdef->signalList.size(); ++methodindex) {
const FunctionDef &f = cdef->signalList.at(methodindex);
if (f.wasCloned || !f.inPrivateClass.isEmpty() || f.isStatic)
continue;
anythingUsed = true;

View File

@ -326,6 +326,8 @@ public slots:
signals:
void sig0();
QString sig1(QString s1);
void sig10(QString s1, QString s2, QString s3, QString s4, QString s5, QString s6, QString s7,
QString s8, QString s9, QString s10);
protected:
QtTestObject(QVariant) {}
@ -725,6 +727,7 @@ typedef QString CustomString;
class QtTestCustomObject: public QObject
{
Q_OBJECT
friend class tst_QMetaObject;
public:
QtTestCustomObject(): QObject(), sum(0) {}
@ -1129,11 +1132,9 @@ void tst_QMetaObject::indexOfMethodPMF()
}
INDEXOFMETHODPMF_HELPER(tst_QMetaObject, value7Changed, (const QString&))
INDEXOFMETHODPMF_HELPER(tst_QMetaObject, stdSet, ())
INDEXOFMETHODPMF_HELPER(QtTestObject, sl10, (QString,QString,QString,QString,QString,QString,QString,QString,QString,QString))
INDEXOFMETHODPMF_HELPER(QtTestObject, sig0, ())
INDEXOFMETHODPMF_HELPER(QtTestObject, testLongLong, (qint64, quint64))
INDEXOFMETHODPMF_HELPER(QtTestObject, testReference, (QString&))
INDEXOFMETHODPMF_HELPER(QtTestObject, sig10, (QString,QString,QString,QString,QString,QString,QString,QString,QString,QString))
INDEXOFMETHODPMF_HELPER(QtTestCustomObject, sig_custom, (const CustomString &))
}
QTEST_MAIN(tst_QMetaObject)