-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for names of method and signal arguments in DBus introspection #57
Comments
@mkaranki - Thanks for starting on this work. It wasn't something I was aware of before you pointed it out. It looks like you have are really terrific start on this! Since I don't recognize your name, a few items for your awareness:
Thinking through it a little bit, one flaw we might have is that return values we don't require to be named in the sdbus++ YAML. We could start enforcing that and I may have to clean up some of the YAML in openbmc/phosphor-dbus-interfaces. I'd be fine with requiring names on those. We could also generate a fake name like
I don't think there are any cases of people using
Have you looked at
In that case it looks like parameters are passed to the |
I did not know about those. Their API indeed looks nicer, but I've been thinking few days now how they could be used in sdbusplus. The main issue with them I think is that it is actually a variadic macro (https://github.com/systemd/systemd/blob/301e7cd047c8d07715d5dc37f713e8aa031581b4/src/systemd/sd-bus-vtable.h#L287). Thus implementing vtable::method as a proper, type safe C++ (constexpr) method that calls the macro with the correct number of arguments seems to not to be really possible. Or at least it would require defining an own overloaded function for each number of arguments. If I understand the macro implementation of SD_BUS_METHOD_WITH_ARGS correctly, it is supporting up to 50 arguments and return values. To fully support the same 50 * 50 = 2500 overloaded C++ constexpr methods would be required. That's quite a lot. The alternatives so far I've been thinking could be to generate the needed vtable::method and vtable::signal code with mako templates based on the yaml file, or then just simply omit using all kinds of the constexpr vtable::method alike "type safety layers" and call directly the SD_BUS_METHOD_WITH_ARGS macro from the sdbus++ generated code. The generated vtable would look something like: const vtable::vtable_t xyz::_vtable[] = {
vtable::start(),
SD_BUS_METHOD_WITH_ARGS("Method1",
SD_BUS_ARGS(std::get<0>(details::xyz::_param_Method1[0])
std::get<1>(details::xyz::_param_Method1[0]),
std::get<0>(details::xyz::_param_Method1[1]),
std::get<1>(details::xyz::_param_Method1[1])),
SD_BUS_RESULT(std::get<0>(details::xyz::_return_Method1[0]),
std::get<1>(details::xyz::_return_Method1[0])),
_callback_Method1,
flags),
SD_BUS_SIGNAL_WITH_ARGS("Signal1",
SD_BUS_NO_ARGS,
flags),
vtable::end()
}; |
Looking at the implementation of |
sdbusplus does not add names of the arguments of methods and parameters to the D-Bus introspection document.
systemd sd-bus has added support for that in v242 release. See systemd/systemd#1564
I did a quick try out how the support could be implemented. See
mkaranki@27e6a8d
I could spend few more moments to polish that to perhaps get it merged, but would like to receive some advice regarding the at least the following things:
The vtable API compatibility. Is is preferred to add
vtable::method_n
andvtable::signal_n
, i.e. functions defining method or signal with argument names, to retain the old API, or would it be better to add the name parameters to thevtable::method
andvtable::signal
functions? Is there value of maintaining the old API or supporting genuinely unnamed arguments?vtable::method_n
arguments. sdbus'SD_BUS_METHOD_WITH_NAMES
macro is having separate arguments for parameter names and return value names. Those seem to be expected to be string literals and are concatenated to be a singlenames
array, where names are delimited by nil characters. Would it be better to keep thevtable::method_n
to have a single names argument, which is rather simple, or have in and out names separated just likeSD_BUS_METHOD_WITH_NAMES
has it, and then somehow combine them to be one list? I am unsure could the latter be constexpr or not / how to do that without spending extra memory for that.The text was updated successfully, but these errors were encountered: