dbus/glib dbus-gparser.c, 1.17, 1.18 dbus-gobject.c, 1.40, 1.41 dbus-gidl.h, 1.11, 1.12 dbus-gidl.c, 1.14, 1.15 dbus-binding-tool-glib.h, 1.5, 1.6 dbus-binding-tool-glib.c, 1.16, 1.17

Colin Walters walters at freedesktop.org
Sun Jul 10 03:52:54 EST 2005


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

Modified Files:
	dbus-gparser.c dbus-gobject.c dbus-gidl.h dbus-gidl.c 
	dbus-binding-tool-glib.h dbus-binding-tool-glib.c 
Log Message:
2005-07-09  Colin Walters  <walters at verbum.org>

	* glib/dbus-binding-tool-glib.h (DBUS_GLIB_ANNOTATION_CONST):
	Define.

	* glib/dbus-binding-tool-glib.c (generate_glue): Handle Const
	annotation.

	* glib/dbus-gobject.c (arg_iterate): Update to parse constval too.
	(method_dir_signature_from_object_info): Handle arg_iterate change.
	(write_interface): Ditto.
	(lookup_object_info): Don't barf if format_version is > 0.
	(invoke_object_method): Handle arg constness.

	* glib/dbus-gidl.c (struct ArgInfo): Add annotations.
	(arg_info_new): Create.
	(arg_info_unref): Destroy.
	(arg_info_get_annotations, arg_info_get_annotation) 
	(arg_info_add_annotation): New functions.

	* glib/dbus-gidl.h: Prototype them.

	* glib/dbus-gparser.c (parse_annotation): Allow annotations in
	args, disallow them in properties.
	(parse_annotation): Handle arg annotations.

	* test/glib/test-service-glib.xml: 
	* test/glib/test-service-glib.c: Update to make some methods
	const.


Index: dbus-gparser.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gparser.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- dbus-gparser.c	6 Jul 2005 21:27:49 -0000	1.17
+++ dbus-gparser.c	9 Jul 2005 17:52:51 -0000	1.18
@@ -694,9 +694,10 @@
   const char *name;
   const char *value;
   
