From 030cc1e53c6216853e08e27b92f72db80d001873 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sat, 12 Mar 2005 20:07:21 +0000 Subject: 2005-03-12 Colin Walters * 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. --- bus/Makefile.am | 2 +- bus/driver.c | 97 +++++++++++++++++++++------------------------------------ 2 files changed, 37 insertions(+), 62 deletions(-) (limited to 'bus') 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 #include +#include #include static dbus_bool_t bus_driver_send_welcome_message (DBusConnection *connection, @@ -1098,6 +1099,34 @@ struct bus_driver_handle_reload_config } }; +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, " \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, @@ -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, " \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, " \n", DBUS_TYPE_STRING_AS_STRING)) - goto oom; - if (!_dbus_string_append_printf (&xml, " \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, " \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, " \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, " \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, " \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, " \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, " \n")) - goto oom; + goto oom; ++i; } -- cgit