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 /glib/dbus-binding-tool-glib.c | |
parent | 3dea5c183f65c3f924fb442bf606dfeb50f028a4 (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 'glib/dbus-binding-tool-glib.c')
-rw-r--r-- | glib/dbus-binding-tool-glib.c | 64 |
1 files changed, 56 insertions, 8 deletions
diff --git a/glib/dbus-binding-tool-glib.c b/glib/dbus-binding-tool-glib.c index 5bd413e1..c78b9d53 100644 --- a/glib/dbus-binding-tool-glib.c +++ b/glib/dbus-binding-tool-glib.c @@ -38,6 +38,7 @@ typedef struct { + gboolean ignore_unsupported; GIOChannel *channel; GError **error; @@ -576,15 +577,12 @@ iface_to_c_prefix (const char *iface) } static char * -compute_client_method_name (InterfaceInfo *iface, MethodInfo *method) +compute_client_method_name (const char *iface_prefix, MethodInfo *method) { GString *ret; char *method_name_uscored; - char *iface_prefix; - iface_prefix = iface_to_c_prefix (interface_info_get_name (iface)); ret = g_string_new (iface_prefix); - g_free (iface_prefix); method_name_uscored = _dbus_gutils_wincaps_to_uscore (method_info_get_name (method)); g_string_append_c (ret, '_'); @@ -617,8 +615,10 @@ write_formal_parameters (InterfaceInfo *iface, MethodInfo *method, GIOChannel *c g_set_error (error, DBUS_BINDING_TOOL_ERROR, DBUS_BINDING_TOOL_ERROR_UNSUPPORTED_CONVERSION, - _("Unsupported conversion from D-BUS type %s to glib C type"), - arg_info_get_type (arg)); + _("Unsupported conversion from D-BUS type signature \"%s\" to glib C type in method \"%s\" of interface \"%s\""), + arg_info_get_type (arg), + method_info_get_name (method), + interface_info_get_name (iface)); return FALSE; } @@ -708,6 +708,22 @@ write_args_for_direction (InterfaceInfo *iface, MethodInfo *method, GIOChannel * } static gboolean +check_supported_parameters (MethodInfo *method) +{ + GSList *args; + + for (args = method_info_get_args (method); args; args = args->next) + { + ArgInfo *arg; + arg = args->data; + if (!dbus_gvalue_ctype_from_type (arg_info_get_type (arg), + arg_info_get_direction (arg))) + return FALSE; + } + return TRUE; +} + +static gboolean generate_client_glue_list (GSList *list, DBusBindingToolCData *data, GError **error) { GSList *tmp; @@ -741,6 +757,7 @@ generate_client_glue (BaseInfo *base, DBusBindingToolCData *data, GError **error GSList *methods; GSList *tmp; int count; + char *iface_prefix; channel = data->channel; @@ -749,6 +766,17 @@ generate_client_glue (BaseInfo *base, DBusBindingToolCData *data, GError **error methods = interface_info_get_methods (interface); count = 0; + iface_prefix = iface_to_c_prefix (interface_info_get_name (interface)); + + if (!write_printf_to_iochannel ("#ifndef DBUS_GLIB_CLIENT_WRAPPERS_%s\n" + "#define DBUS_GLIB_CLIENT_WRAPPERS_%s\n\n", + channel, error, + iface_prefix, iface_prefix)) + { + g_free (iface_prefix); + goto io_lose; + } + for (tmp = methods; tmp != NULL; tmp = g_slist_next (tmp)) { MethodInfo *method; @@ -756,7 +784,15 @@ generate_client_glue (BaseInfo *base, DBusBindingToolCData *data, GError **error method = (MethodInfo *) tmp->data; - method_name = compute_client_method_name (interface, method); + if (data->ignore_unsupported && !check_supported_parameters (method)) + { + g_warning ("Ignoring unsupported signature in method \"%s\" of interface \"%s\"\n", + method_info_get_name (method), + interface_info_get_name (interface)); + continue; + } + + method_name = compute_client_method_name (iface_prefix, method); WRITE_OR_LOSE ("static\n#ifdef G_HAVE_INLINE\ninline\n#endif\ngboolean\n"); if (!write_printf_to_iochannel ("%s (DBusGProxy *proxy", channel, error, @@ -791,6 +827,12 @@ generate_client_glue (BaseInfo *base, DBusBindingToolCData *data, GError **error WRITE_OR_LOSE ("NULL);\n}\n\n"); } + + if (!write_printf_to_iochannel ("#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_%s */\n\n", channel, error, iface_prefix)) + { + g_free (iface_prefix); + goto io_lose; + } } return TRUE; io_lose: @@ -799,7 +841,7 @@ generate_client_glue (BaseInfo *base, DBusBindingToolCData *data, GError **error gboolean -dbus_binding_tool_output_glib_client (BaseInfo *info, GIOChannel *channel, GError **error) +dbus_binding_tool_output_glib_client (BaseInfo *info, GIOChannel *channel, gboolean ignore_unsupported, GError **error) { DBusBindingToolCData data; gboolean ret; @@ -807,13 +849,19 @@ dbus_binding_tool_output_glib_client (BaseInfo *info, GIOChannel *channel, GErro memset (&data, 0, sizeof (data)); data.channel = channel; + data.ignore_unsupported = ignore_unsupported; WRITE_OR_LOSE ("/* Generated by dbus-binding-tool; do not edit! */\n\n"); WRITE_OR_LOSE ("#include <glib/gtypes.h>\n"); WRITE_OR_LOSE ("#include <glib/gerror.h>\n"); WRITE_OR_LOSE ("#include <dbus/dbus-glib.h>\n\n"); + WRITE_OR_LOSE ("G_BEGIN_DECLS\n\n"); ret = generate_client_glue (info, &data, error); + if (!ret) + goto io_lose; + + WRITE_OR_LOSE ("G_END_DECLS\n"); return ret; io_lose: |