dbus/tools print-introspect.c, 1.1, 1.2 dbus-viewer.c, 1.12, 1.13 dbus-names-model.c, 1.5, 1.6 Makefile.am, 1.14, 1.15

Colin Walters walters at freedesktop.org
Sun Jun 12 20:01:20 PDT 2005


Update of /cvs/dbus/dbus/tools
In directory gabe:/tmp/cvs-serv11651/tools

Modified Files:
	print-introspect.c dbus-viewer.c dbus-names-model.c 
	Makefile.am 
Log Message:
2005-06-12  Colin Walters  <walters at verbum.org>

	Async signals and various bugfixes and testing by
	Ross Burton <ross at burtonini.com>.

	* glib/dbus-gvalue.h: (struct DBusBasicGValue): Delete.
	(dbus_gvalue_genmarshal_name_from_type)
	(dbus_gvalue_ctype_from_type): Moved to dbus-binding-tool-glib.c.
	(dbus_gtype_to_dbus_type): Renamed to dbus_gtype_from_signature.
	(dbus_g_value_types_init, dbus_gtype_from_signature)
	(dbus_gtype_from_signature_iter, dbus_gtype_to_signature)
	(dbus_gtypes_from_arg_signature): New function prototypes.
	(dbus_gvalue_demarshal): Take context and error arguments.
	(dbus_gvalue_demarshal_variant): New function.
	(dbus_gvalue_demarshal_message): New function.
	(dbus_gvalue_store): Delete.

	* glib/dbus-gvalue.c:

	File has been almost entirely rewritten; now we special-case
	more types such as DBUS_TYPE_SIGNATURE, handle arrays and
	hash tables correctly, etc.  Full support for recursive values
	is not yet complete.

	* glib/dbus-gproxy.c (dbus_g_proxy_class_init): Change last
	argument of signal to G_TYPE_POINTER since we now pass a
	structure.
	(lookup_g_marshaller): Delete in favor of
	_dbus_gobject_lookup_marshaller.
	(marshal_dbus_message_to_g_marshaller): Use
	_dbus_gobject_lookup_marshaller and dbus_gvalue_demarshal_message
	to handle remote signal callbacks.
	(dbus_g_proxy_new_from_proxy): New function; creates a new
	DBusGProxy by copying an existing one.
	(dbus_g_proxy_get_interface, dbus_g_proxy_set_interface)
	(dbus_g_proxy_get_path): New functions.
	(dbus_g_proxy_marshal_args_to_message): New function;
	factored out of existing code.
	(DBUS_G_VALUE_ARRAY_COLLECT_ALL): Collect all arguments
	from a varargs array.
	(dbus_g_proxy_begin_call_internal): New function.
	(dbus_g_proxy_end_call_internal): New function.
	(dbus_g_proxy_begin_call): Take GTypes instead of DBus types
	as arguments; simply invoke dbus_g_proxy_begin_call_internal
	after collecting args into value array.
	(dbus_g_proxy_end_call): Take GTypes instead of DBus types;
	invoke dbus_g_proxy_end_call_internal.
	(dbus_g_proxy_invoke): Simply invoke begin_call_interanl and
	end_call_internal.
	(dbus_g_proxy_call_no_reply): Take GTypes instead of DBus
	types.
	(array_free_all): New function.
	(dbus_g_proxy_add_signal): Take GTypes.

	* glib/dbus-gobject.h:
	(_dbus_glib_marshal_dbus_message_to_gvalue_array): Delete.
	(_dbus_gobject_get_path, _dbus_gobject_lookup_marshaller):
	Prototype.

	* glib/dbus-gobject.c: Add a global marshal_table hash which
	stores mappings from type signatures to marshallers.  Change lots
	of invocations of dbus_gtype_to_dbus_type to
	dbus_gtype_to_signature.
	(_dbus_glib_marshal_dbus_message_to_gvalue_array): Delete.
	(introspect_signals): Fix test for query.return_type.
	(set_object_property): Update invocation of dbus_gvalue_demarshal.
	(invoke_object_method): Many changes.  Handle asynchronous
	invocations.  Convert arguments with
	dbus_gvalue_demarshal_message.  Handle errors.  Use
	DBusSignatureIter instead of strlen on args. Handle all arguments
	generically.  Special-case variants.
	(dbus_g_method_return, dbus_g_method_return_error): New function.
	(DBusGSignalClosure): New structure, closes over signal
	information.
	(dbus_g_signal_closure_new): New function.
	(dbus_g_signal_closure_finalize): New function.
	(signal_emitter_marshaller): New function; is special marshaller
	which emits signals on bus.
	(export_signals): New function; introspects object signals and
	connects to them.
	(dbus_g_object_type_install_info): Take GType instead of
	GObjectClass.
	(dbus_g_connection_register_g_object): Invoke export_signals.
	(dbus_g_connection_lookup_g_object): New function.
	(DBusGFuncSignature) New structure; used for mapping type
	signatures to marshallers.
	(funcsig_hash): New function; hashes DBusGFuncSignature.
	(funcsig_equal): New function; compares DBusGFuncSignature.
	(_dbus_gobject_lookup_marshaller): New function.
	(dbus_g_object_register_marshaller): New function; used to
	register a marshaller at runtime for a particular signature.

	* glib/dbus-gmain.c (_dbus_gmain_test): Add various tests.

	* glib/dbus-binding-tool-glib.h: Add DBUS_GLIB_ANNOTATION_ASYNC
	which notes a server method implementation should be
	asynchronous.

	* glib/dbus-binding-tool-glib.c
	(dbus_binding_tool_output_glib_server): Call
	dbus_g_value_types_init.
	(write_formal_parameters): Use dbus_gtype_from_signature.  Handle
	variants specially.
	(dbus_g_type_get_lookup_function): Turn GType into an invocation
	of a lookup function.
	(write_args_for_direction): Use dbus_g_type_get_lookup_function.
	(write_untyped_out_args): New method; write output arguments.
	(write_formal_declarations_for_direction): Function for
	writing prototypes.
	(write_formal_parameters_for_direction): Function for
	writing implementations.
	(write_typed_args_for_direction): Function for writing
	arguments prefixed with GTypes.
	(write_async_method_client): Write out async version
	of method.

	* glib/dbus-binding-tool-glib.c: Include dbus-gvalue-utils.h.
	(dbus_g_type_get_marshal_name): Move mapping from GType
	to marshal name into here.
	(dbus_g_type_get_c_name): Move into here.
	(compute_marshaller): Convert signature to type with
	dbus_gtype_from_signature, use dbus_g_type_get_marshal_name.
	(compute_marshaller_name): Ditto.
	(compute_marshaller): Handle async signal annotations.
	(gather_marshallers): Return if we don't have a known
	prefix.
	(generate_glue): Collect introspection blob here, and
	write all of the blob at the end.  This allows an object
	with multiple interfaces to work.
	Mark async methods in introspection blob.

	* glib/Makefile.am (libdbus_glib_1_la_SOURCES): Add
	dbus-gtype-specialized.c, dbus-gtype-specialized.h,
	dbus-gvalue-utils.h, dbus-gvalue-utils.c.

	* dbus/dbus-glib.h: Don't include dbus-protocol.h; this
	avoids people accidentally using DBUS_TYPE_* which should
	not be necessary anymore.
	Do include dbus-gtype-specialized.h, which are utilities
	for GLib container types.
	Add various #defines for types such as
	DBUS_TYPE_G_BOOLEAN_ARRAY.
	(DBusGValueIterator, DBusGValue): Define, not fully used
	yet.
	(dbus_g_value_get_g_type): Type for recursive value.
	(dbus_g_value_open, dbus_g_value_iterator_get_value)
	(dbus_g_value_iterator_get_values, dbus_g_value_iterator_recurse)
	(dbus_g_value_free): Prototypes.
	(dbus_g_object_register_marshaller, dbus_g_proxy_new_from_proxy): Prototype.
	(dbus_g_proxy_set_interface): Prototype.
	(dbus_g_proxy_begin_call, dbus_g_proxy_end_call)
	(dbus_g_proxy_call_no_reply): Take GLib types instead of DBus
	types.
	(dbus_g_proxy_get_path, dbus_g_proxy_get_interface):
	Accessors.
	(DBusGAsyncData, DBusGMethodInvocation): Structures for
	doing async invocations.
	(dbus_g_method_return, dbus_g_method_return_error):
	Prototypes.
	* doc/dbus-tutorial.xml: Update GLib section.
	
	* tools/dbus-viewer.c (load_child_nodes): Update
	for new invocation type of dbus_g_proxy_end_call.
	(load_from_service_thread_func): Ditto.

	* tools/print-introspect.c (main): Ditto.

	* tools/dbus-names-model.c (have_names_notify)
	(names_model_reload, names_model_set_connection)
	Use GTypes.

	* python/Makefile.am (INCLUDES): Define DBUS_COMPILATION,
	needed since Python bindings use GLib bindings.

	* test/glib/Makefile.am (INCLUDES): Define DBUS_COMPILATION.
	Add --prefix argument.

	* tools/Makefile.am: Define DBUS_COMPILATION.  Remove
	unneeded --ignore-unsupported arg.
	
	* test/glib/test-service-glib.c: 
	* test/glib/test-service-glib.xml:
	* test/glib/test-dbus-glib.c: Add many more tests.


