diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-07-24 14:53:21 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-07-24 14:53:21 +0200 |
commit | a60d8280521131e0b80a32eac4ad46403c6ef8c3 (patch) | |
tree | 1a7838c82ac68655f52a1ad1cce6a7d40647adb6 | |
parent | 6cb22db3307d09803cd946763d9fbd60ea5b6664 (diff) | |
parent | 09c8a7c63c431b70e373a25e2de3bdcad3cda608 (diff) |
Merge pull request #712 from daurnimator/577-sd_bus-vtable-methods-do-not-have-offset
sd-bus: Add offset member for vtable methods
-rw-r--r-- | src/libsystemd/sd-bus/bus-objects.c | 8 | ||||
-rw-r--r-- | src/systemd/sd-bus-vtable.h | 6 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c index cbdf6552f9..a973bca84c 100644 --- a/src/libsystemd/sd-bus/bus-objects.c +++ b/src/libsystemd/sd-bus/bus-objects.c @@ -68,6 +68,12 @@ static int node_vtable_get_userdata( return 1; } +static void *vtable_method_convert_userdata(const sd_bus_vtable *p, void *u) { + assert(p); + + return (uint8_t*) u + p->x.method.offset; +} + static void *vtable_property_convert_userdata(const sd_bus_vtable *p, void *u) { assert(p); @@ -360,6 +366,8 @@ static int method_callbacks_run( if (bus->nodes_modified) return 0; + u = vtable_method_convert_userdata(c->vtable, u); + *found_object = true; if (c->last_iteration == bus->iteration_counter) diff --git a/src/systemd/sd-bus-vtable.h b/src/systemd/sd-bus-vtable.h index a03221502a..b4d6ed03b3 100644 --- a/src/systemd/sd-bus-vtable.h +++ b/src/systemd/sd-bus-vtable.h @@ -67,6 +67,7 @@ struct sd_bus_vtable { const char *signature; const char *result; sd_bus_message_handler_t handler; + size_t offset; } method; struct { const char *member; @@ -89,7 +90,7 @@ struct sd_bus_vtable { .x.start.element_size = sizeof(sd_bus_vtable), \ } -#define SD_BUS_METHOD(_member, _signature, _result, _handler, _flags) \ +#define SD_BUS_VTABLE_METHOD_WITH_OFFSET(_member, _signature, _result, _handler, _offset, _flags) \ { \ .type = _SD_BUS_VTABLE_METHOD, \ .flags = _flags, \ @@ -97,7 +98,10 @@ struct sd_bus_vtable { .x.method.signature = _signature, \ .x.method.result = _result, \ .x.method.handler = _handler, \ + .x.method.offset = _offset, \ } +#define SD_BUS_METHOD(_member, _signature, _result, _handler, _flags) \ + SD_BUS_VTABLE_METHOD_WITH_OFFSET(_member, _signature, _result, _handler, 0, _flags) #define SD_BUS_SIGNAL(_member, _signature, _flags) \ { \ |