dbus/glib dbus-gvalue.c, 1.13, 1.14 dbus-binding-tool-glib.c, 1.13, 1.14

Colin Walters walters at freedesktop.org
Wed Jun 29 16:52:37 PDT 2005


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

Modified Files:
	dbus-gvalue.c dbus-binding-tool-glib.c 
Log Message:
2005-06-29  Colin Walters  <walters at verbum.org>

	* dbus/dbus-glib.h: Delete DBUS_TYPE_G_PROXY_ARRAY.  Add
	DBUS_TYPE_G_OBJECT_PATH.

	* glib/dbus-gvalue.c (dbus_g_value_types_init): Remove marshallers
	for G_TYPE_OBJECT and DBUS_TYPE_G_PROXY_ARRAY (the latter should
	be handled more generically).  Add DBUS_TYPE_G_OBJECT_PATH.
	(dbus_g_object_path_get_g_type): New function.
	(dbus_gtype_from_signature_iter): Map DBUS_TYPE_OBJECT_PATH
	to DBUS_TYPE_G_OBJECT_PATH by default.
	(demarshal_proxy): Remove unused name variable.
	(demarshal_object_path, marshal_object_path): New functions.
	(demarshal_proxy_array, marshal_proxy_array): Delete.
	
	* glib/dbus-binding-tool-glib.c (dbus_g_type_get_c_name): Map
	DBUS_TYPE_G_OBJECT_PATH to char *.
	(dbus_g_type_get_lookup_function): Map builtin
	DBUS_TYPE_G_OBJECT_PATH.

	* test/glib/test-dbus-glib.c
	* test/glib/test-service-glib.c (my_object_objpath): 
	Adapt tests to new object path marshalling.


Index: dbus-gvalue.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gvalue.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- dbus-gvalue.c	19 Jun 2005 15:31:25 -0000	1.13
+++ dbus-gvalue.c	29 Jun 2005 23:52:35 -0000	1.14
@@ -88,15 +88,15 @@
 						 DBusMessageIter           *iter,
 						 GValue                    *value,
 						 GError                   **error);
