[Interest] Support for multiple 'out' parameters in qdbusxml2cpp

Adriano Campos adrianoribeirocampos at gmail.com
Thu Sep 25 19:45:21 CEST 2014


Hi,
I'm using QT5.3 and I've the same problem with multiple 'out' parameters in
qdbusxml2cpp, that I just found in this mail list but I don't understand
the solution.

So,
My XML file is:

<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection
1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="Notifications">
<interface name="com.dtvr.Notifications">
<method name="GetServerInformation">
                    <arg name="return_name" type="s" direction="out"/>
                    <arg name="return_vendor" type="s" direction="out"/>
                    <arg name="return_version" type="s" direction="out"/>
                    <arg name="return_spec_version" type="s"
direction="out"/>
</method>
</interface>
</node>

qdbusxml2cpp command is:

qdbusxml2cpp -v -a notifications_adaptor.h:
../demo/com.gnome.Notifications.xml
qdbusxml2cpp -v -i notifications_adaptor.h -a :notifications_adaptor.cpp
../demo/com.gnome.Notifications.xml

the result notifications_adaptor.cpp is:

QString NotificationsAdaptor::GetServerInformation(QString &return_vendor,
QString &return_version, QString &return_spec_version)
{
    // handle method call com.gnome.Notifications.GetServerInformation
    //return static_cast<YourObjectType
*>(parent())->GetServerInformation(return_vendor, return_version,
return_spec_version);
}

So, following the email list, I've to pass the -l parameter to the
generator. Someone can help-me using this parameter?
I use this:
qdbusxml2cpp -v -a notifications_adaptor.h:
../demo/com.gnome.Notifications.xml
qdbusxml2cpp -v -l Interface -i interface.h -i notifications_adaptor.h -a
:notifications_adaptor.cpp ../demo/com.gnome.Notifications.xml

and the result notifications_adaptor.cpp is:

QString NotificationsAdaptor::GetServerInformation(QString &return_vendor,
QString &return_version, QString &return_spec_version)
{
    // handle method call com.dtvr.Notifications.GetServerInformation
    return parent()->GetServerInformation(return_vendor, return_version,
return_spec_version);
}

But now I got that error when I'm compiling the program with QT5.3:
/notifications_adaptor.cpp:52: error: 'class QObject' has no member named
'GetServerInformation'

Adriano Campos
adrianoribeirocampos at gmail.com


>On sexta-feira, 26 de julho de 2013 16:35:24, Matt Hoosier wrote:
>>* Okay, I agree that I could pin down the parent class name and get automatic
*>>* dispatch wired up. But I'd like to understand why the normal
*>>* QMetaObject::invokeMethod() dispatch isn't allowed in this case (that is,
*>>* more than one 'out' parameter).
*
>Because invokeMethod cannot pass non-const references. That's a limitation of
>QMetaObject::invokeMethod.

>Or, at least, it was a limitation when this code was written back in Qt 4.2
>days. Looking at the Q_ARG macro and its classes today, looks like I fixed it
>for Qt 4.7:
>  http://gitorious.org/qt/qt/commit/67cd8cc97104e38f2e3bae03b2a4c3575c73c461
>  https://bugreports.qt-project.org/browse/QTBUG-8592
>
>It appears to be testing this particular code:
>    // make the INVOKABLE call without a return type
>    QDBusVariant arg3("hello"), arg4("world");
>    QVERIFY(QMetaObject::invokeMethod(&iface, "ping_invokable",
>                                      Q_RETURN_ARG(QDBusVariant, retArg),
>                                      Q_ARG(QDBusVariant, arg3),
>                                      Q_ARG(QDBusVariant, arg4),
>                                      Q_ARG(QDBusVariant&, retArg2)));
> Which is exactly your case. So apparently it is now supported, but I've never
>got around to updating the generator, especially because all serious users of
>the generator pass the -l parameter.
>
>>* The test up top there forbids the generated code from ever using
*>>* QMetaObject::invokeMethod() if there's more than one output argument for
*>>* the D-Bus method. Why's that? The MOC doesn't generally have any trouble
*>>* plumbing up calls using arbitrarily many arguments, including non-const ref
*>>* types that would be used to pass down "out" parameters.
*>--
>Thiago Macieira - thiago.macieira (AT) intel.com
>  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140925/ff6d1df6/attachment.html>


More information about the Interest mailing list