dbus/glib dbus-glib-tool.c, 1.11, 1.12 dbus-binding-tool-glib.h, 1.2, 1.3 dbus-binding-tool-glib.c, 1.5, 1.6 Makefile.am, 1.15, 1.16

Colin Walters walters at freedesktop.org
Sat Mar 12 12:07:23 PST 2005


Update of /cvs/dbus/dbus/glib
In directory gabe:/tmp/cvs-serv23478/glib

Modified Files:
	dbus-glib-tool.c dbus-binding-tool-glib.h 
	dbus-binding-tool-glib.c Makefile.am 
Log Message:
2005-03-12  Colin Walters  <walters at 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.


Index: dbus-glib-tool.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-glib-tool.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- dbus-glib-tool.c	27 Feb 2005 17:38:12 -0000	1.11
+++ dbus-glib-tool.c	12 Mar 2005 20:07:21 -0000	1.12
@@ -277,6 +277,7 @@
   struct stat srcbuf;
   struct stat targetbuf;
   gboolean force;
+  gboolean ignore_unsupported;
 
   setlocale (LC_ALL, "");
   bindtextdomain (GETTEXT_PACKAGE, DBUS_LOCALEDIR);
@@ -290,6 +291,7 @@
   files = NULL;
   prev_arg = NULL;
   output_file = NULL;
+  ignore_unsupported = FALSE;
   force = FALSE;
   i = 1;
   while (i < argc)
@@ -322,6 +324,8 @@
 	      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 @@
 		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:

Index: dbus-binding-tool-glib.h
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-binding-tool-glib.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- dbus-binding-tool-glib.h	17 Feb 2005 21:11:18 -0000	1.2
+++ dbus-binding-tool-glib.h	12 Mar 2005 20:07:21 -0000	1.3
@@ -27,7 +27,7 @@
 
 #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

Index: dbus-binding-tool-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-binding-tool-glib.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- dbus-binding-tool-glib.c	9 Mar 2005 17:09:11 -0000	1.5
+++ dbus-binding-tool-glib.c	12 Mar 2005 20:07:21 -0000	1.6
@@ -38,6 +38,7 @@
 
 typedef struct
 {
+  gboolean ignore_unsupported;
   GIOChannel *channel;
   
   GError **error;
@@ -576,15 +577,12 @@
 }
 
 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 @@
 	  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 @@
 }
 
 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 @@
       GSList *methods;
       GSList *tmp;
       int count;
+      char *iface_prefix;
 
       channel = data->channel;
 
@@ -749,6 +766,17 @@
       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 @@
 
           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 @@
 
 	  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 @@
 
 
 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 @@
   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:

Index: Makefile.am
===================================================================
RCS file: /cvs/dbus/dbus/glib/Makefile.am,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- Makefile.am	12 Mar 2005 16:33:00 -0000	1.15
+++ Makefile.am	12 Mar 2005 20:07:21 -0000	1.16
@@ -51,7 +51,7 @@
 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
 



More information about the dbus-commit mailing list