D-Bus interface macro improvements

* Descriptions for methods, signals and arguments
 * Use real boolean in method descriptor
 * Use dedicated macros for in and out params. The direction argument is always a C constant.
This commit is contained in:
Nedko Arnaudov 2009-08-09 19:23:04 +03:00
parent fe774ef28d
commit d88e11f203
5 changed files with 38 additions and 27 deletions

View File

@ -205,20 +205,20 @@ void emit_studio_disappeared()
signal_new_valist(g_dbus_connection, CONTROL_OBJECT_PATH, INTERFACE_NAME, "StudioDisappeared", DBUS_TYPE_INVALID); signal_new_valist(g_dbus_connection, CONTROL_OBJECT_PATH, INTERFACE_NAME, "StudioDisappeared", DBUS_TYPE_INVALID);
} }
METHOD_ARGS_BEGIN(GetStudioList) METHOD_ARGS_BEGIN(GetStudioList, "Get list of studios")
METHOD_ARG_DESCRIBE("studio_list", "a(sa{sv})", DIRECTION_OUT) METHOD_ARG_DESCRIBE_OUT("studio_list", "a(sa{sv})", "List of studios, name and properties")
METHOD_ARGS_END METHOD_ARGS_END
METHOD_ARGS_BEGIN(LoadStudio) METHOD_ARGS_BEGIN(LoadStudio, "Load studio")
METHOD_ARG_DESCRIBE("studio_name", "s", DIRECTION_IN) METHOD_ARG_DESCRIBE_IN("studio_name", "s", "Name of studio to load")
METHOD_ARG_DESCRIBE("options", "a{sv}", DIRECTION_IN) METHOD_ARG_DESCRIBE_IN("options", "a{sv}", "Load options")
METHOD_ARGS_END METHOD_ARGS_END
METHOD_ARGS_BEGIN(GetApplicationList) METHOD_ARGS_BEGIN(GetApplicationList, "Get list of applications that can be launched")
METHOD_ARG_DESCRIBE("applications", "a(sa{sv})", DIRECTION_OUT) METHOD_ARG_DESCRIBE_OUT("applications", "a(sa{sv})", "List of applications, name and properties")
METHOD_ARGS_END METHOD_ARGS_END
METHOD_ARGS_BEGIN(Exit) METHOD_ARGS_BEGIN(Exit, "Tell ladish D-Bus service to exit")
METHOD_ARGS_END METHOD_ARGS_END
METHODS_BEGIN METHODS_BEGIN
@ -228,10 +228,10 @@ METHODS_BEGIN
METHOD_DESCRIBE(Exit, ladish_exit) METHOD_DESCRIBE(Exit, ladish_exit)
METHODS_END METHODS_END
SIGNAL_ARGS_BEGIN(StudioAppeared) SIGNAL_ARGS_BEGIN(StudioAppeared, "Studio D-Bus object appeared")
SIGNAL_ARGS_END SIGNAL_ARGS_END
SIGNAL_ARGS_BEGIN(StudioDisappeared) SIGNAL_ARGS_BEGIN(StudioDisappeared, "Studio D-Bus object disappeared")
SIGNAL_ARGS_END SIGNAL_ARGS_END
SIGNALS_BEGIN SIGNALS_BEGIN

View File

@ -2,7 +2,7 @@
/* /*
* LADI Session Handler (ladish) * LADI Session Handler (ladish)
* *
* Copyright (C) 2008 Nedko Arnaudov <nedko@arnaudov.name> * Copyright (C) 2008, 2009 Nedko Arnaudov <nedko@arnaudov.name>
* Copyright (C) 2008 Juuso Alasuutari <juuso.alasuutari@gmail.com> * Copyright (C) 2008 Juuso Alasuutari <juuso.alasuutari@gmail.com>
* *
************************************************************************** **************************************************************************
@ -89,7 +89,7 @@ introspection_new(object_path_t *path)
write_buf(" <arg name=\"%s\" type=\"%s\" direction=\"%s\" />\n", write_buf(" <arg name=\"%s\" type=\"%s\" direction=\"%s\" />\n",
method_arg_ptr->name, method_arg_ptr->name,
method_arg_ptr->type, method_arg_ptr->type,
method_arg_ptr->direction == DIRECTION_IN ? "in" : "out"); method_arg_ptr->direction_in ? "in" : "out");
} }
write_buf(" </method>\n"); write_buf(" </method>\n");
} }
@ -191,8 +191,8 @@ introspection_handler(const interface_t *interface,
* Interface description. * Interface description.
*/ */
METHOD_ARGS_BEGIN(Introspect) METHOD_ARGS_BEGIN(Introspect, "Get introspection XML")
METHOD_ARG_DESCRIBE("xml_data", "s", DIRECTION_OUT) METHOD_ARG_DESCRIBE_OUT("xml_data", "s", "XML description of the object")
METHOD_ARGS_END METHOD_ARGS_END
METHODS_BEGIN METHODS_BEGIN

View File

