diff options
author | Colin Walters <walters@verbum.org> | 2005-03-12 20:07:21 +0000 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2005-03-12 20:07:21 +0000 |
commit | 030cc1e53c6216853e08e27b92f72db80d001873 (patch) | |
tree | b13acda1a445ddd1ef730ec9c6603e38b0796fbe /bus/driver.c | |
parent | 3dea5c183f65c3f924fb442bf606dfeb50f028a4 (diff) | |
download | dbus-030cc1e53c6216853e08e27b92f72db80d001873.tar.gz |
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/driver.c')
-rw-r--r-- | bus/driver.c | 97 |
1 files changed, 36 insertions, 61 deletions
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; } |