Fix signal code generation
The old code is broken because it was passing signal.outputArgs as inputArgs variable of writeArgList, fix can not be passing signal.outputArgs as outputArgs of writeArgList since that ignores the first of the list, so i added a new function that does the right thing Change-Id: If54484e04880d5dcebfedb9d478ee0e9faf37baa Task-number: QTBUG-21577 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
ad1555be7f
commit
c62f717226
|
|
@ -9,12 +9,12 @@
|
|||
|
||||
<signal name="AddAccessible">
|
||||
<arg name="nodeAdded" type="((so)(so)a(so)assusau)"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QSpiAccessibleCacheItem"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QSpiAccessibleCacheItem"/>
|
||||
</signal>
|
||||
|
||||
<signal name="RemoveAccessible">
|
||||
<arg name="nodeRemoved" type="(so)"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QSpiObjectReference"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QSpiObjectReference"/>
|
||||
</signal>
|
||||
|
||||
</interface>
|
||||
|
|
|
|||
|
|
@ -332,7 +332,10 @@ static QString classNameForInterface(const QString &interface, ClassType classTy
|
|||
return retval;
|
||||
}
|
||||
|
||||
static QByteArray qtTypeName(const QString &signature, const QDBusIntrospection::Annotations &annotations, int paramId = -1, const char *direction = "Out")
|
||||
// ### Qt6 Remove the two isSignal ifs
|
||||
// They are only here because before signal arguments where previously searched as "In" so to maintain compatibility
|
||||
// we first search for "Out" and if not found we search for "In"
|
||||
static QByteArray qtTypeName(const QString &signature, const QDBusIntrospection::Annotations &annotations, int paramId = -1, const char *direction = "Out", bool isSignal = false)
|
||||
{
|
||||
int type = QDBusMetaType::signatureToType(signature.toLatin1());
|
||||
if (type == QVariant::Invalid) {
|
||||
|
|
@ -349,9 +352,15 @@ static QByteArray qtTypeName(const QString &signature, const QDBusIntrospection:
|
|||
qttype = annotations.value(oldAnnotationName);
|
||||
|
||||
if (qttype.isEmpty()) {
|
||||
fprintf(stderr, "Got unknown type `%s'\n", qPrintable(signature));
|
||||
fprintf(stderr, "You should add <annotation name=\"%s\" value=\"<type>\"/> to the XML description\n",
|
||||
qPrintable(annotationName));
|
||||
if (!isSignal || qstrcmp(direction, "Out") == 0) {
|
||||
fprintf(stderr, "Got unknown type `%s'\n", qPrintable(signature));
|
||||
fprintf(stderr, "You should add <annotation name=\"%s\" value=\"<type>\"/> to the XML description\n",
|
||||
qPrintable(annotationName));
|
||||
}
|
||||
|
||||
if (isSignal)
|
||||
return qtTypeName(signature, annotations, paramId, "In", isSignal);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -451,6 +460,23 @@ static void writeArgList(QTextStream &ts, const QStringList &argNames,
|
|||
}
|
||||
}
|
||||
|
||||
static void writeSignalArgList(QTextStream &ts, const QStringList &argNames,
|
||||
const QDBusIntrospection::Annotations &annotations,
|
||||
const QDBusIntrospection::Arguments &outputArgs)
|
||||
{
|
||||
bool first = true;
|
||||
int argPos = 0;
|
||||
for (int i = 0; i < outputArgs.count(); ++i) {
|
||||
const QDBusIntrospection::Argument &arg = outputArgs.at(i);
|
||||
QString type = constRefArg(qtTypeName(arg.type, annotations, i, "Out", true /* isSignal */));
|
||||
|
||||
if (!first)
|
||||
ts << ", ";
|
||||
ts << type << argNames.at(argPos++);
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
static QString propertyGetter(const QDBusIntrospection::Property &property)
|
||||
{
|
||||
QString getter = property.annotations.value(QLatin1String("org.qtproject.QtDBus.PropertyGetter"));
|
||||
|
|
@ -765,7 +791,7 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf
|
|||
hs << "void " << signal.name << "(";
|
||||
|
||||
QStringList argNames = makeArgNames(signal.outputArgs);
|
||||
writeArgList(hs, argNames, signal.annotations, signal.outputArgs);
|
||||
writeSignalArgList(hs, argNames, signal.annotations, signal.outputArgs);
|
||||
|
||||
hs << ");" << endl; // finished for header
|
||||
}
|
||||
|
|
@ -1109,7 +1135,7 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte
|
|||
hs << "void " << signal.name << "(";
|
||||
|
||||
QStringList argNames = makeArgNames(signal.outputArgs);
|
||||
writeArgList(hs, argNames, signal.annotations, signal.outputArgs);
|
||||
writeSignalArgList(hs, argNames, signal.annotations, signal.outputArgs);
|
||||
|
||||
hs << ");" << endl; // finished for header
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue