From d86fc68738bb31e1ed26680ca5d1548721bc9de8 Mon Sep 17 00:00:00 2001 From: Simon Feltman Date: Wed, 10 Oct 2012 16:20:50 -0700 Subject: [gobject-introspection] Add test method for GDestroy with no user data Added regress_test_callback_destroy_notify_no_user_data. Updated Regress-1.0-expected.gir https://bugzilla.gnome.org/show_bug.cgi?id=685922 --- tests/scanner/regress.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/scanner/regress.c') diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index 2fba9fd5..c6ca6b74 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -3323,6 +3323,20 @@ regress_test_callback_destroy_notify (RegressTestCallbackUserData callback, return retval; } +/** + * regress_test_callback_destroy_notify_no_user_data: + * @callback: (scope notified): + * + * Adds a scope notified callback with no user data. This can invoke an error + * condition in bindings which needs to be tested. + **/ +int +regress_test_callback_destroy_notify_no_user_data (RegressTestCallbackUserData callback, + GDestroyNotify notify) +{ + return regress_test_callback_destroy_notify(callback, NULL, notify); +} + /** * regress_test_callback_thaw_notifications: * -- cgit v1.2.1 From 6fc366a66c58039aec345cc531c329729b6bce18 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sat, 27 Oct 2012 13:54:44 -0400 Subject: regress: Add a test case for skipping a function with an unannotated callback https://bugzilla.gnome.org/show_bug.cgi?id=685399 --- tests/scanner/regress.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/scanner/regress.c') diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index c6ca6b74..bdc1dc3c 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -3514,6 +3514,18 @@ regress_test_owned_gerror_callback (RegressTestCallbackOwnedGError callback) callback (error); } +/** + * regress_test_skip_unannotated_callback: (skip) + * @callback: No annotation here + * + * Should not emit a warning: + * https://bugzilla.gnome.org/show_bug.cgi?id=685399 + */ +void +regress_test_skip_unannotated_callback (RegressTestCallback callback) +{ +} + /* interface */ static void -- cgit v1.2.1 From 5153efd29e9a813a97d58905340c0ec4af04c5bd Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Tue, 20 Nov 2012 00:20:46 +0100 Subject: Add more tests for boxed types gjs needs a boxed type that cannot be trivially allocated but has also a complex constructor. https://bugzilla.gnome.org/show_bug.cgi?id=612033 --- tests/scanner/regress.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'tests/scanner/regress.c') diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index bdc1dc3c..b7526bfb 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -1953,6 +1953,53 @@ G_DEFINE_BOXED_TYPE(RegressTestBoxedC, regress_test_boxed_c_ref, regress_test_boxed_c_unref); +struct _RegressTestBoxedD { + char *a_string; + gint a_int; +}; + +RegressTestBoxedD * +regress_test_boxed_d_new (const char *a_string, int a_int) +{ + RegressTestBoxedD *boxed; + + boxed = g_slice_new (RegressTestBoxedD); + boxed->a_string = g_strdup (a_string); + boxed->a_int = a_int; + + return boxed; +} + +RegressTestBoxedD * +regress_test_boxed_d_copy (RegressTestBoxedD *boxed) +{ + RegressTestBoxedD *ret; + + ret = g_slice_new (RegressTestBoxedD); + ret->a_string = g_strdup (boxed->a_string); + ret->a_int = boxed->a_int; + + return ret; +} + +void +regress_test_boxed_d_free (RegressTestBoxedD *boxed) +{ + g_free (boxed->a_string); + g_slice_free (RegressTestBoxedD, boxed); +} + +int +regress_test_boxed_d_get_magic (RegressTestBoxedD *boxed) +{ + return strlen (boxed->a_string) + boxed->a_int; +} + +G_DEFINE_BOXED_TYPE(RegressTestBoxedD, + regress_test_boxed_d, + regress_test_boxed_d_copy, + regress_test_boxed_d_free); + G_DEFINE_TYPE(RegressTestObj, regress_test_obj, G_TYPE_OBJECT); enum -- cgit v1.2.1 From 97b30ae5e77d5e36d127d02b247d6d41b8e1c8c3 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sun, 2 Dec 2012 12:15:53 -0500 Subject: WarnLib: New library for testing API that emits warnings Both GIMarshallingTests and Regress right now use --warn-error; but in some cases (e.g. GErrors without a corresponding enum), we still want bindings to support the functionality. So add this new library where we can add C API that emits introspection warnings. https://bugzilla.gnome.org/show_bug.cgi?id=689488 --- tests/scanner/regress.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/scanner/regress.c') diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index b7526bfb..27791d7e 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -1656,6 +1656,20 @@ regress_atest_error_quark (void) return g_quark_from_static_string ("regress-atest-error"); } +GQuark +regress_unpaired_error_quark (void) +{ + return g_quark_from_static_string ("regress-unpaired-error"); +} + +gboolean +regress_throw_unpaired (GError **error) +{ + g_set_error_literal (error, regress_unpaired_error_quark (), 0, + "Unpaired error"); + return FALSE; +} + /* structures */ /** -- cgit v1.2.1 From 2663872328758510c713546c610c12af05ffecb3 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 5 Dec 2012 15:40:15 -0500 Subject: tests: Fix up WarnLib build, remove accidental additions to regress.c Previous WarnLib commit was broken. --- tests/scanner/regress.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'tests/scanner/regress.c') diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index 27791d7e..b7526bfb 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -1656,20 +1656,6 @@ regress_atest_error_quark (void) return g_quark_from_static_string ("regress-atest-error"); } -GQuark -regress_unpaired_error_quark (void) -{ - return g_quark_from_static_string ("regress-unpaired-error"); -} - -gboolean -regress_throw_unpaired (GError **error) -{ - g_set_error_literal (error, regress_unpaired_error_quark (), 0, - "Unpaired error"); - return FALSE; -} - /* structures */ /** -- cgit v1.2.1 From eff011ce1d274e9add73fbf71fb8617ba37fb9f8 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Fri, 4 Jan 2013 09:32:45 +0100 Subject: Regress: Add signal returning a GArray https://bugzilla.gnome.org/show_bug.cgi?id=690514 --- tests/scanner/regress.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/scanner/regress.c') diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index b7526bfb..06089c38 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -2181,6 +2181,7 @@ enum { REGRESS_TEST_OBJ_SIGNAL_ALL, REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INT64_PROP, REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_UINT64_PROP, + REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INTARRAY_RET, N_REGRESS_TEST_OBJ_SIGNALS }; @@ -2387,6 +2388,25 @@ regress_test_obj_class_init (RegressTestObjClass *klass) 1, G_TYPE_UINT64); + /** + * RegressTestObj::sig-with-intarray-ret: + * @self: an object + * @i: an integer + * + * Returns: (array zero-terminated=1) (element-type gint) (transfer full): + */ + regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INTARRAY_RET] = + g_signal_new ("sig-with-intarray-ret", + G_TYPE_FROM_CLASS (gobject_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, + NULL, + g_cclosure_marshal_VOID__BOXED, + G_TYPE_ARRAY, + 1, + G_TYPE_INT); + gobject_class->set_property = regress_test_obj_set_property; gobject_class->get_property = regress_test_obj_get_property; gobject_class->dispose = regress_test_obj_dispose; -- cgit v1.2.1 From f5631640751b5a998b3616db78dd5dcd9ee62126 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 7 Jan 2013 12:57:17 -0500 Subject: Clean up cairo handling somewhat I'm building on RHEL6 which doesn't have cairo-gobject. Now, we tried to support this in that 'make' would succeed, but 'make check' would blow up. This patch allows more of 'make check' to succeed - I just need to figure out how to make the diff against the -expected.gir work. What's more important though, is this will allow gjs to also #define _GI_DISABLE_CAIRO. --- tests/scanner/regress.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests/scanner/regress.c') diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index 06089c38..89dc8738 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -3,7 +3,6 @@ #include #include #include -#include #include "regress.h" @@ -285,6 +284,7 @@ regress_test_value_return(int i) /************************************************************************/ /* foreign structs */ +#ifndef _GI_DISABLE_CAIRO /** * regress_test_cairo_context_full_return: * @@ -365,6 +365,7 @@ regress_test_cairo_surface_full_out (cairo_surface_t **surface) { *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 10, 10); } +#endif /** * regress_test_gvariant_i: @@ -2298,6 +2299,7 @@ regress_test_obj_class_init (RegressTestObjClass *klass) 1, G_TYPE_OBJECT); +#ifndef _GI_DISABLE_CAIRO /** * RegressTestObj::sig-with-foreign-struct: * @self: an object @@ -2314,6 +2316,7 @@ regress_test_obj_class_init (RegressTestObjClass *klass) G_TYPE_NONE, 1, CAIRO_GOBJECT_TYPE_CONTEXT); +#endif regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_FIRST] = g_signal_new ("first", @@ -2620,6 +2623,7 @@ regress_test_obj_emit_sig_with_obj (RegressTestObj *obj) g_object_unref (obj_param); } +#ifndef _GI_DISABLE_CAIRO void regress_test_obj_emit_sig_with_foreign_struct (RegressTestObj *obj) { @@ -2627,6 +2631,7 @@ regress_test_obj_emit_sig_with_foreign_struct (RegressTestObj *obj) g_signal_emit_by_name (obj, "sig-with-foreign-struct", cr); cairo_destroy (cr); } +#endif void regress_test_obj_emit_sig_with_int64 (RegressTestObj *obj) -- cgit v1.2.1 From f65395f5f9f1ef980315ae11c454c324bb61e24d Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 15 Jan 2013 10:05:20 +0100 Subject: tests: Fix compiler warnings Fix (void) function declarations that occur with -Wstrict-prototypes, and the g_param_spec_get_name() which drops the const from its argument. --- tests/scanner/regress.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/scanner/regress.c') diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index 89dc8738..b5fc8585 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -908,7 +908,7 @@ regress_test_array_int_null_out (int **arr, int *len) /* GList */ static /*const*/ GList * -regress_test_sequence_list() +regress_test_sequence_list (void) { static GList *list = NULL; if (!list) { @@ -1029,7 +1029,7 @@ regress_test_glist_null_out (GSList **out_list) /* GSList */ static /*const*/ GSList * -regress_test_sequence_slist() +regress_test_sequence_slist (void) { static GSList *list = NULL; if (!list) { @@ -1153,7 +1153,7 @@ static char *table_data[3][2] = { }; static GHashTable * -regress_test_table_ghash_new_container() +regress_test_table_ghash_new_container (void) { GHashTable *hash; int i; @@ -1164,7 +1164,7 @@ regress_test_table_ghash_new_container() } static GHashTable * -regress_test_table_ghash_new_full() +regress_test_table_ghash_new_full (void) { GHashTable *hash; int i; @@ -1177,7 +1177,7 @@ regress_test_table_ghash_new_full() } static /*const*/ GHashTable * -regress_test_table_ghash_const() +regress_test_table_ghash_const (void) { static GHashTable *hash = NULL; if (!hash) { -- cgit v1.2.1 From 2af5386d6cc1deba21f03c398c6368a9de6ed4ba Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 27 Feb 2013 12:14:16 +0100 Subject: Add test case for signal with a C array and length argument By-product of https://bugzilla.gnome.org/show_bug.cgi?id=662241. --- tests/scanner/regress.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/scanner/regress.c') diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index b5fc8585..f54c2f91 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -2173,6 +2173,7 @@ regress_test_obj_default_matrix (RegressTestObj *obj, const char *somestr) enum { REGRESS_TEST_OBJ_SIGNAL_SIG_NEW_WITH_ARRAY_PROP, + REGRESS_TEST_OBJ_SIGNAL_SIG_NEW_WITH_ARRAY_LEN_PROP, REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_HASH_PROP, REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_STRV, REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_OBJ, @@ -2240,6 +2241,27 @@ regress_test_obj_class_init (RegressTestObjClass *klass) 1, G_TYPE_ARRAY); + /** + * RegressTestObj::sig-with-array-len-prop: + * @self: an object + * @arr: (array length=len) (element-type uint) (allow-none): numbers, or %NULL + * @len: length of @arr, or 0 + * + * This test signal similar to GSettings::change-event + */ + regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_NEW_WITH_ARRAY_LEN_PROP] = + g_signal_new ("sig-with-array-len-prop", + G_TYPE_FROM_CLASS (gobject_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, + NULL, + NULL, + G_TYPE_NONE, + 2, + G_TYPE_POINTER, + G_TYPE_INT); + /** * RegressTestObj::sig-with-hash-prop: * @self: an object -- cgit v1.2.1 From a09072bd1f75dfc7497ed599e03e331bff411fd4 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 19 Apr 2013 19:12:14 -0400 Subject: tests: Add a struct with fixed-size gchar See https://bugzilla.redhat.com/920595 --- tests/scanner/regress.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/scanner/regress.c') diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index f54c2f91..d32c52be 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -4007,3 +4007,11 @@ void regress_test_versioning (void) { } + +void +regress_like_xkl_config_item_set_name (RegressLikeXklConfigItem *self, + const char *name) +{ + strncpy (self->name, name, sizeof (self->name) - 1); + self->name[sizeof(self->name)-1] = '\0'; +} -- cgit v1.2.1 From b6954536f32352c0c29fe5a9a73de1018559a9c5 Mon Sep 17 00:00:00 2001 From: Dieter Verfaillie Date: Thu, 25 Jul 2013 17:49:11 +0200 Subject: giscanner: deprecate GObject-Introspection GTK-Doc tags After discussing a different issue with the GTK-Doc maintainers, we learned that our g-i specific top level tags should never have existed in the first place. The prefered notation for annotations that apply to the identifier should be written on the identifier line, for example like what we already do with (skip). As a result, this patch deprecates g-i specific top level tags and implements them as annotations on the identifier instead but still keeps support for malformed comment blocks using g-i specific top level tags. This means that all annotated code "out there" will continue to work just fine with this version of g-i, but when a developer decides to fix deprecation warnings in his/her comment blocks, the dependency on g-i needs to be raised to a version that contains at least this patch. #676133 https://bugzilla.gnome.org/show_bug.cgi?id=676133 --- tests/scanner/regress.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) (limited to 'tests/scanner/regress.c') diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index d32c52be..aa9f83a8 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -2455,10 +2455,7 @@ regress_test_obj_class_init (RegressTestObjClass *klass) pspec); /** - * RegressTestObj:hash-table: - * - * Type: GLib.HashTable(utf8,gint8) - * Transfer: container + * RegressTestObj:hash-table: (type GLib.HashTable(utf8,gint8)) (transfer container) */ pspec = g_param_spec_boxed ("hash-table", "GHashTable property", @@ -2470,10 +2467,7 @@ regress_test_obj_class_init (RegressTestObjClass *klass) pspec); /** - * RegressTestObj:list: - * - * Type: GLib.List(utf8) - * Transfer: none + * RegressTestObj:list: (type GLib.List(utf8)) (transfer none) */ pspec = g_param_spec_pointer ("list", "GList property", @@ -2484,10 +2478,7 @@ regress_test_obj_class_init (RegressTestObjClass *klass) pspec); /** - * RegressTestObj:hash-table-old: - * - * Type: GLib.HashTable - * Transfer: container + * RegressTestObj:hash-table-old: (type GLib.HashTable) (transfer container) */ pspec = g_param_spec_boxed ("hash-table-old", "GHashTable property with <>", @@ -2499,10 +2490,7 @@ regress_test_obj_class_init (RegressTestObjClass *klass) pspec); /** - * RegressTestObj:list-old: - * - * Type: GLib.List - * Transfer: none + * RegressTestObj:list-old: (type GLib.List) (transfer none) */ pspec = g_param_spec_pointer ("list-old", "GList property with ()", @@ -2923,15 +2911,13 @@ regress_test_obj_skip_inout_param (RegressTestObj *obj, } /** - * regress_test_obj_do_matrix: + * regress_test_obj_do_matrix: (virtual matrix) * @obj: A #RegressTestObj * @somestr: Meaningless string * * This method is virtual. Notably its name differs from the virtual * slot name, which makes it useful for testing bindings handle this * case. - * - * Virtual: matrix */ int regress_test_obj_do_matrix (RegressTestObj *obj, const char *somestr) @@ -3181,12 +3167,7 @@ regress_test_fundamental_object_init (GTypeInstance * instance, gpointer klass) } /** - * RegressTestFundamentalObject: - * - * Ref Func: regress_test_fundamental_object_ref - * Unref Func: regress_test_fundamental_object_unref - * Set Value Func: regress_test_value_set_fundamental_object - * Get Value Func: regress_test_value_get_fundamental_object + * RegressTestFundamentalObject: (ref-func regress_test_fundamental_object_ref) (unref-func regress_test_fundamental_object_unref) (set-value-func regress_test_value_set_fundamental_object) (get-value-func regress_test_value_get_fundamental_object) */ GType -- cgit v1.2.1 From 556bb8ee3402b92e2936ed3b594cdfc0b04a9db5 Mon Sep 17 00:00:00 2001 From: Dieter Verfaillie Date: Tue, 21 May 2013 10:47:11 +0200 Subject: giscanner: fix description field storage in .gir files GTK-Doc description fields for tags can contain multiple lines and even multiple paragraphs. Whitespace cannot be preserved in XML attributes, so we move the "deprecated" description text into a "" element right next to where we already have the "" element. Keep the "deprecated" attribute around for backwards compatibility though, but set its value to "1" (analogous to the "writable", "contruct", etc attributes) if the annotated symbol is marked as deprecated. While at it, add and which was not yet available in the .gir files... This takes care of the "Since:", "Stability:" and "Deprecated:" GTK-Doc tags. Nothing needs to be done for the "Returns:" tag as as we already write a "" child element on "". --- tests/scanner/regress.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tests/scanner/regress.c') diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index aa9f83a8..14df4744 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -3980,9 +3980,12 @@ regress_has_parameter_named_attrs (int foo, /** * regress_test_versioning: * - * Since: 1.32.1 - * Deprecated: 1.33.3: Use foobar instead - * Stability: Unstable + * Since: 1.32.1: Actually, this function was introduced earlier + * than this, but it didn't do anything before this version. + * Deprecated: 1.33.3: This function has been deprecated, + * because it sucks. Use foobar instead. + * Stability: Unstable: Maybe someday we will find the time + * to stabilize this function. Who knows? */ void regress_test_versioning (void) -- cgit v1.2.1 From 9c2a45a635d9cd6ac752245be4af6d3f00212349 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 14 Jan 2014 08:50:25 +0100 Subject: regress: Fix regress_test_torture_signature_2() to actually call the callback This provides a test case for https://bugzilla.gnome.org/show_bug.cgi?id=722104 --- tests/scanner/regress.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/scanner/regress.c') diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index 14df4744..4507bc6c 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -3834,6 +3834,7 @@ regress_test_torture_signature_2 (int x, *y = x; *z = x * 2; *q = g_utf8_strlen (foo, -1) + m; + callback(user_data); notify (user_data); } -- cgit v1.2.1