@ -2,7 +2,7 @@
/* /*
* LADI Session Handler (ladish) * LADI Session Handler (ladish)
* *
* Copyright (C) 2008 Nedko Arnaudov <nedko@arnaudov.name> * Copyright (C) 2008, 2009 Nedko Arnaudov <nedko@arnaudov.name>
* Copyright (C) 2008 Juuso Alasuutari <juuso.alasuutari@gmail.com> * Copyright (C) 2008 Juuso Alasuutari <juuso.alasuutari@gmail.com>
* *
************************************************************************** **************************************************************************
@ -33,9 +33,6 @@
#include "types.h" #include "types.h"
#define DIRECTION_OUT (0)
#define DIRECTION_IN (1)
struct _method_msg struct _method_msg
{ {
const service_t *service; const service_t *service;
@ -59,7 +56,7 @@ struct _method_arg
{ {
const char *name; const char *name;
const char *type; const char *type;
const int direction; /* 0 == out, 1 == in */ const bool direction_in; /* false == out, true == in */
}; };
struct _method struct _method
@ -164,22 +161,27 @@ method_iter_get_dict_entry(DBusMessageIter *iter,
int *type_ptr, int *type_ptr,
int *size_ptr); int *size_ptr);
#define METHOD_ARGS_BEGIN(method_name) \ #define METHOD_ARGS_BEGIN(method_name, descr) \
static const struct _method_arg method_name ## _args_dtor[] = \ static const struct _method_arg method_name ## _args_dtor[] = \
{ {
#define METHOD_ARG_DESCRIBE(arg_name, arg_type, arg_direction) \ #define METHOD_ARG_DESCRIBE_IN(arg_name, arg_type, descr) \
{ \ { \
.name = arg_name, \ .name = arg_name, \
.type = arg_type, \ .type = arg_type, \
.direction = arg_direction \ .direction_in = true \
},
#define METHOD_ARG_DESCRIBE_OUT(arg_name, arg_type, descr) \
{ \
.name = arg_name, \
.type = arg_type, \
.direction_in = false \
}, },
#define METHOD_ARGS_END \ #define METHOD_ARGS_END \
{ \ { \
.name = NULL, \ .name = NULL, \
.type = NULL, \
.direction = 0 \
} \ } \
}; };

View File

@ -68,11 +68,11 @@ signal_new_valist(
int type, int type,
...); ...);
#define SIGNAL_ARGS_BEGIN(signal_name) \ #define SIGNAL_ARGS_BEGIN(signal_name, descr) \
static const struct _signal_arg signal_name ## _args_dtor[] = \ static const struct _signal_arg signal_name ## _args_dtor[] = \
{ {
#define SIGNAL_ARG_DESCRIBE(arg_name, arg_type) \ #define SIGNAL_ARG_DESCRIBE(arg_name, arg_type, descr) \
{ \ { \
.name = arg_name, \ .name = arg_name, \
.type = arg_type \ .type = arg_type \

View File

@ -1,8 +1,8 @@
/* /*
* LASH * LASH
* *
* Copyright (C) 2008, 2009 Nedko Arnaudov <nedko@arnaudov.name>
* Copyright (C) 2008 Juuso Alasuutari <juuso.alasuutari@gmail.com> * Copyright (C) 2008 Juuso Alasuutari <juuso.alasuutari@gmail.com>
* Copyright (C) 2008 Nedko Arnaudov <nedko@arnaudov.name>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -39,6 +39,8 @@
# include "lash/config.h" # include "lash/config.h"
#endif #endif
#if 0
#define client_ptr ((lash_client_t *)(((object_path_t *)call->context)->context)) #define client_ptr ((lash_client_t *)(((object_path_t *)call->context)->context))
static void static void
@ -667,10 +669,14 @@ lash_dbus_client_name_changed(method_call_t *call)
#undef client_ptr #undef client_ptr
#endif
/* /*
* Interface methods. * Interface methods.
*/ */
#if 0
METHOD_ARGS_BEGIN(Save) METHOD_ARGS_BEGIN(Save)
METHOD_ARG_DESCRIBE("task_id", "t", DIRECTION_IN) METHOD_ARG_DESCRIBE("task_id", "t", DIRECTION_IN)
METHOD_ARGS_END METHOD_ARGS_END
@ -699,8 +705,10 @@ METHOD_ARGS_END
METHOD_ARGS_BEGIN(ClientNameChanged) METHOD_ARGS_BEGIN(ClientNameChanged)
METHOD_ARG_DESCRIBE("new_name", "s", DIRECTION_IN) METHOD_ARG_DESCRIBE("new_name", "s", DIRECTION_IN)
METHOD_ARGS_END METHOD_ARGS_END
#endif
METHODS_BEGIN METHODS_BEGIN
#if 0
METHOD_DESCRIBE(Save, lash_dbus_save) METHOD_DESCRIBE(Save, lash_dbus_save)
METHOD_DESCRIBE(Load, lash_dbus_load) METHOD_DESCRIBE(Load, lash_dbus_load)
METHOD_DESCRIBE(LoadDataSet, lash_dbus_load_data_set) METHOD_DESCRIBE(LoadDataSet, lash_dbus_load_data_set)
@ -708,6 +716,7 @@ METHODS_BEGIN
METHOD_DESCRIBE(TrySave, lash_dbus_try_save) METHOD_DESCRIBE(TrySave, lash_dbus_try_save)
METHOD_DESCRIBE(TryPathChange, lash_dbus_try_path_change) METHOD_DESCRIBE(TryPathChange, lash_dbus_try_path_change)
METHOD_DESCRIBE(ClientNameChanged, lash_dbus_client_name_changed) METHOD_DESCRIBE(ClientNameChanged, lash_dbus_client_name_changed)
#endif
METHODS_END METHODS_END
/* /*