Default value for `in` parameter
Thiago Macieira
thiago at kde.org
Sat Jan 28 16:03:28 UTC 2023
On Saturday, 28 January 2023 04:01:14 PST Charles Wong wrote:
> Hi,
>
> Is this the right place to ask dbus questions?
>
> For example, there is a dbus config (is from
> https://gjs.guide/guides/gio/dbus.html#high-level-proxies):
> ```xml
> <method name="ComplexMethod">
> <arg type="b" direction="in" name="input"/>
> <arg type="u" direction="out" name="length"/>
> </method>
> ```
>
> Is it possible to set a default value to parameter `input` and mark it as
> unrequired?
No, it's not. Please understand the introspection is a completely optional
step. What you're suggestion would require a client to parse the XML to
discover the default value.
However, the client can just place the call with fewer arguments. If the
destination service knows how to deal with that, then the problem is solved.
This would be like "overloading" in C++, where you can have multiple methods
with the same names but different parameters. The wire protocol permits this
and many C++-based applications have such methods. It's also permitted and
permissible in the XML introspection by the schema, but it is discouraged for
compatibility reasons. For your own service and clients, you can do it, but
just remember this won't be accepted for use in widely-standardised services.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel DCAI Cloud Engineering
More information about the dbus
mailing list