From ab8a6d9694ebd79b202b470c3742e8d521faf722 Mon Sep 17 00:00:00 2001 From: Matthew Booth Date: Tue, 6 Mar 2012 11:57:01 -0300 Subject: Fix matching of methods named *_get_type() The code which heuristically turned functions into class methods would always ignore any function called *_get_type or *_get_gtype. However, the code which looked for GI metadata functions to execute them was much more comprehensive, checking not just the name, but also that it had no parameters and that it returned a GType. This change abstracts the more comprehensive check into the Function class, and uses the same check in both places. https://bugzilla.gnome.org/show_bug.cgi?id=671218 --- tests/scanner/gettype.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 tests/scanner/gettype.c (limited to 'tests/scanner/gettype.c') diff --git a/tests/scanner/gettype.c b/tests/scanner/gettype.c new file mode 100644 index 00000000..cd816735 --- /dev/null +++ b/tests/scanner/gettype.c @@ -0,0 +1,62 @@ +#include "gettype.h" + +G_DEFINE_TYPE(GetTypeObject, gettype_object, G_TYPE_OBJECT); + +static void +gettype_object_class_init (GetTypeObjectClass *klass) +{ +} + +static void +gettype_object_init (GetTypeObject *object) +{ +} + +GetTypeObject * +gettype_object_new (void) +{ + return g_object_new (GETTYPE_TYPE_OBJECT, NULL); +} + +/** + * gettype_object_nonmeta1_get_type: + * @obj: self + * + * This shouldn't be scanned as a *_get_type function because it takes + * arguments. + * + * Returns: 0 + */ +GType +gettype_object_nonmeta1_get_type (GetTypeObject *obj) +{ + return 0; +} + +/** + * gettype_object_nonmeta2_get_type: + * + * This shouldn't be scanned as a *_get_type function because it doesn't return + * a GType. It will generate a warning. + * + * Returns: true + */ +gboolean +gettype_object_nonmeta2_get_type (void) +{ + return TRUE; +} + +/** + * gettype_object_nonmeta_get_gtype: + * + * This shouldn't be scanned as a *_get_type function because it doesn't return + * a GType. It will generate a warning. + * + * Returns: true + */ +gboolean +gettype_object_nonmeta_get_gtype (void) +{ + return TRUE; +} -- cgit v1.2.1