diff options
Diffstat (limited to 'tests/scanner/regress.c')
-rw-r--r-- | tests/scanner/regress.c | 181 |
1 files changed, 147 insertions, 34 deletions
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index 2fba9fd5..4507bc6c 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -3,7 +3,6 @@ #include <stdlib.h> #include <glib-object.h> #include <gobject/gvaluecollector.h> -#include <cairo-gobject.h> #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: @@ -907,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) { @@ -1028,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) { @@ -1152,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; @@ -1163,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; @@ -1176,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) { @@ -1953,6 +1954,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 @@ -2125,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, @@ -2134,6 +2183,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 }; @@ -2192,6 +2242,27 @@ regress_test_obj_class_init (RegressTestObjClass *klass) 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 * @hash: (element-type utf8 GObject.Value): @@ -2250,6 +2321,7 @@ regress_test_obj_class_init (RegressTestObjClass *klass) 1, G_TYPE_OBJECT); +#ifndef _GI_DISABLE_CAIRO /** * RegressTestObj::sig-with-foreign-struct: * @self: an object @@ -2266,6 +2338,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", @@ -2340,6 +2413,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; @@ -2363,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", @@ -2378,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", @@ -2392,10 +2478,7 @@ regress_test_obj_class_init (RegressTestObjClass *klass) pspec); /** - * RegressTestObj:hash-table-old: - * - * Type: GLib.HashTable<utf8,gint8> - * Transfer: container + * RegressTestObj:hash-table-old: (type GLib.HashTable<utf8,gint8>) (transfer container) */ pspec = g_param_spec_boxed ("hash-table-old", "GHashTable property with <>", @@ -2407,10 +2490,7 @@ regress_test_obj_class_init (RegressTestObjClass *klass) pspec); /** - * RegressTestObj:list-old: - * - * Type: GLib.List<utf8> - * Transfer: none + * RegressTestObj:list-old: (type GLib.List<utf8>) (transfer none) */ pspec = g_param_spec_pointer ("list-old", "GList property with ()", @@ -2553,6 +2633,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) { @@ -2560,6 +2641,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) @@ -2829,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) @@ -3087,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 @@ -3324,6 +3399,20 @@ regress_test_callback_destroy_notify (RegressTestCallbackUserData callback, } /** + * 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: * * Invokes all callbacks installed by #test_callback_destroy_notify(), @@ -3500,6 +3589,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 @@ -3733,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); } @@ -3879,11 +3981,22 @@ 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) { } + +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'; +} |