From 9e903476ea20e0bc3593816b932eae6b0afd0f2e Mon Sep 17 00:00:00 2001 From: Pavel Holejsovsky Date: Mon, 12 Sep 2011 19:54:39 +0200 Subject: Fix g_type_info_is_pointer() for overriden types of arguments. Algorithm which detects whether argument type is pointer checks for trailing '*' characters in c:type .gir elements. This failed if ctype is either 'gpointer' or 'gconstpointer'. Add specific check for gpointer/gconstpointer types when deducing pointerness of the type. https://bugzilla.gnome.org/show_bug.cgi?id=658848 --- tests/repository/gitypelibtest.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'tests') diff --git a/tests/repository/gitypelibtest.c b/tests/repository/gitypelibtest.c index 6e69b096..de821e01 100644 --- a/tests/repository/gitypelibtest.c +++ b/tests/repository/gitypelibtest.c @@ -131,6 +131,44 @@ test_size_of_struct_with_array_of_anon_unions(GIRepository *repo) g_base_info_unref (struct_info); } +static void +test_is_pointer_for_struct_arg (GIRepository *repo) +{ + GITypelib *ret; + GError *error = NULL; + GIStructInfo *variant_info; + GIFunctionInfo *equal_info; + GIArgInfo *arg_info; + GITypeInfo *type_info; + + ret = g_irepository_require (repo, "GLib", NULL, 0, &error); + if (!ret) + g_error ("%s", error->message); + + variant_info = g_irepository_find_by_name (repo, "GLib", "Variant"); + if (!variant_info) + g_error ("Could not find GLib.Variant"); + + equal_info = g_struct_info_find_method (variant_info, "equal"); + if (!equal_info) + g_error ("Could not find GLib.Variant.equal()"); + + arg_info = g_callable_info_get_arg (equal_info, 0); + if (!arg_info) + g_error ("Could not find 1st arg of GLib.Variant.equal()"); + + type_info = g_arg_info_get_type (arg_info); + if (!type_info) + g_error ("Could not find typeinfo of 1st arg of GLib.Variant.equal()"); + + g_assert (g_type_info_is_pointer (type_info)); + + g_base_info_unref (type_info); + g_base_info_unref (arg_info); + g_base_info_unref (equal_info); + g_base_info_unref (variant_info); +} + int main(int argc, char **argv) { @@ -144,6 +182,7 @@ main(int argc, char **argv) test_enum_and_flags_cidentifier (repo); test_enum_and_flags_static_methods (repo); test_size_of_struct_with_array_of_anon_unions (repo); + test_is_pointer_for_struct_arg (repo); exit(0); } -- cgit v1.2.1