summaryrefslogtreecommitdiffstats
path: root/src/tools/qdbusxml2cpp
diff options
context:
space:
mode:
authorDavid Edmundson <davidedmundson@kde.org>2014-11-21 14:54:33 +0100
committerDavid Edmundson <davidedmundson@kde.org>2015-01-05 12:29:14 +0100
commit54079de9f9968513a741eeceb2a24c2fd2ddbb96 (patch)
treee045615a3ff753506d91a9f021c4f000f9599271 /src/tools/qdbusxml2cpp
parentaeceb5e383c2c2946dd09dc70136cb905481b924 (diff)
Add annotation to rename methods created by qdbusxml2cpp
Under DBus it is possible to have methods and signals with the same name or have methods which are reserved c++ keywords. For example the logind session interface has a signal and method both called Lock. This patch allows generated methods to use a different method name specified in the annotation that the original DBus name in the DBus interface in a similar manner to how one can rename accessors. [ChangeLog][QtDBus] Add annotation org.qtproject.QtDBus.MethodName to allow autogenerating C++ methods with different names to the original DBus method Change-Id: I08bbe77554fbdd348e93f82d45bab0d75d360c27 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/tools/qdbusxml2cpp')
-rw-r--r--src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp
index a85dd44f65..871175a822 100644
--- a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp
+++ b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp
@@ -488,6 +488,15 @@ static QString propertySetter(const QDBusIntrospection::Property &property)
return setter;
}
+static QString methodName(const QDBusIntrospection::Method &method)
+{
+ QString name = method.annotations.value(QStringLiteral("org.qtproject.QtDBus.MethodName"));
+ if (!name.isEmpty())
+ return name;
+
+ return method.name;
+}
+
static QString stringify(const QString &data)
{
QString retval;
@@ -679,7 +688,7 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf
hs << "> ";
}
- hs << method.name << "(";
+ hs << methodName(method) << "(";
QStringList argNames = makeArgNames(method.inputArgs);
writeArgList(hs, argNames, method.annotations, method.inputArgs);
@@ -1012,7 +1021,7 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte
cs << returnType << " ";
}
- QString name = method.name;
+ QString name = methodName(method);
hs << name << "(";
cs << className << "::" << name << "(";
@@ -1023,7 +1032,7 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte
hs << ");" << endl; // finished for header
cs << ")" << endl
<< "{" << endl
- << " // handle method call " << interface->name << "." << method.name << endl;
+ << " // handle method call " << interface->name << "." << methodName(method) << endl;
// make the call
bool usingInvokeMethod = false;