diff options
author | Tomeu Vizoso <tomeu.vizoso@collabora.co.uk> | 2011-02-04 13:16:20 +0100 |
---|---|---|
committer | Tomeu Vizoso <tomeu.vizoso@collabora.co.uk> | 2011-02-22 17:15:19 +0100 |
commit | c8e04058f412a1d8618e35589b738c92da017911 (patch) | |
tree | c117782928440ca95f9bbdf606653f6d923dff92 /tests | |
parent | 8f320a6b3c5d468cd4d5be580c167da071fc0856 (diff) | |
download | gobject-introspection-c8e04058f412a1d8618e35589b738c92da017911.tar.gz |
Add warnings for the (constructor) annotation
https://bugzilla.gnome.org/show_bug.cgi?id=641347
Diffstat (limited to 'tests')
-rw-r--r-- | tests/scanner/Regress-1.0-expected.gir | 5 | ||||
-rw-r--r-- | tests/scanner/regress.c | 10 | ||||
-rw-r--r-- | tests/scanner/regress.h | 1 | ||||
-rw-r--r-- | tests/warn/Makefile.am | 1 | ||||
-rw-r--r-- | tests/warn/invalid-constructor.h | 18 |
5 files changed, 35 insertions, 0 deletions
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index 10429ac7..2bae748b 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -372,6 +372,11 @@ use it should be.</doc> glib:type-name="RegressTestObj" glib:get-type="regress_test_obj_get_type" glib:type-struct="TestObjClass"> + <constructor name="constructor" c:identifier="regress_constructor"> + <return-value transfer-ownership="full"> + <type name="TestObj" c:type="RegressTestObj*"/> + </return-value> + </constructor> <constructor name="new" c:identifier="regress_test_obj_new"> <return-value transfer-ownership="full"> <type name="TestObj" c:type="RegressTestObj*"/> diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index 8b71bc8c..3ed9a862 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -1920,6 +1920,16 @@ regress_test_obj_new (RegressTestObj *obj) } /** + * regress_constructor: (constructor) + * + */ +RegressTestObj * +regress_constructor (void) +{ + return g_object_new (REGRESS_TEST_TYPE_OBJ, NULL); +} + +/** * regress_test_obj_new_from_file: */ RegressTestObj * diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h index 360390d4..89209ebc 100644 --- a/tests/scanner/regress.h +++ b/tests/scanner/regress.h @@ -298,6 +298,7 @@ struct _RegressTestObjClass GType regress_test_obj_get_type (void); RegressTestObj* regress_test_obj_new (RegressTestObj *obj); +RegressTestObj* regress_constructor (void); RegressTestObj* regress_test_obj_new_from_file (const char *x, GError **error); void regress_test_obj_set_bare (RegressTestObj *obj, GObject *bare); int regress_test_obj_instance_method (RegressTestObj *obj); diff --git a/tests/warn/Makefile.am b/tests/warn/Makefile.am index 571ca4a3..7d81d9ef 100644 --- a/tests/warn/Makefile.am +++ b/tests/warn/Makefile.am @@ -6,6 +6,7 @@ TESTS = \ return-gobject.h \ invalid-array.h \ invalid-closure.h \ + invalid-constructor.h \ invalid-element-type.h \ invalid-method.h \ invalid-option.h \ diff --git a/tests/warn/invalid-constructor.h b/tests/warn/invalid-constructor.h new file mode 100644 index 00000000..a80d79ea --- /dev/null +++ b/tests/warn/invalid-constructor.h @@ -0,0 +1,18 @@ +#include "common.h" + +/** + * test_constructor_invalid_return: (constructor) + * + */ +int test_constructor_invalid_return(); + +// EXPECT:7: Warning: Test: test_constructor_invalid_return: Constructors must return an instance of their class + +/** + * test_constructor_invalid_return_pointer: (constructor) + * + */ +GClosure *test_constructor_invalid_return_pointer(); + +// EXPECT:15: Warning: Test: test_constructor_invalid_return_pointer: Constructors must belong to the same namespace as the class they belong to + |