diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-05-14 10:02:17 +0900 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-08-24 16:47:08 +0200 |
commit | 323e81a0b8a8264001a9d0ff97544d263a47e60a (patch) | |
tree | 28aea871ef17e9acc93bef32e27b1bf36014c389 | |
parent | 2d8a35e2eb9b93aafe0a86e45bb4cb0abf8b6c3a (diff) |
bus-util: add more macros for defining functions of getting dbus properties
-rw-r--r-- | src/shared/bus-util.h | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/src/shared/bus-util.h b/src/shared/bus-util.h index b65fce184..db1ce4280 100644 --- a/src/shared/bus-util.h +++ b/src/shared/bus-util.h @@ -173,34 +173,15 @@ int bus_log_create_error(int r); } #define ident(x) (x) -#define BUS_DEFINE_PROPERTY_GET(function, bus_type, data_type, get1) \ +#define BUS_DEFINE_PROPERTY_GET(function, bus_type, data_type, get1) \ BUS_DEFINE_PROPERTY_GET2(function, bus_type, data_type, get1, ident) +#define ref(x) (*(x)) +#define BUS_DEFINE_PROPERTY_GET_REF(function, bus_type, data_type, get) \ + BUS_DEFINE_PROPERTY_GET2(function, bus_type, data_type, ref, get) + #define BUS_DEFINE_PROPERTY_GET_ENUM(function, name, type) \ - int function(sd_bus *bus, \ - const char *path, \ - const char *interface, \ - const char *property, \ - sd_bus_message *reply, \ - void *userdata, \ - sd_bus_error *error) { \ - \ - const char *value; \ - type *field = userdata; \ - int r; \ - \ - assert(bus); \ - assert(reply); \ - assert(field); \ - \ - value = strempty(name##_to_string(*field)); \ - \ - r = sd_bus_message_append_basic(reply, 's', value); \ - if (r < 0) \ - return r; \ - \ - return 1; \ - } + BUS_DEFINE_PROPERTY_GET_REF(function, "s", type, name##_to_string) #define BUS_PROPERTY_DUAL_TIMESTAMP(name, offset, flags) \ SD_BUS_PROPERTY(name, "t", bus_property_get_usec, (offset) + offsetof(struct dual_timestamp, realtime), (flags)), \ |