2 #include "everything.h"
5 gboolean test_boolean (gboolean in)
10 gint8 test_int8 (gint8 in)
15 guint8 test_uint8 (guint8 in)
20 gint16 test_int16 (gint16 in)
25 guint16 test_uint16 (guint16 in)
30 gint32 test_int32 (gint32 in)
35 guint32 test_uint32 (guint32 in)
40 gint64 test_int64 (gint64 in)
45 guint64 test_uint64 (guint64 in)
50 gint test_int (gint in)
55 guint test_uint (guint in)
60 glong test_long (glong in)
65 gulong test_ulong (gulong in)
70 gssize test_ssize (gssize in)
75 gsize test_size (gsize in)
80 gfloat test_float (gfloat in)
85 gdouble test_double (gdouble in)
91 time_t test_timet (time_t in)
96 GType test_gtype (GType in)
101 int test_closure (GClosure *closure)
103 GValue return_value = {0, };
106 g_value_init (&return_value, G_TYPE_INT);
108 g_closure_invoke (closure,
113 ret = g_value_get_int (&return_value);
115 g_value_unset(&return_value);
120 int test_closure_one_arg (GClosure *closure, int arg)
122 GValue return_value = {0, };
126 g_value_init (&return_value, G_TYPE_INT);
128 memset (&arguments[0], 0, sizeof (arguments));
129 g_value_init (&arguments[0], G_TYPE_INT);
130 g_value_set_int (&arguments[0], arg);
132 g_closure_invoke (closure,
137 ret = g_value_get_int (&return_value);
139 g_value_unset(&return_value);
140 g_value_unset(&arguments[0]);
147 * @v: (transfer none): a GValue expected to contain an int
149 * Return value: the int contained in the GValue.
151 int test_int_value_arg(const GValue *v) {
154 i = g_value_get_int (v);
164 * Return value: (transfer none): the int wrapped in a GValue.
166 const GValue *test_value_return(int i) {
167 memset(&value, '\0', sizeof(GValue));
169 g_value_init (&value, G_TYPE_INT);
170 g_value_set_int (&value, i);
176 /************************************************************************/
178 /* insert BLACK HEART SUIT to ensure UTF-8 doesn't get mangled */
179 static const char utf8_const[] = "const \xe2\x99\xa5 utf8";
180 static const char utf8_nonconst[] = "nonconst \xe2\x99\xa5 utf8";
183 * test_utf8_const_return:
184 * Return value: <const char*> UTF-8 string
186 G_CONST_RETURN char *test_utf8_const_return (void)
188 /* transfer mode none */
193 * test_utf8_nonconst_return:
194 * Return value: <char*> UTF-8 string
196 char *test_utf8_nonconst_return (void)
198 /* transfer mode full */
199 return g_strdup (utf8_nonconst);
202 void test_utf8_nonconst_in (char *in)
204 /* transfer mode full */
205 g_assert (strcmp (in, utf8_nonconst) == 0);
209 void test_utf8_const_in (const char *in)
211 /* transfer mode none */
212 g_assert (strcmp (in, utf8_const) == 0);
217 * @out: (out) (transfer full):
219 void test_utf8_out (char **out)
221 /* out parameter, transfer mode full */
222 *out = g_strdup (utf8_nonconst);
229 void test_utf8_inout (char **inout)
231 /* inout parameter, transfer mode full */
232 g_assert (strcmp (*inout, utf8_const) == 0);
234 *inout = g_strdup (utf8_nonconst);
238 * test_filename_return:
240 * Return value: (element-type filename) (transfer full): list of strings
242 GSList *test_filename_return (void)
244 GSList *filenames = NULL;
245 filenames = g_slist_prepend (filenames, g_filename_from_utf8("/etc/fstab", -1, NULL, NULL, NULL));
246 filenames = g_slist_prepend (filenames, g_filename_from_utf8("åäö", -1, NULL, NULL, NULL));
250 /* non-basic-types */
252 static const char *test_sequence[] = {"1", "2", "3"};
259 * @ints: (array length=n_ints): List of ints
262 test_array_int_in (int n_ints, int *ints)
265 for (i = 0; i < n_ints; i++)
271 * test_array_gint8_in:
273 * @ints: (array length=n_ints): List of ints
276 test_array_gint8_in (int n_ints, gint8 *ints)
279 for (i = 0; i < n_ints; i++)
285 * test_array_gint16_in:
287 * @ints: (array length=n_ints): List of ints
290 test_array_gint16_in (int n_ints, gint16 *ints)
293 for (i = 0; i < n_ints; i++)
299 * test_array_gint32_in:
301 * @ints: (array length=n_ints): List of ints
304 test_array_gint32_in (int n_ints, gint32 *ints)
308 for (i = 0; i < n_ints; i++)
314 * test_array_gint64_in:
316 * @ints: (array length=n_ints): List of ints
319 test_array_gint64_in (int n_ints, gint64 *ints)
323 for (i = 0; i < n_ints; i++)
330 * @arr: (array zero-terminated=1) (transfer none):
333 test_strv_in (char **arr)
335 if (g_strv_length (arr) != 3)
337 if (strcmp (arr[0], "1") != 0)
339 if (strcmp (arr[1], "2") != 0)
341 if (strcmp (arr[2], "3") != 0)
347 * test_strv_in_container:
348 * @arr: (array zero-terminated=1) (transfer container):
351 test_strv_in_container (char **arr)
353 gboolean result = test_strv_in (arr);
359 * test_array_gtype_in:
361 * @types: (array length=n_types): List of types
362 * Return value: string representation of provided types
365 test_array_gtype_in (int n_types, GType *types)
370 string = g_string_new ("[");
371 for (i = 0; i < n_types; i++)
373 g_string_append (string, g_type_name (types[i]));
374 g_string_append_c (string, ',');
376 g_string_append_c (string, ']');
377 return g_string_free (string, FALSE);
383 * No annotations here. We want the default to Do The Right Thing.
390 char **ret = g_new (char *, n);
391 ret[i++] = g_strdup ("thanks");
392 ret[i++] = g_strdup ("for");
393 ret[i++] = g_strdup ("all");
394 ret[i++] = g_strdup ("the");
395 ret[i++] = g_strdup ("fish");
402 * test_strv_out_container:
404 * Return value: (array zero-terminated=1) (transfer container):
407 test_strv_out_container (void)
409 char **ret = g_new (char *, 4);
419 * @retp: (array zero-terminated=1) (out) (transfer container):
422 test_strv_outarg (char ***retp)
424 char **ret = g_new (char *, 4);
433 * test_array_int_in_take:
435 * @ints: (array length=n_ints) (transfer full): List of ints
437 int test_array_int_in_take (int n_ints, int *ints)
440 for (i = 0; i < n_ints; i++)
449 * No annotations here. We want the default to Do The Right Thing.
452 test_strv_out_c (void)
454 static char **ret = NULL;
457 ret = test_strv_out ();
459 return (const char * const *) ret;
463 * test_array_int_full_out:
464 * @len: length of the returned array.
465 * Returns: (array length=len) (transfer full): a new array of integers.
468 test_array_int_full_out(int *len) {
471 result = g_malloc0(sizeof(*result) * (*len));
472 for (i=1; i < (*len); i++)
473 result[i] = result[i-1] + 1;
478 * test_array_int_none_out:
479 * @len: length of the returned array.
480 * Returns: (array length=len) (transfer none): a static array of integers.
483 test_array_int_none_out(int *len) {
484 static int result[5] = { 1, 2, 3, 4, 5 };
491 /************************************************************************/
494 static /*const*/ GList *test_sequence_list()
496 static GList *list = NULL;
499 for (i = 0; i < G_N_ELEMENTS(test_sequence); ++i) {
500 list = g_list_prepend (list, (gpointer)test_sequence[i]);
502 list = g_list_reverse (list);
509 * @in: (element-type utf8) (transfer full):
511 void test_glist_free (GList *in)
513 g_list_foreach (in, (GFunc)g_free, NULL);
518 * test_glist_nothing_return:
520 * Return value: (element-type utf8) (transfer none):
522 G_CONST_RETURN GList *test_glist_nothing_return (void)
524 return test_sequence_list ();
528 * test_glist_nothing_return2:
530 * Return value: (element-type utf8) (transfer none):
532 GList *test_glist_nothing_return2 (void)
534 return test_sequence_list ();
538 * test_glist_container_return:
540 * Return value: (element-type utf8) (transfer container):
542 GList *test_glist_container_return (void)
544 return g_list_copy (test_sequence_list ());
548 * test_glist_everything_return:
550 * Return value: (element-type utf8) (transfer full):
552 GList *test_glist_everything_return (void)
557 list = g_list_copy (test_sequence_list ());
558 for (l = list; l != NULL; l = l->next)
559 l->data = g_strdup (l->data);
563 static void assert_test_sequence_list (const GList *in)
568 for (i = 0, l = in; l != NULL; ++i, l = l->next) {
569 g_assert (i < G_N_ELEMENTS(test_sequence));
570 g_assert (strcmp (l->data, test_sequence[i]) == 0);
572 g_assert (i == G_N_ELEMENTS(test_sequence));
576 * test_glist_nothing_in:
577 * @in: (element-type utf8):
579 void test_glist_nothing_in (const GList *in)
581 assert_test_sequence_list (in);
585 * test_glist_nothing_in2:
586 * @in: (element-type utf8):
588 void test_glist_nothing_in2 (GList *in)
590 assert_test_sequence_list (in);
594 * test_glist_container_in:
595 * @in: (element-type utf8) (transfer container):
597 void test_glist_container_in (GList *in)
599 assert_test_sequence_list (in);
604 * test_glist_everything_in:
605 * @in: (element-type utf8) (transfer full):
607 void test_glist_everything_in (GList *in)
609 assert_test_sequence_list (in);
610 test_glist_free (in);
613 /************************************************************************/
616 static /*const*/ GSList *test_sequence_slist()
618 static GSList *list = NULL;
621 for (i = 0; i < G_N_ELEMENTS(test_sequence); ++i) {
622 list = g_slist_prepend (list, (gpointer)test_sequence[i]);
624 list = g_slist_reverse (list);
631 * @in: (element-type utf8) (transfer full):
633 void test_gslist_free (GSList *in)
635 g_slist_foreach (in, (GFunc)g_free, NULL);
640 * test_gslist_nothing_return:
642 * Return value: (element-type utf8) (transfer none):
644 G_CONST_RETURN GSList *test_gslist_nothing_return (void)
646 return test_sequence_slist ();
650 * test_gslist_nothing_return2:
652 * Return value: (element-type utf8) (transfer none):
654 GSList *test_gslist_nothing_return2 (void)
656 return test_sequence_slist ();
660 * test_gslist_container_return:
662 * Return value: (element-type utf8) (transfer container):
664 GSList *test_gslist_container_return (void)
666 return g_slist_copy (test_sequence_slist ());
670 * test_gslist_everything_return:
672 * Return value: (element-type utf8) (transfer full):
674 GSList *test_gslist_everything_return (void)
679 list = g_slist_copy (test_sequence_slist ());
680 for (l = list; l != NULL; l = l->next)
681 l->data = g_strdup (l->data);
685 static void assert_test_sequence_slist (const GSList *in)
690 for (i = 0, l = in; l != NULL; ++i, l = l->next) {
691 g_assert (i < G_N_ELEMENTS(test_sequence));
692 g_assert (strcmp (l->data, test_sequence[i]) == 0);
694 g_assert (i == G_N_ELEMENTS(test_sequence));
698 * test_gslist_nothing_in:
699 * @in: (element-type utf8):
701 void test_gslist_nothing_in (const GSList *in)
703 assert_test_sequence_slist (in);
707 * test_gslist_nothing_in2:
708 * @in: (element-type utf8):
710 void test_gslist_nothing_in2 (GSList *in)
712 assert_test_sequence_slist (in);
716 * test_gslist_container_in:
717 * @in: (element-type utf8) (transfer container):
719 void test_gslist_container_in (GSList *in)
721 assert_test_sequence_slist (in);
726 * test_gslist_everything_in:
727 * @in: (element-type utf8) (transfer full):
729 void test_gslist_everything_in (GSList *in)
731 assert_test_sequence_slist (in);
732 test_gslist_free (in);
735 /************************************************************************/
738 static char *table_data[3][2] = {
739 { "foo", "bar" }, { "baz", "bat" }, { "qux", "quux" }
742 static GHashTable *test_table_ghash_new_container()
746 hash = g_hash_table_new(g_str_hash, g_str_equal);
748 g_hash_table_insert(hash, table_data[i][0], table_data[i][1]);
752 static GHashTable *test_table_ghash_new_full()
756 hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
758 g_hash_table_insert(hash,
759 g_strdup(table_data[i][0]),
760 g_strdup(table_data[i][1]));
764 static /*const*/ GHashTable *test_table_ghash_const()
766 static GHashTable *hash = NULL;
768 hash = test_table_ghash_new_container();
775 * @in: (transfer full) (element-type utf8 utf8)
777 void test_ghash_free (GHashTable *in)
779 /* keys and values are deleted iff an appropriate element destroy function
781 g_hash_table_unref(in);
785 * test_ghash_null_return:
787 * Return value: (element-type utf8 utf8) (transfer none) (allow-none):
789 G_CONST_RETURN GHashTable *test_ghash_null_return (void)
795 * test_ghash_nothing_return:
797 * Return value: (element-type utf8 utf8) (transfer none):
799 G_CONST_RETURN GHashTable *test_ghash_nothing_return (void)
801 return test_table_ghash_const ();
805 * test_ghash_nothing_return2:
807 * Return value: (element-type utf8 utf8) (transfer none):
809 GHashTable *test_ghash_nothing_return2 (void)
811 return test_table_ghash_const ();
815 * test_ghash_container_return:
817 * Return value: (element-type utf8 utf8) (transfer container):
819 GHashTable *test_ghash_container_return (void)
821 return test_table_ghash_new_container ();
825 * test_ghash_everything_return:
827 * Return value: (element-type utf8 utf8) (transfer full):
829 GHashTable *test_ghash_everything_return (void)
831 return test_table_ghash_new_full ();
834 static void assert_test_table_ghash (const GHashTable *in)
836 GHashTable *h = test_table_ghash_const();
840 g_assert(g_hash_table_size(h) ==
841 g_hash_table_size((GHashTable*)in));
843 g_hash_table_iter_init(&iter, (GHashTable*)in);
844 while (g_hash_table_iter_next (&iter, &key, &value))
845 g_assert( strcmp(g_hash_table_lookup(h, (char*)key), (char*)value) == 0);
849 * test_ghash_null_in:
850 * @in: (element-type utf8 utf8) (allow-none):
852 void test_ghash_null_in (const GHashTable *in)
854 g_assert (in == NULL);
858 * test_ghash_nothing_in:
859 * @in: (element-type utf8 utf8):
861 void test_ghash_nothing_in (const GHashTable *in)
863 assert_test_table_ghash (in);
867 * test_ghash_nothing_in2:
868 * @in: (element-type utf8 utf8):
870 void test_ghash_nothing_in2 (GHashTable *in)
872 assert_test_table_ghash (in);
876 * test_ghash_container_in:
877 * @in: (transfer container) (element-type utf8 utf8):
879 void test_ghash_container_in (GHashTable *in)
881 assert_test_table_ghash (in);
882 /* be careful and explicitly steal all the elements from the ghash before
884 g_hash_table_steal_all (in);
885 g_hash_table_destroy (in);
888 static gboolean ghash_freer(gpointer key, gpointer value, gpointer user_data) {
895 * test_ghash_everything_in:
896 * @in: (transfer full) (element-type utf8 utf8):
898 void test_ghash_everything_in (GHashTable *in)
900 assert_test_table_ghash (in);
901 /* free the elements, then free the container. Don't rely on the
902 * GHashTable's key/value destructor functions. */
903 g_hash_table_foreach_steal (in, ghash_freer, NULL);
904 /* okay, dealloc the hash table. */
905 g_hash_table_destroy (in);
908 /************************************************************************/
915 test_enum_get_type (void)
917 static GType etype = 0;
918 if (G_UNLIKELY(etype == 0)) {
919 static const GEnumValue values[] = {
920 { TEST_VALUE1, "TEST_VALUE1", "value1" },
921 { TEST_VALUE2, "TEST_VALUE2", "value2" },
922 { TEST_VALUE3, "TEST_VALUE3", "value3" },
925 etype = g_enum_register_static (g_intern_static_string ("TestEnum"), values);
932 test_flags_get_type (void)
934 static GType etype = 0;
935 if (G_UNLIKELY(etype == 0)) {
936 static const GFlagsValue values[] = {
937 { TEST_FLAG1, "TEST_FLAG1", "flag1" },
938 { TEST_FLAG2, "TEST_FLAG2", "flag2" },
939 { TEST_FLAG3, "TEST_FLAG3", "flag2" },
942 etype = g_flags_register_static (g_intern_static_string ("TestFlags"), values);
949 test_enum_param(TestEnum e)
954 ec = g_type_class_ref (test_enum_get_type ());
955 ev = g_enum_get_value (ec, e);
956 g_type_class_unref (ec);
958 return ev->value_nick;
964 * test_struct_a_clone:
966 * @a_out: the cloned structure
968 * Make a copy of a TestStructA
971 test_struct_a_clone (TestStructA *a,
978 * test_struct_b_clone:
980 * @b_out: the cloned structure
982 * Make a copy of a TestStructB
985 test_struct_b_clone (TestStructB *b,
991 /* plain-old-data boxed types */
994 test_simple_boxed_a_copy (TestSimpleBoxedA *a)
996 TestSimpleBoxedA *new_a = g_slice_new (TestSimpleBoxedA);
1004 test_simple_boxed_a_free (TestSimpleBoxedA *a)
1006 g_slice_free (TestSimpleBoxedA, a);
1010 test_simple_boxed_a_get_type (void)
1012 static GType our_type = 0;
1015 our_type = g_boxed_type_register_static (g_intern_static_string ("TestSimpleBoxedA"),
1016 (GBoxedCopyFunc)test_simple_boxed_a_copy,
1017 (GBoxedFreeFunc)test_simple_boxed_a_free);
1022 test_simple_boxed_b_copy (TestSimpleBoxedB *b)
1024 TestSimpleBoxedB *new_b = g_slice_new (TestSimpleBoxedB);
1032 test_simple_boxed_a_equals (TestSimpleBoxedA *a,
1033 TestSimpleBoxedA *other_a)
1035 return (a->some_int == other_a->some_int &&
1036 a->some_int8 == other_a->some_int8 &&
1037 a->some_double == other_a->some_double);
1040 const TestSimpleBoxedA*
1041 test_simple_boxed_a_const_return (void)
1043 static TestSimpleBoxedA simple_a = {
1051 test_simple_boxed_b_free (TestSimpleBoxedB *a)
1053 g_slice_free (TestSimpleBoxedB, a);
1057 test_simple_boxed_b_get_type (void)
1059 static GType our_type = 0;
1062 our_type = g_boxed_type_register_static (g_intern_static_string ("TestSimpleBoxedB"),
1063 (GBoxedCopyFunc)test_simple_boxed_b_copy,
1064 (GBoxedFreeFunc)test_simple_boxed_b_free);
1070 struct _TestBoxedPrivate
1076 test_boxed_new (void)
1078 TestBoxed *boxed = g_slice_new0(TestBoxed);
1079 boxed->priv = g_slice_new0(TestBoxedPrivate);
1080 boxed->priv->magic = 0xdeadbeef;
1086 test_boxed_copy (TestBoxed *boxed)
1088 TestBoxed *new_boxed = test_boxed_new();
1089 TestBoxedPrivate *save;
1091 save = new_boxed->priv;
1092 *new_boxed = *boxed;
1093 new_boxed->priv = save;
1099 test_boxed_equals (TestBoxed *boxed,
1102 return (other->some_int8 == boxed->some_int8 &&
1103 test_simple_boxed_a_equals(&other->nested_a, &boxed->nested_a));
1107 test_boxed_free (TestBoxed *boxed)
1109 g_assert (boxed->priv->magic == 0xdeadbeef);
1111 g_slice_free (TestBoxedPrivate, boxed->priv);
1112 g_slice_free (TestBoxed, boxed);
1116 test_boxed_get_type (void)
1118 static GType our_type = 0;
1121 our_type = g_boxed_type_register_static (g_intern_static_string ("TestBoxed"),
1122 (GBoxedCopyFunc)test_boxed_copy,
1123 (GBoxedFreeFunc)test_boxed_free);
1127 G_DEFINE_TYPE(TestObj, test_obj, G_TYPE_OBJECT);
1131 PROP_TEST_OBJ_BARE = 1
1135 test_obj_set_property (GObject *object,
1137 const GValue *value,
1140 TestObj *self = TEST_OBJECT (object);
1142 switch (property_id)
1144 case PROP_TEST_OBJ_BARE:
1145 test_obj_set_bare (self, g_value_get_object (value));
1149 /* We don't have any other property... */
1150 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1156 test_obj_get_property (GObject *object,
1161 TestObj *self = TEST_OBJECT (object);
1163 switch (property_id)
1165 case PROP_TEST_OBJ_BARE:
1166 g_value_set_object (value, self->bare);
1170 /* We don't have any other property... */
1171 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1177 test_obj_dispose (GObject *gobject)
1179 TestObj *self = TEST_OBJECT (gobject);
1183 g_object_unref (self->bare);
1188 /* Chain up to the parent class */
1189 G_OBJECT_CLASS (test_obj_parent_class)->dispose (gobject);
1193 test_obj_default_matrix (TestObj *obj, const char *somestr)
1199 test_obj_class_init (TestObjClass *klass)
1201 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
1203 GType param_types[1];
1205 klass->test_signal =
1206 g_signal_newv ("test",
1207 G_TYPE_FROM_CLASS (gobject_class),
1208 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
1210 NULL /* accumulator */,
1211 NULL /* accumulator data */,
1212 g_cclosure_marshal_VOID__VOID,
1213 G_TYPE_NONE /* return_type */,
1215 NULL /* param_types */);
1217 param_types[0] = test_simple_boxed_a_get_type() | G_SIGNAL_TYPE_STATIC_SCOPE;
1218 klass->test_signal_with_static_scope_arg =
1219 g_signal_newv ("test-with-static-scope-arg",
1220 G_TYPE_FROM_CLASS (gobject_class),
1221 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
1223 NULL /* accumulator */,
1224 NULL /* accumulator data */,
1225 g_cclosure_marshal_VOID__BOXED,
1226 G_TYPE_NONE /* return_type */,
1230 gobject_class->set_property = test_obj_set_property;
1231 gobject_class->get_property = test_obj_get_property;
1232 gobject_class->dispose = test_obj_dispose;
1234 pspec = g_param_spec_object ("bare",
1236 "A contained object",
1239 g_object_class_install_property (gobject_class,
1243 klass->matrix = test_obj_default_matrix;
1247 test_obj_init (TestObj *obj)
1253 test_obj_new_from_file (const char *x, GError **error)
1255 return g_object_new (TEST_TYPE_OBJ, NULL);
1259 * test_obj_set_bare:
1260 * @bare: (allow-none):
1263 test_obj_set_bare (TestObj *obj, GObject *bare)
1266 g_object_unref (obj->bare);
1269 g_object_ref (obj->bare);
1273 test_obj_static_method (int x)
1279 * test_obj_do_matrix:
1281 * @somestr: Meaningless string
1283 * This method is virtual. Notably its name differs from the virtual
1284 * slot name, which makes it useful for testing bindings handle this
1290 test_obj_do_matrix (TestObj *obj, const char *somestr)
1292 return TEST_OBJ_GET_CLASS (obj)->matrix (obj, somestr);
1295 typedef struct _CallbackInfo CallbackInfo;
1297 struct _CallbackInfo
1299 TestCallbackUserData callback;
1300 GDestroyNotify notify;
1307 * @callback: (scope call):
1311 test_callback (TestCallback callback)
1317 * test_callback_user_data:
1318 * @callback: (scope call):
1320 * Call - callback parameter persists for the duration of the method
1321 * call and can be released on return.
1324 test_callback_user_data (TestCallbackUserData callback,
1327 return callback(user_data);
1330 static GSList *notified_callbacks = NULL;
1333 * test_callback_destroy_notify:
1334 * @callback: (scope notified):
1336 * Notified - callback persists until a DestroyNotify delegate
1340 test_callback_destroy_notify (TestCallbackUserData callback,
1342 GDestroyNotify notify)
1347 retval = callback(user_data);
1349 info = g_new(CallbackInfo, 1);
1350 info->callback = callback;
1351 info->notify = notify;
1352 info->user_data = user_data;
1354 notified_callbacks = g_slist_prepend(notified_callbacks, info);
1360 * test_callback_thaw_notifications:
1362 * Invokes all callbacks installed by #test_callback_destroy_notify(),
1363 * adding up their return values, and removes them, invoking the
1364 * corresponding destroy notfications.
1366 * Return value: Sum of the return values of the invoked callbacks.
1369 test_callback_thaw_notifications (void)
1374 for (node = notified_callbacks; node != NULL; node = node->next)
1376 CallbackInfo *info = (CallbackInfo *)node->data;
1377 retval += info->callback (info->user_data);
1379 info->notify (info->user_data);
1383 g_slist_free (notified_callbacks);
1384 notified_callbacks = NULL;
1390 * test_callback_infinte:
1391 * @callback: (scope infinte):
1393 * Infinite - callback persists forever.
1396 static GSList *infinite_callbacks = NULL;
1399 test_callback_infinte (TestCallbackUserData callback,
1402 infinite_callbacks = g_slist_prepend(infinite_callbacks, callback);
1404 return callback(user_data);
1410 test_interface_class_init(void *g_iface)
1415 test_interface_get_type(void)
1417 static GType type = 0;
1419 type = g_type_register_static_simple (G_TYPE_INTERFACE,
1420 "EverythingTestInterface",
1421 sizeof (TestInterfaceIface),
1422 (GClassInitFunc) test_interface_class_init,
1429 /* gobject with non-standard prefix */
1430 G_DEFINE_TYPE(TestWi8021x, test_wi_802_1x, G_TYPE_OBJECT);
1434 PROP_TEST_WI_802_1X_TESTBOOL = 1
1438 test_wi_802_1x_set_property (GObject *object,
1440 const GValue *value,
1443 TestWi8021x *self = TEST_WI_802_1X (object);
1445 switch (property_id)
1447 case PROP_TEST_WI_802_1X_TESTBOOL:
1448 test_wi_802_1x_set_testbool (self, g_value_get_boolean (value));
1452 /* We don't have any other property... */
1453 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1459 test_wi_802_1x_get_property (GObject *object,
1464 TestWi8021x *self = TEST_WI_802_1X (object);
1466 switch (property_id)
1468 case PROP_TEST_WI_802_1X_TESTBOOL:
1469 g_value_set_boolean (value, test_wi_802_1x_get_testbool (self));
1473 /* We don't have any other property... */
1474 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1480 test_wi_802_1x_dispose (GObject *gobject)
1482 /* Chain up to the parent class */
1483 G_OBJECT_CLASS (test_wi_802_1x_parent_class)->dispose (gobject);
1487 test_wi_802_1x_class_init (TestWi8021xClass *klass)
1489 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
1492 gobject_class->set_property = test_wi_802_1x_set_property;
1493 gobject_class->get_property = test_wi_802_1x_get_property;
1494 gobject_class->dispose = test_wi_802_1x_dispose;
1496 pspec = g_param_spec_boolean ("testbool",
1497 "Nick for testbool",
1498 "Blurb for testbool",
1501 g_object_class_install_property (gobject_class,
1502 PROP_TEST_WI_802_1X_TESTBOOL,
1507 test_wi_802_1x_init (TestWi8021x *obj)
1509 obj->testbool = TRUE;
1513 test_wi_802_1x_new (void)
1515 return g_object_new (TEST_TYPE_WI_802_1X, NULL);
1519 test_wi_802_1x_set_testbool (TestWi8021x *obj, gboolean val)
1521 obj->testbool = val;
1525 test_wi_802_1x_get_testbool (TestWi8021x *obj)
1527 return obj->testbool;
1531 test_wi_802_1x_static_method (int x)