dbus/glib dbus-gparser.c, 1.18, 1.19 dbus-gobject.c, 1.41,
1.42 dbus-glib-tool.h, 1.1, 1.2 dbus-binding-tool-glib.c, 1.17, 1.18
Colin Walters
walters at freedesktop.org
Sun Jul 10 04:54:47 EST 2005
Update of /cvs/dbus/dbus/glib
In directory gabe:/tmp/cvs-serv10159/glib
Modified Files:
dbus-gparser.c dbus-gobject.c dbus-glib-tool.h
dbus-binding-tool-glib.c
Log Message:
2005-07-09 Colin Walters <walters at verbum.org>
* glib/dbus-gparser.c (parse_annotation): Add annotations to
argument if available, not method.
* glib/dbus-gobject.c (arg_iterate): More verbose warnings.
(invoke_object_method): First, remove some redundant
GValues (object_value, error_value) in favor of working on
array directly. Second, rework constness to be less buggy.
Now we iterate directly over the argument metadata instead
of parallel iterating over output signature and metadata.
* glib/dbus-glib-tool.h: Add INVALID_ANNOTATION error.
* glib/dbus-binding-tool-glib.c (generate_glue): Barf on const
annotation on input args.
Index: dbus-gparser.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gparser.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- dbus-gparser.c 9 Jul 2005 17:52:51 -0000 1.18
+++ dbus-gparser.c 9 Jul 2005 18:54:45 -0000 1.19
@@ -666,7 +666,6 @@
method_info_get_n_args (parser->method) :
signal_info_get_n_args (parser->signal));
-
arg = arg_info_new (name ? name : generated_name, dir, type);
if (parser->method)
method_info_add_arg (parser->method, arg);
@@ -732,12 +731,12 @@
return FALSE;
}
- if (parser->method)
+ if (parser->arg)
+ arg_info_add_annotation (parser->arg, name, value);
+ else if (parser->method)
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.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- dbus-gobject.c 9 Jul 2005 17:52:52 -0000 1.41
+++ dbus-gobject.c 9 Jul 2005 18:54:45 -0000 1.42
@@ -162,7 +162,7 @@
*in = FALSE;
break;
default:
- g_warning ("invalid arg direction");
+ g_warning ("invalid arg direction '%c'", *data);
break;
}
@@ -176,7 +176,7 @@
*constval = TRUE;
break;
default:
- g_warning ("invalid arg const value");
+ g_warning ("invalid arg const value '%c'", *data);
break;
}
@@ -843,8 +843,6 @@
gboolean had_error, call_only;
GError *gerror;
GValueArray *value_array;
- GValue object_value = {0,};
- GValue error_value = {0,};
GValue return_value = {0,};
GClosure closure;
char *in_signature;
@@ -860,6 +858,9 @@
gerror = NULL;
+ /* Determine whether or not this method should be invoked in a new
+ thread
+ */
if (strcmp (string_table_lookup (get_method_data (object_info, method), 2), "A") == 0)
call_only = TRUE;
else
@@ -904,10 +905,9 @@
}
/* Prepend object as first argument */
- g_value_init (&object_value, G_TYPE_OBJECT);
- g_value_set_object (&object_value, object);
- g_value_array_prepend (value_array, &object_value);
- g_value_unset (&object_value);
+ g_value_array_prepend (value_array, NULL);
+ g_value_init (g_value_array_get_nth (value_array, 0), G_TYPE_OBJECT);
+ g_value_set_object (g_value_array_get_nth (value_array, 0), object);
if (call_only)
{
@@ -975,9 +975,9 @@
}
/* Append GError as final argument */
- g_value_init (&error_value, G_TYPE_POINTER);
- g_value_set_pointer (&error_value, &gerror);
- g_value_array_append (value_array, &error_value);
+ g_value_array_append (value_array, NULL);
+ g_value_init (g_value_array_get_nth (value_array, value_array->n_values - 1), G_TYPE_POINTER);
+ g_value_set_pointer (g_value_array_get_nth (value_array, value_array->n_values - 1), &gerror);
}
/* Actually invoke method */
g_value_init (&return_value, G_TYPE_BOOLEAN);
@@ -997,9 +997,7 @@
DBusMessageIter iter;
const char *arg_metadata;
- /* Grab the metadata and iterate over it so we can determine
- * whether or not a value is constant
- */
+ /* Grab the argument metadata and iterate over it */
arg_metadata = method_arg_info_from_object_info (object_info, method);
reply = dbus_message_new_method_return (message);
@@ -1008,22 +1006,36 @@
/* Append OUT arguments to reply */
dbus_message_iter_init_append (reply, &iter);
- dbus_signature_iter_init (&out_signature_iter, out_signature);
out_param_pos = 0;
out_param_gvalue_pos = 0;
- while ((current_type = dbus_signature_iter_get_current_type (&out_signature_iter)) != DBUS_TYPE_INVALID)
+ while (*arg_metadata)
{
GValue gvalue = {0, };
const char *arg_name;
gboolean arg_in;
gboolean constval;
const char *arg_signature;
+ DBusSignatureIter argsigiter;
- g_assert (*arg_metadata);
- arg_metadata = arg_iterate (arg_metadata, &arg_name, &arg_in, &constval, &arg_signature);
+ do
+ {
+ /* Look for constness; skip over input arguments */
+ arg_metadata = arg_iterate (arg_metadata, &arg_name, &arg_in, &constval, &arg_signature);
+ }
+ while (arg_in && *arg_metadata);
+
+ /* If the last argument we saw was input, we must be done iterating over
+ * output arguments.
+ */
+ if (arg_in)
+ break;
+
+ dbus_signature_iter_init (&argsigiter, arg_signature);
- g_value_init (&gvalue, dbus_gtype_from_signature_iter (&out_signature_iter, FALSE));
- if (current_type != DBUS_TYPE_VARIANT)
+ g_print ("looking at arg %s (%s)\n", arg_name, constval ? "TRUE" : "FALSE");
+
+ g_value_init (&gvalue, dbus_gtype_from_signature_iter (&argsigiter, FALSE));
+ if (G_VALUE_TYPE (&gvalue) != G_TYPE_VALUE)
{
if (!dbus_gvalue_take (&gvalue,
&(g_array_index (out_param_values, GTypeCValue, out_param_pos))))
@@ -1044,7 +1056,6 @@
*/
if (!constval)
g_value_unset (&gvalue);
- dbus_signature_iter_next (&out_signature_iter);
}
}
else
@@ -1064,7 +1075,6 @@
{
g_array_free (out_param_values, TRUE);
g_value_array_free (out_param_gvalues);
- g_value_unset (&error_value);
}
g_value_array_free (value_array);
g_value_unset (&return_value);
Index: dbus-glib-tool.h
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-glib-tool.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dbus-glib-tool.h 17 Feb 2005 17:41:26 -0000 1.1
+++ dbus-glib-tool.h 9 Jul 2005 18:54:45 -0000 1.2
@@ -27,7 +27,8 @@
typedef enum
{
- DBUS_BINDING_TOOL_ERROR_UNSUPPORTED_CONVERSION
+ DBUS_BINDING_TOOL_ERROR_UNSUPPORTED_CONVERSION,
+ DBUS_BINDING_TOOL_ERROR_INVALID_ANNOTATION
} DBusBindingToolError;
#define DBUS_BINDING_TOOL_ERROR dbus_binding_tool_error_quark ()
Index: dbus-binding-tool-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-binding-tool-glib.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- dbus-binding-tool-glib.c 9 Jul 2005 17:52:52 -0000 1.17
+++ dbus-binding-tool-glib.c 9 Jul 2005 18:54:45 -0000 1.18
@@ -554,8 +554,21 @@
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');
+ if (arg_info_get_annotation (arg, DBUS_GLIB_ANNOTATION_CONST) != NULL)
+ {
+ if (arg_info_get_direction (arg) == ARG_IN)
+ {
+ g_set_error (error,
+ DBUS_BINDING_TOOL_ERROR,
+ DBUS_BINDING_TOOL_ERROR_INVALID_ANNOTATION,
+ "Input argument \"%s\" has const annotation in method \"%s\" of interface \"%s\"\n",
+ arg_info_get_name (arg),
+ method_info_get_name (method),
+ interface_info_get_name (interface));
+ return FALSE;
+ }
+ 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');
More information about the dbus-commit
mailing list