diff options
Diffstat (limited to 'glib')
-rw-r--r-- | glib/Makefile.am | 2 | ||||
-rw-r--r-- | glib/dbus-binding-tool-glib.c | 64 | ||||
-rw-r--r-- | glib/dbus-binding-tool-glib.h | 2 | ||||
-rw-r--r-- | glib/dbus-glib-tool.c | 6 |
4 files changed, 63 insertions, 11 deletions
diff --git a/glib/Makefile.am b/glib/Makefile.am index 4cfea7f0..b4256fac 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -51,7 +51,7 @@ dbus_binding_tool_SOURCES = \ dbus_binding_tool_LDADD= -lexpat libdbus-gtool.la dbus-glib-bindings.h: $(top_builddir)/bus/dbus-bus-introspect.xml dbus-binding-tool - ./dbus-binding-tool --mode=glib-client --output=dbus-glib-bindings.h $(top_builddir)/bus/dbus-bus-introspect.xml + ./dbus-binding-tool --ignore-unsupported --mode=glib-client --output=dbus-glib-bindings.h $(top_builddir)/bus/dbus-bus-introspect.xml # FIXME - remove --ignore-unsupported when we can do arrays BUILT_SOURCES = dbus-glib-bindings.h 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: diff --git a/glib/dbus-binding-tool-glib.h b/glib/dbus-binding-tool-glib.h index 6667438a..411c024e 100644 --- a/glib/dbus-binding-tool-glib.h +++ b/glib/dbus-binding-tool-glib.h @@ -27,7 +27,7 @@ G_BEGIN_DECLS #define DBUS_GLIB_ANNOTATION_C_SYMBOL "org.freedesktop.DBus.GLib.CSymbol" -gboolean dbus_binding_tool_output_glib_client (BaseInfo *info, GIOChannel *channel, GError **error); +gboolean dbus_binding_tool_output_glib_client (BaseInfo *info, GIOChannel *channel, gboolean ignore_unsupported, GError **error); gboolean dbus_binding_tool_output_glib_server (BaseInfo *info, GIOChannel *channel, GError **error); G_END_DECLS diff --git a/glib/dbus-glib-tool.c b/glib/dbus-glib-tool.c index 2fc564c4..85f78ed4 100644 --- a/glib/dbus-glib-tool.c +++ b/glib/dbus-glib-tool.c @@ -277,6 +277,7 @@ main (int argc, char **argv) struct stat srcbuf; struct stat targetbuf; gboolean force; + gboolean ignore_unsupported; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, DBUS_LOCALEDIR); @@ -290,6 +291,7 @@ main (int argc, char **argv) files = NULL; prev_arg = NULL; output_file = NULL; + ignore_unsupported = FALSE; force = FALSE; i = 1; while (i < argc) @@ -322,6 +324,8 @@ main (int argc, char **argv) else usage (1); } + else if (strcmp (arg, "--ignore-unsupported") == 0) + ignore_unsupported = TRUE; else if (strncmp (arg, "--output=", 9) == 0) { output_file = arg + 9; @@ -413,7 +417,7 @@ main (int argc, char **argv) lose_gerror (_("Compilation failed"), error); break; case DBUS_BINDING_OUTPUT_GLIB_CLIENT: - if (!dbus_binding_tool_output_glib_client ((BaseInfo *) node, channel, &error)) + if (!dbus_binding_tool_output_glib_client ((BaseInfo *) node, channel, ignore_unsupported, &error)) lose_gerror (_("Compilation failed"), error); break; case DBUS_BINDING_OUTPUT_NONE: |