summaryrefslogtreecommitdiffstats
path: root/bus
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2005-03-12 20:07:21 +0000
committerColin Walters <walters@verbum.org>2005-03-12 20:07:21 +0000
commit030cc1e53c6216853e08e27b92f72db80d001873 (patch)
treeb13acda1a445ddd1ef730ec9c6603e38b0796fbe /bus
parent3dea5c183f65c3f924fb442bf606dfeb50f028a4 (diff)
2005-03-12 Colin Walters <walters@verbum.org>
* bus/driver.c (write_args_for_direction): New function, parses a type signature into arguments and outputs to XML. (bus_driver_handle_introspect): Use it instead of hardcoding XML for certain signatures. * bus/Makefile.am (dbus-bus-introspect.xml): Add dependency on dbus-daemon. * glib/dbus-glib-tool.c (main): Parse ignore_unsupported argument, pass it to dbus_binding_tool_output_glib_client. * glib/dbus-binding-tool-glib.c (generate_client_glue): Protect against multiple inclusion. (dbus_binding_tool_output_glib_client): Add G_BEGIN_DECLS/G_END_DECLS. * glib/dbus-binding-tool-glib.c (compute_client_method_name): Change to just take iface prefix directly. (write_formal_parameters): Clarify error message. (check_supported_parameters): New function; checks to see type signatures of method parameters are supported. (generate_client_glue): Handle ignore_unsupported flag. (dbus_binding_tool_output_glib_client): Handle ignore_unsupported parameter. * glib/Makefile.am (dbus-glib-bindings.h): Pass --ignore-unsupported by default until glib bindings support arrays.
Diffstat (limited to 'bus')
-rw-r--r--bus/Makefile.am2
-rw-r--r--bus/driver.c97
2 files changed, 37 insertions, 62 deletions
diff --git a/bus/Makefile.am b/bus/Makefile.am
index f6e04ee7..a1fb76a0 100644
--- a/bus/Makefile.am
+++ b/bus/Makefile.am
@@ -92,7 +92,7 @@ run-with-tmp-session-bus.sh: dbus-daemon
all-local: dbus-bus-introspect.xml
-dbus-bus-introspect.xml: $(srcdir)/run-with-tmp-session-bus.sh
+dbus-bus-introspect.xml: $(srcdir)/run-with-tmp-session-bus.sh dbus-daemon
DBUS_TOP_BUILDDIR=$(top_builddir) $(srcdir)/run-with-tmp-session-bus.sh ./print-introspect org.freedesktop.DBus /org/freedesktop/DBus > dbus-bus-introspect.xml.tmp && mv dbus-bus-introspect.xml.tmp dbus-bus-introspect.xml
## mop up the gcov files
diff --git a/bus/driver.c b/bus/driver.c
index e647fbf3..8f627787 100644
--- a/bus/driver.c
+++ b/bus/driver.c
@@ -31,6 +31,7 @@
#include "utils.h"
#include <dbus/dbus-string.h>
#include <dbus/dbus-internals.h>
+#include <dbus/dbus-marshal-recursive.h>
#include <string.h>
static dbus_bool_t bus_driver_send_welcome_message (DBusConnection *connection,
@@ -1099,6 +1100,34 @@ struct
};
static dbus_bool_t
+write_args_for_direction (DBusString *xml,
+ const char *signature,
+ dbus_bool_t in)
+{
+ DBusTypeReader typereader;
+ DBusString sigstr;
+ int current_type;
+
+ _dbus_string_init_const (&sigstr, signature);
+ _dbus_type_reader_init_types_only (&typereader, &sigstr, 0);
+
+ while ((current_type = _dbus_type_reader_get_current_type (&typereader)) != DBUS_TYPE_INVALID)
+ {
+ const DBusString *subsig;
+ int start, len;
+
+ _dbus_type_reader_get_signature (&typereader, &subsig, &start, &len);
+ if (!_dbus_string_append_printf (xml, " <arg direction=\"%s\" type=\"%s\"/>\n", in ? "in" : "out", _dbus_string_get_const_data_len (subsig, start, len)))
+ goto oom;
+
+ _dbus_type_reader_next (&typereader);
+ }
+ return TRUE;
+ oom:
+ return FALSE;
+}
+
+static dbus_bool_t
bus_driver_handle_introspect (DBusConnection *connection,
BusTransaction *transaction,
DBusMessage *message,
@@ -1150,73 +1179,19 @@ bus_driver_handle_introspect (DBusConnection *connection,
i = 0;
while (i < _DBUS_N_ELEMENTS (message_handlers))
{
+
if (!_dbus_string_append_printf (&xml, " <method name=\"%s\">\n",
message_handlers[i].name))
goto oom;
- /* This hacky mess can probably get mopped up eventually when the
- * introspection format is related to the signature format
- */
-
- if (strcmp (message_handlers[i].in_args, "") == 0)
- ;
- else if (strcmp (message_handlers[i].in_args,
- DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_UINT32_AS_STRING) == 0)
- {
- if (!_dbus_string_append_printf (&xml, " <arg direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING))
- goto oom;
- if (!_dbus_string_append_printf (&xml, " <arg direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_UINT32_AS_STRING))
- goto oom;
- }
- else if (strcmp (message_handlers[i].in_args,
- DBUS_TYPE_STRING_AS_STRING) == 0)
- {
- if (!_dbus_string_append_printf (&xml, " <arg direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING))
- goto oom;
- }
- else
- {
- _dbus_warn ("Lack introspection code for in sig '%s'\n",
- message_handlers[i].in_args);
- _dbus_assert_not_reached ("FIXME introspection missing");
- }
+ if (!write_args_for_direction (&xml, message_handlers[i].in_args, TRUE))
+ goto oom;
+
+ if (!write_args_for_direction (&xml, message_handlers[i].out_args, FALSE))
+ goto oom;
- if (strcmp (message_handlers[i].out_args, "") == 0)
- ;
- else if (strcmp (message_handlers[i].out_args,
- DBUS_TYPE_STRING_AS_STRING) == 0)
- {
- if (!_dbus_string_append_printf (&xml, " <arg direction=\"out\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING))
- goto oom;
- }
- else if (strcmp (message_handlers[i].out_args,
- DBUS_TYPE_BOOLEAN_AS_STRING) == 0)
- {
- if (!_dbus_string_append_printf (&xml, " <arg direction=\"out\" type=\"%s\"/>\n", DBUS_TYPE_BOOLEAN_AS_STRING))
- goto oom;
- }
- else if (strcmp (message_handlers[i].out_args,
- DBUS_TYPE_UINT32_AS_STRING) == 0)
- {
- if (!_dbus_string_append_printf (&xml, " <arg direction=\"out\" type=\"%s\"/>\n", DBUS_TYPE_UINT32_AS_STRING))
- goto oom;
- }
- else if (strcmp (message_handlers[i].out_args,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING) == 0)
- {
- /* FIXME introspection format doesn't handle arrays yet */
- if (!_dbus_string_append_printf (&xml, " <arg direction=\"out\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING))
- goto oom;
- }
- else
- {
- _dbus_warn ("Lack introspection code for out sig '%s'\n",
- message_handlers[i].out_args);
- _dbus_assert_not_reached ("FIXME introspection missing");
- }
-
if (!_dbus_string_append (&xml, " </method>\n"))
- goto oom;
+ goto oom;
++i;
}