Update com.trolltech -> org.qtproject in the bootstrapped tools
authorThiago Macieira <thiago.macieira@intel.com>
Thu, 29 Mar 2012 14:14:12 +0000 (11:14 -0300)
committerQt by Nokia <qt-info@nokia.com>
Sun, 15 Apr 2012 22:08:13 +0000 (00:08 +0200)
The tools will now generate the new org.qtproject annotations only,
matching the XML generator in the library. They accept both types of
annotations as input though -- and will generate a warning about the
older one.

This commit should be backported to Qt 4, so XML files can start to be
ported.

Task-number: QTBUG-23274
Change-Id: If298c342ab4774cbca1be1898a01af8b46e80446
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
Reviewed-by: Lorn Potter <lorn.potter@nokia.com>
src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp
src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp

index 66a59b5..60fd730 100644 (file)
@@ -129,7 +129,7 @@ static QString addFunction(const FunctionDef &mm, bool isSignal = false) {
 
                     // do we need to describe this argument?
                     if (QDBusMetaType::signatureToType(typeName) == QVariant::Invalid)
-                        xml += QString::fromLatin1("      <annotation name=\"com.trolltech.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n")
+                        xml += QString::fromLatin1("      <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n")
                             .arg(typeNameToXml(mm.normalizedType.constData()));
             } else {
                 return QString();
@@ -171,7 +171,7 @@ static QString addFunction(const FunctionDef &mm, bool isSignal = false) {
         // do we need to describe this argument?
         if (QDBusMetaType::signatureToType(signature) == QVariant::Invalid) {
             const char *typeName = QMetaType::typeName(types.at(j));
-            xml += QString::fromLatin1("      <annotation name=\"com.trolltech.QtDBus.QtTypeName.%1%2\" value=\"%3\"/>\n")
+            xml += QString::fromLatin1("      <annotation name=\"org.qtproject.QtDBus.QtTypeName.%1%2\" value=\"%3\"/>\n")
                     .arg(isOutput ? QLatin1String("Out") : QLatin1String("In"))
                     .arg(isOutput && !isSignal ? j - inputCount : j - 1)
                     .arg(typeNameToXml(typeName));
@@ -233,7 +233,7 @@ static QString generateInterfaceXml(const ClassDef *mo)
                       .arg(QLatin1String(accessvalues[access]));
 
             if (QDBusMetaType::signatureToType(signature) == QVariant::Invalid) {
-                retval += QString::fromLatin1(">\n      <annotation name=\"com.trolltech.QtDBus.QtTypeName\" value=\"%3\"/>\n    </property>\n")
+                retval += QString::fromLatin1(">\n      <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n    </property>\n")
                           .arg(typeNameToXml(mp.type.constData()));
             } else {
                 retval += QLatin1String("/>\n");
@@ -277,11 +277,11 @@ QString qDBusInterfaceFromClassDef(const ClassDef *mo)
     interface.replace(QLatin1String("::"), QLatin1String("."));
 
     if (interface.startsWith(QLatin1String("QDBus"))) {
-        interface.prepend(QLatin1String("com.trolltech.QtDBus."));
+        interface.prepend(QLatin1String("org.qtproject.QtDBus."));
     } else if (interface.startsWith(QLatin1Char('Q')) &&
                 interface.length() >= 2 && interface.at(1).isUpper()) {
         // assume it's Qt
-        interface.prepend(QLatin1String("local.com.trolltech.Qt."));
+        interface.prepend(QLatin1String("local.org.qtproject.Qt."));
     } else {
         interface.prepend(QLatin1String("local."));
     }
index cc30567..8c75c8a 100644 (file)
@@ -343,17 +343,28 @@ static QByteArray qtTypeName(const QString &signature, const QDBusIntrospection:
 {
     int type = QDBusMetaType::signatureToType(signature.toLatin1());
     if (type == QVariant::Invalid) {
-        QString annotationName = QString::fromLatin1("com.trolltech.QtDBus.QtTypeName");
+        QString annotationName = QString::fromLatin1("org.qtproject.QtDBus.QtTypeName");
         if (paramId >= 0)
             annotationName += QString::fromLatin1(".%1%2").arg(QLatin1String(direction)).arg(paramId);
         QString qttype = annotations.value(annotationName);
         if (!qttype.isEmpty())
             return qttype.toLatin1();
 
-        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));
-        exit(1);
+        QString oldAnnotationName = QString::fromLatin1("com.trolltech.QtDBus.QtTypeName");
+        if (paramId >= 0)
+            oldAnnotationName += QString::fromLatin1(".%1%2").arg(QLatin1String(direction)).arg(paramId);
+        qttype = annotations.value(annotationName);
+
+        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));
+            exit(1);
+        }
+
+        fprintf(stderr, "Warning: deprecated annotation '%s' found; suggest updating to '%s'\n",
+                qPrintable(oldAnnotationName), qPrintable(annotationName));
+        return qttype.toLatin1();
     }
 
     return QVariant::typeToName(QVariant::Type(type));
@@ -442,21 +453,37 @@ static void writeArgList(QTextStream &ts, const QStringList &argNames,
 
 static QString propertyGetter(const QDBusIntrospection::Property &property)
 {
-    QString getter = property.annotations.value(QLatin1String("com.trolltech.QtDBus.propertyGetter"));
-    if (getter.isEmpty()) {
-        getter =  property.name;
-        getter[0] = getter[0].toLower();
+    QString getter = property.annotations.value(QLatin1String("org.qtproject.QtDBus.PropertyGetter"));
+    if (!getter.isEmpty())
+        return getter;
+
+    getter = property.annotations.value(QLatin1String("com.trolltech.QtDBus.propertyGetter"));
+    if (!getter.isEmpty()) {
+        fprintf(stderr, "Warning: deprecated annotation 'com.trolltech.QtDBus.propertyGetter' found;"
+                " suggest updating to 'org.qtproject.QtDBus.PropertyGetter'\n");
+        return getter;
     }
+
+    getter =  property.name;
+    getter[0] = getter[0].toLower();
     return getter;
 }
 
 static QString propertySetter(const QDBusIntrospection::Property &property)
 {
-    QString setter = property.annotations.value(QLatin1String("com.trolltech.QtDBus.propertySetter"));
-    if (setter.isEmpty()) {
-        setter = QLatin1String("set") + property.name;
-        setter[3] = setter[3].toUpper();
+    QString setter = property.annotations.value(QLatin1String("org.qtproject.QtDBus.PropertySetter"));
+    if (!setter.isEmpty())
+        return setter;
+
+    setter = property.annotations.value(QLatin1String("com.trolltech.QtDBus.propertySetter"));
+    if (!setter.isEmpty()) {
+        fprintf(stderr, "Warning: deprecated annotation 'com.trolltech.QtDBus.propertySetter' found;"
+                " suggest updating to 'org.qtproject.QtDBus.PropertySetter'\n");
+        return setter;
     }
+
+    setter = QLatin1String("set") + property.name;
+    setter[3] = setter[3].toUpper();
     return setter;
 }