summaryrefslogtreecommitdiffstats
path: root/test/glib/test-service-glib.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2005-07-10 22:54:19 +0000
committerColin Walters <walters@verbum.org>2005-07-10 22:54:19 +0000
commit8c095eea8fbe2f8c219bdb2aebcf61e4e3993f53 (patch)
treeaf9030f8b45381f290c89b793e067a588c6d6353 /test/glib/test-service-glib.c
parent745b19d640e657118b298c6b7cc37798af878a5a (diff)
2005-07-10 Colin Walters <walters@verbum.org>
* doc/TODO: Knock off some GLib items with this patch. * glib/dbus-gvalue-utils.c (_dbus_gtype_can_signal_error) (_dbus_gvalue_signals_error): New functions. * glib/dbus-gvalue-utils.h: Prototype them. * glib/dbus-gobject.c (arg_iterate): Update to handle return vals and change to not output const/retval flags for input args. All callers updated. (invoke_object_method): Refactor to handle return values. Add some more comments in various places. Remove debug g_print. * glib/dbus-binding-tool-glib.h (DBUS_GLIB_ANNOTATION_RETURNVAL): New. * glib/dbus-binding-tool-glib.c (dbus_g_type_get_marshal_name): Handle G_TYPE_NONE. (compute_gsignature): New function; refactored from code from compute_marshaller and compute_marshaller_name. Enhance to handle return values and async ops more cleanly. Update for async ops returning NONE instead of BOOLEAN. (compute_marshaller, compute_marshaller_name): Call compute_gsignature and output appropriate string. (generate_glue): Handle return value annotation. Also don't dump constness flag for input arguments. * glib/Makefile.am (DBUS_GLIB_INTERNALS): New variable; contains files shared between installed library and utilities. (libdbus_glib_1_la_SOURCES): Move some stuf into DBUS_GLIB_INTERNALS. (libdbus_gtool_la_SOURCES): Suck in DBUS_GLIB_INTERNALS so the binding tool can access gtype utility functions. * test/glib/test-service-glib.c: * test/glib/test-service-glib.xml: * test/glib/test-dbus-glib.c: Add some tests for return values.
Diffstat (limited to 'test/glib/test-service-glib.c')
-rw-r--r--test/glib/test-service-glib.c46
1 files changed, 37 insertions, 9 deletions
diff --git a/test/glib/test-service-glib.c b/test/glib/test-service-glib.c
index 853b401a..e44310f3 100644
--- a/test/glib/test-service-glib.c
+++ b/test/glib/test-service-glib.c
@@ -52,6 +52,10 @@ gboolean my_object_do_nothing (MyObject *obj, GError **error);
gboolean my_object_increment (MyObject *obj, gint32 x, gint32 *ret, GError **error);
+gint32 my_object_increment_retval (MyObject *obj, gint32 x);
+
+gint32 my_object_increment_retval_error (MyObject *obj, gint32 x, GError **error);
+
gboolean my_object_throw_error (MyObject *obj, GError **error);
gboolean my_object_uppercase (MyObject *obj, const char *str, char **ret, GError **error);
@@ -91,9 +95,9 @@ gboolean my_object_emit_frobnicate (MyObject *obj, GError **error);
gboolean my_object_terminate (MyObject *obj, GError **error);
-gboolean my_object_async_increment (MyObject *obj, gint32 x, DBusGMethodInvocation *context);
+void my_object_async_increment (MyObject *obj, gint32 x, DBusGMethodInvocation *context);
-gboolean my_object_async_throw_error (MyObject *obj, DBusGMethodInvocation *context);
+void my_object_async_throw_error (MyObject *obj, DBusGMethodInvocation *context);
#include "test-service-glib-glue.h"
@@ -283,6 +287,27 @@ my_object_increment (MyObject *obj, gint32 x, gint32 *ret, GError **error)
return TRUE;
}
+gint32
+my_object_increment_retval (MyObject *obj, gint32 x)
+{
+ return x + 1;
+}
+
+gint32
+my_object_increment_retval_error (MyObject *obj, gint32 x, GError **error)
+{
+ if (x + 1 > 10)
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "%s",
+ "x is bigger than 9");
+ return FALSE;
+ }
+ return x + 1;
+}
+
gboolean
my_object_throw_error (MyObject *obj, GError **error)
{
@@ -559,14 +584,13 @@ do_async_increment (IncrementData *data)
return FALSE;
}
-gboolean
+void
my_object_async_increment (MyObject *obj, gint32 x, DBusGMethodInvocation *context)
{
IncrementData *data = g_new0 (IncrementData, 1);
data->x = x;
data->context = context;
g_idle_add ((GSourceFunc)do_async_increment, data);
- return TRUE;
}
static gboolean
@@ -582,13 +606,12 @@ do_async_error (IncrementData *data)
return FALSE;
}
-gboolean
+void
my_object_async_throw_error (MyObject *obj, DBusGMethodInvocation *context)
{
IncrementData *data = g_new0(IncrementData, 1);
data->context = context;
g_idle_add ((GSourceFunc)do_async_error, data);
- return TRUE;
}
@@ -623,11 +646,16 @@ main (int argc, char **argv)
g_printerr ("Launching test-service-glib\n");
- g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL);
- g_log_set_always_fatal (G_LOG_LEVEL_WARNING);
-
loop = g_main_loop_new (NULL, FALSE);
+ {
+ GLogLevelFlags fatal_mask;
+
+ fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
+ fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
+ g_log_set_always_fatal (fatal_mask);
+ }
+
error = NULL;
connection = dbus_g_bus_get (DBUS_BUS_STARTER,
&error);