Index: print-introspect.c
===================================================================
RCS file: /cvs/dbus/dbus/tools/print-introspect.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- print-introspect.c	17 Mar 2005 17:48:29 -0000	1.1
+++ print-introspect.c	13 Jun 2005 03:01:17 -0000	1.2
@@ -41,7 +41,7 @@
   GError *error;
   const char *service;
   const char *path;
-  const char *introspect_data;
+  char *introspect_data;
   
   if (argc != 3)
     usage (argv[0], 1);
@@ -64,9 +64,9 @@
   proxy = dbus_g_proxy_new_for_name (connection,
 				     service, path,
 				     DBUS_INTERFACE_INTROSPECTABLE);
-  call = dbus_g_proxy_begin_call (proxy, "Introspect", DBUS_TYPE_INVALID);
-  if (!dbus_g_proxy_end_call (proxy, call, &error, DBUS_TYPE_STRING,
-			      &introspect_data, DBUS_TYPE_INVALID))
+  call = dbus_g_proxy_begin_call (proxy, "Introspect", G_TYPE_INVALID);
+  if (!dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING,
+			      &introspect_data, G_TYPE_INVALID))
     {
       fprintf (stderr, "Failed to get introspection data: %s\n",
                error->message);
@@ -75,8 +75,8 @@
     }
       
   printf ("%s", introspect_data);
