diff options
author | Johan Bilien <jobi@via.ecp.fr> | 2008-11-20 11:54:05 +0000 |
---|---|---|
committer | Johan Bilien <jobi@src.gnome.org> | 2008-11-20 11:54:05 +0000 |
commit | 112ce7798d88e6d64ae2440237ddaab8aa776c15 (patch) | |
tree | 3209065a6be6feb751175966950495309ed16e4f | |
parent | 676bd789f0fb9decadea6097692e75299b3cf0a9 (diff) | |
download | gobject-introspection-112ce7798d88e6d64ae2440237ddaab8aa776c15.tar.gz |
add a test function which calls a closure.
2008-11-20 Johan Bilien <jobi@via.ecp.fr>
* tests/everything/everything.[ch]: add a test function which calls a
closure.
svn path=/trunk/; revision=954
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | tests/everything/everything.c | 43 | ||||
-rw-r--r-- | tests/everything/everything.h | 4 |
3 files changed, 52 insertions, 0 deletions
@@ -1,3 +1,8 @@ +2008-11-20 Johan Bilien <jobi@via.ecp.fr> + + * tests/everything/everything.[ch]: add a test function which calls a + closure. + 2008-11-19 Johan Dahlin <jdahlin@async.com.br> * giscanner/cachestore.py: diff --git a/tests/everything/everything.c b/tests/everything/everything.c index d90c98f5..6a162303 100644 --- a/tests/everything/everything.c +++ b/tests/everything/everything.c @@ -94,6 +94,49 @@ GType test_gtype (GType in) return in; } +int test_closure (GClosure *closure) +{ + GValue return_value = {0, }; + int ret; + + g_value_init (&return_value, G_TYPE_INT); + + g_closure_invoke (closure, + &return_value, + 0, NULL, + NULL); + + ret = g_value_get_int (&return_value); + + g_value_unset(&return_value); + + return ret; +} + +int test_closure_one_arg (GClosure *closure, int arg) +{ + GValue return_value = {0, }; + GValue arguments[1]; + int ret; + + g_value_init (&return_value, G_TYPE_INT); + + g_value_init (&arguments[0], G_TYPE_INT); + g_value_set_int (&arguments[0], arg); + + g_closure_invoke (closure, + &return_value, + 1, arguments, + NULL); + + ret = g_value_get_int (&return_value); + + g_value_unset(&return_value); + g_value_unset(&arguments[0]); + + return ret; +} + #if 0 /************************************************************************/ /* utf8 */ diff --git a/tests/everything/everything.h b/tests/everything/everything.h index 541e51c3..9f7cc08b 100644 --- a/tests/everything/everything.h +++ b/tests/everything/everything.h @@ -65,6 +65,10 @@ void test_gslist_free (GSList *in); /* ghash? */ /* error? */ +/* closure */ +int test_closure (GClosure *closure); +int test_closure_one_arg (GClosure *closure, int arg); + /* enums / flags */ typedef enum |