summaryrefslogtreecommitdiffstats
path: root/glib/dbus-binding-tool-glib.c
diff options
context:
space:
mode:
Diffstat (limited to 'glib/dbus-binding-tool-glib.c')
-rw-r--r--glib/dbus-binding-tool-glib.c64
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: