diff options
author | Giovanni Campagna <gcampagna@src.gnome.org> | 2014-05-06 18:53:21 +0200 |
---|---|---|
committer | Giovanni Campagna <gcampagna@src.gnome.org> | 2014-07-03 10:31:17 +0200 |
commit | a4c9d09d7a89d3c80b4465a5c2ae0efa24158b24 (patch) | |
tree | f56b061a761dd45ed64d9015c8a7cf00b46be710 /tests/repository | |
parent | b2bf49eae922bffddc952fcc22e4acbd7d40c5f3 (diff) | |
download | gobject-introspection-a4c9d09d7a89d3c80b4465a5c2ae0efa24158b24.tar.gz |
Parse and expose ownership transfer for instance parameters
Knowing the ownership transfer for instance parameters is
necessary for correct memory management of functions which
"eat" their instance argument, such as g_dbus_method_invocation_return_*.
Parse this information from the gir file and store in the
typelib, and then provide new API on GICallableInfo to
retrieve this.
https://bugzilla.gnome.org/show_bug.cgi?id=729662
Diffstat (limited to 'tests/repository')
-rw-r--r-- | tests/repository/gitypelibtest.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/repository/gitypelibtest.c b/tests/repository/gitypelibtest.c index 565c95c3..7b9cb357 100644 --- a/tests/repository/gitypelibtest.c +++ b/tests/repository/gitypelibtest.c @@ -276,6 +276,34 @@ test_signal_array_len (GIRepository * repo) g_base_info_unref (testobj_info); } +static void +test_instance_transfer_ownership (GIRepository * repo) +{ + GIObjectInfo *testobj_info; + GIFunctionInfo *func_info; + GITransfer transfer; + + g_assert (g_irepository_require (repo, "Regress", NULL, 0, NULL)); + testobj_info = g_irepository_find_by_name (repo, "Regress", "TestObj"); + g_assert (testobj_info != NULL); + + func_info = g_object_info_find_method (testobj_info, "instance_method"); + g_assert (func_info != NULL); + transfer = g_callable_info_get_instance_ownership_transfer ((GICallableInfo*) func_info); + g_assert_cmpint (GI_TRANSFER_NOTHING, ==, transfer); + + g_base_info_unref (func_info); + + func_info = g_object_info_find_method (testobj_info, "instance_method_full"); + g_assert (func_info != NULL); + transfer = g_callable_info_get_instance_ownership_transfer ((GICallableInfo*) func_info); + g_assert_cmpint (GI_TRANSFER_EVERYTHING, ==, transfer); + + g_base_info_unref (func_info); + + g_base_info_unref (testobj_info); +} + int main (int argc, char **argv) { @@ -292,6 +320,7 @@ main (int argc, char **argv) test_hash_with_cairo_typelib (repo); test_char_types (repo); test_signal_array_len (repo); + test_instance_transfer_ownership (repo); exit (0); } |