+  g_free (introspect_data);
 
-  dbus_g_pending_call_unref (call);
   g_object_unref (proxy);
 
   exit (0);

Index: dbus-viewer.c
===================================================================
RCS file: /cvs/dbus/dbus/tools/dbus-viewer.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- dbus-viewer.c	31 Mar 2005 02:24:12 -0000	1.12
+++ dbus-viewer.c	13 Jun 2005 03:01:17 -0000	1.13
@@ -148,7 +148,7 @@
     {
       DBusGProxy *proxy;
       DBusGPendingCall *call;
-      const char *data;
+      char *data;
       NodeInfo *child;
       NodeInfo *complete_child;
       int save_len;
@@ -184,14 +184,19 @@
         }
   
       call = dbus_g_proxy_begin_call (proxy, "Introspect",
-                                      DBUS_TYPE_INVALID);
+                                      G_TYPE_INVALID);
       
       data = NULL;
-      if (!dbus_g_proxy_end_call (proxy, call, error, DBUS_TYPE_STRING, &data,
-                                  DBUS_TYPE_INVALID))
-        goto done;
+      if (!dbus_g_proxy_end_call (proxy, call, error, G_TYPE_STRING, &data,
+                                  G_TYPE_INVALID))
+	{
+	  call = NULL;
+	  goto done;
+	}
+      call = NULL;
       
       complete_child = description_load_from_string (data, -1, error);
+      g_free (data);
       if (complete_child == NULL)
         {
           g_printerr ("%s\n", data);
@@ -300,16 +305,18 @@
 #endif
   
   call = dbus_g_proxy_begin_call (root_proxy, "Introspect",
-                                  DBUS_TYPE_INVALID);
+                                  G_TYPE_INVALID);
 
   data = NULL;
