dbus/test/glib test-service-glib.xml, 1.8, 1.9 test-service-glib.c, 1.18, 1.19 test-dbus-glib.c, 1.25, 1.26

Colin Walters walters at freedesktop.org
Sat Jul 9 02:25:32 EST 2005


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

Modified Files:
	test-service-glib.xml test-service-glib.c test-dbus-glib.c 
Log Message:
2005-07-08  Colin Walters  <walters at verbum.org>

	* tools/Makefile.am: Kill of print-introspect in favor of using
	dbus-send --print-reply=literal.
	* tools/print-introspect.c: Deleted.

	* test/glib/test-service-glib.xml: 
	* test/glib/test-service-glib.c (my_object_get_objs): New test
	for "ao".

	* test/glib/test-dbus-glib.c (echo_received_cb): Free echo data.
	(main): Test GetObjs.

	* glib/examples/statemachine/Makefile.am:
	* glib/examples/statemachine/sm-marshal.list:
	* glib/examples/statemachine/statemachine-client.c:
	* glib/examples/statemachine/statemachine-server.c:
	* glib/examples/statemachine/statemachine-server.xml:
	* glib/examples/statemachine/statemachine.c:
	* glib/examples/statemachine/statemachine.h:
	* glib/examples/statemachine/statemachine.xml:

	New example.

	* glib/examples/example-service.c (main): Move invocation
	of dbus_g_object_type_install_info earlier, to emphasize it
	should only be done once.

	* glib/examples/example-signal-emitter.c (main): Ditto.

	* glib/examples/Makefile.am (SUBDIRS): Include statemachine.

	* glib/dbus-gvalue.h (dbus_gtype_to_signature)
	(dbus_gvalue_marshal): Update prototypes.

	* glib/dbus-gvalue.c: Update all marshalling functions to take
	const GValue instead of GValue.
	(signature_iter_to_g_type_array): Return a GPtrArray for nonfixed
	types.
	(dbus_gvalue_to_signature): Update for dbus_gtype_to_signature
	change.
	(dbus_gtype_to_signature): Handle generic collecitons and maps.
	Return a newly-allocated string.
	(demarshal_proxy, demarshal_object_path, demarshal_object)
	(demarshal_strv, demarshal_ghashtable): Set error, don't assert if
	we get the wrong types from message.
	(get_type_demarshaller): New function, extracted from
	dbus_gvalue_demarshal.
	(demarshal_collection): New function, demarshals generic
	collection.
	(dbus_gvalue_demarshal): Just invoke result of
	get_type_demarshaller.  Throw error if we don't have one.
	(marshal_garray_basic): Abort on OOM.
	(get_type_marshaller): New function, extracted from
	dbus_gvalue_marshal.
	(collection_marshal_iterator, marshal_collection): New functions;
	implements generic marshalling for an iteratable specialized
	collection.
	(dbus_gvalue_marshal): Just invoke result of get_type_marshaller.

	* glib/dbus-gvalue-utils.c (gvalue_from_ptrarray_value): Handle
	G_TYPE_STRING.
	(ptrarray_value_from_gvalue): Ditto.
	(ptrarray_append, ptrarray_free): New functions.
	(slist_constructor, slist_iterator, slist_copy_elt, slist_copy) 
	(slist_append, slist_end_append, slist_free): New functions.
	(dbus_g_type_specialized_builtins_init): Add append fuctions
	for GPtrArray and GSList.  Register GSList.
	(test_specialized_hash, _dbus_gvalue_utils_test): New functions.

	* glib/dbus-gtype-specialized.h (DBusGTypeSpecializedAppendContext):
	New.
	(dbus_g_type_specialized_collection_init_append)
	(dbus_g_type_specialized_collection_append)
	(dbus_g_type_specialized_collection_end_append): Prototype.
	(DBusGTypeSpecializedCollectionVtable): Add append_func and
	end_append_func.

	* glib/dbus-gtype-specialized.c (dbus_g_type_specialized_collection_init_append) 
	(dbus_g_type_specialized_collection_append) 
	(dbus_g_type_specialized_collection_end_append): New functions.
	(dbus_g_type_map_value_iterate): Take const GValue.
	(dbus_g_type_collection_value_iterate): Ditto.

	* glib/dbus-gtest.c (dbus_glib_internal_do_not_use_run_tests): Run
	_dbus_gvalue_utils_test.
	
	* glib/dbus-gtest.h: Prototype it.

	* glib/dbus-gproxy.c (dbus_g_proxy_manager_filter): Avoid
	using uninitialized owner_list.
	(dbus_g_proxy_begin_call_internal): Move return_if_fail to
	public API.
	(dbus_g_proxy_end_call_internal): Update to use error set
	from dbus_gvalue_demarshal instead of setting it here.
	(dbus_g_proxy_begin_call): Move return_if_fail here.

	* glib/dbus-gobject.c (write_interface): Update for
	dbus_gtype_to_signature returning new string.

	* configure.in: Add glib/examples/statemachine.


