diff options
| author | Patrick Venture <venture@google.com> | 2018-04-16 14:19:08 -0700 |
|---|---|---|
| committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-05-30 13:38:35 +0000 |
| commit | 263712fe36576f7225aa89fdabaf20eb7b16f258 (patch) | |
| tree | d04ca585e9f908d458ab4b618593c7168080c161 /tools | |
| parent | a489b94b14fd3e307db4278bef5a0377d92cae10 (diff) | |
| download | sdbusplus-263712fe36576f7225aa89fdabaf20eb7b16f258.tar.gz sdbusplus-263712fe36576f7225aa89fdabaf20eb7b16f258.zip | |
sdbusplus:: dbus-interfaces generated use inteface
The generated dbus-interface server objects now pass their
sd-bus library calls through whatever interface was provided
in the sdbusplus::bus::bus they received.
Change-Id: Ib57a0f7c87c3cad9920cb4427b833cc66932afa2
Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/sdbusplus/templates/interface.mako.server.cpp.in | 21 | ||||
| -rw-r--r-- | tools/sdbusplus/templates/interface.mako.server.hpp | 2 |
2 files changed, 15 insertions, 8 deletions
diff --git a/tools/sdbusplus/templates/interface.mako.server.cpp.in b/tools/sdbusplus/templates/interface.mako.server.cpp.in index 7a2a798..d519c26 100644 --- a/tools/sdbusplus/templates/interface.mako.server.cpp.in +++ b/tools/sdbusplus/templates/interface.mako.server.cpp.in @@ -1,4 +1,5 @@ #include <algorithm> +#include <sdbusplus/sdbus.hpp> #include <sdbusplus/server.hpp> #include <sdbusplus/exception.hpp> #include <${"/".join(interface.name.split('.') + [ 'server.hpp' ])}> @@ -23,7 +24,7 @@ namespace server ${classname}::${classname}(bus::bus& bus, const char* path) : _${interface_instance()}( - bus, path, _interface, _vtable, this) + bus, path, _interface, _vtable, this), _intf(bus.getInterface()) { } @@ -61,9 +62,13 @@ int ${classname}::_callback_get_${p.name}( { using sdbusplus::server::binding::details::convertForMessage; + // TODO(venture): Can this except? I wouldn't think so. + auto o = static_cast<${classname}*>(context); + try { - auto m = message::message(reply); + auto m = message::message(reply, o->_intf); + #if @WANT_TRANSACTION@ { auto tbus = m.get_bus(); @@ -73,12 +78,11 @@ int ${classname}::_callback_get_${p.name}( } #endif - auto o = static_cast<${classname}*>(context); m.append(convertForMessage(o->${p.camelCase}())); } catch(sdbusplus::internal_exception_t& e) { - sd_bus_error_set_const(error, e.name(), e.description()); + o->_intf->sd_bus_error_set_const(error, e.name(), e.description()); return -EINVAL; } @@ -102,9 +106,12 @@ int ${classname}::_callback_set_${p.name}( const char* property, sd_bus_message* value, void* context, sd_bus_error* error) { + auto o = static_cast<${classname}*>(context); + try { - auto m = message::message(value); + auto m = message::message(value, o->_intf); + #if @WANT_TRANSACTION@ { auto tbus = m.get_bus(); @@ -114,8 +121,6 @@ int ${classname}::_callback_set_${p.name}( } #endif - auto o = static_cast<${classname}*>(context); - ${p.cppTypeMessage(interface.name)} v{}; m.read(v); % if p.is_enum(): @@ -127,7 +132,7 @@ convert${p.enum_name(interface.name)}FromString(v)); } catch(sdbusplus::internal_exception_t& e) { - sd_bus_error_set_const(error, e.name(), e.description()); + o->_intf->sd_bus_error_set_const(error, e.name(), e.description()); return -EINVAL; } diff --git a/tools/sdbusplus/templates/interface.mako.server.hpp b/tools/sdbusplus/templates/interface.mako.server.hpp index 9ca67e0..ec02c57 100644 --- a/tools/sdbusplus/templates/interface.mako.server.hpp +++ b/tools/sdbusplus/templates/interface.mako.server.hpp @@ -1,6 +1,7 @@ #pragma once #include <tuple> #include <systemd/sd-bus.h> +#include <sdbusplus/sdbus.hpp> #include <sdbusplus/server.hpp> <% namespaces = interface.name.split('.') @@ -129,6 +130,7 @@ ${ m.cpp_prototype(loader, interface=interface, ptype='callback-header') } static const vtable::vtable_t _vtable[]; sdbusplus::server::interface::interface _${"_".join(interface.name.split('.'))}_interface; + sdbusplus::SdBusInterface *_intf; % for p in interface.properties: % if p.defaultValue: |