-  if (!dbus_g_proxy_end_call (root_proxy, call, &lfsd->error, DBUS_TYPE_STRING, &data,
-                              DBUS_TYPE_INVALID))
+  if (!dbus_g_proxy_end_call (root_proxy, call, &lfsd->error, G_TYPE_STRING, &data,
+                              G_TYPE_INVALID))
     {
+      call = NULL;
       g_printerr ("Failed to Introspect() %s\n",
                   dbus_g_proxy_get_bus_name (root_proxy));
       goto out;
     }
+  call = NULL;
 
   node = description_load_from_string (data, -1, &lfsd->error);
 

Index: dbus-names-model.c
===================================================================
RCS file: /cvs/dbus/dbus/tools/dbus-names-model.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- dbus-names-model.c	17 Feb 2005 21:19:48 -0000	1.5
+++ dbus-names-model.c	13 Jun 2005 03:01:17 -0000	1.6
@@ -23,6 +23,7 @@
 #include "dbus-names-model.h"
 #include <glib/gi18n.h>
 #include <string.h>
+#include <dbus/dbus-protocol.h>
 
 enum
 {
@@ -76,8 +77,8 @@
   error = NULL;
   if (!dbus_g_proxy_end_call (names_model->driver_proxy,
                               names_model->pending_list_names,
-                              &error, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
-                              &names, &n_elements, DBUS_TYPE_INVALID))
+                              &error, G_TYPE_STRV,
+                              &names, &n_elements, G_TYPE_INVALID))
     {
       g_assert (names == NULL);
       g_assert (error != NULL);
@@ -210,7 +211,7 @@
   names_model->pending_list_names =
     dbus_g_proxy_begin_call (names_model->driver_proxy,
                              "ListNames",
-                             DBUS_TYPE_INVALID);
+                             G_TYPE_INVALID);
 
   dbus_g_pending_call_set_notify (names_model->pending_list_names,
                                   have_names_notify, names_model, NULL);
@@ -252,9 +253,10 @@
 
       dbus_g_proxy_add_signal (names_model->driver_proxy,
                                "NameOwnerChanged",
-                               DBUS_TYPE_STRING_AS_STRING
-                               DBUS_TYPE_STRING_AS_STRING
-                               DBUS_TYPE_STRING_AS_STRING);
+                               G_TYPE_STRING,
+                               G_TYPE_STRING,
+                               G_TYPE_STRING,
+			       G_TYPE_INVALID);
       
       dbus_g_proxy_connect_signal (names_model->driver_proxy,
                                    "NameOwnerChanged", 

Index: Makefile.am
===================================================================
RCS file: /cvs/dbus/dbus/tools/Makefile.am,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Makefile.am	24 Mar 2005 15:44:43 -0000	1.14
+++ Makefile.am	13 Jun 2005 03:01:17 -0000	1.15
@@ -1,4 +1,4 @@
-INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_GLIB_CFLAGS) $(DBUS_X_CFLAGS) $(DBUS_GTK_THREADS_CFLAGS) -DDBUS_LOCALEDIR=\"$(prefix)/@DATADIRNAME@/locale\"
+INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_GLIB_CFLAGS) $(DBUS_X_CFLAGS) $(DBUS_GTK_THREADS_CFLAGS) -DDBUS_LOCALEDIR=\"$(prefix)/@DATADIRNAME@/locale\" -DDBUS_COMPILATION
 
 if HAVE_GLIB
 GLIB_TOOLS=dbus-monitor
@@ -7,7 +7,7 @@
 libdbus_glibdir = $(includedir)/dbus-1.0/dbus
 
 dbus-glib-bindings.h: dbus-bus-introspect.xml $(top_builddir)/glib/dbus-binding-tool
-	$(top_builddir)/glib/dbus-binding-tool --ignore-unsupported --mode=glib-client --output=dbus-glib-bindings.h dbus-bus-introspect.xml # FIXME - remove --ignore-unsupported when we can do arrays
+	$(top_builddir)/glib/dbus-binding-tool --mode=glib-client --output=dbus-glib-bindings.h dbus-bus-introspect.xml
 
 BUILT_SOURCES = dbus-glib-bindings.h dbus-bus-introspect.xml
 



More information about the dbus-commit mailing list