Index: test-service-glib.xml
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-service-glib.xml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- test-service-glib.xml	30 Jun 2005 18:22:09 -0000	1.8
+++ test-service-glib.xml	8 Jul 2005 16:25:30 -0000	1.9
@@ -74,6 +74,10 @@
       <arg type="o" direction="out"/>
     </method>
 
+    <method name="GetObjs">
+      <arg type="ao" direction="out"/>
+    </method>
+
     <method name="IncrementVal">
     </method>
 

Index: test-service-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-service-glib.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- test-service-glib.c	30 Jun 2005 18:22:09 -0000	1.18
+++ test-service-glib.c	8 Jul 2005 16:25:30 -0000	1.19
@@ -65,6 +65,8 @@
 
 gboolean my_object_objpath (MyObject *obj, const char *in, char **arg1, GError **error);
 
+gboolean my_object_get_objs (MyObject *obj, GPtrArray **objs, GError **error);
+
 gboolean my_object_stringify (MyObject *obj, GValue *value, char **ret, GError **error);
 gboolean my_object_unstringify (MyObject *obj, const char *str, GValue *value, GError **error);
 
@@ -410,6 +412,17 @@
   return TRUE;
 }
 
+gboolean
+my_object_get_objs (MyObject *obj, GPtrArray **objs, GError **error)
+{
+  *objs = g_ptr_array_new ();
+
+  g_ptr_array_add (*objs, g_strdup ("/org/freedesktop/DBus/Tests/MyTestObject"));
+  g_ptr_array_add (*objs, g_strdup ("/org/freedesktop/DBus/Tests/MyTestObject2"));
+
+  return TRUE;
+}
+
 static void
 hash_foreach (gpointer key, gpointer val, gpointer user_data)
 {

Index: test-dbus-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-dbus-glib.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- test-dbus-glib.c	6 Jul 2005 21:27:47 -0000	1.25
+++ test-dbus-glib.c	8 Jul 2005 16:25:30 -0000	1.26
@@ -195,6 +195,7 @@
     lose_gerror ("Failed to complete async Echo", error);
   g_assert (echo_data != NULL);
   g_print ("Async echo gave \"%s\"", echo_data); 
+  g_free (echo_data);
   g_main_loop_quit (loop);
   g_source_remove (exit_timeout);
 }
@@ -899,6 +900,34 @@
 
   run_mainloop ();
 
+  {
+    GPtrArray *objs;
+    guint i;
+
+    g_print ("Calling GetObjs\n");
+
+    if (!dbus_g_proxy_call (proxy, "GetObjs", &error, G_TYPE_INVALID,
+			    dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
+			    &objs,
+			    G_TYPE_INVALID))
+      lose_gerror ("Failed to complete GetObjs call", error);
+    if (objs->len != 2)
+      lose ("GetObjs call returned unexpected number of objects %d, expected 2",
+	    objs->len);
+
+    if (strcmp ("/org/freedesktop/DBus/Tests/MyTestObject",
+		g_ptr_array_index (objs, 0)) != 0)
+      lose ("GetObjs call returned unexpected path \"%s\" in position 0; expected /org/freedesktop/DBus/Tests/MyTestObject", (char*) g_ptr_array_index (objs, 0));
+
+    if (strcmp ("/org/freedesktop/DBus/Tests/MyTestObject2",
+		g_ptr_array_index (objs, 1)) != 0)
+      lose ("GetObjs call returned unexpected path \"%s\" in position 1; expected /org/freedesktop/DBus/Tests/MyTestObject2", (char*) g_ptr_array_index (objs, 1));
+
+    for (i = 0; i < objs->len; i++)
+      g_free (g_ptr_array_index (objs, i));
+    g_ptr_array_free (objs, TRUE);
+  }
+
   /* Signal handling tests */
   
   g_print ("Testing signal handling\n");



More information about the dbus-commit mailing list