diff options
Diffstat (limited to 'glib/dbus-gutils.h')
-rw-r--r-- | glib/dbus-gutils.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/glib/dbus-gutils.h b/glib/dbus-gutils.h index 84041d04..bed2d295 100644 --- a/glib/dbus-gutils.h +++ b/glib/dbus-gutils.h @@ -35,6 +35,21 @@ char **_dbus_gutils_split_path (const char *path); const char *_dbus_gutils_type_to_string (int type); +/* These munge the pointer to enforce that a plain cast won't work, + * accessor functions must be used; i.e. to ensure the ABI + * reflects our encapsulation. + */ +#define _DBUS_POINTER_SHIFT(p) ((void*) (((char*)p) + sizeof (void*))) +#define _DBUS_POINTER_UNSHIFT(p) ((void*) (((char*)p) - sizeof (void*))) + +#define DBUS_CONNECTION_FROM_G_CONNECTION(x) ((DBusConnection*) _DBUS_POINTER_UNSHIFT(x)) +#define DBUS_MESSAGE_FROM_G_MESSAGE(x) ((DBusMessage*) _DBUS_POINTER_UNSHIFT(x)) +#define DBUS_PENDING_CALL_FROM_G_PENDING_CALL(x) ((DBusPendingCall*) _DBUS_POINTER_UNSHIFT(x)) + +#define DBUS_G_CONNECTION_FROM_CONNECTION(x) ((DBusGConnection*) _DBUS_POINTER_SHIFT(x)) +#define DBUS_G_MESSAGE_FROM_MESSAGE(x) ((DBusGMessage*) _DBUS_POINTER_SHIFT(x)) +#define DBUS_G_PENDING_CALL_FROM_PENDING_CALL(x) ((DBusGPendingCall*) _DBUS_POINTER_SHIFT(x)) + G_END_DECLS #endif /* DBUS_GLIB_UTILS_H */ |