diff options
| author | Colin Walters <walters@verbum.org> | 2005-07-09 17:52:52 +0000 | 
|---|---|---|
| committer | Colin Walters <walters@verbum.org> | 2005-07-09 17:52:52 +0000 | 
| commit | b1ae5399f82a88ba397d55f224d00f437564bac5 (patch) | |
| tree | 5318877a5a8dffa85d2fa9e624e80fb9e9715dc4 /glib/dbus-gobject.c | |
| parent | 0ccef79d7e9d1b19cdb10b3a147b64b41686905d (diff) | |
2005-07-09  Colin Walters  <walters@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.
Diffstat (limited to 'glib/dbus-gobject.c')
| -rw-r--r-- | glib/dbus-gobject.c | 48 | 
1 files changed, 41 insertions, 7 deletions
diff --git a/glib/dbus-gobject.c b/glib/dbus-gobject.c index 4f076cc6..ce90eaa7 100644 --- a/glib/dbus-gobject.c +++ b/glib/dbus-gobject.c @@ -144,8 +144,11 @@ method_arg_info_from_object_info (const DBusGObjectInfo *object,  }  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 @@ arg_iterate (const char *data, const char **name, gboolean *in,        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 @@ method_dir_signature_from_object_info (const DBusGObjectInfo *object,      {        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 @@ lookup_object_info (GObject *object)        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 @@ write_interface (gpointer key, gpointer val, gpointer user_data)  	{  	  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 @@ invoke_object_method (GObject         *object,    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 @@ invoke_object_method (GObject         *object,        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 @@ invoke_object_method (GObject         *object,  	  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);  	}      }  | 
