Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/repository/gitestrepo.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2009-02-28 00:02:48 (GMT)
committer Colin Walters <walters@verbum.org>2009-03-05 20:52:12 (GMT)
commitfdbe3cc3e1cfaa546648a76b1dca72beead0b65b (patch)
tree01156e22ec59d29c642d59ce7ad75f383d77466a /tests/repository/gitestrepo.c
parentb8e3172424ba956a0d18eae8deb305310b2cab74 (diff)
Bug 557383 - Virtual method support
Broadly speaking, this change adds the concept of <vfunc> to the .gir. The typelib already had most of the infrastructure for virtual functions, though there is one API addition. The scanner assumes that any class callback slot that doesn't match a signal name is a virtual. In the .gir, we write out *both* the <method> wrapper and a <vfunc>. If we can determine an association between them (based on the names matching, or a new Virtual: annotation), then we notate that in the .gir. The typelib gains an association from the vfunc to the function, if it exists. This will be useful for bindings since they already know how to consume FunctionInfo.
Diffstat (limited to 'tests/repository/gitestrepo.c')
-rw-r--r--tests/repository/gitestrepo.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/repository/gitestrepo.c b/tests/repository/gitestrepo.c
index 0e67467..a65116b 100644
--- a/tests/repository/gitestrepo.c
+++ b/tests/repository/gitestrepo.c
@@ -73,5 +73,53 @@ main(int argc, char **argv)
info = g_irepository_find_by_name (repo, "Gio", "ThisDoesNotExist");
g_assert (info == NULL);
+ /* vfunc tests */
+ {
+ GIVFuncInfo *vfunc;
+ GIFunctionInfo *invoker;
+
+ /* Test vfunc with invoker on interface */
+ info = g_irepository_find_by_name (repo, "Gio", "File");
+ g_assert (info != NULL);
+
+ vfunc = g_interface_info_find_vfunc ((GIInterfaceInfo*)info, "read_async");
+ g_assert (vfunc != NULL);
+
+ invoker = g_vfunc_info_get_invoker (vfunc);
+ g_assert (invoker != NULL);
+
+ g_assert (strcmp (g_base_info_get_name ((GIBaseInfo*)invoker), "read_async") == 0);
+
+ /* Test vfunc with no known invoker on object */
+ info = g_irepository_find_by_name (repo, "GObject", "Object");
+ g_assert (info != NULL);
+
+ vfunc = g_object_info_find_vfunc ((GIObjectInfo*)info, "dispose");
+ g_assert (vfunc != NULL);
+
+ /* Ok, maybe we should mark g_object_run_dispose as the invoker for
+ * dispose, but...eh. It's pretty special however you cut it.
+ */
+ invoker = g_vfunc_info_get_invoker (vfunc);
+ g_assert (invoker == NULL);
+
+ /* Test vfunc with invoker on object */
+ info = g_irepository_find_by_name (repo, "Gio", "AppLaunchContext");
+ g_assert (info != NULL);
+
+ vfunc = g_object_info_find_vfunc ((GIObjectInfo*)info, "get_display");
+ g_assert (vfunc != NULL);
+
+ invoker = g_vfunc_info_get_invoker (vfunc);
+ g_assert (invoker != NULL);
+ g_assert (strcmp (g_base_info_get_name ((GIBaseInfo*)invoker), "get_display") == 0);
+
+ /* And let's be sure we can find the method directly */
+
+ invoker = g_object_info_find_method ((GIObjectInfo*)info, "get_display");
+ g_assert (invoker != NULL);
+ g_assert (strcmp (g_base_info_get_name ((GIBaseInfo*)invoker), "get_display") == 0);
+ }
+
exit(0);
}