-static gboolean marshal_object                  (DBusMessageIter           *iter,
+static gboolean marshal_object_path             (DBusMessageIter           *iter,
 						 GValue                    *value);
-static gboolean demarshal_object                (DBusGValueMarshalCtx      *context,
+static gboolean demarshal_object_path           (DBusGValueMarshalCtx      *context,
 						 DBusMessageIter           *iter,
 						 GValue                    *value,
 						 GError                   **error);
-static gboolean marshal_proxy_array             (DBusMessageIter           *iter,
+static gboolean marshal_object                  (DBusMessageIter           *iter,
 						 GValue                    *value);
-static gboolean demarshal_proxy_array           (DBusGValueMarshalCtx      *context,
+static gboolean demarshal_object                (DBusGValueMarshalCtx      *context,
 						 DBusMessageIter           *iter,
 						 GValue                    *value,
 						 GError                   **error);
@@ -395,32 +395,49 @@
 
   {
     static const DBusGTypeMarshalVtable vtable = {
-      marshal_object,
-      demarshal_object
+      marshal_object_path,
+      demarshal_object_path
     };
     static const DBusGTypeMarshalData typedata = {
       DBUS_TYPE_OBJECT_PATH_AS_STRING,
       &vtable
     };
-    set_type_metadata (G_TYPE_OBJECT, &typedata);
+    set_type_metadata (DBUS_TYPE_G_OBJECT_PATH, &typedata);
   }
 
   {
     static const DBusGTypeMarshalVtable vtable = {
-      marshal_proxy_array,
-      demarshal_proxy_array
+      marshal_object,
+      demarshal_object
     };
     static const DBusGTypeMarshalData typedata = {
-      DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING,
+      DBUS_TYPE_OBJECT_PATH_AS_STRING,
       &vtable
     };
-    set_type_metadata (DBUS_TYPE_G_PROXY_ARRAY, &typedata);
+    set_type_metadata (G_TYPE_OBJECT, &typedata);
   }
 
   types_initialized = TRUE;
 }
 
 /**
+ * Get the GLib type ID for a DBusGObjectPath boxed type.
+ *
+ * @returns GLib type
+ */
+GType
+dbus_g_object_path_get_g_type (void)
+{
+  static GType type_id = 0;
+
+  if (!type_id)
+    type_id = g_boxed_type_register_static ("DBusGObjectPath",
+					    (GBoxedCopyFunc) g_strdup,
+					    (GBoxedFreeFunc) g_free);
+  return type_id;
+}
+
+/**
  * Get the GLib type ID for a DBusGValue boxed type.
  *
  * @returns GLib type
@@ -592,7 +609,7 @@
   if (dbus_typecode_maps_to_basic (current_type))
     return basic_typecode_to_gtype (current_type);
   else if (current_type == DBUS_TYPE_OBJECT_PATH)
-    return is_client ? DBUS_TYPE_G_PROXY : G_TYPE_OBJECT;
+    return DBUS_TYPE_G_OBJECT_PATH;
   else
     {
       DBusSignatureIter subiter;
@@ -827,7 +844,6 @@
 		 GValue                  *value,
 		 GError                 **error)
 {
-  const char *name;
   DBusGProxy *new_proxy;
   const char *objpath;
   int current_type;
@@ -837,8 +853,6 @@
 
   g_assert (context->proxy != NULL);
   
-  name = dbus_g_proxy_get_bus_name (context->proxy);
-      
   dbus_message_iter_get_basic (iter, &objpath);
 
   new_proxy = dbus_g_proxy_new_from_proxy (context->proxy, NULL, objpath);
@@ -848,6 +862,25 @@
 }
 
 static gboolean
+demarshal_object_path (DBusGValueMarshalCtx    *context,
+		       DBusMessageIter         *iter,
+		       GValue                  *value,
+		       GError                 **error)
+{
+  const char *objpath;
+  int current_type;
+
+  current_type = dbus_message_iter_get_arg_type (iter);
+  g_assert (current_type == DBUS_TYPE_OBJECT_PATH);
+
+  dbus_message_iter_get_basic (iter, &objpath);
+
+  g_value_set_boxed_take_ownership (value, g_strdup (objpath));
+
+  return TRUE;
+}
+
+static gboolean
 demarshal_object (DBusGValueMarshalCtx    *context,
 		  DBusMessageIter         *iter,
 		  GValue                  *value,
@@ -951,50 +984,6 @@
 }
 
 static gboolean
-demarshal_proxy_array (DBusGValueMarshalCtx    *context,
-		       DBusMessageIter         *iter,
-		       GValue                  *value,
-		       GError                 **error)
-{
-  DBusMessageIter subiter;
-  GPtrArray *ret;
-  guint len;
-  guint i;
-  int current_type;
-
-  g_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_ARRAY);
-
-  dbus_message_iter_recurse (iter, &subiter);
-
-  len = dbus_message_iter_get_array_len (&subiter);
-  g_assert (len >= 0);
-  ret = g_ptr_array_sized_new (len);
-  
-  i = 0;
-  while ((current_type = dbus_message_iter_get_arg_type (&subiter)) != DBUS_TYPE_INVALID)
-    {
-      GValue subval = {0, };
-      g_assert (i < len);
-
-      if (!demarshal_proxy (context, &subiter, &subval, error))
-	{
-	  for (i = 0; i < ret->len; i++)
-	    g_object_unref (g_ptr_array_index (ret, i));
-	  g_ptr_array_free (ret, TRUE);
-	  return FALSE;
-	}
-
-      g_ptr_array_index (ret, i) = g_value_get_boxed (&subval);
-      /* Don't unset value, now owned by ret */
-
-      i++;
-    }
-  g_value_set_boxed_take_ownership (value, ret);
-  
-  return TRUE;
-}
-
-static gboolean
 demarshal_ghashtable (DBusGValueMarshalCtx    *context,
 		      DBusMessageIter         *iter,
 		      GValue                  *value,
@@ -1393,6 +1382,23 @@
 }
 
 static gboolean
+marshal_object_path (DBusMessageIter         *iter,
+		     GValue                  *value)
+{
+  const char *path;
+
+  g_assert (G_VALUE_TYPE (value) == DBUS_TYPE_G_OBJECT_PATH);
+
+  path = (const char*) g_value_get_boxed (value);
+  
+  if (!dbus_message_iter_append_basic (iter,
+				       DBUS_TYPE_OBJECT_PATH,
+				       &path))
+    return FALSE;
+  return TRUE;
+}
+
+static gboolean
 marshal_object (DBusMessageIter         *iter,
 		GValue                  *value)
 {
@@ -1413,46 +1419,6 @@
   return TRUE;
 }
 
-static gboolean
-marshal_proxy_array (DBusMessageIter   *iter,
-		     GValue            *value)
-{
-  DBusMessageIter subiter;
-  GPtrArray *array;
-  const char *subsignature_str;
-  gboolean ret = FALSE;
-  guint i;
-
-  subsignature_str = dbus_gtype_to_signature (DBUS_TYPE_G_PROXY);
-  g_assert (subsignature_str != NULL);
-
-  array = g_value_get_boxed (value);
-
-  if (!dbus_message_iter_open_container (iter,
-					 DBUS_TYPE_ARRAY,
-					 subsignature_str,
-					 &subiter))
-    goto out;
-
-  for (i = 0; i < array->len; i++)
-    {
-      GValue val = {0, };
-
-      g_value_init (&val, DBUS_TYPE_G_PROXY);
-      g_value_set_static_boxed (&val, g_ptr_array_index (array, i));
-
-      marshal_proxy (&subiter, &val);
-
-      g_value_unset (&val);
-    }
-
-  if (!dbus_message_iter_close_container (iter, &subiter))
-    goto out;
-  ret = TRUE;
- out:
-  return ret;
-}
-
 struct DBusGLibHashMarshalData
 {
   const char *entry_sig;

Index: dbus-binding-tool-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-binding-tool-glib.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- dbus-binding-tool-glib.c	21 Jun 2005 00:30:20 -0000	1.13
+++ dbus-binding-tool-glib.c	29 Jun 2005 23:52:35 -0000	1.14
@@ -98,7 +98,8 @@
   if (dbus_g_type_is_map (gtype))
     return "GHashTable";
   
-  if (g_type_is_a (gtype, G_TYPE_STRING))
+  if (g_type_is_a (gtype, G_TYPE_STRING)
+      || g_type_is_a (gtype, DBUS_TYPE_G_OBJECT_PATH))
     return "char *";
 
   /* This one is even more hacky...we get an extra *
@@ -892,7 +893,7 @@
   MAP_KNOWN(G_TYPE_VALUE);
   MAP_KNOWN(G_TYPE_STRV);
   MAP_KNOWN(DBUS_TYPE_G_PROXY);
-  MAP_KNOWN(DBUS_TYPE_G_PROXY_ARRAY);
+  MAP_KNOWN(DBUS_TYPE_G_OBJECT_PATH);
   return NULL;
 }
 #undef MAP_FUNDAMENTAL



More information about the dbus-commit mailing list