1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2 * vim: tabstop=4 shiftwidth=4 expandtab
5 #include "gimarshallingtests.h"
9 static void gi_marshalling_tests_boxed_struct_free (GIMarshallingTestsBoxedStruct *struct_);
14 gi_marshalling_tests_boolean_return_true (void)
20 gi_marshalling_tests_boolean_return_false (void)
26 gi_marshalling_tests_boolean_in_true (gboolean bool_)
28 g_assert (bool_ == TRUE);
32 gi_marshalling_tests_boolean_in_false (gboolean bool_)
34 g_assert (bool_ == FALSE);
38 * gi_marshalling_tests_boolean_out_true:
42 gi_marshalling_tests_boolean_out_true (gboolean *bool_)
48 * gi_marshalling_tests_boolean_out_false:
52 gi_marshalling_tests_boolean_out_false (gboolean *bool_)
58 * gi_marshalling_tests_boolean_inout_true_false:
62 gi_marshalling_tests_boolean_inout_true_false (gboolean *bool_)
64 g_assert (*bool_ == TRUE);
69 * gi_marshalling_tests_boolean_inout_false_true:
73 gi_marshalling_tests_boolean_inout_false_true (gboolean *bool_)
75 g_assert (*bool_ == FALSE);
83 gi_marshalling_tests_int8_return_max (void)
89 gi_marshalling_tests_int8_return_min (void)
95 gi_marshalling_tests_int8_in_max (gint8 int8)
97 g_assert(int8 == G_MAXINT8);
101 gi_marshalling_tests_int8_in_min (gint8 int8)
103 g_assert(int8 == G_MININT8);
107 * gi_marshalling_tests_int8_out_max:
111 gi_marshalling_tests_int8_out_max (gint8 *int8)
117 * gi_marshalling_tests_int8_out_min:
121 gi_marshalling_tests_int8_out_min (gint8 *int8)
127 * gi_marshalling_tests_int8_inout_max_min:
131 gi_marshalling_tests_int8_inout_max_min (gint8 *int8)
133 g_assert(*int8 == G_MAXINT8);
138 * gi_marshalling_tests_int8_inout_min_max:
142 gi_marshalling_tests_int8_inout_min_max (gint8 *int8)
144 g_assert(*int8 == G_MININT8);
150 gi_marshalling_tests_uint8_return (void)
156 gi_marshalling_tests_uint8_in (guint8 uint8)
158 g_assert(uint8 == G_MAXUINT8);
162 * gi_marshalling_tests_uint8_out:
166 gi_marshalling_tests_uint8_out (guint8 *uint8)
172 * gi_marshalling_tests_uint8_inout:
176 gi_marshalling_tests_uint8_inout (guint8 *uint8)
178 g_assert(*uint8 == G_MAXUINT8);
184 gi_marshalling_tests_int16_return_max (void)
190 gi_marshalling_tests_int16_return_min (void)
196 gi_marshalling_tests_int16_in_max (gint16 int16)
198 g_assert(int16 == G_MAXINT16);
202 gi_marshalling_tests_int16_in_min (gint16 int16)
204 g_assert(int16 == G_MININT16);
208 * gi_marshalling_tests_int16_out_max:
212 gi_marshalling_tests_int16_out_max (gint16 *int16)
218 * gi_marshalling_tests_int16_out_min:
222 gi_marshalling_tests_int16_out_min (gint16 *int16)
228 * gi_marshalling_tests_int16_inout_max_min:
232 gi_marshalling_tests_int16_inout_max_min (gint16 *int16)
234 g_assert(*int16 == G_MAXINT16);
239 * gi_marshalling_tests_int16_inout_min_max:
243 gi_marshalling_tests_int16_inout_min_max (gint16 *int16)
245 g_assert(*int16 == G_MININT16);
251 gi_marshalling_tests_uint16_return (void)
257 gi_marshalling_tests_uint16_in (guint16 uint16)
259 g_assert(uint16 == G_MAXUINT16);
263 * gi_marshalling_tests_uint16_out:
267 gi_marshalling_tests_uint16_out (guint16 *uint16)
269 *uint16 = G_MAXUINT16;
273 * gi_marshalling_tests_uint16_inout:
277 gi_marshalling_tests_uint16_inout (guint16 *uint16)
279 g_assert(*uint16 == G_MAXUINT16);
285 gi_marshalling_tests_int32_return_max (void)
291 gi_marshalling_tests_int32_return_min (void)
297 gi_marshalling_tests_int32_in_max (gint32 int32)
299 g_assert(int32 == G_MAXINT32);
303 gi_marshalling_tests_int32_in_min (gint32 int32)
305 g_assert(int32 == G_MININT32);
309 * gi_marshalling_tests_int32_out_max:
313 gi_marshalling_tests_int32_out_max (gint32 *int32)
319 * gi_marshalling_tests_int32_out_min:
323 gi_marshalling_tests_int32_out_min (gint32 *int32)
329 * gi_marshalling_tests_int32_inout_max_min:
333 gi_marshalling_tests_int32_inout_max_min (gint32 *int32)
335 g_assert(*int32 == G_MAXINT32);
340 * gi_marshalling_tests_int32_inout_min_max:
344 gi_marshalling_tests_int32_inout_min_max (gint32 *int32)
346 g_assert(*int32 == G_MININT32);
352 gi_marshalling_tests_uint32_return (void)
358 gi_marshalling_tests_uint32_in (guint32 uint32)
360 g_assert(uint32 == G_MAXUINT32);
364 * gi_marshalling_tests_uint32_out:
368 gi_marshalling_tests_uint32_out (guint32 *uint32)
370 *uint32 = G_MAXUINT32;
374 * gi_marshalling_tests_uint32_inout:
378 gi_marshalling_tests_uint32_inout (guint32 *uint32)
380 g_assert(*uint32 == G_MAXUINT32);
386 gi_marshalling_tests_int64_return_max (void)
392 gi_marshalling_tests_int64_return_min (void)
398 gi_marshalling_tests_int64_in_max (gint64 int64)
400 g_assert(int64 == G_MAXINT64);
404 gi_marshalling_tests_int64_in_min (gint64 int64)
406 g_assert(int64 == G_MININT64);
410 * gi_marshalling_tests_int64_out_max:
414 gi_marshalling_tests_int64_out_max (gint64 *int64)
420 * gi_marshalling_tests_int64_out_min:
424 gi_marshalling_tests_int64_out_min (gint64 *int64)
430 * gi_marshalling_tests_int64_inout_max_min:
434 gi_marshalling_tests_int64_inout_max_min (gint64 *int64)
436 g_assert(*int64 == G_MAXINT64);
441 * gi_marshalling_tests_int64_inout_min_max:
445 gi_marshalling_tests_int64_inout_min_max (gint64 *int64)
447 g_assert(*int64 == G_MININT64);
453 gi_marshalling_tests_uint64_return (void)
459 gi_marshalling_tests_uint64_in (guint64 uint64)
461 g_assert(uint64 == G_MAXUINT64);
465 * gi_marshalling_tests_uint64_out:
469 gi_marshalling_tests_uint64_out (guint64 *uint64)
471 *uint64 = G_MAXUINT64;
475 * gi_marshalling_tests_uint64_inout:
479 gi_marshalling_tests_uint64_inout (guint64 *uint64)
481 g_assert(*uint64 == G_MAXUINT64);
487 gi_marshalling_tests_short_return_max (void)
493 gi_marshalling_tests_short_return_min (void)
499 gi_marshalling_tests_short_in_max (gshort short_)
501 g_assert(short_ == G_MAXSHORT);
505 gi_marshalling_tests_short_in_min (gshort short_)
507 g_assert(short_ == G_MINSHORT);
511 * gi_marshalling_tests_short_out_max:
515 gi_marshalling_tests_short_out_max (gshort *short_)
517 *short_ = G_MAXSHORT;
521 * gi_marshalling_tests_short_out_min:
525 gi_marshalling_tests_short_out_min (gshort *short_)
527 *short_ = G_MINSHORT;
531 * gi_marshalling_tests_short_inout_max_min:
535 gi_marshalling_tests_short_inout_max_min (gshort *short_)
537 g_assert(*short_ == G_MAXSHORT);
538 *short_ = G_MINSHORT;
542 * gi_marshalling_tests_short_inout_min_max:
546 gi_marshalling_tests_short_inout_min_max (gshort *short_)
548 g_assert(*short_ == G_MINSHORT);
549 *short_ = G_MAXSHORT;
554 gi_marshalling_tests_ushort_return (void)
560 gi_marshalling_tests_ushort_in (gushort ushort_)
562 g_assert(ushort_ == G_MAXUSHORT);
566 * gi_marshalling_tests_ushort_out:
570 gi_marshalling_tests_ushort_out (gushort *ushort_)
572 *ushort_ = G_MAXUSHORT;
576 * gi_marshalling_tests_ushort_inout:
580 gi_marshalling_tests_ushort_inout (gushort *ushort_)
582 g_assert(*ushort_ == G_MAXUSHORT);
588 gi_marshalling_tests_int_return_max (void)
594 gi_marshalling_tests_int_return_min (void)
600 gi_marshalling_tests_int_in_max (gint int_)
602 g_assert(int_ == G_MAXINT);
606 gi_marshalling_tests_int_in_min (gint int_)
608 g_assert(int_ == G_MININT);
612 * gi_marshalling_tests_int_out_max:
616 gi_marshalling_tests_int_out_max (gint *int_)
622 * gi_marshalling_tests_int_out_min:
626 gi_marshalling_tests_int_out_min (gint *int_)
632 * gi_marshalling_tests_int_inout_max_min:
636 gi_marshalling_tests_int_inout_max_min (gint *int_)
638 g_assert(*int_ == G_MAXINT);
643 * gi_marshalling_tests_int_inout_min_max:
647 gi_marshalling_tests_int_inout_min_max (gint *int_)
649 g_assert(*int_ == G_MININT);
655 gi_marshalling_tests_uint_return (void)
661 gi_marshalling_tests_uint_in (guint uint_)
663 g_assert(uint_ == G_MAXUINT);
667 * gi_marshalling_tests_uint_out:
671 gi_marshalling_tests_uint_out (guint *uint_)
677 * gi_marshalling_tests_uint_inout:
681 gi_marshalling_tests_uint_inout (guint *uint_)
683 g_assert(*uint_ == G_MAXUINT);
689 gi_marshalling_tests_long_return_max (void)
695 gi_marshalling_tests_long_return_min (void)
701 gi_marshalling_tests_long_in_max (glong long_)
703 g_assert(long_ == G_MAXLONG);
707 gi_marshalling_tests_long_in_min (glong long_)
709 g_assert(long_ == G_MINLONG);
713 * gi_marshalling_tests_long_out_max:
717 gi_marshalling_tests_long_out_max (glong *long_)
723 * gi_marshalling_tests_long_out_min:
727 gi_marshalling_tests_long_out_min (glong *long_)
733 * gi_marshalling_tests_long_inout_max_min:
737 gi_marshalling_tests_long_inout_max_min (glong *long_)
739 g_assert(*long_ == G_MAXLONG);
744 * gi_marshalling_tests_long_inout_min_max:
748 gi_marshalling_tests_long_inout_min_max (glong *long_)
750 g_assert(*long_ == G_MINLONG);
756 gi_marshalling_tests_ulong_return (void)
762 gi_marshalling_tests_ulong_in (gulong ulong_)
764 g_assert(ulong_ == G_MAXULONG);
768 * gi_marshalling_tests_ulong_out:
772 gi_marshalling_tests_ulong_out (gulong *ulong_)
774 *ulong_ = G_MAXULONG;
778 * gi_marshalling_tests_ulong_inout:
782 gi_marshalling_tests_ulong_inout (gulong *ulong_)
784 g_assert(*ulong_ == G_MAXULONG);
790 gi_marshalling_tests_ssize_return_max (void)
796 gi_marshalling_tests_ssize_return_min (void)
802 gi_marshalling_tests_ssize_in_max (gssize ssize)
804 g_assert(ssize == G_MAXSSIZE);
808 gi_marshalling_tests_ssize_in_min (gssize ssize)
810 g_assert(ssize == G_MINSSIZE);
814 * gi_marshalling_tests_ssize_out_max:
818 gi_marshalling_tests_ssize_out_max (gssize *ssize)
824 * gi_marshalling_tests_ssize_out_min:
828 gi_marshalling_tests_ssize_out_min (gssize *ssize)
834 * gi_marshalling_tests_ssize_inout_max_min:
838 gi_marshalling_tests_ssize_inout_max_min (gssize *ssize)
840 g_assert(*ssize == G_MAXSSIZE);
845 * gi_marshalling_tests_ssize_inout_min_max:
849 gi_marshalling_tests_ssize_inout_min_max (gssize *ssize)
851 g_assert(*ssize == G_MINSSIZE);
857 gi_marshalling_tests_size_return (void)
863 gi_marshalling_tests_size_in (gsize size)
865 g_assert(size == G_MAXSIZE);
869 * gi_marshalling_tests_size_out:
873 gi_marshalling_tests_size_out (gsize *size)
879 * gi_marshalling_tests_size_inout:
883 gi_marshalling_tests_size_inout (gsize *size)
885 g_assert(*size == G_MAXSIZE);
891 gi_marshalling_tests_float_return (void)
897 gi_marshalling_tests_float_in (gfloat float_)
899 g_assert(float_ == G_MAXFLOAT);
903 * gi_marshalling_tests_float_out:
907 gi_marshalling_tests_float_out (gfloat *float_)
909 *float_ = G_MAXFLOAT;
913 * gi_marshalling_tests_float_inout:
917 gi_marshalling_tests_float_inout (gfloat *float_)
919 g_assert(*float_ == G_MAXFLOAT);
920 *float_ = G_MINFLOAT;
925 gi_marshalling_tests_double_return (void)
931 gi_marshalling_tests_double_in (gdouble double_)
933 g_assert(double_ == G_MAXDOUBLE);
937 * gi_marshalling_tests_double_out:
941 gi_marshalling_tests_double_out (gdouble *double_)
943 *double_ = G_MAXDOUBLE;
947 * gi_marshalling_tests_double_inout:
951 gi_marshalling_tests_double_inout (gdouble *double_)
953 g_assert(*double_ == G_MAXDOUBLE);
954 *double_ = G_MINDOUBLE;
959 gi_marshalling_tests_time_t_return (void)
965 gi_marshalling_tests_time_t_in (time_t time_t_)
967 g_assert(time_t_ == 1234567890);
971 * gi_marshalling_tests_time_t_out:
975 gi_marshalling_tests_time_t_out (time_t *time_t_)
977 *time_t_ = 1234567890;
981 * gi_marshalling_tests_time_t_inout:
985 gi_marshalling_tests_time_t_inout (time_t *time_t_)
987 g_assert(*time_t_ == 1234567890);
993 gi_marshalling_tests_gtype_return (void)
999 gi_marshalling_tests_gtype_string_return (void)
1001 return G_TYPE_STRING;
1005 gi_marshalling_tests_gtype_in (GType gtype)
1007 g_assert(gtype == G_TYPE_NONE);
1011 gi_marshalling_tests_gtype_string_in (GType gtype)
1013 g_assert(gtype == G_TYPE_STRING);
1018 * gi_marshalling_tests_gtype_out:
1022 gi_marshalling_tests_gtype_out (GType *gtype)
1024 *gtype = G_TYPE_NONE;
1028 * gi_marshalling_tests_gtype_string_out:
1032 gi_marshalling_tests_gtype_string_out (GType *gtype)
1034 *gtype = G_TYPE_STRING;
1038 * gi_marshalling_tests_gtype_inout:
1042 gi_marshalling_tests_gtype_inout (GType *gtype)
1044 g_assert(*gtype == G_TYPE_NONE);
1045 *gtype = G_TYPE_INT;
1050 gi_marshalling_tests_utf8_none_return (void)
1052 return GI_MARSHALLING_TESTS_CONSTANT_UTF8;
1056 gi_marshalling_tests_utf8_full_return (void)
1058 return g_strdup(GI_MARSHALLING_TESTS_CONSTANT_UTF8);
1062 gi_marshalling_tests_utf8_none_in (const gchar *utf8)
1064 g_assert(strcmp(GI_MARSHALLING_TESTS_CONSTANT_UTF8, utf8) == 0);
1068 * gi_marshalling_tests_utf8_none_out:
1069 * @utf8: (out) (transfer none):
1072 gi_marshalling_tests_utf8_none_out (gchar **utf8)
1074 *utf8 = GI_MARSHALLING_TESTS_CONSTANT_UTF8;
1078 * gi_marshalling_tests_utf8_full_out:
1079 * @utf8: (out) (transfer full):
1082 gi_marshalling_tests_utf8_full_out (gchar **utf8)
1084 *utf8 = g_strdup(GI_MARSHALLING_TESTS_CONSTANT_UTF8);
1088 * gi_marshalling_tests_utf8_dangling_out:
1089 * @utf8: (out) (transfer full):
1092 gi_marshalling_tests_utf8_dangling_out (gchar **utf8)
1094 /* Intentionally don't touch the pointer to see how
1095 the bindings handle this case. Bindings should be
1096 robust against broken C functions and can initialize
1097 even OUT vlues to NULL.
1102 * gi_marshalling_tests_utf8_none_inout:
1103 * @utf8: (inout) (transfer none):
1106 gi_marshalling_tests_utf8_none_inout (gchar **utf8)
1108 g_assert(strcmp(GI_MARSHALLING_TESTS_CONSTANT_UTF8, *utf8) == 0);
1113 * gi_marshalling_tests_utf8_full_inout:
1114 * @utf8: (inout) (transfer full):
1117 gi_marshalling_tests_utf8_full_inout (gchar **utf8)
1119 g_assert(strcmp(GI_MARSHALLING_TESTS_CONSTANT_UTF8, *utf8) == 0);
1121 *utf8 = g_strdup("");
1126 * gi_marshalling_tests_init_function:
1127 * @n_args: (inout) (allow-none): number of args
1128 * @argv: (inout) (array length=n_args) (allow-none): args
1130 * This is like gtk_init().
1133 gi_marshalling_tests_init_function (gint *n_args, char ***argv)
1141 g_assert (argv != NULL);
1142 (*argv)[*n_args] = NULL;
1147 * gi_marshalling_tests_array_fixed_int_return:
1148 * Returns: (array fixed-size=4):
1151 gi_marshalling_tests_array_fixed_int_return (void)
1153 static gint ints[] = {-1, 0, 1, 2};
1158 * gi_marshalling_tests_array_fixed_short_return:
1159 * Returns: (array fixed-size=4):
1162 gi_marshalling_tests_array_fixed_short_return (void)
1164 static gshort shorts[] = {-1, 0, 1, 2};
1169 * gi_marshalling_tests_array_fixed_int_in:
1170 * @ints: (array fixed-size=4):
1173 gi_marshalling_tests_array_fixed_int_in (const gint *ints)
1175 g_assert(ints[0] == -1);
1176 g_assert(ints[1] == 0);
1177 g_assert(ints[2] == 1);
1178 g_assert(ints[3] == 2);
1182 * gi_marshalling_tests_array_fixed_short_in:
1183 * @shorts: (array fixed-size=4):
1186 gi_marshalling_tests_array_fixed_short_in (const gshort *shorts)
1188 g_assert(shorts[0] == -1);
1189 g_assert(shorts[1] == 0);
1190 g_assert(shorts[2] == 1);
1191 g_assert(shorts[3] == 2);
1195 * gi_marshalling_tests_array_fixed_out:
1196 * @ints: (out) (array fixed-size=4) (transfer none):
1199 gi_marshalling_tests_array_fixed_out (gint **ints)
1201 static gint values[] = {-1, 0, 1, 2};
1206 * gi_marshalling_tests_array_fixed_out_struct:
1207 * @structs: (out) (array fixed-size=2) (transfer none):
1210 gi_marshalling_tests_array_fixed_out_struct (GIMarshallingTestsSimpleStruct **structs)
1212 static GIMarshallingTestsSimpleStruct *values;
1214 if (values == NULL) {
1215 values = g_new(GIMarshallingTestsSimpleStruct, 2);
1217 values[0].long_ = 7;
1220 values[1].long_ = 6;
1228 * gi_marshalling_tests_array_fixed_inout:
1229 * @ints: (inout) (array fixed-size=4) (transfer none):
1232 gi_marshalling_tests_array_fixed_inout (gint **ints)
1234 static gint values[] = {2, 1, 0, -1};
1236 g_assert((*ints)[0] == -1);
1237 g_assert((*ints)[1] == 0);
1238 g_assert((*ints)[2] == 1);
1239 g_assert((*ints)[3] == 2);
1246 * gi_marshalling_tests_array_return:
1247 * Returns: (array length=length):
1250 gi_marshalling_tests_array_return (gint *length)
1252 static gint ints[] = {-1, 0, 1, 2};
1259 * gi_marshalling_tests_array_return_etc:
1264 * Returns: (array length=length):
1267 gi_marshalling_tests_array_return_etc (gint first, gint *length, gint last, gint *sum)
1269 static gint ints[] = {-1, 0, 1, 2};
1273 *sum = first + last;
1279 * gi_marshalling_tests_array_in:
1280 * @ints: (array length=length):
1284 gi_marshalling_tests_array_in (const gint *ints, gint length)
1286 g_assert(length == 4);
1287 g_assert(ints[0] == -1);
1288 g_assert(ints[1] == 0);
1289 g_assert(ints[2] == 1);
1290 g_assert(ints[3] == 2);
1294 * gi_marshalling_tests_array_in_len_before:
1296 * @ints: (array length=length):
1299 gi_marshalling_tests_array_in_len_before (gint length, const gint *ints)
1301 gi_marshalling_tests_array_in (ints, length);
1305 * gi_marshalling_tests_array_in_len_zero_terminated:
1306 * @ints: (array length=length zero-terminated=1):
1310 gi_marshalling_tests_array_in_len_zero_terminated (const gint *ints, gint length)
1312 g_assert (length == 4);
1314 g_assert (ints[0] == -1);
1315 g_assert (ints[1] == 0);
1316 g_assert (ints[2] == 1);
1317 g_assert (ints[3] == 2);
1319 /* One past the end, null terminator */
1320 g_assert (ints[4] == 0);
1324 * gi_marshalling_tests_array_string_in:
1325 * @strings: (array length=length):
1328 gi_marshalling_tests_array_string_in (const gchar **strings, gint length)
1330 g_assert(length == 2);
1331 g_assert(g_strcmp0(strings[0], "foo") == 0);
1332 g_assert(g_strcmp0(strings[1], "bar") == 0);
1336 * gi_marshalling_tests_array_uint8_in:
1337 * @chars: (array length=length):
1340 gi_marshalling_tests_array_uint8_in (const guint8 *chars, gint length)
1342 g_assert(length == 4);
1343 g_assert(chars[0] == 'a');
1344 g_assert(chars[1] == 'b');
1345 g_assert(chars[2] == 'c');
1346 g_assert(chars[3] == 'd');
1350 * gi_marshalling_tests_array_struct_in:
1351 * @structs: (array length=length):
1354 gi_marshalling_tests_array_struct_in (GIMarshallingTestsBoxedStruct **structs, gint length)
1356 g_assert(length == 3);
1357 g_assert(structs[0]->long_ == 1);
1358 g_assert(structs[1]->long_ == 2);
1359 g_assert(structs[2]->long_ == 3);
1363 * gi_marshalling_tests_array_simple_struct_in:
1364 * @structs: (array length=length):
1367 gi_marshalling_tests_array_simple_struct_in (GIMarshallingTestsSimpleStruct *structs, gint length)
1369 g_assert(length == 3);
1370 g_assert(structs[0].long_ == 1);
1371 g_assert(structs[1].long_ == 2);
1372 g_assert(structs[2].long_ == 3);
1376 * gi_marshalling_tests_multi_array_key_value_in:
1377 * @keys: (array length=length):
1378 * @values: (array length=length):
1381 gi_marshalling_tests_multi_array_key_value_in (gint length, const gchar **keys, const GValue *values)
1383 g_assert(length == 3);
1384 g_assert(g_strcmp0("one", keys[0]) == 0);
1385 g_assert(g_value_get_int(&values[0]) == 1);
1386 g_assert(g_strcmp0("two", keys[1]) == 0);
1387 g_assert(g_value_get_int(&values[1]) == 2);
1388 g_assert(g_strcmp0("three", keys[2]) == 0);
1389 g_assert(g_value_get_int(&values[2]) == 3);
1394 * gi_marshalling_tests_array_struct_take_in:
1395 * @structs: (array length=length) (transfer full):
1398 gi_marshalling_tests_array_struct_take_in (GIMarshallingTestsBoxedStruct **structs, gint length)
1400 gi_marshalling_tests_array_struct_in (structs, length);
1402 /* only really useful if run in valgrind actually */
1403 gi_marshalling_tests_boxed_struct_free (structs[0]);
1404 gi_marshalling_tests_boxed_struct_free (structs[1]);
1405 gi_marshalling_tests_boxed_struct_free (structs[2]);
1410 * gi_marshalling_tests_array_enum_in:
1411 * @_enum: (array length=length) (transfer none):
1415 gi_marshalling_tests_array_enum_in (GIMarshallingTestsEnum *_enum, gint length)
1417 g_assert (length == 3);
1418 g_assert (_enum[0] == GI_MARSHALLING_TESTS_ENUM_VALUE1);
1419 g_assert (_enum[1] == GI_MARSHALLING_TESTS_ENUM_VALUE2);
1420 g_assert (_enum[2] == GI_MARSHALLING_TESTS_ENUM_VALUE3);
1424 * gi_marshalling_tests_array_in_guint64_len:
1425 * @ints: (array length=length) (transfer none):
1429 gi_marshalling_tests_array_in_guint64_len (const gint *ints, guint64 length)
1431 g_assert (length == 4);
1433 gi_marshalling_tests_array_in (ints, length);
1437 * gi_marshalling_tests_array_in_guint8_len:
1438 * @ints: (array length=length) (transfer none):
1442 gi_marshalling_tests_array_in_guint8_len (const gint *ints, guint8 length)
1444 g_assert (length == 4);
1446 gi_marshalling_tests_array_in (ints, length);
1450 * gi_marshalling_tests_array_out:
1451 * @ints: (out) (array length=length) (transfer none):
1454 gi_marshalling_tests_array_out (gint **ints, gint *length)
1456 static gint values[] = {-1, 0, 1, 2};
1463 * gi_marshalling_tests_array_out_etc:
1465 * @ints: (out) (array length=length) (transfer none):
1471 gi_marshalling_tests_array_out_etc (gint first, gint **ints, gint *length, gint last, gint *sum)
1473 static gint values[] = {-1, 0, 1, 2};
1477 *sum = first + last;
1483 * gi_marshalling_tests_array_inout:
1484 * @ints: (inout) (array length=length) (transfer none):
1488 gi_marshalling_tests_array_inout (gint **ints, gint *length)
1490 static gint values[] = {-2, -1, 0, 1, 2};
1492 g_assert(*length == 4);
1493 g_assert((*ints)[0] == -1);
1494 g_assert((*ints)[1] == 0);
1495 g_assert((*ints)[2] == 1);
1496 g_assert((*ints)[3] == 2);
1503 * gi_marshalling_tests_array_inout_etc:
1505 * @ints: (inout) (array length=length) (transfer none):
1511 gi_marshalling_tests_array_inout_etc (gint first, gint **ints, gint *length, gint last, gint *sum)
1513 static gint values[] = {-2, -1, 0, 1, 2};
1515 g_assert(*length == 4);
1516 g_assert((*ints)[0] == -1);
1517 g_assert((*ints)[1] == 0);
1518 g_assert((*ints)[2] == 1);
1519 g_assert((*ints)[3] == 2);
1523 *sum = first + last;
1529 * gi_marshalling_tests_array_zero_terminated_return:
1530 * Returns: (array zero-terminated=1) (transfer none):
1533 gi_marshalling_tests_array_zero_terminated_return (void)
1535 static gchar *values[] = {"0", "1", "2", NULL};
1540 * gi_marshalling_tests_array_zero_terminated_return_null:
1541 * Returns: (array zero-terminated=1) (transfer none):
1544 gi_marshalling_tests_array_zero_terminated_return_null (void)
1550 * gi_marshalling_tests_array_zero_terminated_return_struct:
1551 * Returns: (array zero-terminated=1) (transfer full):
1553 GIMarshallingTestsBoxedStruct **
1554 gi_marshalling_tests_array_zero_terminated_return_struct (void)
1556 GIMarshallingTestsBoxedStruct **ret = (GIMarshallingTestsBoxedStruct**) g_new (gpointer, 4);
1558 ret[0] = gi_marshalling_tests_boxed_struct_new ();
1561 ret[1] = gi_marshalling_tests_boxed_struct_new ();
1564 ret[2] = gi_marshalling_tests_boxed_struct_new ();
1573 * gi_marshalling_tests_array_zero_terminated_in:
1574 * @utf8s: (array zero-terminated=1) (transfer none):
1577 gi_marshalling_tests_array_zero_terminated_in (gchar **utf8s)
1579 g_assert(g_strv_length(utf8s));
1580 g_assert(strcmp(utf8s[0], "0") == 0);
1581 g_assert(strcmp(utf8s[1], "1") == 0);
1582 g_assert(strcmp(utf8s[2], "2") == 0);
1586 * gi_marshalling_tests_array_zero_terminated_out:
1587 * @utf8s: (out) (array zero-terminated=1) (transfer none):
1590 gi_marshalling_tests_array_zero_terminated_out (gchar ***utf8s)
1592 static gchar *values[] = {"0", "1", "2", NULL};
1597 * gi_marshalling_tests_array_zero_terminated_inout:
1598 * @utf8s: (inout) (array zero-terminated=1) (transfer none):
1601 gi_marshalling_tests_array_zero_terminated_inout (gchar ***utf8s)
1603 static gchar *values[] = {"-1", "0", "1", "2", NULL};
1605 g_assert(g_strv_length(*utf8s));
1606 g_assert(strcmp((*utf8s)[0], "0") == 0);
1607 g_assert(strcmp((*utf8s)[1], "1") == 0);
1608 g_assert(strcmp((*utf8s)[2], "2") == 0);
1614 * gi_marshalling_tests_array_gvariant_none_in:
1615 * @variants: (array zero-terminated=1) (transfer none):
1616 * Returns: (array zero-terminated=1) (transfer none):
1619 gi_marshalling_tests_array_gvariant_none_in (GVariant **variants)
1621 /* Use a static container to detect if someone tries to free it */
1622 static GVariant *private_container[3] = { NULL, NULL, NULL };
1624 if (private_container[0] == NULL) {
1625 private_container[0] = g_variant_new_int32 (27);
1626 private_container[1] = g_variant_new_string ("Hello");
1629 g_assert (variants != NULL);
1630 g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1631 g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1632 g_assert (variants[2] == NULL);
1634 return private_container;
1638 * gi_marshalling_tests_array_gvariant_container_in:
1639 * @variants: (array zero-terminated=1) (transfer container):
1640 * Returns: (array zero-terminated=1) (transfer container):
1643 gi_marshalling_tests_array_gvariant_container_in (GVariant **variants)
1645 GVariant **container;
1647 g_assert (variants != NULL);
1648 g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1649 g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1650 g_assert (variants[2] == NULL);
1652 container = g_new0 (GVariant*, 3);
1653 container[0] = variants[0];
1654 container[1] = variants[1];
1661 * gi_marshalling_tests_array_gvariant_full_in:
1662 * @variants: (array zero-terminated=1) (transfer full):
1663 * Returns: (array zero-terminated=1) (transfer full):
1666 gi_marshalling_tests_array_gvariant_full_in (GVariant **variants)
1668 GVariant **container;
1670 g_assert (variants != NULL);
1671 g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1672 g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1673 g_assert (variants[2] == NULL);
1675 /* To catch different behaviors we reconstruct one variant from scratch,
1676 * while leaving the other untouched. Both approaches are legal with full
1677 * transfer in and out */
1678 container = g_new0 (GVariant*, 3);
1679 container[0] = g_variant_new_int32 (g_variant_get_int32 (variants[0]));
1680 g_variant_unref (variants[0]);
1681 container[1] = variants[1];
1688 * gi_marshalling_tests_garray_int_none_return:
1689 * Returns: (element-type gint) (transfer none):
1692 gi_marshalling_tests_garray_int_none_return (void)
1694 static GArray *array = NULL;
1697 if (array == NULL) {
1698 array = g_array_new (TRUE, TRUE, sizeof (gint));
1699 for (i = -1; i < 3; i++)
1700 g_array_append_val (array, i);
1707 * gi_marshalling_tests_garray_utf8_none_return:
1708 * Returns: (element-type utf8) (transfer none):
1711 gi_marshalling_tests_garray_utf8_none_return (void)
1713 static GArray *array = NULL;
1714 static gchar *values[] = {"0", "1", "2", NULL};
1717 if (array == NULL) {
1718 array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1719 for (i = 0; values[i]; i++)
1720 g_array_append_val (array, values[i]);
1727 * gi_marshalling_tests_garray_utf8_container_return:
1728 * Returns: (element-type utf8) (transfer container):
1731 gi_marshalling_tests_garray_utf8_container_return (void)
1733 GArray *array = NULL;
1734 static gchar *values[] = {"0", "1", "2", NULL};
1737 array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1738 for (i = 0; values[i]; i++)
1739 g_array_append_val (array, values[i]);
1745 * gi_marshalling_tests_garray_utf8_full_return:
1746 * Returns: (element-type utf8) (transfer full):
1749 gi_marshalling_tests_garray_utf8_full_return (void)
1751 GArray *array = NULL;
1752 static gchar *values[] = {"0", "1", "2", NULL};
1755 array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1756 for (i = 0; values[i]; i++) {
1757 gchar *str = g_strdup (values[i]);
1758 g_array_append_val (array, str);
1765 * gi_marshalling_tests_garray_int_none_in:
1766 * @array_: (element-type gint) (transfer none):
1769 gi_marshalling_tests_garray_int_none_in (GArray *array_)
1771 g_assert (array_->len == 4);
1772 g_assert (g_array_index (array_, gint, 0) == -1);
1773 g_assert (g_array_index (array_, gint, 1) == 0);
1774 g_assert (g_array_index (array_, gint, 2) == 1);
1775 g_assert (g_array_index (array_, gint, 3) == 2);
1779 * gi_marshalling_tests_garray_utf8_none_in:
1780 * @array_: (element-type utf8) (transfer none):
1783 gi_marshalling_tests_garray_utf8_none_in (GArray *array_)
1785 g_assert (array_->len == 3);
1786 g_assert (strcmp (g_array_index (array_, gchar*, 0), "0") == 0);
1787 g_assert (strcmp (g_array_index (array_, gchar*, 1), "1") == 0);
1788 g_assert (strcmp (g_array_index (array_, gchar*, 2), "2") == 0);
1792 * gi_marshalling_tests_garray_utf8_none_out:
1793 * @array_: (out) (element-type utf8) (transfer none):
1796 gi_marshalling_tests_garray_utf8_none_out (GArray **array_)
1798 static GArray *internal = NULL;
1799 static gchar *values[] = {"0", "1", "2", NULL};
1802 if (internal == NULL) {
1803 internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
1804 for (i = 0; values[i]; i++)
1805 g_array_append_val (internal, values[i]);
1812 * gi_marshalling_tests_garray_utf8_container_out:
1813 * @array_: (out) (element-type utf8) (transfer container):
1816 gi_marshalling_tests_garray_utf8_container_out (GArray **array_)
1818 static gchar *values[] = {"0", "1", "2", NULL};
1823 *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
1824 for (i = 0; values[i]; i++)
1825 g_array_append_val (*array_, values[i]);
1829 * gi_marshalling_tests_garray_utf8_full_out:
1830 * @array_: (out) (element-type utf8) (transfer full):
1833 gi_marshalling_tests_garray_utf8_full_out (GArray **array_)
1835 static gchar *values[] = {"0", "1", "2", NULL};
1840 *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
1841 for (i = 0; values[i]; i++) {
1842 gchar *str = g_strdup (values[i]);
1843 g_array_append_val (*array_, str);
1848 * gi_marshalling_tests_garray_utf8_none_inout:
1849 * @array_: (inout) (element-type utf8) (transfer none):
1852 gi_marshalling_tests_garray_utf8_none_inout (GArray **array_)
1854 static GArray *internal = NULL;
1855 static gchar *values[] = {"-2", "-1", "0", "1", NULL};
1858 g_assert ((*array_)->len == 3);
1859 g_assert (strcmp (g_array_index (*array_, gchar*, 0), "0") == 0);
1860 g_assert (strcmp (g_array_index (*array_, gchar*, 1), "1") == 0);
1861 g_assert (strcmp (g_array_index (*array_, gchar*, 2), "2") == 0);
1863 if (internal == NULL) {
1864 internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
1865 for (i = 0; values[i]; i++)
1866 g_array_append_val (internal, values[i]);
1873 * gi_marshalling_tests_garray_utf8_container_inout:
1874 * @array_: (inout) (element-type utf8) (transfer container):
1877 gi_marshalling_tests_garray_utf8_container_inout (GArray **array_)
1879 static gchar *val1 = "-2";
1880 static gchar *val2 = "-1";
1881 static gchar *val3 = "0";
1882 static gchar *val4 = "1";
1885 g_assert ((*array_)->len == 3);
1886 g_assert (strcmp (g_array_index (*array_, gchar*, 0), "0") == 0);
1887 g_assert (strcmp (g_array_index (*array_, gchar*, 1), "1") == 0);
1888 g_assert (strcmp (g_array_index (*array_, gchar*, 2), "2") == 0);
1890 result = g_array_new (TRUE, TRUE, sizeof (gchar *));
1891 g_array_append_val (result, val1);
1892 g_array_append_val (result, val2);
1893 g_array_append_val (result, val3);
1894 g_array_append_val (result, val4);
1900 * gi_marshalling_tests_garray_utf8_full_inout:
1901 * @array_: (inout) (element-type utf8) (transfer full):
1904 gi_marshalling_tests_garray_utf8_full_inout (GArray **array_)
1906 static gchar *val1 = "-1";
1907 static gchar *val2 = "-2";
1911 g_assert ((*array_)->len == 3);
1912 g_assert (strcmp (g_array_index (*array_, gchar*, 0), "0") == 0);
1913 g_assert (strcmp (g_array_index (*array_, gchar*, 1), "1") == 0);
1914 g_assert (strcmp (g_array_index (*array_, gchar*, 2), "2") == 0);
1916 result = g_array_new (TRUE, TRUE, sizeof (gchar *));
1917 val = g_strdup (val2);
1918 g_array_append_val(result, val);
1919 val = g_strdup (val1);
1920 g_array_append_val(result, val);
1921 val = g_strdup ("0");
1922 g_array_append_val(result, val);
1923 val = g_strdup ("1");
1924 g_array_append_val(result, val);
1930 * gi_marshalling_tests_gptrarray_utf8_none_return:
1931 * Returns: (element-type utf8) (transfer none):
1934 gi_marshalling_tests_gptrarray_utf8_none_return (void)
1936 static GPtrArray *parray = NULL;
1937 static gchar *values[] = {"0", "1", "2"};
1940 if (parray == NULL) {
1941 parray = g_ptr_array_new ();
1942 for (i = 0; i < 3; i++)
1943 g_ptr_array_add (parray, (gpointer) values[i]);
1950 * gi_marshalling_tests_gptrarray_utf8_container_return:
1951 * Returns: (element-type utf8) (transfer container):
1954 gi_marshalling_tests_gptrarray_utf8_container_return (void)
1956 GPtrArray *parray = NULL;
1957 static gchar *values[] = {"0", "1", "2", NULL};
1960 parray = g_ptr_array_new ();
1961 for (i = 0; values[i]; i++)
1962 g_ptr_array_add (parray, (gpointer)values[i]);
1968 * gi_marshalling_tests_gptrarray_utf8_full_return:
1969 * Returns: (element-type utf8) (transfer full):
1972 gi_marshalling_tests_gptrarray_utf8_full_return (void)
1974 GPtrArray *parray = NULL;
1975 static gchar *values[] = {"0", "1", "2", NULL};
1978 parray = g_ptr_array_new ();
1979 for (i = 0; values[i]; i++) {
1980 gchar *str = g_strdup (values[i]);
1981 g_ptr_array_add (parray, (gpointer)str);
1988 * gi_marshalling_tests_gptrarray_utf8_none_in:
1989 * @parray_: (element-type utf8) (transfer none):
1992 gi_marshalling_tests_gptrarray_utf8_none_in (GPtrArray *parray_)
1994 g_assert (parray_->len == 3);
1995 g_assert (strcmp (g_ptr_array_index (parray_, 0), "0") == 0);
1996 g_assert (strcmp (g_ptr_array_index (parray_, 1), "1") == 0);
1997 g_assert (strcmp (g_ptr_array_index (parray_, 2), "2") == 0);
2001 * gi_marshalling_tests_gptrarray_utf8_none_out:
2002 * @parray_: (out) (element-type utf8) (transfer none):
2005 gi_marshalling_tests_gptrarray_utf8_none_out (GPtrArray **parray_)
2007 static GPtrArray *internal = NULL;
2008 static gchar *values[] = {"0", "1", "2", NULL};
2011 if (internal == NULL) {
2012 internal = g_ptr_array_new ();
2013 for (i = 0; values[i]; i++)
2014 g_ptr_array_add (internal, (gpointer)values[i]);
2017 *parray_ = internal;
2021 * gi_marshalling_tests_gptrarray_utf8_container_out:
2022 * @parray_: (out) (element-type utf8) (transfer container):
2025 gi_marshalling_tests_gptrarray_utf8_container_out (GPtrArray **parray_)
2027 static gchar *values[] = {"0", "1", "2", NULL};
2032 *parray_ = g_ptr_array_new ();
2033 for (i = 0; values[i]; i++)
2034 g_ptr_array_add (*parray_, (gpointer)values[i]);
2038 * gi_marshalling_tests_gptrarray_utf8_full_out:
2039 * @parray_: (out) (element-type utf8) (transfer full):
2042 gi_marshalling_tests_gptrarray_utf8_full_out (GPtrArray **parray_)
2044 static gchar *values[] = {"0", "1", "2", NULL};
2049 *parray_ = g_ptr_array_new ();
2050 for (i = 0; values[i]; i++) {
2051 gchar *str = g_strdup (values[i]);
2052 g_ptr_array_add (*parray_, (gpointer)str);
2057 * gi_marshalling_tests_gptrarray_utf8_none_inout:
2058 * @parray_: (inout) (element-type utf8) (transfer none):
2061 gi_marshalling_tests_gptrarray_utf8_none_inout (GPtrArray **parray_)
2063 static GPtrArray *internal = NULL;
2064 static gchar *values[] = {"-2", "-1", "0", "1", NULL};
2067 g_assert ((*parray_)->len == 3);
2068 g_assert (strcmp (g_ptr_array_index (*parray_, 0), "0") == 0);
2069 g_assert (strcmp (g_ptr_array_index (*parray_, 1), "1") == 0);
2070 g_assert (strcmp (g_ptr_array_index (*parray_, 2), "2") == 0);
2072 if (internal == NULL) {
2073 internal = g_ptr_array_new ();
2074 for (i = 0; values[i]; i++)
2075 g_ptr_array_add (internal, (gpointer) values[i]);
2078 *parray_ = internal;
2082 * gi_marshalling_tests_gptrarray_utf8_container_inout:
2083 * @parray_: (inout) (element-type utf8) (transfer container):
2086 gi_marshalling_tests_gptrarray_utf8_container_inout (GPtrArray **parray_)
2088 static gchar *val1 = "-2";
2089 static gchar *val2 = "-1";
2090 static gchar *val3 = "0";
2091 static gchar *val4 = "1";
2094 g_assert ((*parray_)->len == 3);
2095 g_assert (strcmp (g_ptr_array_index (*parray_, 0), "0") == 0);
2096 g_assert (strcmp (g_ptr_array_index (*parray_, 1), "1") == 0);
2097 g_assert (strcmp (g_ptr_array_index (*parray_, 2), "2") == 0);
2099 result = g_ptr_array_new ();
2100 g_ptr_array_add (result, (gpointer) val1);
2101 g_ptr_array_add (result, (gpointer) val2);
2102 g_ptr_array_add (result, (gpointer) val3);
2103 g_ptr_array_add (result, (gpointer) val4);
2109 * gi_marshalling_tests_gptrarray_utf8_full_inout:
2110 * @parray_: (inout) (element-type utf8) (transfer full):
2113 gi_marshalling_tests_gptrarray_utf8_full_inout (GPtrArray **parray_)
2115 static gchar *val1 = "-1";
2116 static gchar *val2 = "-2";
2120 g_assert ((*parray_)->len == 3);
2121 g_assert (strcmp (g_ptr_array_index (*parray_, 0), "0") == 0);
2122 g_assert (strcmp (g_ptr_array_index (*parray_, 1), "1") == 0);
2123 g_assert (strcmp (g_ptr_array_index (*parray_, 2), "2") == 0);
2125 result = g_ptr_array_new ();
2126 val = g_strdup (val2);
2127 g_ptr_array_add(result, (gpointer) val);
2128 val = g_strdup (val1);
2129 g_ptr_array_add(result, (gpointer) val);
2130 val = g_strdup ("0");
2131 g_ptr_array_add(result, (gpointer) val);
2132 val = g_strdup ("1");
2133 g_ptr_array_add(result, (gpointer) val);
2139 * gi_marshalling_tests_bytearray_full_return:
2140 * Returns: (transfer full):
2143 gi_marshalling_tests_bytearray_full_return (void)
2145 GByteArray *array = NULL;
2146 guint8 data[] = {'\0', '1', '\xFF', '3'};
2148 array = g_byte_array_new ();
2149 g_byte_array_append (array, (const guint8*)data, G_N_ELEMENTS(data));
2156 * gi_marshalling_tests_bytearray_none_in:
2157 * @array_: (element-type gint8) (transfer none):
2160 gi_marshalling_tests_bytearray_none_in (GByteArray *array_)
2162 g_assert_cmpuint (array_->len, ==, 4);
2163 g_assert_cmpuint (g_array_index (array_, unsigned char, 0), ==, 0);
2164 g_assert_cmpuint (g_array_index (array_, unsigned char, 1), ==, 49);
2165 g_assert_cmpuint (g_array_index (array_, unsigned char, 2), ==, 0xFF);
2166 g_assert_cmpuint (g_array_index (array_, unsigned char, 3), ==, 51);
2170 * gi_marshalling_tests_gstrv_return:
2172 * Returns: (transfer full): an array of strings
2175 gi_marshalling_tests_gstrv_return (void)
2177 GStrv values = g_new0 (gchar*, 4);
2178 values[0] = g_strdup ("0");
2179 values[1] = g_strdup ("1");
2180 values[2] = g_strdup ("2");
2186 * gi_marshalling_tests_gstrv_in:
2190 gi_marshalling_tests_gstrv_in (GStrv g_strv)
2192 g_assert(g_strv_length(g_strv) == 3);
2193 g_assert(strcmp(g_strv[0], "0") == 0);
2194 g_assert(strcmp(g_strv[1], "1") == 0);
2195 g_assert(strcmp(g_strv[2], "2") == 0);
2199 * gi_marshalling_tests_gstrv_out:
2200 * @g_strv: (out) (transfer none):
2203 gi_marshalling_tests_gstrv_out (GStrv *g_strv)
2205 static gchar *values[] = {"0", "1", "2", NULL};
2210 * gi_marshalling_tests_gstrv_inout:
2211 * @g_strv: (inout) (transfer none):
2214 gi_marshalling_tests_gstrv_inout (GStrv *g_strv)
2216 static gchar *values[] = {"-1", "0", "1", "2", NULL};
2218 g_assert(g_strv_length(*g_strv) == 3);
2219 g_assert(strcmp((*g_strv)[0], "0") == 0);
2220 g_assert(strcmp((*g_strv)[1], "1") == 0);
2221 g_assert(strcmp((*g_strv)[2], "2") == 0);
2227 * gi_marshalling_tests_glist_int_none_return:
2228 * Returns: (element-type gint) (transfer none):
2231 gi_marshalling_tests_glist_int_none_return (void)
2233 static GList *list = NULL;
2236 list = g_list_append(list, GINT_TO_POINTER(-1));
2237 list = g_list_append(list, GINT_TO_POINTER(0));
2238 list = g_list_append(list, GINT_TO_POINTER(1));
2239 list = g_list_append(list, GINT_TO_POINTER(2));
2246 * gi_marshalling_tests_glist_utf8_none_return:
2247 * Returns: (element-type utf8) (transfer none):
2250 gi_marshalling_tests_glist_utf8_none_return (void)
2252 static GList *list = NULL;
2255 list = g_list_append(list, "0");
2256 list = g_list_append(list, "1");
2257 list = g_list_append(list, "2");
2264 * gi_marshalling_tests_glist_utf8_container_return:
2265 * Returns: (element-type utf8) (transfer container):
2268 gi_marshalling_tests_glist_utf8_container_return (void)
2272 list = g_list_append(list, "0");
2273 list = g_list_append(list, "1");
2274 list = g_list_append(list, "2");
2280 * gi_marshalling_tests_glist_utf8_full_return:
2281 * Returns: (element-type utf8) (transfer full):
2284 gi_marshalling_tests_glist_utf8_full_return (void)
2288 list = g_list_append(list, g_strdup("0"));
2289 list = g_list_append(list, g_strdup("1"));
2290 list = g_list_append(list, g_strdup("2"));
2296 * gi_marshalling_tests_glist_int_none_in:
2297 * @list: (element-type gint) (transfer none):
2300 gi_marshalling_tests_glist_int_none_in (GList *list)
2302 g_assert(g_list_length(list) == 4);
2303 g_assert(GPOINTER_TO_INT(g_list_nth_data(list, 0)) == -1);
2304 g_assert(GPOINTER_TO_INT(g_list_nth_data(list, 1)) == 0);
2305 g_assert(GPOINTER_TO_INT(g_list_nth_data(list, 2)) == 1);
2306 g_assert(GPOINTER_TO_INT(g_list_nth_data(list, 3)) == 2);
2310 * gi_marshalling_tests_glist_utf8_none_in:
2311 * @list: (element-type utf8) (transfer none):
2314 gi_marshalling_tests_glist_utf8_none_in (GList *list)
2316 g_assert(g_list_length(list) == 3);
2317 g_assert(strcmp(g_list_nth_data(list, 0), "0") == 0);
2318 g_assert(strcmp(g_list_nth_data(list, 1), "1") == 0);
2319 g_assert(strcmp(g_list_nth_data(list, 2), "2") == 0);
2323 * gi_marshalling_tests_glist_utf8_none_out:
2324 * @list: (out) (element-type utf8) (transfer none):
2327 gi_marshalling_tests_glist_utf8_none_out (GList **list)
2329 static GList *values = NULL;
2331 if (values == NULL) {
2332 values = g_list_append(values, "0");
2333 values = g_list_append(values, "1");
2334 values = g_list_append(values, "2");
2341 * gi_marshalling_tests_glist_utf8_container_out:
2342 * @list: (out) (element-type utf8) (transfer container):
2345 gi_marshalling_tests_glist_utf8_container_out (GList **list)
2349 *list = g_list_append(*list, "0");
2350 *list = g_list_append(*list, "1");
2351 *list = g_list_append(*list, "2");
2355 * gi_marshalling_tests_glist_utf8_full_out:
2356 * @list: (out) (element-type utf8) (transfer full):
2359 gi_marshalling_tests_glist_utf8_full_out (GList **list)
2363 *list = g_list_append(*list, g_strdup("0"));
2364 *list = g_list_append(*list, g_strdup("1"));
2365 *list = g_list_append(*list, g_strdup("2"));
2369 * gi_marshalling_tests_glist_utf8_none_inout:
2370 * @list: (inout) (element-type utf8) (transfer none):
2373 gi_marshalling_tests_glist_utf8_none_inout (GList **list)
2375 static GList *values = NULL;
2377 g_assert(g_list_length(*list) == 3);
2378 g_assert(strcmp(g_list_nth_data(*list, 0), "0") == 0);
2379 g_assert(strcmp(g_list_nth_data(*list, 1), "1") == 0);
2380 g_assert(strcmp(g_list_nth_data(*list, 2), "2") == 0);
2382 if (values == NULL) {
2383 values = g_list_append(values, "-2");
2384 values = g_list_append(values, "-1");
2385 values = g_list_append(values, "0");
2386 values = g_list_append(values, "1");
2393 * gi_marshalling_tests_glist_utf8_container_inout:
2394 * @list: (inout) (element-type utf8) (transfer container):
2397 gi_marshalling_tests_glist_utf8_container_inout (GList **list)
2399 GList *result = NULL;
2401 g_assert(g_list_length(*list) == 3);
2402 g_assert(strcmp(g_list_nth_data(*list, 0), "0") == 0);
2403 g_assert(strcmp(g_list_nth_data(*list, 1), "1") == 0);
2404 g_assert(strcmp(g_list_nth_data(*list, 2), "2") == 0);
2406 result = g_list_prepend(result, "1");
2407 result = g_list_prepend(result, "0");
2408 result = g_list_prepend(result, "-1");
2409 result = g_list_prepend(result, "-2");
2415 * gi_marshalling_tests_glist_utf8_full_inout:
2416 * @list: (inout) (element-type utf8) (transfer full):
2419 gi_marshalling_tests_glist_utf8_full_inout (GList **list)
2421 GList *result = NULL;
2423 g_assert(g_list_length(*list) == 3);
2424 g_assert(strcmp(g_list_nth_data(*list, 0), "0") == 0);
2425 g_assert(strcmp(g_list_nth_data(*list, 1), "1") == 0);
2426 g_assert(strcmp(g_list_nth_data(*list, 2), "2") == 0);
2428 result = g_list_prepend(result, g_strdup("1"));
2429 result = g_list_prepend(result, g_strdup("0"));
2430 result = g_list_prepend(result, g_strdup("-1"));
2431 result = g_list_prepend(result, g_strdup("-2"));
2438 * gi_marshalling_tests_gslist_int_none_return:
2439 * Returns: (element-type gint) (transfer none):
2442 gi_marshalling_tests_gslist_int_none_return (void)
2444 static GSList *list = NULL;
2447 list = g_slist_prepend(list, GINT_TO_POINTER(-1));
2448 list = g_slist_prepend(list, GINT_TO_POINTER(0));
2449 list = g_slist_prepend(list, GINT_TO_POINTER(1));
2450 list = g_slist_prepend(list, GINT_TO_POINTER(2));
2451 list = g_slist_reverse(list);
2458 * gi_marshalling_tests_gslist_utf8_none_return:
2459 * Returns: (element-type utf8) (transfer none):
2462 gi_marshalling_tests_gslist_utf8_none_return (void)
2464 static GSList *list = NULL;
2467 list = g_slist_prepend(list, "0");
2468 list = g_slist_prepend(list, "1");
2469 list = g_slist_prepend(list, "2");
2470 list = g_slist_reverse(list);
2477 * gi_marshalling_tests_gslist_utf8_container_return:
2478 * Returns: (element-type utf8) (transfer container):
2481 gi_marshalling_tests_gslist_utf8_container_return (void)
2483 GSList *list = NULL;
2485 list = g_slist_prepend(list, "0");
2486 list = g_slist_prepend(list, "1");
2487 list = g_slist_prepend(list, "2");
2488 list = g_slist_reverse(list);
2494 * gi_marshalling_tests_gslist_utf8_full_return:
2495 * Returns: (element-type utf8) (transfer full):
2498 gi_marshalling_tests_gslist_utf8_full_return (void)
2500 GSList *list = NULL;
2502 list = g_slist_prepend(list, g_strdup("0"));
2503 list = g_slist_prepend(list, g_strdup("1"));
2504 list = g_slist_prepend(list, g_strdup("2"));
2505 list = g_slist_reverse(list);
2511 * gi_marshalling_tests_gslist_int_none_in:
2512 * @list: (element-type gint) (transfer none):
2515 gi_marshalling_tests_gslist_int_none_in (GSList *list)
2517 g_assert(g_slist_length(list) == 4);
2518 g_assert(GPOINTER_TO_INT(g_slist_nth_data(list, 0)) == -1);
2519 g_assert(GPOINTER_TO_INT(g_slist_nth_data(list, 1)) == 0);
2520 g_assert(GPOINTER_TO_INT(g_slist_nth_data(list, 2)) == 1);
2521 g_assert(GPOINTER_TO_INT(g_slist_nth_data(list, 3)) == 2);
2525 * gi_marshalling_tests_gslist_utf8_none_in:
2526 * @list: (element-type utf8) (transfer none):
2529 gi_marshalling_tests_gslist_utf8_none_in (GSList *list)
2531 g_assert(g_slist_length(list) == 3);
2532 g_assert(strcmp(g_slist_nth_data(list, 0), "0") == 0);
2533 g_assert(strcmp(g_slist_nth_data(list, 1), "1") == 0);
2534 g_assert(strcmp(g_slist_nth_data(list, 2), "2") == 0);
2538 * gi_marshalling_tests_gslist_utf8_none_out:
2539 * @list: (out) (element-type utf8) (transfer none):
2542 gi_marshalling_tests_gslist_utf8_none_out (GSList **list)
2544 static GSList *values = NULL;
2546 if (values == NULL) {
2547 values = g_slist_prepend(values, "0");
2548 values = g_slist_prepend(values, "1");
2549 values = g_slist_prepend(values, "2");
2550 values = g_slist_reverse(values);
2557 * gi_marshalling_tests_gslist_utf8_container_out:
2558 * @list: (out) (element-type utf8) (transfer container):
2561 gi_marshalling_tests_gslist_utf8_container_out (GSList **list)
2565 *list = g_slist_prepend(*list, "0");
2566 *list = g_slist_prepend(*list, "1");
2567 *list = g_slist_prepend(*list, "2");
2568 *list = g_slist_reverse(*list);
2572 * gi_marshalling_tests_gslist_utf8_full_out:
2573 * @list: (out) (element-type utf8) (transfer full):
2576 gi_marshalling_tests_gslist_utf8_full_out (GSList **list)
2580 *list = g_slist_prepend(*list, g_strdup("0"));
2581 *list = g_slist_prepend(*list, g_strdup("1"));
2582 *list = g_slist_prepend(*list, g_strdup("2"));
2583 *list = g_slist_reverse(*list);
2587 * gi_marshalling_tests_gslist_utf8_none_inout:
2588 * @list: (inout) (element-type utf8) (transfer none):
2591 gi_marshalling_tests_gslist_utf8_none_inout (GSList **list)
2593 static GSList *values = NULL;
2595 g_assert(g_slist_length(*list) == 3);
2596 g_assert(strcmp(g_slist_nth_data(*list, 0), "0") == 0);
2597 g_assert(strcmp(g_slist_nth_data(*list, 1), "1") == 0);
2598 g_assert(strcmp(g_slist_nth_data(*list, 2), "2") == 0);
2600 if (values == NULL) {
2601 values = g_slist_prepend(values, "-2");
2602 values = g_slist_prepend(values, "-1");
2603 values = g_slist_prepend(values, "0");
2604 values = g_slist_prepend(values, "1");
2605 values = g_slist_reverse(values);
2612 * gi_marshalling_tests_gslist_utf8_container_inout:
2613 * @list: (inout) (element-type utf8) (transfer container):
2616 gi_marshalling_tests_gslist_utf8_container_inout (GSList **list)
2618 GSList *result = NULL;
2620 g_assert(g_slist_length(*list) == 3);
2621 g_assert(strcmp(g_slist_nth_data(*list, 0), "0") == 0);
2622 g_assert(strcmp(g_slist_nth_data(*list, 1), "1") == 0);
2623 g_assert(strcmp(g_slist_nth_data(*list, 2), "2") == 0);
2625 result = g_slist_prepend(result, "1");
2626 result = g_slist_prepend(result, "0");
2627 result = g_slist_prepend(result, "-1");
2628 result = g_slist_prepend(result, "-2");
2634 * gi_marshalling_tests_gslist_utf8_full_inout:
2635 * @list: (inout) (element-type utf8) (transfer full):
2638 gi_marshalling_tests_gslist_utf8_full_inout (GSList **list)
2640 GSList *result = NULL;
2642 g_assert(g_slist_length(*list) == 3);
2643 g_assert(strcmp(g_slist_nth_data(*list, 0), "0") == 0);
2644 g_assert(strcmp(g_slist_nth_data(*list, 1), "1") == 0);
2645 g_assert(strcmp(g_slist_nth_data(*list, 2), "2") == 0);
2647 result = g_slist_prepend(result, g_strdup("1"));
2648 result = g_slist_prepend(result, g_strdup("0"));
2649 result = g_slist_prepend(result, g_strdup("-1"));
2650 result = g_slist_prepend(result, g_strdup("-2"));
2657 * gi_marshalling_tests_ghashtable_int_none_return:
2658 * Returns: (element-type gint gint) (transfer none):
2661 gi_marshalling_tests_ghashtable_int_none_return (void)
2663 static GHashTable *hash_table = NULL;
2665 if (hash_table == NULL) {
2666 hash_table = g_hash_table_new(NULL, NULL);
2667 g_hash_table_insert(hash_table, GINT_TO_POINTER(-1), GINT_TO_POINTER(1));
2668 g_hash_table_insert(hash_table, GINT_TO_POINTER(0), GINT_TO_POINTER(0));
2669 g_hash_table_insert(hash_table, GINT_TO_POINTER(1), GINT_TO_POINTER(-1));
2670 g_hash_table_insert(hash_table, GINT_TO_POINTER(2), GINT_TO_POINTER(-2));
2677 * gi_marshalling_tests_ghashtable_utf8_none_return:
2678 * Returns: (element-type utf8 utf8) (transfer none):
2681 gi_marshalling_tests_ghashtable_utf8_none_return (void)
2683 static GHashTable *hash_table = NULL;
2685 if (hash_table == NULL) {
2686 hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2687 g_hash_table_insert(hash_table, "-1", "1");
2688 g_hash_table_insert(hash_table, "0", "0");
2689 g_hash_table_insert(hash_table, "1", "-1");
2690 g_hash_table_insert(hash_table, "2", "-2");
2697 * gi_marshalling_tests_ghashtable_utf8_container_return:
2698 * Returns: (element-type utf8 utf8) (transfer container):
2701 gi_marshalling_tests_ghashtable_utf8_container_return (void)
2703 GHashTable *hash_table = NULL;
2705 hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2706 g_hash_table_insert(hash_table, "-1", "1");
2707 g_hash_table_insert(hash_table, "0", "0");
2708 g_hash_table_insert(hash_table, "1", "-1");
2709 g_hash_table_insert(hash_table, "2", "-2");
2715 * gi_marshalling_tests_ghashtable_utf8_full_return:
2716 * Returns: (element-type utf8 utf8) (transfer full):
2719 gi_marshalling_tests_ghashtable_utf8_full_return (void)
2721 GHashTable *hash_table = NULL;
2723 hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2724 g_hash_table_insert(hash_table, g_strdup("-1"), g_strdup("1"));
2725 g_hash_table_insert(hash_table, g_strdup("0"), g_strdup("0"));
2726 g_hash_table_insert(hash_table, g_strdup("1"), g_strdup("-1"));
2727 g_hash_table_insert(hash_table, g_strdup("2"), g_strdup("-2"));
2733 * gi_marshalling_tests_ghashtable_int_none_in:
2734 * @hash_table: (element-type gint gint) (transfer none):
2737 gi_marshalling_tests_ghashtable_int_none_in (GHashTable *hash_table)
2739 g_assert(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(-1))) == 1);
2740 g_assert(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(0))) == 0);
2741 g_assert(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(1))) == -1);
2742 g_assert(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(2))) == -2);
2746 * gi_marshalling_tests_ghashtable_utf8_none_in:
2747 * @hash_table: (element-type utf8 utf8) (transfer none):
2750 gi_marshalling_tests_ghashtable_utf8_none_in (GHashTable *hash_table)
2752 g_assert(strcmp(g_hash_table_lookup(hash_table, "-1"), "1") == 0);
2753 g_assert(strcmp(g_hash_table_lookup(hash_table, "0"), "0") == 0);
2754 g_assert(strcmp(g_hash_table_lookup(hash_table, "1"), "-1") == 0);
2755 g_assert(strcmp(g_hash_table_lookup(hash_table, "2"), "-2") == 0);
2759 * gi_marshalling_tests_ghashtable_utf8_none_out:
2760 * @hash_table: (out) (element-type utf8 utf8) (transfer none):
2763 gi_marshalling_tests_ghashtable_utf8_none_out (GHashTable **hash_table)
2765 static GHashTable *new_hash_table = NULL;
2767 if (new_hash_table == NULL) {
2768 new_hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2769 g_hash_table_insert(new_hash_table, "-1", "1");
2770 g_hash_table_insert(new_hash_table, "0", "0");
2771 g_hash_table_insert(new_hash_table, "1", "-1");
2772 g_hash_table_insert(new_hash_table, "2", "-2");
2775 *hash_table = new_hash_table;
2779 * gi_marshalling_tests_ghashtable_utf8_container_out:
2780 * @hash_table: (out) (element-type utf8 utf8) (transfer container):
2783 gi_marshalling_tests_ghashtable_utf8_container_out (GHashTable **hash_table)
2785 *hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2786 g_hash_table_insert(*hash_table, "-1", "1");
2787 g_hash_table_insert(*hash_table, "0", "0");
2788 g_hash_table_insert(*hash_table, "1", "-1");
2789 g_hash_table_insert(*hash_table, "2", "-2");
2793 * gi_marshalling_tests_ghashtable_utf8_full_out:
2794 * @hash_table: (out) (element-type utf8 utf8) (transfer full):
2797 gi_marshalling_tests_ghashtable_utf8_full_out (GHashTable **hash_table)
2799 *hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2800 g_hash_table_insert(*hash_table, g_strdup("-1"), g_strdup("1"));
2801 g_hash_table_insert(*hash_table, g_strdup("0"), g_strdup("0"));
2802 g_hash_table_insert(*hash_table, g_strdup("1"), g_strdup("-1"));
2803 g_hash_table_insert(*hash_table, g_strdup("2"), g_strdup("-2"));
2807 * gi_marshalling_tests_ghashtable_utf8_none_inout:
2808 * @hash_table: (inout) (element-type utf8 utf8) (transfer none):
2811 gi_marshalling_tests_ghashtable_utf8_none_inout (GHashTable **hash_table)
2813 static GHashTable *new_hash_table = NULL;
2815 g_assert(strcmp(g_hash_table_lookup(*hash_table, "-1"), "1") == 0);
2816 g_assert(strcmp(g_hash_table_lookup(*hash_table, "0"), "0") == 0);
2817 g_assert(strcmp(g_hash_table_lookup(*hash_table, "1"), "-1") == 0);
2818 g_assert(strcmp(g_hash_table_lookup(*hash_table, "2"), "-2") == 0);
2820 if (new_hash_table == NULL) {
2821 new_hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2822 g_hash_table_insert(new_hash_table, "-1", "1");
2823 g_hash_table_insert(new_hash_table, "0", "0");
2824 g_hash_table_insert(new_hash_table, "1", "1");
2827 *hash_table = new_hash_table;
2831 * gi_marshalling_tests_ghashtable_utf8_container_inout:
2832 * @hash_table: (inout) (element-type utf8 utf8) (transfer container):
2835 gi_marshalling_tests_ghashtable_utf8_container_inout (GHashTable **hash_table)
2837 GHashTable *result = g_hash_table_new(g_str_hash, g_str_equal);
2839 g_assert(strcmp(g_hash_table_lookup(*hash_table, "-1"), "1") == 0);
2840 g_assert(strcmp(g_hash_table_lookup(*hash_table, "0"), "0") == 0);
2841 g_assert(strcmp(g_hash_table_lookup(*hash_table, "1"), "-1") == 0);
2842 g_assert(strcmp(g_hash_table_lookup(*hash_table, "2"), "-2") == 0);
2844 g_hash_table_insert(result, "-1", "1");
2845 g_hash_table_insert(result, "0", "0");
2846 g_hash_table_insert(result, "1", "1");
2848 *hash_table = result;
2852 * gi_marshalling_tests_ghashtable_utf8_full_inout:
2853 * @hash_table: (inout) (element-type utf8 utf8) (transfer full):
2856 gi_marshalling_tests_ghashtable_utf8_full_inout (GHashTable **hash_table)
2858 GHashTable *result = g_hash_table_new_full(g_str_hash, g_str_equal,
2861 g_assert(strcmp(g_hash_table_lookup(*hash_table, "-1"), "1") == 0);
2862 g_assert(strcmp(g_hash_table_lookup(*hash_table, "0"), "0") == 0);
2863 g_assert(strcmp(g_hash_table_lookup(*hash_table, "1"), "-1") == 0);
2864 g_assert(strcmp(g_hash_table_lookup(*hash_table, "2"), "-2") == 0);
2866 g_hash_table_insert(result, g_strdup("-1"), g_strdup("1"));
2867 g_hash_table_insert(result, g_strdup("0"), g_strdup("0"));
2868 g_hash_table_insert(result, g_strdup("1"), g_strdup("1"));
2870 *hash_table = result;
2875 * gi_marshalling_tests_gvalue_return:
2876 * Returns: (transfer none):
2879 gi_marshalling_tests_gvalue_return (void)
2881 static GValue *value = NULL;
2883 if (value == NULL) {
2884 value = g_new0(GValue, 1);
2885 g_value_init(value, G_TYPE_INT);
2886 g_value_set_int(value, 42);
2893 * gi_marshalling_tests_gvalue_in:
2894 * @value: (transfer none):
2897 gi_marshalling_tests_gvalue_in (GValue *value)
2899 g_assert(g_value_get_int(value) == 42);
2903 * gi_marshalling_tests_gvalue_in_with_type:
2904 * @value: (transfer none):
2908 gi_marshalling_tests_gvalue_in_with_type (GValue *value, GType type)
2910 g_assert(g_type_is_a(G_VALUE_TYPE(value), type));
2914 * gi_marshalling_tests_gvalue_in_enum:
2915 * @value: (transfer none):
2918 gi_marshalling_tests_gvalue_in_enum (GValue *value)
2920 g_assert(g_value_get_enum(value) == GI_MARSHALLING_TESTS_ENUM_VALUE3);
2924 * gi_marshalling_tests_gvalue_out:
2925 * @value: (out) (transfer none):
2928 gi_marshalling_tests_gvalue_out (GValue **value)
2930 static GValue *new_value = NULL;
2932 if (new_value == NULL) {
2933 new_value = g_new0(GValue, 1);
2934 g_value_init(new_value, G_TYPE_INT);
2935 g_value_set_int(new_value, 42);
2942 * gi_marshalling_tests_gvalue_inout:
2943 * @value: (inout) (transfer none):
2946 gi_marshalling_tests_gvalue_inout (GValue **value)
2948 g_assert(g_value_get_int(*value) == 42);
2949 g_value_unset(*value);
2950 g_value_init(*value, G_TYPE_STRING);
2951 g_value_set_string(*value, "42");
2955 * gi_marshalling_tests_gvalue_flat_array:
2956 * @n_values: number of values
2957 * @values: (array length=n_values): an array containing values
2960 gi_marshalling_tests_gvalue_flat_array (guint n_values,
2961 const GValue *values)
2963 g_assert (n_values == 3);
2965 g_assert_cmpint (g_value_get_int (&values[0]), ==, 42);
2966 g_assert_cmpstr (g_value_get_string (&values[1]), ==, "42");
2967 g_assert_cmpint (g_value_get_boolean (&values[2]), ==, TRUE);
2971 * gi_marshalling_tests_return_gvalue_flat_array:
2973 * Returns: (array fixed-size=3) (transfer full): a flat GValue array
2976 gi_marshalling_tests_return_gvalue_flat_array (void)
2978 GValue *array = g_new0 (GValue, 3);
2980 g_value_init (&array[0], G_TYPE_INT);
2981 g_value_set_int (&array[0], 42);
2983 g_value_init (&array[1], G_TYPE_STRING);
2984 g_value_set_static_string (&array[1], "42");
2986 g_value_init (&array[2], G_TYPE_BOOLEAN);
2987 g_value_set_boolean (&array[2], TRUE);
2993 * gi_marshalling_tests_gvalue_flat_array_round_trip:
2994 * @one: The first GValue
2995 * @two: The second GValue
2996 * @three: The third GValue
2998 * Returns: (array fixed-size=3) (transfer full): a flat array of [@one, @two, @three]
3001 gi_marshalling_tests_gvalue_flat_array_round_trip (const GValue one,
3005 GValue *array = g_new (GValue, 3);
3014 * gi_marshalling_tests_gclosure_in:
3015 * @closure: (transfer none):
3018 gi_marshalling_tests_gclosure_in (GClosure *closure)
3020 GValue return_value = {0, };
3022 g_value_init (&return_value, G_TYPE_INT);
3024 g_closure_invoke (closure,
3029 g_assert(g_value_get_int (&return_value) == 42);
3031 g_value_unset(&return_value);
3035 _closure_return_42 (void)
3041 _marshal_INT__VOID (GClosure *closure,
3042 GValue *return_value,
3043 guint n_param_values,
3044 const GValue *param_values,
3045 gpointer invocation_hint,
3046 gpointer marshal_data)
3048 typedef gint (*GMarshalFunc_INT__VOID) (void);
3049 register GMarshalFunc_INT__VOID callback;
3050 register GCClosure *cc = (GCClosure*) closure;
3052 callback = (GMarshalFunc_INT__VOID) cc->callback;
3053 g_value_set_int(return_value, callback());
3057 * gi_marshalling_tests_gclosure_return:
3059 * Return: a #GClosure
3062 gi_marshalling_tests_gclosure_return (void)
3064 GClosure *closure = g_cclosure_new ((GCallback)_closure_return_42,
3066 g_closure_set_marshal (closure, _marshal_INT__VOID);
3073 * gi_marshalling_tests_callback_return_value_only:
3074 * @callback: (scope call):
3077 gi_marshalling_tests_callback_return_value_only (GIMarshallingTestsCallbackReturnValueOnly callback)
3083 * gi_marshalling_tests_callback_one_out_parameter:
3084 * @callback: (scope call):
3088 gi_marshalling_tests_callback_one_out_parameter (GIMarshallingTestsCallbackOneOutParameter callback,
3095 * gi_marshalling_tests_callback_multiple_out_parameters:
3096 * @callback: (scope call):
3101 gi_marshalling_tests_callback_multiple_out_parameters (GIMarshallingTestsCallbackMultipleOutParameters callback,
3109 * gi_marshalling_tests_callback_return_value_and_one_out_parameter:
3110 * @callback: (scope call):
3114 gi_marshalling_tests_callback_return_value_and_one_out_parameter (GIMarshallingTestsCallbackReturnValueAndOneOutParameter callback,
3117 return callback (a);
3121 * gi_marshalling_tests_callback_return_value_and_multiple_out_parameters:
3122 * @callback: (scope call):
3127 gi_marshalling_tests_callback_return_value_and_multiple_out_parameters (GIMarshallingTestsCallbackReturnValueAndMultipleOutParameters callback,
3131 return callback (a, b);
3137 * gi_marshalling_tests_pointer_in_return:
3139 * Returns: (transfer none): The same pointer
3142 gi_marshalling_tests_pointer_in_return (gpointer pointer)
3148 gi_marshalling_tests_genum_get_type (void)
3150 static GType type = 0;
3151 if (G_UNLIKELY(type == 0)) {
3152 static const GEnumValue values[] = {
3153 { GI_MARSHALLING_TESTS_GENUM_VALUE1, "GI_MARSHALLING_TESTS_GENUM_VALUE1", "value1" },
3154 { GI_MARSHALLING_TESTS_GENUM_VALUE2, "GI_MARSHALLING_TESTS_GENUM_VALUE2", "value2" },
3155 { GI_MARSHALLING_TESTS_GENUM_VALUE3, "GI_MARSHALLING_TESTS_GENUM_VALUE3", "value3" },
3158 type = g_enum_register_static (g_intern_static_string ("GIMarshallingTestsGEnum"), values);
3164 GIMarshallingTestsEnum
3165 gi_marshalling_tests_genum_returnv (void)
3167 return GI_MARSHALLING_TESTS_GENUM_VALUE3;
3171 gi_marshalling_tests_genum_in (GIMarshallingTestsGEnum enum_)
3173 g_assert(enum_ == GI_MARSHALLING_TESTS_GENUM_VALUE3);
3177 * gi_marshalling_tests_genum_out:
3181 gi_marshalling_tests_genum_out (GIMarshallingTestsGEnum *enum_)
3183 *enum_ = GI_MARSHALLING_TESTS_GENUM_VALUE3;
3187 * gi_marshalling_tests_genum_inout:
3191 gi_marshalling_tests_genum_inout (GIMarshallingTestsGEnum *enum_)
3193 g_assert(*enum_ == GI_MARSHALLING_TESTS_GENUM_VALUE3);
3194 *enum_ = GI_MARSHALLING_TESTS_GENUM_VALUE1;
3198 GIMarshallingTestsEnum
3199 gi_marshalling_tests_enum_returnv (void)
3201 return GI_MARSHALLING_TESTS_ENUM_VALUE3;
3205 gi_marshalling_tests_enum_in (GIMarshallingTestsEnum enum_)
3207 g_assert(enum_ == GI_MARSHALLING_TESTS_ENUM_VALUE3);
3211 * gi_marshalling_tests_enum_out:
3215 gi_marshalling_tests_enum_out (GIMarshallingTestsEnum *enum_)
3217 *enum_ = GI_MARSHALLING_TESTS_ENUM_VALUE3;
3221 * gi_marshalling_tests_enum_inout:
3225 gi_marshalling_tests_enum_inout (GIMarshallingTestsEnum *enum_)
3227 g_assert(*enum_ == GI_MARSHALLING_TESTS_ENUM_VALUE3);
3228 *enum_ = GI_MARSHALLING_TESTS_ENUM_VALUE1;
3233 gi_marshalling_tests_flags_get_type (void)
3235 static GType type = 0;
3236 if (G_UNLIKELY(type == 0)) {
3237 static const GFlagsValue values[] = {
3238 { GI_MARSHALLING_TESTS_FLAGS_VALUE1, "GI_MARSHALLING_TESTS_FLAGS_VALUE1", "value1" },
3239 { GI_MARSHALLING_TESTS_FLAGS_VALUE2, "GI_MARSHALLING_TESTS_FLAGS_VALUE2", "value2" },
3240 { GI_MARSHALLING_TESTS_FLAGS_VALUE3, "GI_MARSHALLING_TESTS_FLAGS_VALUE3", "value3" },
3241 { GI_MARSHALLING_TESTS_FLAGS_MASK, "GI_MARSHALLING_TESTS_FLAGS_MASK", "mask" },
3242 { GI_MARSHALLING_TESTS_FLAGS_MASK2, "GI_MARSHALLING_TESTS_FLAGS_MASK2", "mask2" },
3245 type = g_flags_register_static (g_intern_static_string ("GIMarshallingTestsFlags"), values);
3251 GIMarshallingTestsFlags
3252 gi_marshalling_tests_flags_returnv (void)
3254 return GI_MARSHALLING_TESTS_FLAGS_VALUE2;
3258 gi_marshalling_tests_flags_in (GIMarshallingTestsFlags flags_)
3260 g_assert(flags_ == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
3264 gi_marshalling_tests_flags_in_zero (GIMarshallingTestsFlags flags)
3266 g_assert(flags == 0);
3270 * gi_marshalling_tests_flags_out:
3274 gi_marshalling_tests_flags_out (GIMarshallingTestsFlags *flags_)
3276 *flags_ = GI_MARSHALLING_TESTS_FLAGS_VALUE2;
3280 * gi_marshalling_tests_flags_inout:
3284 gi_marshalling_tests_flags_inout (GIMarshallingTestsFlags *flags_)
3286 g_assert(*flags_ == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
3287 *flags_ = GI_MARSHALLING_TESTS_FLAGS_VALUE1;
3291 GIMarshallingTestsNoTypeFlags
3292 gi_marshalling_tests_no_type_flags_returnv (void)
3294 return GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
3298 gi_marshalling_tests_no_type_flags_in (GIMarshallingTestsNoTypeFlags flags_)
3300 g_assert(flags_ == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
3304 gi_marshalling_tests_no_type_flags_in_zero (GIMarshallingTestsNoTypeFlags flags)
3306 g_assert(flags == 0);
3310 * gi_marshalling_tests_no_type_flags_out:
3314 gi_marshalling_tests_no_type_flags_out (GIMarshallingTestsNoTypeFlags *flags_)
3316 *flags_ = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
3320 * gi_marshalling_tests_no_type_flags_inout:
3324 gi_marshalling_tests_no_type_flags_inout (GIMarshallingTestsNoTypeFlags *flags_)
3326 g_assert(*flags_ == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
3327 *flags_ = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE1;
3332 * gi_marshalling_tests_simple_struct_returnv:
3333 * Returns: (transfer none):
3335 GIMarshallingTestsSimpleStruct *
3336 gi_marshalling_tests_simple_struct_returnv (void)
3338 static GIMarshallingTestsSimpleStruct *struct_ = NULL;
3340 if (struct_ == NULL) {
3341 struct_ = g_new(GIMarshallingTestsSimpleStruct, 1);
3351 * gi_marshalling_tests_simple_struct_inv:
3352 * @struct_: (transfer none):
3355 gi_marshalling_tests_simple_struct_inv (GIMarshallingTestsSimpleStruct *struct_)
3357 g_assert(struct_->long_ == 6);
3358 g_assert(struct_->int8 == 7);
3362 gi_marshalling_tests_simple_struct_method (GIMarshallingTestsSimpleStruct *struct_)
3364 g_assert(struct_->long_ == 6);
3365 g_assert(struct_->int8 == 7);
3370 gi_marshalling_tests_pointer_struct_get_type (void)
3372 static GType type = 0;
3375 type = g_pointer_type_register_static ("GIMarshallingTestsPointerStruct");
3382 * gi_marshalling_tests_pointer_struct_returnv:
3383 * Returns: (transfer none):
3385 GIMarshallingTestsPointerStruct *
3386 gi_marshalling_tests_pointer_struct_returnv (void)
3388 static GIMarshallingTestsPointerStruct *struct_ = NULL;
3390 if (struct_ == NULL) {
3391 struct_ = g_new(GIMarshallingTestsPointerStruct, 1);
3393 struct_->long_ = 42;
3400 * gi_marshalling_tests_pointer_struct_inv:
3401 * @struct_: (transfer none):
3404 gi_marshalling_tests_pointer_struct_inv (GIMarshallingTestsPointerStruct *struct_)
3406 g_assert(struct_->long_ == 42);
3409 static GIMarshallingTestsBoxedStruct *
3410 gi_marshalling_tests_boxed_struct_copy (GIMarshallingTestsBoxedStruct *struct_)
3412 GIMarshallingTestsBoxedStruct *new_struct;
3414 new_struct = g_slice_new (GIMarshallingTestsBoxedStruct);
3416 *new_struct = *struct_;
3422 gi_marshalling_tests_boxed_struct_free (GIMarshallingTestsBoxedStruct *struct_)
3424 g_slice_free (GIMarshallingTestsBoxedStruct, struct_);
3428 gi_marshalling_tests_boxed_struct_get_type (void)
3430 static GType type = 0;
3433 type = g_boxed_type_register_static ("GIMarshallingTestsBoxedStruct",
3434 (GBoxedCopyFunc) gi_marshalling_tests_boxed_struct_copy,
3435 (GBoxedFreeFunc) gi_marshalling_tests_boxed_struct_free);
3441 GIMarshallingTestsBoxedStruct *
3442 gi_marshalling_tests_boxed_struct_new (void)
3444 return g_slice_new0 (GIMarshallingTestsBoxedStruct);
3448 * gi_marshalling_tests_boxed_struct_returnv:
3449 * Returns: (transfer none):
3451 GIMarshallingTestsBoxedStruct *
3452 gi_marshalling_tests_boxed_struct_returnv (void)
3454 static GIMarshallingTestsBoxedStruct *struct_ = NULL;
3456 if (struct_ == NULL) {
3457 struct_ = g_new(GIMarshallingTestsBoxedStruct, 1);
3459 struct_->long_ = 42;
3460 struct_->g_strv = g_new0(gchar*, 4);
3461 struct_->g_strv[0] = g_strdup("0");
3462 struct_->g_strv[1] = g_strdup("1");
3463 struct_->g_strv[2] = g_strdup("2");
3464 struct_->g_strv[3] = NULL;
3471 * gi_marshalling_tests_boxed_struct_inv:
3472 * @struct_: (transfer none):
3475 gi_marshalling_tests_boxed_struct_inv (GIMarshallingTestsBoxedStruct *struct_)
3477 g_assert(struct_->long_ == 42);
3481 * gi_marshalling_tests_boxed_struct_out:
3482 * @struct_: (out) (transfer none):
3485 gi_marshalling_tests_boxed_struct_out (GIMarshallingTestsBoxedStruct **struct_)
3487 static GIMarshallingTestsBoxedStruct *new_struct = NULL;
3489 if (new_struct == NULL) {
3490 new_struct = g_new(GIMarshallingTestsBoxedStruct, 1);
3492 new_struct->long_ = 42;
3495 *struct_ = new_struct;
3499 * gi_marshalling_tests_boxed_struct_inout:
3500 * @struct_: (inout) (transfer full):
3503 gi_marshalling_tests_boxed_struct_inout (GIMarshallingTestsBoxedStruct **struct_)
3505 g_assert((*struct_)->long_ == 42);
3507 (*struct_) = g_slice_new (GIMarshallingTestsBoxedStruct);
3508 (*struct_)->long_ = 0;
3511 static GIMarshallingTestsUnion *
3512 gi_marshalling_tests_union_copy (GIMarshallingTestsUnion *union_)
3514 GIMarshallingTestsUnion *new_union;
3516 new_union = g_slice_new (GIMarshallingTestsUnion);
3518 *new_union = *union_;
3524 gi_marshalling_tests_union_free (GIMarshallingTestsUnion *union_)
3526 g_slice_free (GIMarshallingTestsUnion, union_);
3530 gi_marshalling_tests_union_get_type (void)
3532 static GType type = 0;
3535 type = g_boxed_type_register_static ("GIMarshallingTestsUnion",
3536 (GBoxedCopyFunc) gi_marshalling_tests_union_copy,
3537 (GBoxedFreeFunc) gi_marshalling_tests_union_free);
3544 * gi_marshalling_tests_union_returnv:
3545 * Returns: (transfer none):
3547 GIMarshallingTestsUnion *
3548 gi_marshalling_tests_union_returnv (void)
3550 static GIMarshallingTestsUnion *union_ = NULL;
3552 if (union_ == NULL) {
3553 union_ = g_new(GIMarshallingTestsUnion, 1);
3562 * gi_marshalling_tests_union_inv:
3563 * @union_: (transfer none):
3566 gi_marshalling_tests_union_inv (GIMarshallingTestsUnion *union_)
3568 g_assert(union_->long_ == 42);
3572 gi_marshalling_tests_union_method (GIMarshallingTestsUnion *union_)
3574 g_assert(union_->long_ == 42);
3585 static void gi_marshalling_tests_object_real_method_with_default_implementation (
3586 GIMarshallingTestsObject *self, gint8 in);
3588 G_DEFINE_TYPE (GIMarshallingTestsObject, gi_marshalling_tests_object, G_TYPE_OBJECT);
3591 gi_marshalling_tests_object_init (GIMarshallingTestsObject *object)
3596 gi_marshalling_tests_object_finalize (GObject *object)
3598 G_OBJECT_CLASS (gi_marshalling_tests_object_parent_class)->finalize (object);
3602 gi_marshalling_tests_object_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
3604 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3608 GI_MARSHALLING_TESTS_OBJECT (object)->int_ = g_value_get_int (value);
3611 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3617 gi_marshalling_tests_object_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
3619 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3623 g_value_set_int (value, GI_MARSHALLING_TESTS_OBJECT (object)->int_);
3626 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3632 gi_marshalling_tests_object_class_init (GIMarshallingTestsObjectClass *klass)
3634 GObjectClass* object_class = G_OBJECT_CLASS (klass);
3636 GObjectClass* parent_class = G_OBJECT_CLASS (klass);
3639 object_class->finalize = gi_marshalling_tests_object_finalize;
3640 object_class->set_property = gi_marshalling_tests_object_set_property;
3641 object_class->get_property = gi_marshalling_tests_object_get_property;
3643 g_object_class_install_property (object_class, PROP_INT_,
3644 g_param_spec_int ("int", "Integer", "An integer", G_MININT, G_MAXINT, 0,
3645 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
3647 klass->method_with_default_implementation = gi_marshalling_tests_object_real_method_with_default_implementation;
3652 gi_marshalling_tests_object_static_method (void)
3657 gi_marshalling_tests_object_method (GIMarshallingTestsObject *object)
3659 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3660 g_assert (object->int_ == 42);
3664 gi_marshalling_tests_object_overridden_method (GIMarshallingTestsObject *object)
3666 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3667 g_assert (object->int_ == 0);
3670 GIMarshallingTestsObject *
3671 gi_marshalling_tests_object_new (gint int_)
3673 return g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, "int", int_, NULL);
3677 * gi_marshalling_tests_object_method_array_in:
3678 * @ints: (array length=length):
3681 gi_marshalling_tests_object_method_array_in (GIMarshallingTestsObject *object, const gint *ints, gint length)
3683 g_assert(length == 4);
3684 g_assert(ints[0] == -1);
3685 g_assert(ints[1] == 0);
3686 g_assert(ints[2] == 1);
3687 g_assert(ints[3] == 2);
3691 * gi_marshalling_tests_object_method_array_out:
3692 * @ints: (out) (array length=length) (transfer none):
3695 gi_marshalling_tests_object_method_array_out (GIMarshallingTestsObject *object, gint **ints, gint *length)
3697 static gint values[] = {-1, 0, 1, 2};
3704 * gi_marshalling_tests_object_method_array_inout:
3705 * @ints: (inout) (array length=length) (transfer none):
3709 gi_marshalling_tests_object_method_array_inout (GIMarshallingTestsObject *object, gint **ints, gint *length)
3711 static gint values[] = {-2, -1, 0, 1, 2};
3713 g_assert(*length == 4);
3714 g_assert((*ints)[0] == -1);
3715 g_assert((*ints)[1] == 0);
3716 g_assert((*ints)[2] == 1);
3717 g_assert((*ints)[3] == 2);
3724 * gi_marshalling_tests_object_method_array_return:
3725 * Returns: (array length=length):
3728 gi_marshalling_tests_object_method_array_return (GIMarshallingTestsObject *object, gint *length)
3730 static gint ints[] = {-1, 0, 1, 2};
3737 * gi_marshalling_tests_object_method_int8_in:
3741 gi_marshalling_tests_object_method_int8_in (GIMarshallingTestsObject *self, gint8 in)
3743 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_in (self, in);
3747 * gi_marshalling_tests_object_method_int8_out:
3751 gi_marshalling_tests_object_method_int8_out (GIMarshallingTestsObject *self, gint8 *out)
3753 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_out (self, out);
3757 * gi_marshalling_tests_object_method_with_default_implementation:
3761 gi_marshalling_tests_object_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
3763 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_with_default_implementation (self, in);
3767 gi_marshalling_tests_object_real_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
3770 g_value_init (&val, G_TYPE_INT);
3771 g_value_set_int (&val, in);
3772 g_object_set_property (G_OBJECT (self), "int", &val);
3776 * gi_marshalling_tests_object_vfunc_with_callback:
3777 * @callback: (scope call) (closure callback_data):
3778 * @callback_data: (allow-none):
3780 * Virtual: vfunc_with_callback
3783 gi_marshalling_tests_object_vfunc_with_callback (GIMarshallingTestsObject *object,
3784 GIMarshallingTestsCallbackIntInt callback,
3785 void *callback_data)
3791 _callback (int val, void *user_data)
3793 g_assert(user_data == 0xdeadbeef);
3798 gi_marshalling_tests_object_call_vfunc_with_callback (GIMarshallingTestsObject *object)
3800 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (object)->vfunc_with_callback (object,
3802 (void *) 0xdeadbeef);
3806 * gi_marshalling_tests_object_none_return:
3807 * Returns: (transfer none):
3809 GIMarshallingTestsObject *
3810 gi_marshalling_tests_object_none_return (void)
3812 static GIMarshallingTestsObject *object = NULL;
3814 if (object == NULL) {
3815 object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
3822 * gi_marshalling_tests_object_full_return:
3823 * Returns: (transfer full):
3825 GIMarshallingTestsObject *
3826 gi_marshalling_tests_object_full_return (void)
3828 return g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
3832 * gi_marshalling_tests_object_none_in:
3833 * @object: (transfer none):
3836 gi_marshalling_tests_object_none_in (GIMarshallingTestsObject *object)
3838 g_assert(object->int_ == 42);
3842 * gi_marshalling_tests_object_none_out:
3843 * @object: (out) (transfer none):
3846 gi_marshalling_tests_object_none_out (GIMarshallingTestsObject **object)
3848 static GIMarshallingTestsObject *new_object = NULL;
3850 if (new_object == NULL) {
3851 new_object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
3854 *object = new_object;
3858 * gi_marshalling_tests_object_full_out:
3859 * @object: (out) (transfer full):
3862 gi_marshalling_tests_object_full_out (GIMarshallingTestsObject **object)
3864 *object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
3868 * gi_marshalling_tests_object_none_inout:
3869 * @object: (inout) (transfer none):
3872 gi_marshalling_tests_object_none_inout (GIMarshallingTestsObject **object)
3874 static GIMarshallingTestsObject *new_object = NULL;
3876 g_assert((*object)->int_ == 42);
3878 if (new_object == NULL) {
3879 new_object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
3880 new_object->int_ = 0;
3883 *object = new_object;
3887 * gi_marshalling_tests_object_full_inout:
3888 * @object: (inout) (transfer full):
3891 gi_marshalling_tests_object_full_inout (GIMarshallingTestsObject **object)
3893 g_assert((*object)->int_ == 42);
3895 *object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
3899 * gi_marshalling_tests_object_test_int8_in:
3903 gi_marshalling_tests_object_int8_in (GIMarshallingTestsObject *object, gint8 in)
3905 gi_marshalling_tests_object_method_int8_in (object, in);
3909 * gi_marshalling_tests_object_test_int8_out:
3913 gi_marshalling_tests_object_int8_out (GIMarshallingTestsObject *object, gint8 *out)
3915 gi_marshalling_tests_object_method_int8_out (object, out);
3919 * gi_marshalling_tests_object_vfunc_return_value_only:
3922 gi_marshalling_tests_object_vfunc_return_value_only (GIMarshallingTestsObject *self)
3924 /* make sure that local variables don't get smashed */
3926 gulong local = 0x12345678;
3927 return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_only (self);
3928 g_assert_cmpint(local, ==, 0x12345678);
3929 return return_value;
3933 * gi_marshalling_tests_object_vfunc_one_out_parameter:
3937 gi_marshalling_tests_object_vfunc_one_out_parameter (GIMarshallingTestsObject *self, gfloat *a)
3939 /* make sure that local variables don't get smashed */
3940 gulong local = 0x12345678;
3941 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_one_out_parameter (self, a);
3942 g_assert_cmpint(local, ==, 0x12345678);
3946 * gi_marshalling_tests_object_vfunc_multiple_out_parameters:
3951 gi_marshalling_tests_object_vfunc_multiple_out_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b)
3953 /* make sure that local variables don't get smashed */
3954 gulong local = 0x12345678;
3955 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_multiple_out_parameters (self, a, b);
3956 g_assert_cmpint(local, ==, 0x12345678);
3960 * gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter:
3964 gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter (GIMarshallingTestsObject *self, glong *a)
3966 /* make sure that local variables don't get smashed */
3967 gulong return_value;
3968 gulong local = 0x12345678;
3969 return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_one_out_parameter (self, a);
3970 g_assert_cmpint(local, ==, 0x12345678);
3971 return return_value;
3975 * gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters:
3980 gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters (GIMarshallingTestsObject *self, glong *a, glong *b)
3982 gulong return_value;
3983 gulong local = 0x12345678;
3984 return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_multiple_out_parameters (self, a, b);
3985 g_assert_cmpint(local, ==, 0x12345678);
3986 return return_value;
3990 gi_marshalling_tests_object_vfunc_meth_with_error (GIMarshallingTestsObject *self,
3994 gulong local = 0x12345678;
3995 gboolean ret = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_meth_with_err (self, x, error);
3996 g_assert_cmpint(local, ==, 0x12345678);
4000 G_DEFINE_TYPE (GIMarshallingTestsSubObject, gi_marshalling_tests_sub_object, GI_MARSHALLING_TESTS_TYPE_OBJECT);
4003 gi_marshalling_tests_sub_object_init (GIMarshallingTestsSubObject *object)
4008 gi_marshalling_tests_sub_object_finalize (GObject *object)
4010 G_OBJECT_CLASS(gi_marshalling_tests_sub_object_parent_class)->finalize(object);
4014 method_deep_hierarchy (GIMarshallingTestsObject *self, gint8 in)
4017 g_value_init (&val, G_TYPE_INT);
4018 g_value_set_int (&val, in);
4019 g_object_set_property (G_OBJECT (self), "int", &val);
4023 gi_marshalling_tests_sub_object_class_init (GIMarshallingTestsSubObjectClass *klass)
4025 G_OBJECT_CLASS(klass)->finalize = gi_marshalling_tests_sub_object_finalize;
4026 GI_MARSHALLING_TESTS_OBJECT_CLASS(klass)->method_deep_hierarchy = method_deep_hierarchy;
4030 gi_marshalling_tests_sub_object_sub_method (GIMarshallingTestsSubObject *object)
4032 g_assert(GI_MARSHALLING_TESTS_OBJECT(object)->int_ == 0);
4036 gi_marshalling_tests_sub_object_overwritten_method (GIMarshallingTestsSubObject *object)
4038 g_assert(GI_MARSHALLING_TESTS_OBJECT(object)->int_ == 0);
4041 G_DEFINE_TYPE (GIMarshallingTestsSubSubObject, gi_marshalling_tests_sub_sub_object, GI_MARSHALLING_TESTS_TYPE_SUB_OBJECT);
4044 gi_marshalling_tests_sub_sub_object_init (GIMarshallingTestsSubSubObject *object)
4049 gi_marshalling_tests_sub_sub_object_class_init (GIMarshallingTestsSubSubObjectClass *klass)
4056 gi_marshalling_tests_interface_class_init(void *g_iface)
4061 gi_marshalling_tests_interface_get_type(void)
4063 static GType type = 0;
4065 type = g_type_register_static_simple (G_TYPE_INTERFACE,
4066 "GIMarshallingTestsInterface",
4067 sizeof (GIMarshallingTestsInterfaceIface),
4068 (GClassInitFunc) gi_marshalling_tests_interface_class_init,
4076 * gi_marshalling_tests_interface_test_int8_in:
4080 gi_marshalling_tests_interface_test_int8_in (GIMarshallingTestsInterface *self, gint8 in)
4082 GI_MARSHALLING_TESTS_INTERFACE_GET_IFACE (self)->test_int8_in (self, in);
4086 * gi_marshalling_tests_test_interface_test_int8_in:
4090 gi_marshalling_tests_test_interface_test_int8_in (GIMarshallingTestsInterface *test_iface, gint8 in)
4092 gi_marshalling_tests_interface_test_int8_in (test_iface, in);
4097 gi_marshalling_tests_interface2_class_init(void *g_iface)
4102 gi_marshalling_tests_interface2_get_type(void)
4104 static GType type = 0;
4106 type = g_type_register_static_simple (G_TYPE_INTERFACE,
4107 "GIMarshallingTestsInterface2",
4108 sizeof (GIMarshallingTestsInterface2Iface),
4109 (GClassInitFunc) gi_marshalling_tests_interface2_class_init,
4118 * gi_marshalling_tests_int_out_out:
4123 gi_marshalling_tests_int_out_out (gint *int0, gint *int1)
4130 * gi_marshalling_tests_int_three_in_three_out:
4139 gi_marshalling_tests_int_three_in_three_out(gint a, gint b, gint c,
4140 gint *out0, gint *out1, gint *out2)
4148 * gi_marshalling_tests_int_return_out:
4152 gi_marshalling_tests_int_return_out (gint *int_)
4161 gi_marshalling_tests_gerror(GError **error)
4163 GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4164 g_set_error_literal(error,
4166 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4167 GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4171 * gi_marshalling_tests_gerror_array_in:
4172 * @in_ints: (array zero-terminated=1):
4175 gi_marshalling_tests_gerror_array_in(gint *in_ints, GError **error)
4177 GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4178 g_set_error_literal(error,
4180 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4181 GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4185 * gi_marshalling_tests_gerror_out:
4186 * @error: (out) (allow-none) (transfer full): location for the GError.
4187 * @debug: (out) (allow-none) (transfer full): location for the debug message
4189 * Inspired by gst_message_parse_error.
4192 gi_marshalling_tests_gerror_out(GError **error, gchar **debug)
4194 GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4195 g_set_error_literal(error,
4197 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4198 GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4200 if (debug != NULL) {
4201 *debug = g_strdup (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE);
4206 * gi_marshalling_tests_gerror_out_transfer_none:
4207 * @err: (out) (allow-none) (transfer none): location for the GError.
4208 * @debug: (out) (allow-none) (transfer none): location for the debug message
4210 * A variant of gi_marshalling_tests_gerror_out() which returns data the caller
4214 gi_marshalling_tests_gerror_out_transfer_none(GError **err, const gchar **debug)
4216 static GError error = { 0,
4217 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4218 GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE };
4219 error.domain = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4221 *debug = GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE;
4225 * gi_marshalling_tests_gerror_return:
4227 * Yet another variant of gi_marshalling_tests_gerror_out().
4229 * Returns: (transfer full): a GError
4232 gi_marshalling_tests_gerror_return(void)
4234 GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4236 return g_error_new(quark,
4237 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4238 GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4241 static GIMarshallingTestsOverridesStruct *
4242 gi_marshalling_tests_overrides_struct_copy (GIMarshallingTestsOverridesStruct *struct_)
4244 GIMarshallingTestsOverridesStruct *new_struct;
4246 new_struct = g_slice_new (GIMarshallingTestsOverridesStruct);
4248 *new_struct = *struct_;
4254 gi_marshalling_tests_overrides_struct_free (GIMarshallingTestsOverridesStruct *struct_)
4256 g_slice_free (GIMarshallingTestsOverridesStruct, struct_);
4260 gi_marshalling_tests_overrides_struct_get_type (void)
4262 static GType type = 0;
4265 type = g_boxed_type_register_static ("GIMarshallingTestsOverridesStruct",
4266 (GBoxedCopyFunc) gi_marshalling_tests_overrides_struct_copy,
4267 (GBoxedFreeFunc) gi_marshalling_tests_overrides_struct_free);
4273 GIMarshallingTestsOverridesStruct *
4274 gi_marshalling_tests_overrides_struct_new (void)
4276 return g_slice_new (GIMarshallingTestsOverridesStruct);
4280 gi_marshalling_tests_overrides_struct_method (GIMarshallingTestsOverridesStruct *struct_)
4287 * gi_marshalling_tests_overrides_struct_returnv:
4289 * Returns: (transfer full):
4291 GIMarshallingTestsOverridesStruct *
4292 gi_marshalling_tests_overrides_struct_returnv (void)
4294 return gi_marshalling_tests_overrides_struct_new();
4298 G_DEFINE_TYPE (GIMarshallingTestsOverridesObject, gi_marshalling_tests_overrides_object, G_TYPE_OBJECT);
4301 gi_marshalling_tests_overrides_object_init (GIMarshallingTestsOverridesObject *object)
4306 gi_marshalling_tests_overrides_object_finalize (GObject *object)
4308 G_OBJECT_CLASS (gi_marshalling_tests_overrides_object_parent_class)->finalize (object);
4312 gi_marshalling_tests_overrides_object_class_init (GIMarshallingTestsOverridesObjectClass *klass)
4314 GObjectClass* object_class = G_OBJECT_CLASS (klass);
4316 GObjectClass* parent_class = G_OBJECT_CLASS (klass);
4319 object_class->finalize = gi_marshalling_tests_overrides_object_finalize;
4322 GIMarshallingTestsOverridesObject *
4323 gi_marshalling_tests_overrides_object_new (void)
4325 return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
4329 gi_marshalling_tests_overrides_object_method (GIMarshallingTestsOverridesObject *object)
4335 * gi_marshalling_tests_overrides_object_returnv:
4337 * Returns: (transfer full):
4339 GIMarshallingTestsOverridesObject *
4340 gi_marshalling_tests_overrides_object_returnv (void)
4342 return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
4346 * gi_marshalling_tests_filename_list_return:
4348 * Returns: (transfer none) (element-type filename): List of filenames
4351 gi_marshalling_tests_filename_list_return (void)
4359 SOME_BOOLEAN_PROPERTY,
4361 SOME_UCHAR_PROPERTY,
4365 SOME_ULONG_PROPERTY,
4366 SOME_INT64_PROPERTY,
4367 SOME_UINT64_PROPERTY,
4368 SOME_FLOAT_PROPERTY,
4369 SOME_DOUBLE_PROPERTY
4372 G_DEFINE_TYPE (GIMarshallingTestsPropertiesObject, gi_marshalling_tests_properties_object, G_TYPE_OBJECT);
4375 gi_marshalling_tests_properties_object_init (GIMarshallingTestsPropertiesObject * self)
4380 gi_marshalling_tests_properties_object_finalize (GObject* obj)
4382 G_OBJECT_CLASS (gi_marshalling_tests_properties_object_parent_class)->finalize (obj);
4386 gi_marshalling_tests_properties_object_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec)
4388 GIMarshallingTestsPropertiesObject * self;
4389 self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
4390 switch (property_id) {
4391 case SOME_BOOLEAN_PROPERTY:
4392 g_value_set_boolean (value, self->some_boolean);
4394 case SOME_CHAR_PROPERTY:
4395 g_value_set_schar (value, self->some_char);
4397 case SOME_UCHAR_PROPERTY:
4398 g_value_set_uchar (value, self->some_uchar);
4400 case SOME_INT_PROPERTY:
4401 g_value_set_int (value, self->some_int);
4403 case SOME_UINT_PROPERTY:
4404 g_value_set_uint (value, self->some_uint);
4406 case SOME_LONG_PROPERTY:
4407 g_value_set_long (value, self->some_long);
4409 case SOME_ULONG_PROPERTY:
4410 g_value_set_ulong (value, self->some_ulong);
4412 case SOME_INT64_PROPERTY:
4413 g_value_set_int64 (value, self->some_int64);
4415 case SOME_UINT64_PROPERTY:
4416 g_value_set_uint64 (value, self->some_uint64);
4418 case SOME_FLOAT_PROPERTY:
4419 g_value_set_float (value, self->some_float);
4421 case SOME_DOUBLE_PROPERTY:
4422 g_value_set_double (value, self->some_double);
4425 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
4431 gi_marshalling_tests_properties_object_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec)
4433 GIMarshallingTestsPropertiesObject * self;
4434 self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
4435 switch (property_id) {
4436 case SOME_BOOLEAN_PROPERTY:
4437 self->some_boolean = g_value_get_boolean (value);
4439 case SOME_CHAR_PROPERTY:
4440 self->some_char = g_value_get_schar (value);
4442 case SOME_UCHAR_PROPERTY:
4443 self->some_uchar = g_value_get_uchar (value);
4445 case SOME_INT_PROPERTY:
4446 self->some_int = g_value_get_int (value);
4448 case SOME_UINT_PROPERTY:
4449 self->some_uint = g_value_get_uint (value);
4451 case SOME_LONG_PROPERTY:
4452 self->some_long = g_value_get_long (value);
4454 case SOME_ULONG_PROPERTY:
4455 self->some_ulong = g_value_get_ulong (value);
4457 case SOME_INT64_PROPERTY:
4458 self->some_int64 = g_value_get_int64 (value);
4460 case SOME_UINT64_PROPERTY:
4461 self->some_uint64 = g_value_get_uint64 (value);
4463 case SOME_FLOAT_PROPERTY:
4464 self->some_float = g_value_get_float (value);
4466 case SOME_DOUBLE_PROPERTY:
4467 self->some_double = g_value_get_double (value);
4470 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
4476 gi_marshalling_tests_properties_object_class_init (GIMarshallingTestsPropertiesObjectClass * klass)
4478 GObjectClass* object_class = G_OBJECT_CLASS (klass);
4480 object_class->finalize = gi_marshalling_tests_properties_object_finalize;
4481 object_class->get_property = gi_marshalling_tests_properties_object_get_property;
4482 object_class->set_property = gi_marshalling_tests_properties_object_set_property;
4484 g_object_class_install_property (object_class, SOME_BOOLEAN_PROPERTY,
4485 g_param_spec_boolean ("some-boolean", "some-boolean", "some-boolean", FALSE,
4486 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4488 g_object_class_install_property (object_class, SOME_CHAR_PROPERTY,
4489 g_param_spec_char ("some-char", "some-char", "some-char", G_MININT8, G_MAXINT8, 0,
4490 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4492 g_object_class_install_property (object_class, SOME_UCHAR_PROPERTY,
4493 g_param_spec_uchar ("some-uchar", "some-uchar", "some-uchar", 0, G_MAXUINT8, 0,
4494 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4496 g_object_class_install_property (object_class, SOME_INT_PROPERTY,
4497 g_param_spec_int ("some-int", "some-int", "some-int", G_MININT, G_MAXINT, 0,
4498 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4500 g_object_class_install_property (object_class, SOME_UINT_PROPERTY,
4501 g_param_spec_uint ("some-uint", "some-uint", "some-uint", 0, G_MAXUINT, 0,
4502 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4504 g_object_class_install_property (object_class, SOME_LONG_PROPERTY,
4505 g_param_spec_long ("some-long", "some-long", "some-long", G_MINLONG, G_MAXLONG, 0,
4506 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4508 g_object_class_install_property (object_class, SOME_ULONG_PROPERTY,
4509 g_param_spec_ulong ("some-ulong", "some-ulong", "some-ulong", 0, G_MAXULONG, 0,
4510 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4512 g_object_class_install_property (object_class, SOME_INT64_PROPERTY,
4513 g_param_spec_int64 ("some-int64", "some-int64", "some-int64", G_MININT64, G_MAXINT64, 0,
4514 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4516 g_object_class_install_property (object_class, SOME_UINT64_PROPERTY,
4517 g_param_spec_uint64 ("some-uint64", "some-uint64", "some-uint64", 0, G_MAXUINT64, 0,
4518 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4520 g_object_class_install_property (object_class, SOME_FLOAT_PROPERTY,
4521 g_param_spec_float ("some-float", "some-float", "some-float", -1 * G_MAXFLOAT, G_MAXFLOAT, 0,
4522 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4524 g_object_class_install_property (object_class, SOME_DOUBLE_PROPERTY,
4525 g_param_spec_double ("some-double", "some-double", "some-double", -1 * G_MAXDOUBLE, G_MAXDOUBLE, 0,
4526 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4529 GIMarshallingTestsPropertiesObject*
4530 gi_marshalling_tests_properties_object_new (void)
4532 return g_object_new (GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT, NULL);