-  if (!(parser->method || parser->interface) || 
+  if (!(parser->method || parser->interface || parser->arg) || 
       parser->node_stack == NULL ||
       parser->signal ||
+      parser->property ||
       parser->in_annotation)
     {
       g_set_error (error, G_MARKUP_ERROR,
@@ -735,6 +736,8 @@
     method_info_add_annotation (parser->method, name, value);
   else if (parser->interface)
     interface_info_add_annotation (parser->interface, name, value);
+  else if (parser->arg)
+    arg_info_add_annotation (parser->arg, name, value);
   else
     g_assert_not_reached ();
 

Index: dbus-gobject.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gobject.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- dbus-gobject.c	8 Jul 2005 16:25:37 -0000	1.40
+++ dbus-gobject.c	9 Jul 2005 17:52:52 -0000	1.41
@@ -144,8 +144,11 @@
 }
 
 static const char *
-arg_iterate (const char *data, const char **name, gboolean *in,
-	     const char **type)
+arg_iterate (const char    *data,
+	     const char   **name,
+	     gboolean      *in,
+	     gboolean      *constval,
+	     const char   **type)
 {
   *name = data;
 
@@ -162,6 +165,20 @@
       g_warning ("invalid arg direction");
       break;
     }
+
+  data = string_table_next (data);
+  switch (*data)
+    {
+    case 'F':
+      *constval = FALSE;
+      break;
+    case 'C':
+      *constval = TRUE;
+      break;
+    default:
+      g_warning ("invalid arg const value");
+      break;
+    }
   
   data = string_table_next (data);
   *type = data;
@@ -185,9 +202,10 @@
     {
       const char *name;
       gboolean arg_in;
+      gboolean constval;
       const char *type;
 
-      arg = arg_iterate (arg, &name, &arg_in, &type);
+      arg = arg_iterate (arg, &name, &arg_in, &constval, &type);
 
       if (arg_in == in)
 	g_string_append (ret, type);
@@ -245,7 +263,7 @@
 
       info = g_type_get_qdata (classtype, dbus_g_object_type_dbus_metadata_quark ()); 
 
-      if (info != NULL && info->format_version == 0)
+      if (info != NULL && info->format_version >= 0)
 	{
 	  ret = info;
 	  break;
@@ -322,9 +340,10 @@
 	{
 	  const char *name;
 	  gboolean arg_in;
+	  gboolean constval;
 	  const char *type;
 	  
-	  args = arg_iterate (args, &name, &arg_in, &type);
+	  args = arg_iterate (args, &name, &arg_in, &constval, &type);
 
 	  /* FIXME - handle container types */
 	  g_string_append_printf (xml, "      <arg name=\"%s\" type=\"%s\" direction=\"%s\"/>\n",
@@ -976,6 +995,12 @@
   if (!had_error)
     {
       DBusMessageIter iter;
+      const char *arg_metadata;
+
+      /* Grab the metadata and iterate over it so we can determine
+       * whether or not a value is constant
+       */
+      arg_metadata = method_arg_info_from_object_info (object_info, method);
 
       reply = dbus_message_new_method_return (message);
       if (reply == NULL)
@@ -989,6 +1014,13 @@
       while ((current_type = dbus_signature_iter_get_current_type (&out_signature_iter)) != DBUS_TYPE_INVALID)
 	{
 	  GValue gvalue = {0, };
+	  const char *arg_name;
+	  gboolean arg_in;
+	  gboolean constval;
+	  const char *arg_signature;
+
+	  g_assert (*arg_metadata);
+	  arg_metadata = arg_iterate (arg_metadata, &arg_name, &arg_in, &constval, &arg_signature);
 	  
 	  g_value_init (&gvalue, dbus_gtype_from_signature_iter (&out_signature_iter, FALSE));
 	  if (current_type != DBUS_TYPE_VARIANT)
@@ -1007,9 +1039,11 @@
 	  if (!dbus_gvalue_marshal (&iter, &gvalue))
 	    goto nomem;
 	  /* Here we actually free the allocated value; we
-	   * took ownership of it with dbus_gvalue_take.
+	   * took ownership of it with dbus_gvalue_take, unless
+	   * an annotation has specified this value as constant.
 	   */
-	  g_value_unset (&gvalue);
+	  if (!constval)
+	    g_value_unset (&gvalue);
 	  dbus_signature_iter_next (&out_signature_iter);
 	}
     }

Index: dbus-gidl.h
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gidl.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- dbus-gidl.h	27 Feb 2005 17:38:12 -0000	1.11
+++ dbus-gidl.h	9 Jul 2005 17:52:52 -0000	1.12
@@ -143,6 +143,13 @@
 const char*         arg_info_get_name             (ArgInfo             *info);
 const char*         arg_info_get_type             (ArgInfo             *info);
 ArgDirection        arg_info_get_direction        (ArgInfo             *info);
+GSList*             arg_info_get_annotations      (ArgInfo             *info);
+const char*         arg_info_get_annotation       (ArgInfo             *info,
+						   const char          *annotation);
+void                arg_info_add_annotation       (ArgInfo             *info,
+						   const char          *name,
+						   const char          *value);
+
 
 G_END_DECLS
 

Index: dbus-gidl.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gidl.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- dbus-gidl.c	27 Feb 2005 17:38:12 -0000	1.14
+++ dbus-gidl.c	9 Jul 2005 17:52:52 -0000	1.15
@@ -75,6 +75,7 @@
   BaseInfo base;
   char *type;
   ArgDirection direction;
+  GHashTable *annotations;
 };
 
 static void
@@ -699,6 +700,9 @@
   info->base.name = g_strdup (name);
   info->direction = direction;
   info->type = g_strdup (type);
+  info->annotations = g_hash_table_new_full (g_str_hash, g_str_equal,
+					     (GDestroyNotify) g_free,
+					     (GDestroyNotify) g_free);
 
   return info;
 }
@@ -717,10 +721,12 @@
   info->base.refcount -= 1;
   if (info->base.refcount == 0)
     {
+      g_hash_table_destroy (info->annotations);
       base_info_free (info);
       g_free (info->type);
     }
 }
+
 const char*
 arg_info_get_name (ArgInfo *info)
 {
@@ -739,6 +745,30 @@
   return info->direction;
 }
 
+GSList*
+arg_info_get_annotations (ArgInfo *info)
+{
+  return get_hash_keys (info->annotations);
+}
+
+const char*
+arg_info_get_annotation (ArgInfo    *info,
+			 const char *annotation)
+{
+  return g_hash_table_lookup (info->annotations, annotation);
+}
+
+void
+arg_info_add_annotation (ArgInfo             *info,
+			 const char          *name,
+			 const char          *value)
+{
+  g_hash_table_insert (info->annotations,
+		       g_strdup (name),
+		       g_strdup (value));
+}
+
+
 #ifdef DBUS_BUILD_TESTS
 
 /**

Index: dbus-binding-tool-glib.h
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-binding-tool-glib.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- dbus-binding-tool-glib.h	13 Jun 2005 03:01:24 -0000	1.5
+++ dbus-binding-tool-glib.h	9 Jul 2005 17:52:52 -0000	1.6
@@ -27,6 +27,7 @@
 
 #define DBUS_GLIB_ANNOTATION_C_SYMBOL "org.freedesktop.DBus.GLib.CSymbol"
 #define DBUS_GLIB_ANNOTATION_ASYNC "org.freedesktop.DBus.GLib.Async"
+#define DBUS_GLIB_ANNOTATION_CONST "org.freedesktop.DBus.GLib.Const"
 
 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, const char *prefix, GError **error);

Index: dbus-binding-tool-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-binding-tool-glib.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- dbus-binding-tool-glib.c	8 Jul 2005 17:02:42 -0000	1.16
+++ dbus-binding-tool-glib.c	9 Jul 2005 17:52:52 -0000	1.17
@@ -554,6 +554,12 @@
 	      g_string_append_c (object_introspection_data_blob, direction);
 	      g_string_append_c (object_introspection_data_blob, '\0');
 
+	      if (method_info_get_annotation (method, DBUS_GLIB_ANNOTATION_CONST) != NULL)
+		g_string_append_c (object_introspection_data_blob, 'C');
+	      else
+		g_string_append_c (object_introspection_data_blob, 'F');
+	      g_string_append_c (object_introspection_data_blob, '\0');
+
 	      g_string_append (object_introspection_data_blob, arg_info_get_type (arg));
 	      g_string_append_c (object_introspection_data_blob, '\0');
 	    }



More information about the dbus-commit mailing list