[gobject-introspection] Fix g_type_info_is_pointer() for overriden types of arguments.
- From: Pavel Holejsovsky <pholejs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] Fix g_type_info_is_pointer() for overriden types of arguments.
- Date: Mon, 12 Sep 2011 18:21:10 +0000 (UTC)
commit 9e903476ea20e0bc3593816b932eae6b0afd0f2e
Author: Pavel Holejsovsky <pholejs src gnome org>
Date: Mon Sep 12 19:54:39 2011 +0200
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
girepository/girparser.c | 4 +++
tests/repository/gitypelibtest.c | 39 ++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/girepository/girparser.c b/girepository/girparser.c
index 6984e82..0a4a65d 100644
--- a/girepository/girparser.c
+++ b/girepository/girparser.c
@@ -1947,6 +1947,10 @@ start_type (GMarkupParseContext *context,
const char *cp = ctype + strlen(ctype) - 1;
while (cp > ctype && *cp-- == '*')
pointer_depth++;
+
+ if (g_str_has_prefix (ctype, "gpointer")
+ || g_str_has_prefix (ctype, "gconstpointer"))
+ pointer_depth++;
}
if (ctx->current_typed->type == G_IR_NODE_PARAM &&
diff --git a/tests/repository/gitypelibtest.c b/tests/repository/gitypelibtest.c
index 6e69b09..de821e0 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]