diff options
author | Max Kellermann <max@musicpd.org> | 2018-06-03 20:26:15 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-06-03 20:30:08 +0200 |
commit | aea6d354b7f0843a93ce52af2a5608e4708eee4c (patch) | |
tree | a3182745a96f2bc81d9f4fedf5c108cd8fc56a11 /src | |
parent | d3793dfe5bc53e4b8e2f2073a3774cff5071bfe8 (diff) |
lib/dbus/ObjectManager: use TypeTraits instead of CPP macro
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/dbus/ObjectManager.hxx | 33 | ||||
-rw-r--r-- | src/neighbor/plugins/UdisksNeighborPlugin.cxx | 4 |
2 files changed, 15 insertions, 22 deletions
diff --git a/src/lib/dbus/ObjectManager.hxx b/src/lib/dbus/ObjectManager.hxx index e37ee28e8..e0a83e2d0 100644 --- a/src/lib/dbus/ObjectManager.hxx +++ b/src/lib/dbus/ObjectManager.hxx @@ -21,35 +21,28 @@ #define ODBUS_OBJECT_MANAGER_HXX #include "ReadIter.hxx" +#include "Types.hxx" #include <dbus/dbus.h> #define DBUS_OM_INTERFACE "org.freedesktop.DBus.ObjectManager" -#define DBUS_OM_PROPERTIES_SIGNATURE \ - DBUS_TYPE_ARRAY_AS_STRING \ - DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING \ - DBUS_TYPE_STRING_AS_STRING \ - DBUS_TYPE_VARIANT_AS_STRING \ - DBUS_DICT_ENTRY_END_CHAR_AS_STRING +namespace ODBus { -#define DBUS_OM_INTERFACES_SIGNATURE \ - DBUS_TYPE_ARRAY_AS_STRING \ - DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING \ - DBUS_TYPE_STRING_AS_STRING \ - DBUS_OM_PROPERTIES_SIGNATURE \ - DBUS_DICT_ENTRY_END_CHAR_AS_STRING +using PropertiesType = + ArrayTypeTraits<DictEntryTypeTraits<StringTypeTraits, + VariantTypeTraits>>; -#define DBUS_OM_INTERFACES_ADDED_SIGNATURE \ - DBUS_TYPE_OBJECT_PATH_AS_STRING \ - DBUS_OM_INTERFACES_SIGNATURE +using InterfacesType = + ArrayTypeTraits<DictEntryTypeTraits<StringTypeTraits, + PropertiesType>>; -#define DBUS_OM_INTERFACES_REMOVED_SIGNATURE \ - DBUS_TYPE_OBJECT_PATH_AS_STRING \ - DBUS_TYPE_ARRAY_AS_STRING \ - DBUS_TYPE_STRING_AS_STRING +using InterfacesAddedType = + ConcatTypeAsString<ObjectPathTypeTraits, + InterfacesType>; -namespace ODBus { +using InterfacesRemovedType = ConcatTypeAsString<ObjectPathTypeTraits, + ArrayTypeTraits<StringTypeTraits>>; template<typename F> inline void diff --git a/src/neighbor/plugins/UdisksNeighborPlugin.cxx b/src/neighbor/plugins/UdisksNeighborPlugin.cxx index b5927fd6c..658ecc39a 100644 --- a/src/neighbor/plugins/UdisksNeighborPlugin.cxx +++ b/src/neighbor/plugins/UdisksNeighborPlugin.cxx @@ -353,7 +353,7 @@ UdisksNeighborExplorer::HandleMessage(DBusConnection *, DBusMessage *message) no if (dbus_message_is_signal(message, DBUS_OM_INTERFACE, "InterfacesAdded") && - dbus_message_has_signature(message, DBUS_OM_INTERFACES_ADDED_SIGNATURE)) { + dbus_message_has_signature(message, InterfacesAddedType::value)) { RecurseInterfaceDictEntry(ReadMessageIter(*message), [this](const char *path, auto &&i){ UdisksObject o(path); if (ParseObject(o, std::move(i)) && o.IsValid()) @@ -363,7 +363,7 @@ UdisksNeighborExplorer::HandleMessage(DBusConnection *, DBusMessage *message) no return DBUS_HANDLER_RESULT_HANDLED; } else if (dbus_message_is_signal(message, DBUS_OM_INTERFACE, "InterfacesRemoved") && - dbus_message_has_signature(message, DBUS_OM_INTERFACES_REMOVED_SIGNATURE)) { + dbus_message_has_signature(message, InterfacesRemovedType::value)) { Remove(ReadMessageIter(*message).GetString()); return DBUS_HANDLER_RESULT_HANDLED; } else |