LEW21 / pydbus

Pythonic DBus library
GNU Lesser General Public License v2.1
327 stars 76 forks source link

How to use "overloaded" methods #19

Closed AlexejStukov closed 7 years ago

AlexejStukov commented 7 years ago

With Qt's Dbus implementation i could do something like this:

<node>
    <interface name="com.<company>.<app>">
        <method name="method">
            <arg name="value1" type="i" direction="in"/>
        </method>
        <method name="method">
            <arg name="value1" type="i" direction="in"/>
            <arg name="value2" type="i" direction="in"/>
        </method>
    </interface>
</node>

The two dbus-method-calls would call one C++ function with a default-value for value2. Is there the possibility to do this with pydbus?

LEW21 commented 7 years ago

Wontfix.

Method overloading is a C++-only feature, other languages don't support them, therefore they shouldn't be used in DBus.

Example from Java bindings: "D-Bus does not support method overloading, only one method or signal should exist with each name." https://dbus.freedesktop.org/doc/dbus-java/dbus-java/dbus-javase1.html

Bug report in the old dbus-python, that's also wontfix: https://bugs.freedesktop.org/show_bug.cgi?id=22429

AlexejStukov commented 7 years ago

Just a small comment on this. I misphrased the heading on this. What i meant were methods with default values. So for the XML in my first post it would have been just one method:

def method(self, value1, value2=0):
    pass

So both exported dbus-methods would call the same python-method.