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 *v);
14 gi_marshalling_tests_boolean_return_true (void)
20 gi_marshalling_tests_boolean_return_false (void)
26 gi_marshalling_tests_boolean_in_true (gboolean v)
32 gi_marshalling_tests_boolean_in_false (gboolean v)
34 g_assert (v == FALSE);
38 * gi_marshalling_tests_boolean_out_true:
42 gi_marshalling_tests_boolean_out_true (gboolean *v)
48 * gi_marshalling_tests_boolean_out_false:
52 gi_marshalling_tests_boolean_out_false (gboolean *v)
58 * gi_marshalling_tests_boolean_inout_true_false:
62 gi_marshalling_tests_boolean_inout_true_false (gboolean *v)
64 g_assert (*v == TRUE);
69 * gi_marshalling_tests_boolean_inout_false_true:
73 gi_marshalling_tests_boolean_inout_false_true (gboolean *v)
75 g_assert (*v == 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 v)
97 g_assert_cmpint(v, ==, G_MAXINT8);
101 gi_marshalling_tests_int8_in_min (gint8 v)
103 g_assert_cmpint(v, ==, G_MININT8);
107 * gi_marshalling_tests_int8_out_max:
111 gi_marshalling_tests_int8_out_max (gint8 *v)
117 * gi_marshalling_tests_int8_out_min:
121 gi_marshalling_tests_int8_out_min (gint8 *v)
127 * gi_marshalling_tests_int8_inout_max_min:
131 gi_marshalling_tests_int8_inout_max_min (gint8 *v)
133 g_assert_cmpint(*v, ==, G_MAXINT8);
138 * gi_marshalling_tests_int8_inout_min_max:
142 gi_marshalling_tests_int8_inout_min_max (gint8 *v)
144 g_assert_cmpint(*v, ==, G_MININT8);
150 gi_marshalling_tests_uint8_return (void)
156 gi_marshalling_tests_uint8_in (guint8 v)
158 g_assert_cmpuint(v, ==, G_MAXUINT8);
162 * gi_marshalling_tests_uint8_out:
166 gi_marshalling_tests_uint8_out (guint8 *v)
172 * gi_marshalling_tests_uint8_inout:
176 gi_marshalling_tests_uint8_inout (guint8 *v)
178 g_assert_cmpuint(*v, ==, 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 v)
198 g_assert_cmpint(v, ==, G_MAXINT16);
202 gi_marshalling_tests_int16_in_min (gint16 v)
204 g_assert_cmpint(v, ==, G_MININT16);
208 * gi_marshalling_tests_int16_out_max:
212 gi_marshalling_tests_int16_out_max (gint16 *v)
218 * gi_marshalling_tests_int16_out_min:
222 gi_marshalling_tests_int16_out_min (gint16 *v)
228 * gi_marshalling_tests_int16_inout_max_min:
232 gi_marshalling_tests_int16_inout_max_min (gint16 *v)
234 g_assert_cmpint(*v, ==, G_MAXINT16);
239 * gi_marshalling_tests_int16_inout_min_max:
243 gi_marshalling_tests_int16_inout_min_max (gint16 *v)
245 g_assert_cmpint(*v, ==, G_MININT16);
251 gi_marshalling_tests_uint16_return (void)
257 gi_marshalling_tests_uint16_in (guint16 v)
259 g_assert_cmpuint(v, ==, G_MAXUINT16);
263 * gi_marshalling_tests_uint16_out:
267 gi_marshalling_tests_uint16_out (guint16 *v)
273 * gi_marshalling_tests_uint16_inout:
277 gi_marshalling_tests_uint16_inout (guint16 *v)
279 g_assert_cmpuint(*v, ==, 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 v)
299 g_assert_cmpint(v, ==, G_MAXINT32);
303 gi_marshalling_tests_int32_in_min (gint32 v)
305 g_assert_cmpint(v, ==, G_MININT32);
309 * gi_marshalling_tests_int32_out_max:
313 gi_marshalling_tests_int32_out_max (gint32 *v)
319 * gi_marshalling_tests_int32_out_min:
323 gi_marshalling_tests_int32_out_min (gint32 *v)
329 * gi_marshalling_tests_int32_inout_max_min:
333 gi_marshalling_tests_int32_inout_max_min (gint32 *v)
335 g_assert_cmpint(*v, ==, G_MAXINT32);
340 * gi_marshalling_tests_int32_inout_min_max:
344 gi_marshalling_tests_int32_inout_min_max (gint32 *v)
346 g_assert_cmpint(*v, ==, G_MININT32);
352 gi_marshalling_tests_uint32_return (void)
358 gi_marshalling_tests_uint32_in (guint32 v)
360 g_assert_cmpuint(v, ==, G_MAXUINT32);
364 * gi_marshalling_tests_uint32_out:
368 gi_marshalling_tests_uint32_out (guint32 *v)
374 * gi_marshalling_tests_uint32_inout:
378 gi_marshalling_tests_uint32_inout (guint32 *v)
380 g_assert_cmpuint(*v, ==, 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 v)
400 g_assert_cmpint(v, ==, G_MAXINT64);
404 gi_marshalling_tests_int64_in_min (gint64 v)
406 g_assert_cmpint(v, ==, G_MININT64);
410 * gi_marshalling_tests_int64_out_max:
414 gi_marshalling_tests_int64_out_max (gint64 *v)
420 * gi_marshalling_tests_int64_out_min:
424 gi_marshalling_tests_int64_out_min (gint64 *v)
430 * gi_marshalling_tests_int64_inout_max_min:
434 gi_marshalling_tests_int64_inout_max_min (gint64 *v)
436 g_assert_cmpint(*v, ==, G_MAXINT64);
441 * gi_marshalling_tests_int64_inout_min_max:
445 gi_marshalling_tests_int64_inout_min_max (gint64 *v)
447 g_assert_cmpint(*v, ==, G_MININT64);
453 gi_marshalling_tests_uint64_return (void)
459 gi_marshalling_tests_uint64_in (guint64 v)
461 g_assert_cmpuint(v, ==, G_MAXUINT64);
465 * gi_marshalling_tests_uint64_out:
469 gi_marshalling_tests_uint64_out (guint64 *v)
475 * gi_marshalling_tests_uint64_inout:
479 gi_marshalling_tests_uint64_inout (guint64 *v)
481 g_assert_cmpuint(*v, ==, 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_cmpint(short_, ==, G_MAXSHORT);
505 gi_marshalling_tests_short_in_min (gshort short_)
507 g_assert_cmpint(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_cmpint(*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_cmpint(*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_cmpuint(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_cmpuint(*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_cmpint(int_, ==, G_MAXINT);
606 gi_marshalling_tests_int_in_min (gint int_)
608 g_assert_cmpint(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_cmpint(*int_, ==, G_MAXINT);
643 * gi_marshalling_tests_int_inout_min_max:
647 gi_marshalling_tests_int_inout_min_max (gint *int_)
649 g_assert_cmpint(*int_, ==, G_MININT);
655 gi_marshalling_tests_uint_return (void)
661 gi_marshalling_tests_uint_in (guint uint_)
663 g_assert_cmpuint(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_cmpuint(*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_cmpint(long_, ==, G_MAXLONG);
707 gi_marshalling_tests_long_in_min (glong long_)
709 g_assert_cmpint(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_cmpint(*long_, ==, G_MAXLONG);
744 * gi_marshalling_tests_long_inout_min_max:
748 gi_marshalling_tests_long_inout_min_max (glong *long_)
750 g_assert_cmpint(*long_, ==, G_MINLONG);
756 gi_marshalling_tests_ulong_return (void)
762 gi_marshalling_tests_ulong_in (gulong ulong_)
764 g_assert_cmpuint(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_cmpuint(*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_cmpint(ssize, ==, G_MAXSSIZE);
808 gi_marshalling_tests_ssize_in_min (gssize ssize)
810 g_assert_cmpint(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_cmpint(*ssize, ==, G_MAXSSIZE);
845 * gi_marshalling_tests_ssize_inout_min_max:
849 gi_marshalling_tests_ssize_inout_min_max (gssize *ssize)
851 g_assert_cmpint(*ssize, ==, G_MINSSIZE);
857 gi_marshalling_tests_size_return (void)
863 gi_marshalling_tests_size_in (gsize size)
865 g_assert_cmpuint(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_cmpuint(*size, ==, G_MAXSIZE);
891 gi_marshalling_tests_float_return (void)
897 gi_marshalling_tests_float_in (gfloat v)
899 g_assert_cmpfloat(v, ==, G_MAXFLOAT);
903 * gi_marshalling_tests_float_out:
907 gi_marshalling_tests_float_out (gfloat *v)
913 * gi_marshalling_tests_float_inout:
917 gi_marshalling_tests_float_inout (gfloat *v)
919 g_assert_cmpfloat(*v, ==, G_MAXFLOAT);
925 gi_marshalling_tests_double_return (void)
931 gi_marshalling_tests_double_in (gdouble v)
933 g_assert_cmpfloat(v, ==, G_MAXDOUBLE);
937 * gi_marshalling_tests_double_out:
941 gi_marshalling_tests_double_out (gdouble *v)
947 * gi_marshalling_tests_double_inout:
951 gi_marshalling_tests_double_inout (gdouble *v)
953 g_assert_cmpfloat(*v, ==, G_MAXDOUBLE);
959 gi_marshalling_tests_time_t_return (void)
965 gi_marshalling_tests_time_t_in (time_t v)
967 g_assert_cmpuint(v, ==, 1234567890);
971 * gi_marshalling_tests_time_t_out:
975 gi_marshalling_tests_time_t_out (time_t *v)
981 * gi_marshalling_tests_time_t_inout:
985 gi_marshalling_tests_time_t_inout (time_t *v)
987 g_assert_cmpuint(*v, ==, 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_cmpstr(GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, utf8);
1068 * gi_marshalling_tests_utf8_as_uint8array_in:
1069 * @array: (array length=len) (element-type guint8): Byte data that happens to be UTF-8
1072 * Takes data that happens to be UTF-8 as a byte array, to test
1073 * binding conversion from their string type (e.g. JavaScript's
1077 gi_marshalling_tests_utf8_as_uint8array_in (const guint8 *array,
1080 gsize orig_len = strlen (GI_MARSHALLING_TESTS_CONSTANT_UTF8);
1081 g_assert_cmpint (orig_len, ==, len);
1082 g_assert (memcmp (GI_MARSHALLING_TESTS_CONSTANT_UTF8, array, len) == 0);
1086 * gi_marshalling_tests_utf8_none_out:
1087 * @utf8: (out) (transfer none):
1090 gi_marshalling_tests_utf8_none_out (gchar **utf8)
1092 *utf8 = GI_MARSHALLING_TESTS_CONSTANT_UTF8;
1096 * gi_marshalling_tests_utf8_full_out:
1097 * @utf8: (out) (transfer full):
1100 gi_marshalling_tests_utf8_full_out (gchar **utf8)
1102 *utf8 = g_strdup(GI_MARSHALLING_TESTS_CONSTANT_UTF8);
1106 * gi_marshalling_tests_utf8_dangling_out:
1107 * @utf8: (out) (transfer full):
1110 gi_marshalling_tests_utf8_dangling_out (gchar **utf8)
1112 /* Intentionally don't touch the pointer to see how
1113 the bindings handle this case. Bindings should be
1114 robust against broken C functions and can initialize
1115 even OUT vlues to NULL.
1120 * gi_marshalling_tests_utf8_none_inout:
1121 * @utf8: (inout) (transfer none):
1124 gi_marshalling_tests_utf8_none_inout (gchar **utf8)
1126 g_assert_cmpstr(GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, *utf8);
1131 * gi_marshalling_tests_utf8_full_inout:
1132 * @utf8: (inout) (transfer full):
1135 gi_marshalling_tests_utf8_full_inout (gchar **utf8)
1137 g_assert_cmpstr(GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, *utf8);
1139 *utf8 = g_strdup("");
1144 * gi_marshalling_tests_init_function:
1145 * @n_args: (inout) (allow-none): number of args
1146 * @argv: (inout) (array length=n_args) (allow-none): args
1148 * This is like gtk_init().
1151 gi_marshalling_tests_init_function (gint *n_args, char ***argv)
1159 g_assert (argv != NULL);
1160 (*argv)[*n_args] = NULL;
1165 * gi_marshalling_tests_array_fixed_int_return:
1167 * Returns: (array fixed-size=4):
1170 gi_marshalling_tests_array_fixed_int_return (void)
1172 static gint ints[] = {-1, 0, 1, 2};
1177 * gi_marshalling_tests_array_fixed_short_return:
1179 * Returns: (array fixed-size=4):
1182 gi_marshalling_tests_array_fixed_short_return (void)
1184 static gshort shorts[] = {-1, 0, 1, 2};
1189 * gi_marshalling_tests_array_fixed_int_in:
1190 * @ints: (array fixed-size=4):
1193 gi_marshalling_tests_array_fixed_int_in (const gint *ints)
1195 g_assert_cmpint(ints[0], ==, -1);
1196 g_assert_cmpint(ints[1], ==, 0);
1197 g_assert_cmpint(ints[2], ==, 1);
1198 g_assert_cmpint(ints[3], ==, 2);
1202 * gi_marshalling_tests_array_fixed_short_in:
1203 * @shorts: (array fixed-size=4):
1206 gi_marshalling_tests_array_fixed_short_in (const gshort *shorts)
1208 g_assert_cmpint(shorts[0], ==, -1);
1209 g_assert_cmpint(shorts[1], ==, 0);
1210 g_assert_cmpint(shorts[2], ==, 1);
1211 g_assert_cmpint(shorts[3], ==, 2);
1215 * gi_marshalling_tests_array_fixed_out:
1216 * @ints: (out) (array fixed-size=4) (transfer none):
1219 gi_marshalling_tests_array_fixed_out (gint **ints)
1221 static gint values[] = {-1, 0, 1, 2};
1226 * gi_marshalling_tests_array_fixed_out_struct:
1227 * @structs: (out) (array fixed-size=2) (transfer none):
1230 gi_marshalling_tests_array_fixed_out_struct (GIMarshallingTestsSimpleStruct **structs)
1232 static GIMarshallingTestsSimpleStruct *values;
1234 if (values == NULL) {
1235 values = g_new(GIMarshallingTestsSimpleStruct, 2);
1237 values[0].long_ = 7;
1240 values[1].long_ = 6;
1248 * gi_marshalling_tests_array_fixed_inout:
1249 * @ints: (inout) (array fixed-size=4) (transfer none):
1252 gi_marshalling_tests_array_fixed_inout (gint **ints)
1254 static gint values[] = {2, 1, 0, -1};
1256 g_assert_cmpint((*ints)[0], ==, -1);
1257 g_assert_cmpint((*ints)[1], ==, 0);
1258 g_assert_cmpint((*ints)[2], ==, 1);
1259 g_assert_cmpint((*ints)[3], ==, 2);
1266 * gi_marshalling_tests_array_return:
1268 * Returns: (array length=length):
1271 gi_marshalling_tests_array_return (gint *length)
1273 static gint ints[] = {-1, 0, 1, 2};
1280 * gi_marshalling_tests_array_return_etc:
1286 * Returns: (array length=length):
1289 gi_marshalling_tests_array_return_etc (gint first, gint *length, gint last, gint *sum)
1291 static gint ints[] = {-1, 0, 1, 2};
1295 *sum = first + last;
1301 * gi_marshalling_tests_array_in:
1302 * @ints: (array length=length):
1306 gi_marshalling_tests_array_in (const gint *ints, gint length)
1308 g_assert_cmpint(length, ==, 4);
1309 g_assert_cmpint(ints[0], ==, -1);
1310 g_assert_cmpint(ints[1], ==, 0);
1311 g_assert_cmpint(ints[2], ==, 1);
1312 g_assert_cmpint(ints[3], ==, 2);
1316 * gi_marshalling_tests_array_in_len_before:
1318 * @ints: (array length=length):
1321 gi_marshalling_tests_array_in_len_before (gint length, const gint *ints)
1323 gi_marshalling_tests_array_in (ints, length);
1327 * gi_marshalling_tests_array_in_len_zero_terminated:
1328 * @ints: (array length=length zero-terminated=1):
1332 gi_marshalling_tests_array_in_len_zero_terminated (const gint *ints, gint length)
1334 g_assert_cmpint(length, ==, 4);
1336 g_assert_cmpint(ints[0], ==, -1);
1337 g_assert_cmpint(ints[1], ==, 0);
1338 g_assert_cmpint(ints[2], ==, 1);
1339 g_assert_cmpint(ints[3], ==, 2);
1341 /* One past the end, null terminator */
1342 g_assert_cmpint(ints[4], ==, 0);
1346 * gi_marshalling_tests_array_string_in:
1347 * @strings: (array length=length):
1350 gi_marshalling_tests_array_string_in (const gchar **strings, gint length)
1352 g_assert_cmpint(length, ==, 2);
1353 g_assert_cmpstr(strings[0], ==, "foo");
1354 g_assert_cmpstr(strings[1], ==, "bar");
1358 * gi_marshalling_tests_array_uint8_in:
1359 * @chars: (array length=length):
1362 gi_marshalling_tests_array_uint8_in (const guint8 *chars, gint length)
1364 g_assert_cmpint(length, ==, 4);
1365 g_assert(chars[0] == 'a');
1366 g_assert(chars[1] == 'b');
1367 g_assert(chars[2] == 'c');
1368 g_assert(chars[3] == 'd');
1372 * gi_marshalling_tests_array_struct_in:
1373 * @structs: (array length=length):
1376 gi_marshalling_tests_array_struct_in (GIMarshallingTestsBoxedStruct **structs, gint length)
1378 g_assert_cmpint(length, ==, 3);
1379 g_assert_cmpint(structs[0]->long_, ==, 1);
1380 g_assert_cmpint(structs[1]->long_, ==, 2);
1381 g_assert_cmpint(structs[2]->long_, ==, 3);
1385 * gi_marshalling_tests_array_simple_struct_in:
1386 * @structs: (array length=length):
1389 gi_marshalling_tests_array_simple_struct_in (GIMarshallingTestsSimpleStruct *structs, gint length)
1391 g_assert_cmpint(length, ==, 3);
1392 g_assert_cmpint(structs[0].long_, ==, 1);
1393 g_assert_cmpint(structs[1].long_, ==, 2);
1394 g_assert_cmpint(structs[2].long_, ==, 3);
1398 * gi_marshalling_tests_multi_array_key_value_in:
1399 * @keys: (array length=length):
1400 * @values: (array length=length):
1403 gi_marshalling_tests_multi_array_key_value_in (gint length, const gchar **keys, const GValue *values)
1405 g_assert_cmpint(length, ==, 3);
1406 g_assert_cmpstr("one", ==, keys[0]);
1407 g_assert_cmpint(g_value_get_int(&values[0]), ==, 1);
1408 g_assert_cmpstr("two", ==, keys[1]);
1409 g_assert_cmpint(g_value_get_int(&values[1]), ==, 2);
1410 g_assert_cmpstr("three", ==, keys[2]);
1411 g_assert_cmpint(g_value_get_int(&values[2]), ==, 3);
1416 * gi_marshalling_tests_array_struct_take_in:
1417 * @structs: (array length=length) (transfer full):
1420 gi_marshalling_tests_array_struct_take_in (GIMarshallingTestsBoxedStruct **structs, gint length)
1422 gi_marshalling_tests_array_struct_in (structs, length);
1424 /* only really useful if run in valgrind actually */
1425 gi_marshalling_tests_boxed_struct_free (structs[0]);
1426 gi_marshalling_tests_boxed_struct_free (structs[1]);
1427 gi_marshalling_tests_boxed_struct_free (structs[2]);
1432 * gi_marshalling_tests_array_enum_in:
1433 * @_enum: (array length=length) (transfer none):
1437 gi_marshalling_tests_array_enum_in (GIMarshallingTestsEnum *v, gint length)
1439 g_assert_cmpint(length, ==, 3);
1440 g_assert_cmpint(v[0], ==, GI_MARSHALLING_TESTS_ENUM_VALUE1);
1441 g_assert_cmpint(v[1], ==, GI_MARSHALLING_TESTS_ENUM_VALUE2);
1442 g_assert_cmpint(v[2], ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
1446 * gi_marshalling_tests_array_in_guint64_len:
1447 * @ints: (array length=length) (transfer none):
1451 gi_marshalling_tests_array_in_guint64_len (const gint *ints, guint64 length)
1453 g_assert_cmpint(length, ==, 4);
1455 gi_marshalling_tests_array_in (ints, length);
1459 * gi_marshalling_tests_array_in_guint8_len:
1460 * @ints: (array length=length) (transfer none):
1464 gi_marshalling_tests_array_in_guint8_len (const gint *ints, guint8 length)
1466 g_assert_cmpint(length, ==, 4);
1468 gi_marshalling_tests_array_in (ints, length);
1472 * gi_marshalling_tests_array_out:
1473 * @ints: (out) (array length=length) (transfer none):
1476 gi_marshalling_tests_array_out (gint **ints, gint *length)
1478 static gint values[] = {-1, 0, 1, 2};
1485 * gi_marshalling_tests_array_out_etc:
1487 * @ints: (out) (array length=length) (transfer none):
1493 gi_marshalling_tests_array_out_etc (gint first, gint **ints, gint *length, gint last, gint *sum)
1495 static gint values[] = {-1, 0, 1, 2};
1499 *sum = first + last;
1505 * gi_marshalling_tests_array_inout:
1506 * @ints: (inout) (array length=length) (transfer none):
1510 gi_marshalling_tests_array_inout (gint **ints, gint *length)
1512 static gint values[] = {-2, -1, 0, 1, 2};
1514 g_assert_cmpint(*length, ==, 4);
1515 g_assert_cmpint((*ints)[0], ==, -1);
1516 g_assert_cmpint((*ints)[1], ==, 0);
1517 g_assert_cmpint((*ints)[2], ==, 1);
1518 g_assert_cmpint((*ints)[3], ==, 2);
1525 * gi_marshalling_tests_array_inout_etc:
1527 * @ints: (inout) (array length=length) (transfer none):
1533 gi_marshalling_tests_array_inout_etc (gint first, gint **ints, gint *length, gint last, gint *sum)
1535 static gint values[] = {-2, -1, 0, 1, 2};
1537 g_assert_cmpint(*length, ==, 4);
1538 g_assert_cmpint((*ints)[0], ==, -1);
1539 g_assert_cmpint((*ints)[1], ==, 0);
1540 g_assert_cmpint((*ints)[2], ==, 1);
1541 g_assert_cmpint((*ints)[3], ==, 2);
1545 *sum = first + last;
1551 * gi_marshalling_tests_array_in_nonzero_nonlen:
1556 gi_marshalling_tests_array_in_nonzero_nonlen (gint first, const guint8 *chars)
1558 g_assert(chars[0] == 'a');
1559 g_assert(chars[1] == 'b');
1560 g_assert(chars[2] == 'c');
1561 g_assert(chars[3] == 'd');
1565 * gi_marshalling_tests_array_zero_terminated_return:
1567 * Returns: (array zero-terminated=1) (transfer none):
1570 gi_marshalling_tests_array_zero_terminated_return (void)
1572 static gchar *values[] = {"0", "1", "2", NULL};
1577 * gi_marshalling_tests_array_zero_terminated_return_null:
1579 * Returns: (array zero-terminated=1) (transfer none):
1582 gi_marshalling_tests_array_zero_terminated_return_null (void)
1588 * gi_marshalling_tests_array_zero_terminated_return_struct:
1590 * Returns: (array zero-terminated=1) (transfer full):
1592 GIMarshallingTestsBoxedStruct **
1593 gi_marshalling_tests_array_zero_terminated_return_struct (void)
1595 GIMarshallingTestsBoxedStruct **ret = (GIMarshallingTestsBoxedStruct**) g_new (gpointer, 4);
1597 ret[0] = gi_marshalling_tests_boxed_struct_new ();
1600 ret[1] = gi_marshalling_tests_boxed_struct_new ();
1603 ret[2] = gi_marshalling_tests_boxed_struct_new ();
1612 * gi_marshalling_tests_array_zero_terminated_in:
1613 * @utf8s: (array zero-terminated=1) (transfer none):
1616 gi_marshalling_tests_array_zero_terminated_in (gchar **utf8s)
1618 g_assert(g_strv_length(utf8s));
1619 g_assert_cmpstr(utf8s[0], ==, "0");
1620 g_assert_cmpstr(utf8s[1], ==, "1");
1621 g_assert_cmpstr(utf8s[2], ==, "2");
1625 * gi_marshalling_tests_array_zero_terminated_out:
1626 * @utf8s: (out) (array zero-terminated=1) (transfer none):
1629 gi_marshalling_tests_array_zero_terminated_out (gchar ***utf8s)
1631 static gchar *values[] = {"0", "1", "2", NULL};
1636 * gi_marshalling_tests_array_zero_terminated_inout:
1637 * @utf8s: (inout) (array zero-terminated=1) (transfer none):
1640 gi_marshalling_tests_array_zero_terminated_inout (gchar ***utf8s)
1642 static gchar *values[] = {"-1", "0", "1", "2", NULL};
1644 g_assert(g_strv_length(*utf8s));
1645 g_assert_cmpstr((*utf8s)[0], ==, "0");
1646 g_assert_cmpstr((*utf8s)[1], ==, "1");
1647 g_assert_cmpstr((*utf8s)[2], ==, "2");
1653 * gi_marshalling_tests_array_gvariant_none_in:
1654 * @variants: (array zero-terminated=1) (transfer none):
1656 * Returns: (array zero-terminated=1) (transfer none):
1659 gi_marshalling_tests_array_gvariant_none_in (GVariant **variants)
1661 /* Use a static container to detect if someone tries to free it */
1662 static GVariant *private_container[3] = { NULL, NULL, NULL };
1664 if (private_container[0] == NULL) {
1665 private_container[0] = g_variant_new_int32 (27);
1666 private_container[1] = g_variant_new_string ("Hello");
1669 g_assert (variants != NULL);
1670 g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1671 g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1672 g_assert (variants[2] == NULL);
1674 return private_container;
1678 * gi_marshalling_tests_array_gvariant_container_in:
1679 * @variants: (array zero-terminated=1) (transfer container):
1681 * Returns: (array zero-terminated=1) (transfer container):
1684 gi_marshalling_tests_array_gvariant_container_in (GVariant **variants)
1686 GVariant **container;
1688 g_assert (variants != NULL);
1689 g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1690 g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1691 g_assert (variants[2] == NULL);
1693 container = g_new0 (GVariant*, 3);
1694 container[0] = variants[0];
1695 container[1] = variants[1];
1702 * gi_marshalling_tests_array_gvariant_full_in:
1703 * @variants: (array zero-terminated=1) (transfer full):
1705 * Returns: (array zero-terminated=1) (transfer full):
1708 gi_marshalling_tests_array_gvariant_full_in (GVariant **variants)
1710 GVariant **container;
1712 g_assert (variants != NULL);
1713 g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1714 g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1715 g_assert (variants[2] == NULL);
1717 /* To catch different behaviors we reconstruct one variant from scratch,
1718 * while leaving the other untouched. Both approaches are legal with full
1719 * transfer in and out */
1720 container = g_new0 (GVariant*, 3);
1721 container[0] = g_variant_new_int32 (g_variant_get_int32 (variants[0]));
1722 g_variant_unref (variants[0]);
1723 container[1] = variants[1];
1730 * gi_marshalling_tests_garray_int_none_return:
1732 * Returns: (element-type gint) (transfer none):
1735 gi_marshalling_tests_garray_int_none_return (void)
1737 static GArray *v = NULL;
1741 v = g_array_new (TRUE, TRUE, sizeof (gint));
1742 for (i = -1; i < 3; i++)
1743 g_array_append_val (v, i);
1750 * gi_marshalling_tests_garray_uint64_none_return:
1752 * Returns: (element-type guint64) (transfer none):
1755 gi_marshalling_tests_garray_uint64_none_return (void)
1757 static GArray *array = NULL;
1760 if (array == NULL) {
1761 array = g_array_new (TRUE, TRUE, sizeof (guint64));
1763 g_array_append_val (array, i);
1765 g_array_append_val (array, i);
1772 * gi_marshalling_tests_garray_utf8_none_return:
1774 * Returns: (element-type utf8) (transfer none):
1777 gi_marshalling_tests_garray_utf8_none_return (void)
1779 static GArray *array = NULL;
1780 static gchar *values[] = {"0", "1", "2", NULL};
1783 if (array == NULL) {
1784 array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1785 for (i = 0; values[i]; i++)
1786 g_array_append_val (array, values[i]);
1793 * gi_marshalling_tests_garray_utf8_container_return:
1795 * Returns: (element-type utf8) (transfer container):
1798 gi_marshalling_tests_garray_utf8_container_return (void)
1800 GArray *array = NULL;
1801 static gchar *values[] = {"0", "1", "2", NULL};
1804 array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1805 for (i = 0; values[i]; i++)
1806 g_array_append_val (array, values[i]);
1812 * gi_marshalling_tests_garray_utf8_full_return:
1814 * Returns: (element-type utf8) (transfer full):
1817 gi_marshalling_tests_garray_utf8_full_return (void)
1819 GArray *array = NULL;
1820 static gchar *values[] = {"0", "1", "2", NULL};
1823 array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1824 for (i = 0; values[i]; i++) {
1825 gchar *str = g_strdup (values[i]);
1826 g_array_append_val (array, str);
1833 * gi_marshalling_tests_garray_int_none_in:
1834 * @array_: (element-type gint) (transfer none):
1837 gi_marshalling_tests_garray_int_none_in (GArray *array_)
1839 g_assert_cmpint(array_->len, ==, 4);
1840 g_assert_cmpint(g_array_index (array_, gint, 0), ==, -1);
1841 g_assert_cmpint(g_array_index (array_, gint, 1), ==, 0);
1842 g_assert_cmpint(g_array_index (array_, gint, 2), ==, 1);
1843 g_assert_cmpint(g_array_index (array_, gint, 3), ==, 2);
1847 * gi_marshalling_tests_garray_uint64_none_in:
1848 * @array_: (element-type guint64) (transfer none):
1851 gi_marshalling_tests_garray_uint64_none_in (GArray *array_)
1853 g_assert_cmpint(array_->len, ==, 2);
1854 g_assert_cmpint(g_array_index (array_, guint64, 0), ==, 0);
1855 g_assert_cmpint(g_array_index (array_, guint64, 1), ==, G_MAXUINT64);
1859 * gi_marshalling_tests_garray_utf8_none_in:
1860 * @array_: (element-type utf8) (transfer none):
1863 gi_marshalling_tests_garray_utf8_none_in (GArray *array_)
1865 g_assert_cmpint(array_->len, ==, 3);
1866 g_assert_cmpstr(g_array_index (array_, gchar*, 0), ==, "0");
1867 g_assert_cmpstr(g_array_index (array_, gchar*, 1), ==, "1");
1868 g_assert_cmpstr(g_array_index (array_, gchar*, 2), ==, "2");
1872 * gi_marshalling_tests_garray_utf8_none_out:
1873 * @array_: (out) (element-type utf8) (transfer none):
1876 gi_marshalling_tests_garray_utf8_none_out (GArray **array_)
1878 static GArray *internal = NULL;
1879 static gchar *values[] = {"0", "1", "2", NULL};
1882 if (internal == NULL) {
1883 internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
1884 for (i = 0; values[i]; i++)
1885 g_array_append_val (internal, values[i]);
1892 * gi_marshalling_tests_garray_utf8_container_out:
1893 * @array_: (out) (element-type utf8) (transfer container):
1896 gi_marshalling_tests_garray_utf8_container_out (GArray **array_)
1898 static gchar *values[] = {"0", "1", "2", NULL};
1903 *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
1904 for (i = 0; values[i]; i++)
1905 g_array_append_val (*array_, values[i]);
1909 * gi_marshalling_tests_garray_utf8_full_out:
1910 * @array_: (out) (element-type utf8) (transfer full):
1913 gi_marshalling_tests_garray_utf8_full_out (GArray **array_)
1915 static gchar *values[] = {"0", "1", "2", NULL};
1920 *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
1921 for (i = 0; values[i]; i++) {
1922 gchar *str = g_strdup (values[i]);
1923 g_array_append_val (*array_, str);
1928 * gi_marshalling_tests_garray_utf8_none_inout:
1929 * @array_: (inout) (element-type utf8) (transfer none):
1932 gi_marshalling_tests_garray_utf8_none_inout (GArray **array_)
1934 static GArray *internal = NULL;
1935 static gchar *values[] = {"-2", "-1", "0", "1", NULL};
1938 g_assert_cmpint((*array_)->len, ==, 3);
1939 g_assert_cmpstr(g_array_index (*array_, gchar*, 0), ==, "0");
1940 g_assert_cmpstr(g_array_index (*array_, gchar*, 1), ==, "1");
1941 g_assert_cmpstr(g_array_index (*array_, gchar*, 2), ==, "2");
1943 if (internal == NULL) {
1944 internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
1945 for (i = 0; values[i]; i++)
1946 g_array_append_val (internal, values[i]);
1953 * gi_marshalling_tests_garray_utf8_container_inout:
1954 * @array_: (inout) (element-type utf8) (transfer container):
1957 gi_marshalling_tests_garray_utf8_container_inout (GArray **array_)
1959 static gchar *val1 = "-2";
1960 static gchar *val2 = "-1";
1961 static gchar *val3 = "0";
1962 static gchar *val4 = "1";
1965 g_assert_cmpint((*array_)->len, ==, 3);
1966 g_assert_cmpstr(g_array_index (*array_, gchar*, 0), ==, "0");
1967 g_assert_cmpstr(g_array_index (*array_, gchar*, 1), ==, "1");
1968 g_assert_cmpstr(g_array_index (*array_, gchar*, 2), ==, "2");
1970 result = g_array_new (TRUE, TRUE, sizeof (gchar *));
1971 g_array_append_val (result, val1);
1972 g_array_append_val (result, val2);
1973 g_array_append_val (result, val3);
1974 g_array_append_val (result, val4);
1980 * gi_marshalling_tests_garray_utf8_full_inout:
1981 * @array_: (inout) (element-type utf8) (transfer full):
1984 gi_marshalling_tests_garray_utf8_full_inout (GArray **array_)
1986 static gchar *val1 = "-1";
1987 static gchar *val2 = "-2";
1991 g_assert_cmpint((*array_)->len, ==, 3);
1992 g_assert_cmpstr(g_array_index (*array_, gchar*, 0), ==, "0");
1993 g_assert_cmpstr(g_array_index (*array_, gchar*, 1), ==, "1");
1994 g_assert_cmpstr(g_array_index (*array_, gchar*, 2), ==, "2");
1996 result = g_array_new (TRUE, TRUE, sizeof (gchar *));
1997 val = g_strdup (val2);
1998 g_array_append_val(result, val);
1999 val = g_strdup (val1);
2000 g_array_append_val(result, val);
2001 val = g_strdup ("0");
2002 g_array_append_val(result, val);
2003 val = g_strdup ("1");
2004 g_array_append_val(result, val);
2010 * gi_marshalling_tests_gptrarray_utf8_none_return:
2012 * Returns: (element-type utf8) (transfer none):
2015 gi_marshalling_tests_gptrarray_utf8_none_return (void)
2017 static GPtrArray *parray = NULL;
2018 static gchar *values[] = {"0", "1", "2"};
2021 if (parray == NULL) {
2022 parray = g_ptr_array_new ();
2023 for (i = 0; i < 3; i++)
2024 g_ptr_array_add (parray, (gpointer) values[i]);
2031 * gi_marshalling_tests_gptrarray_utf8_container_return:
2033 * Returns: (element-type utf8) (transfer container):
2036 gi_marshalling_tests_gptrarray_utf8_container_return (void)
2038 GPtrArray *parray = NULL;
2039 static gchar *values[] = {"0", "1", "2", NULL};
2042 parray = g_ptr_array_new ();
2043 for (i = 0; values[i]; i++)
2044 g_ptr_array_add (parray, (gpointer)values[i]);
2050 * gi_marshalling_tests_gptrarray_utf8_full_return:
2052 * Returns: (element-type utf8) (transfer full):
2055 gi_marshalling_tests_gptrarray_utf8_full_return (void)
2057 GPtrArray *parray = NULL;
2058 static gchar *values[] = {"0", "1", "2", NULL};
2061 parray = g_ptr_array_new ();
2062 for (i = 0; values[i]; i++) {
2063 gchar *str = g_strdup (values[i]);
2064 g_ptr_array_add (parray, (gpointer)str);
2071 * gi_marshalling_tests_gptrarray_utf8_none_in:
2072 * @parray_: (element-type utf8) (transfer none):
2075 gi_marshalling_tests_gptrarray_utf8_none_in (GPtrArray *parray_)
2077 g_assert_cmpint(parray_->len, ==, 3);
2078 g_assert_cmpstr(g_ptr_array_index (parray_, 0), ==, "0");
2079 g_assert_cmpstr(g_ptr_array_index (parray_, 1), ==, "1");
2080 g_assert_cmpstr(g_ptr_array_index (parray_, 2), ==, "2");
2084 * gi_marshalling_tests_gptrarray_utf8_none_out:
2085 * @parray_: (out) (element-type utf8) (transfer none):
2088 gi_marshalling_tests_gptrarray_utf8_none_out (GPtrArray **parray_)
2090 static GPtrArray *internal = NULL;
2091 static gchar *values[] = {"0", "1", "2", NULL};
2094 if (internal == NULL) {
2095 internal = g_ptr_array_new ();
2096 for (i = 0; values[i]; i++)
2097 g_ptr_array_add (internal, (gpointer)values[i]);
2100 *parray_ = internal;
2104 * gi_marshalling_tests_gptrarray_utf8_container_out:
2105 * @parray_: (out) (element-type utf8) (transfer container):
2108 gi_marshalling_tests_gptrarray_utf8_container_out (GPtrArray **parray_)
2110 static gchar *values[] = {"0", "1", "2", NULL};
2115 *parray_ = g_ptr_array_new ();
2116 for (i = 0; values[i]; i++)
2117 g_ptr_array_add (*parray_, (gpointer)values[i]);
2121 * gi_marshalling_tests_gptrarray_utf8_full_out:
2122 * @parray_: (out) (element-type utf8) (transfer full):
2125 gi_marshalling_tests_gptrarray_utf8_full_out (GPtrArray **parray_)
2127 static gchar *values[] = {"0", "1", "2", NULL};
2132 *parray_ = g_ptr_array_new ();
2133 for (i = 0; values[i]; i++) {
2134 gchar *str = g_strdup (values[i]);
2135 g_ptr_array_add (*parray_, (gpointer)str);
2140 * gi_marshalling_tests_gptrarray_utf8_none_inout:
2141 * @parray_: (inout) (element-type utf8) (transfer none):
2144 gi_marshalling_tests_gptrarray_utf8_none_inout (GPtrArray **parray_)
2146 static GPtrArray *internal = NULL;
2147 static gchar *values[] = {"-2", "-1", "0", "1", NULL};
2150 g_assert_cmpint((*parray_)->len, ==, 3);
2151 g_assert_cmpstr(g_ptr_array_index (*parray_, 0), ==, "0");
2152 g_assert_cmpstr(g_ptr_array_index (*parray_, 1), ==, "1");
2153 g_assert_cmpstr(g_ptr_array_index (*parray_, 2), ==, "2");
2155 if (internal == NULL) {
2156 internal = g_ptr_array_new ();
2157 for (i = 0; values[i]; i++)
2158 g_ptr_array_add (internal, (gpointer) values[i]);
2161 *parray_ = internal;
2165 * gi_marshalling_tests_gptrarray_utf8_container_inout:
2166 * @parray_: (inout) (element-type utf8) (transfer container):
2169 gi_marshalling_tests_gptrarray_utf8_container_inout (GPtrArray **parray_)
2171 static gchar *val1 = "-2";
2172 static gchar *val2 = "-1";
2173 static gchar *val3 = "0";
2174 static gchar *val4 = "1";
2177 g_assert_cmpint((*parray_)->len, ==, 3);
2178 g_assert_cmpstr(g_ptr_array_index (*parray_, 0), ==, "0");
2179 g_assert_cmpstr(g_ptr_array_index (*parray_, 1), ==, "1");
2180 g_assert_cmpstr(g_ptr_array_index (*parray_, 2), ==, "2");
2182 result = g_ptr_array_new ();
2183 g_ptr_array_add (result, (gpointer) val1);
2184 g_ptr_array_add (result, (gpointer) val2);
2185 g_ptr_array_add (result, (gpointer) val3);
2186 g_ptr_array_add (result, (gpointer) val4);
2192 * gi_marshalling_tests_gptrarray_utf8_full_inout:
2193 * @parray_: (inout) (element-type utf8) (transfer full):
2196 gi_marshalling_tests_gptrarray_utf8_full_inout (GPtrArray **parray_)
2198 static gchar *val1 = "-1";
2199 static gchar *val2 = "-2";
2203 g_assert_cmpint((*parray_)->len, ==, 3);
2204 g_assert_cmpstr(g_ptr_array_index (*parray_, 0), ==, "0");
2205 g_assert_cmpstr(g_ptr_array_index (*parray_, 1), ==, "1");
2206 g_assert_cmpstr(g_ptr_array_index (*parray_, 2), ==, "2");
2208 result = g_ptr_array_new ();
2209 val = g_strdup (val2);
2210 g_ptr_array_add(result, (gpointer) val);
2211 val = g_strdup (val1);
2212 g_ptr_array_add(result, (gpointer) val);
2213 val = g_strdup ("0");
2214 g_ptr_array_add(result, (gpointer) val);
2215 val = g_strdup ("1");
2216 g_ptr_array_add(result, (gpointer) val);
2222 * gi_marshalling_tests_bytearray_full_return:
2224 * Returns: (transfer full):
2227 gi_marshalling_tests_bytearray_full_return (void)
2229 GByteArray *array = NULL;
2230 guint8 data[] = {'\0', '1', '\xFF', '3'};
2232 array = g_byte_array_new ();
2233 g_byte_array_append (array, (const guint8*)data, G_N_ELEMENTS(data));
2240 * gi_marshalling_tests_bytearray_none_in:
2241 * @v: (element-type gint8) (transfer none):
2244 gi_marshalling_tests_bytearray_none_in (GByteArray *v)
2246 g_assert_cmpuint (v->len, ==, 4);
2247 g_assert_cmpuint (g_array_index (v, unsigned char, 0), ==, 0);
2248 g_assert_cmpuint (g_array_index (v, unsigned char, 1), ==, 49);
2249 g_assert_cmpuint (g_array_index (v, unsigned char, 2), ==, 0xFF);
2250 g_assert_cmpuint (g_array_index (v, unsigned char, 3), ==, 51);
2254 * gi_marshalling_tests_gbytes_full_return:
2256 * Returns: (transfer full):
2259 gi_marshalling_tests_gbytes_full_return (void)
2261 static guint8 data[] = {0, 49, 0xFF, 51};
2263 return g_bytes_new_static (data, G_N_ELEMENTS(data));
2267 * gi_marshalling_tests_gbytes_none_in:
2270 gi_marshalling_tests_gbytes_none_in (GBytes *v)
2274 data = g_bytes_get_data (v, &len);
2276 g_assert_cmpuint (len, ==, 4);
2277 g_assert_cmpuint (data[0], ==, 0);
2278 g_assert_cmpuint (data[1], ==, 49);
2279 g_assert_cmpuint (data[2], ==, 0xFF);
2280 g_assert_cmpuint (data[3], ==, 51);
2284 * gi_marshalling_tests_gstrv_return:
2286 * Returns: (transfer full): an array of strings
2289 gi_marshalling_tests_gstrv_return (void)
2291 GStrv values = g_new0 (gchar*, 4);
2292 values[0] = g_strdup ("0");
2293 values[1] = g_strdup ("1");
2294 values[2] = g_strdup ("2");
2300 * gi_marshalling_tests_gstrv_in:
2304 gi_marshalling_tests_gstrv_in (GStrv g_strv)
2306 g_assert_cmpint(g_strv_length(g_strv), ==, 3);
2307 g_assert_cmpstr(g_strv[0], ==, "0");
2308 g_assert_cmpstr(g_strv[1], ==, "1");
2309 g_assert_cmpstr(g_strv[2], ==, "2");
2313 * gi_marshalling_tests_gstrv_out:
2314 * @g_strv: (out) (transfer none):
2317 gi_marshalling_tests_gstrv_out (GStrv *g_strv)
2319 static gchar *values[] = {"0", "1", "2", NULL};
2324 * gi_marshalling_tests_gstrv_inout:
2325 * @g_strv: (inout) (transfer none):
2328 gi_marshalling_tests_gstrv_inout (GStrv *g_strv)
2330 static gchar *values[] = {"-1", "0", "1", "2", NULL};
2332 g_assert(g_strv_length(*g_strv) == 3);
2333 g_assert(strcmp((*g_strv)[0], "0") == 0);
2334 g_assert(strcmp((*g_strv)[1], "1") == 0);
2335 g_assert(strcmp((*g_strv)[2], "2") == 0);
2341 * gi_marshalling_tests_glist_int_none_return:
2343 * Returns: (element-type gint) (transfer none):
2346 gi_marshalling_tests_glist_int_none_return (void)
2348 static GList *list = NULL;
2351 list = g_list_append(list, GINT_TO_POINTER(-1));
2352 list = g_list_append(list, GINT_TO_POINTER(0));
2353 list = g_list_append(list, GINT_TO_POINTER(1));
2354 list = g_list_append(list, GINT_TO_POINTER(2));
2361 * gi_marshalling_tests_glist_uint32_none_return:
2363 * Returns: (element-type guint32) (transfer none):
2366 gi_marshalling_tests_glist_uint32_none_return (void)
2368 static GList *list = NULL;
2371 list = g_list_append(list, GUINT_TO_POINTER(0));
2372 list = g_list_append(list, GUINT_TO_POINTER(G_MAXUINT32));
2379 * gi_marshalling_tests_glist_utf8_none_return:
2381 * Returns: (element-type utf8) (transfer none):
2384 gi_marshalling_tests_glist_utf8_none_return (void)
2386 static GList *list = NULL;
2389 list = g_list_append(list, "0");
2390 list = g_list_append(list, "1");
2391 list = g_list_append(list, "2");
2398 * gi_marshalling_tests_glist_utf8_container_return:
2400 * Returns: (element-type utf8) (transfer container):
2403 gi_marshalling_tests_glist_utf8_container_return (void)
2407 list = g_list_append(list, "0");
2408 list = g_list_append(list, "1");
2409 list = g_list_append(list, "2");
2415 * gi_marshalling_tests_glist_utf8_full_return:
2417 * Returns: (element-type utf8) (transfer full):
2420 gi_marshalling_tests_glist_utf8_full_return (void)
2424 list = g_list_append(list, g_strdup("0"));
2425 list = g_list_append(list, g_strdup("1"));
2426 list = g_list_append(list, g_strdup("2"));
2432 * gi_marshalling_tests_glist_int_none_in:
2433 * @list: (element-type gint) (transfer none):
2436 gi_marshalling_tests_glist_int_none_in (GList *list)
2438 g_assert_cmpint(g_list_length(list), ==, 4);
2439 g_assert_cmpint(GPOINTER_TO_INT(g_list_nth_data(list, 0)), ==, -1);
2440 g_assert_cmpint(GPOINTER_TO_INT(g_list_nth_data(list, 1)), ==, 0);
2441 g_assert_cmpint(GPOINTER_TO_INT(g_list_nth_data(list, 2)), ==, 1);
2442 g_assert_cmpint(GPOINTER_TO_INT(g_list_nth_data(list, 3)), ==, 2);
2446 * gi_marshalling_tests_glist_uint32_none_in:
2447 * @list: (element-type guint32) (transfer none):
2450 gi_marshalling_tests_glist_uint32_none_in (GList *list)
2452 g_assert_cmpint(g_list_length(list), ==, 2);
2453 g_assert_cmpint(GPOINTER_TO_UINT(g_list_nth_data(list, 0)), ==, 0);
2454 g_assert_cmpint(GPOINTER_TO_UINT(g_list_nth_data(list, 1)), ==, G_MAXUINT32);
2458 * gi_marshalling_tests_glist_utf8_none_in:
2459 * @list: (element-type utf8) (transfer none):
2462 gi_marshalling_tests_glist_utf8_none_in (GList *list)
2464 g_assert_cmpint(g_list_length(list), ==, 3);
2465 g_assert_cmpint(strcmp(g_list_nth_data(list, 0), "0"), ==, 0);
2466 g_assert_cmpint(strcmp(g_list_nth_data(list, 1), "1"), ==, 0);
2467 g_assert_cmpint(strcmp(g_list_nth_data(list, 2), "2"), ==, 0);
2471 * gi_marshalling_tests_glist_utf8_none_out:
2472 * @list: (out) (element-type utf8) (transfer none):
2475 gi_marshalling_tests_glist_utf8_none_out (GList **list)
2477 static GList *values = NULL;
2479 if (values == NULL) {
2480 values = g_list_append(values, "0");
2481 values = g_list_append(values, "1");
2482 values = g_list_append(values, "2");
2489 * gi_marshalling_tests_glist_utf8_container_out:
2490 * @list: (out) (element-type utf8) (transfer container):
2493 gi_marshalling_tests_glist_utf8_container_out (GList **list)
2497 *list = g_list_append(*list, "0");
2498 *list = g_list_append(*list, "1");
2499 *list = g_list_append(*list, "2");
2503 * gi_marshalling_tests_glist_utf8_full_out:
2504 * @list: (out) (element-type utf8) (transfer full):
2507 gi_marshalling_tests_glist_utf8_full_out (GList **list)
2511 *list = g_list_append(*list, g_strdup("0"));
2512 *list = g_list_append(*list, g_strdup("1"));
2513 *list = g_list_append(*list, g_strdup("2"));
2517 * gi_marshalling_tests_glist_utf8_none_inout:
2518 * @list: (inout) (element-type utf8) (transfer none):
2521 gi_marshalling_tests_glist_utf8_none_inout (GList **list)
2523 static GList *values = NULL;
2525 g_assert_cmpint(g_list_length(*list), ==, 3);
2526 g_assert_cmpstr(g_list_nth_data(*list, 0), ==, "0");
2527 g_assert_cmpstr(g_list_nth_data(*list, 1), ==, "1");
2528 g_assert_cmpstr(g_list_nth_data(*list, 2), ==, "2");
2530 if (values == NULL) {
2531 values = g_list_append(values, "-2");
2532 values = g_list_append(values, "-1");
2533 values = g_list_append(values, "0");
2534 values = g_list_append(values, "1");
2541 * gi_marshalling_tests_glist_utf8_container_inout:
2542 * @list: (inout) (element-type utf8) (transfer container):
2545 gi_marshalling_tests_glist_utf8_container_inout (GList **list)
2547 GList *result = NULL;
2549 g_assert_cmpint(g_list_length(*list), ==, 3);
2550 g_assert_cmpstr(g_list_nth_data(*list, 0), ==, "0");
2551 g_assert_cmpstr(g_list_nth_data(*list, 1), ==, "1");
2552 g_assert_cmpstr(g_list_nth_data(*list, 2), ==, "2");
2554 result = g_list_prepend(result, "1");
2555 result = g_list_prepend(result, "0");
2556 result = g_list_prepend(result, "-1");
2557 result = g_list_prepend(result, "-2");
2563 * gi_marshalling_tests_glist_utf8_full_inout:
2564 * @list: (inout) (element-type utf8) (transfer full):
2567 gi_marshalling_tests_glist_utf8_full_inout (GList **list)
2569 GList *result = NULL;
2571 g_assert_cmpint(g_list_length(*list), ==, 3);
2572 g_assert_cmpstr(g_list_nth_data(*list, 0), ==, "0");
2573 g_assert_cmpstr(g_list_nth_data(*list, 1), ==, "1");
2574 g_assert_cmpstr(g_list_nth_data(*list, 2), ==, "2");
2576 result = g_list_prepend(result, g_strdup("1"));
2577 result = g_list_prepend(result, g_strdup("0"));
2578 result = g_list_prepend(result, g_strdup("-1"));
2579 result = g_list_prepend(result, g_strdup("-2"));
2586 * gi_marshalling_tests_gslist_int_none_return:
2588 * Returns: (element-type gint) (transfer none):
2591 gi_marshalling_tests_gslist_int_none_return (void)
2593 static GSList *list = NULL;
2596 list = g_slist_prepend(list, GINT_TO_POINTER(-1));
2597 list = g_slist_prepend(list, GINT_TO_POINTER(0));
2598 list = g_slist_prepend(list, GINT_TO_POINTER(1));
2599 list = g_slist_prepend(list, GINT_TO_POINTER(2));
2600 list = g_slist_reverse(list);
2607 * gi_marshalling_tests_gslist_utf8_none_return:
2609 * Returns: (element-type utf8) (transfer none):
2612 gi_marshalling_tests_gslist_utf8_none_return (void)
2614 static GSList *list = NULL;
2617 list = g_slist_prepend(list, "0");
2618 list = g_slist_prepend(list, "1");
2619 list = g_slist_prepend(list, "2");
2620 list = g_slist_reverse(list);
2627 * gi_marshalling_tests_gslist_utf8_container_return:
2629 * Returns: (element-type utf8) (transfer container):
2632 gi_marshalling_tests_gslist_utf8_container_return (void)
2634 GSList *list = NULL;
2636 list = g_slist_prepend(list, "0");
2637 list = g_slist_prepend(list, "1");
2638 list = g_slist_prepend(list, "2");
2639 list = g_slist_reverse(list);
2645 * gi_marshalling_tests_gslist_utf8_full_return:
2647 * Returns: (element-type utf8) (transfer full):
2650 gi_marshalling_tests_gslist_utf8_full_return (void)
2652 GSList *list = NULL;
2654 list = g_slist_prepend(list, g_strdup("0"));
2655 list = g_slist_prepend(list, g_strdup("1"));
2656 list = g_slist_prepend(list, g_strdup("2"));
2657 list = g_slist_reverse(list);
2663 * gi_marshalling_tests_gslist_int_none_in:
2664 * @list: (element-type gint) (transfer none):
2667 gi_marshalling_tests_gslist_int_none_in (GSList *list)
2669 g_assert_cmpint(g_slist_length(list), ==, 4);
2670 g_assert_cmpint(GPOINTER_TO_INT(g_slist_nth_data(list, 0)), ==, -1);
2671 g_assert_cmpint(GPOINTER_TO_INT(g_slist_nth_data(list, 1)), ==, 0);
2672 g_assert_cmpint(GPOINTER_TO_INT(g_slist_nth_data(list, 2)), ==, 1);
2673 g_assert_cmpint(GPOINTER_TO_INT(g_slist_nth_data(list, 3)), ==, 2);
2677 * gi_marshalling_tests_gslist_utf8_none_in:
2678 * @list: (element-type utf8) (transfer none):
2681 gi_marshalling_tests_gslist_utf8_none_in (GSList *list)
2683 g_assert_cmpint(g_slist_length(list), ==, 3);
2684 g_assert_cmpstr(g_slist_nth_data(list, 0), ==, "0");
2685 g_assert_cmpstr(g_slist_nth_data(list, 1), ==, "1");
2686 g_assert_cmpstr(g_slist_nth_data(list, 2), ==, "2");
2690 * gi_marshalling_tests_gslist_utf8_none_out:
2691 * @list: (out) (element-type utf8) (transfer none):
2694 gi_marshalling_tests_gslist_utf8_none_out (GSList **list)
2696 static GSList *values = NULL;
2698 if (values == NULL) {
2699 values = g_slist_prepend(values, "0");
2700 values = g_slist_prepend(values, "1");
2701 values = g_slist_prepend(values, "2");
2702 values = g_slist_reverse(values);
2709 * gi_marshalling_tests_gslist_utf8_container_out:
2710 * @list: (out) (element-type utf8) (transfer container):
2713 gi_marshalling_tests_gslist_utf8_container_out (GSList **list)
2717 *list = g_slist_prepend(*list, "0");
2718 *list = g_slist_prepend(*list, "1");
2719 *list = g_slist_prepend(*list, "2");
2720 *list = g_slist_reverse(*list);
2724 * gi_marshalling_tests_gslist_utf8_full_out:
2725 * @list: (out) (element-type utf8) (transfer full):
2728 gi_marshalling_tests_gslist_utf8_full_out (GSList **list)
2732 *list = g_slist_prepend(*list, g_strdup("0"));
2733 *list = g_slist_prepend(*list, g_strdup("1"));
2734 *list = g_slist_prepend(*list, g_strdup("2"));
2735 *list = g_slist_reverse(*list);
2739 * gi_marshalling_tests_gslist_utf8_none_inout:
2740 * @list: (inout) (element-type utf8) (transfer none):
2743 gi_marshalling_tests_gslist_utf8_none_inout (GSList **list)
2745 static GSList *values = NULL;
2747 g_assert_cmpint(g_slist_length(*list), ==, 3);
2748 g_assert_cmpstr(g_slist_nth_data(*list, 0), ==, "0");
2749 g_assert_cmpstr(g_slist_nth_data(*list, 1), ==, "1");
2750 g_assert_cmpstr(g_slist_nth_data(*list, 2), ==, "2");
2752 if (values == NULL) {
2753 values = g_slist_prepend(values, "-2");
2754 values = g_slist_prepend(values, "-1");
2755 values = g_slist_prepend(values, "0");
2756 values = g_slist_prepend(values, "1");
2757 values = g_slist_reverse(values);
2764 * gi_marshalling_tests_gslist_utf8_container_inout:
2765 * @list: (inout) (element-type utf8) (transfer container):
2768 gi_marshalling_tests_gslist_utf8_container_inout (GSList **list)
2770 GSList *result = NULL;
2772 g_assert_cmpint(g_slist_length(*list), ==, 3);
2773 g_assert_cmpstr(g_slist_nth_data(*list, 0), ==, "0");
2774 g_assert_cmpstr(g_slist_nth_data(*list, 1), ==, "1");
2775 g_assert_cmpstr(g_slist_nth_data(*list, 2), ==, "2");
2777 result = g_slist_prepend(result, "1");
2778 result = g_slist_prepend(result, "0");
2779 result = g_slist_prepend(result, "-1");
2780 result = g_slist_prepend(result, "-2");
2786 * gi_marshalling_tests_gslist_utf8_full_inout:
2787 * @list: (inout) (element-type utf8) (transfer full):
2790 gi_marshalling_tests_gslist_utf8_full_inout (GSList **list)
2792 GSList *result = NULL;
2794 g_assert_cmpint(g_slist_length(*list), ==, 3);
2795 g_assert_cmpstr(g_slist_nth_data(*list, 0), ==, "0");
2796 g_assert_cmpstr(g_slist_nth_data(*list, 1), ==, "1");
2797 g_assert_cmpstr(g_slist_nth_data(*list, 2), ==, "2");
2799 result = g_slist_prepend(result, g_strdup("1"));
2800 result = g_slist_prepend(result, g_strdup("0"));
2801 result = g_slist_prepend(result, g_strdup("-1"));
2802 result = g_slist_prepend(result, g_strdup("-2"));
2809 * gi_marshalling_tests_ghashtable_int_none_return:
2811 * Returns: (element-type gint gint) (transfer none):
2814 gi_marshalling_tests_ghashtable_int_none_return (void)
2816 static GHashTable *hash_table = NULL;
2818 if (hash_table == NULL) {
2819 hash_table = g_hash_table_new(NULL, NULL);
2820 g_hash_table_insert(hash_table, GINT_TO_POINTER(-1), GINT_TO_POINTER(1));
2821 g_hash_table_insert(hash_table, GINT_TO_POINTER(0), GINT_TO_POINTER(0));
2822 g_hash_table_insert(hash_table, GINT_TO_POINTER(1), GINT_TO_POINTER(-1));
2823 g_hash_table_insert(hash_table, GINT_TO_POINTER(2), GINT_TO_POINTER(-2));
2830 * gi_marshalling_tests_ghashtable_utf8_none_return:
2832 * Returns: (element-type utf8 utf8) (transfer none):
2835 gi_marshalling_tests_ghashtable_utf8_none_return (void)
2837 static GHashTable *hash_table = NULL;
2839 if (hash_table == NULL) {
2840 hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2841 g_hash_table_insert(hash_table, "-1", "1");
2842 g_hash_table_insert(hash_table, "0", "0");
2843 g_hash_table_insert(hash_table, "1", "-1");
2844 g_hash_table_insert(hash_table, "2", "-2");
2851 * gi_marshalling_tests_ghashtable_utf8_container_return:
2853 * Returns: (element-type utf8 utf8) (transfer container):
2856 gi_marshalling_tests_ghashtable_utf8_container_return (void)
2858 GHashTable *hash_table = NULL;
2860 hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2861 g_hash_table_insert(hash_table, "-1", "1");
2862 g_hash_table_insert(hash_table, "0", "0");
2863 g_hash_table_insert(hash_table, "1", "-1");
2864 g_hash_table_insert(hash_table, "2", "-2");
2870 * gi_marshalling_tests_ghashtable_utf8_full_return:
2872 * Returns: (element-type utf8 utf8) (transfer full):
2875 gi_marshalling_tests_ghashtable_utf8_full_return (void)
2877 GHashTable *hash_table = NULL;
2879 hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2880 g_hash_table_insert(hash_table, g_strdup("-1"), g_strdup("1"));
2881 g_hash_table_insert(hash_table, g_strdup("0"), g_strdup("0"));
2882 g_hash_table_insert(hash_table, g_strdup("1"), g_strdup("-1"));
2883 g_hash_table_insert(hash_table, g_strdup("2"), g_strdup("-2"));
2889 * gi_marshalling_tests_ghashtable_int_none_in:
2890 * @hash_table: (element-type gint gint) (transfer none):
2893 gi_marshalling_tests_ghashtable_int_none_in (GHashTable *hash_table)
2895 g_assert_cmpint(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(-1))), ==, 1);
2896 g_assert_cmpint(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(0))), ==, 0);
2897 g_assert_cmpint(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(1))), ==, -1);
2898 g_assert_cmpint(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(2))), ==, -2);
2902 * gi_marshalling_tests_ghashtable_utf8_none_in:
2903 * @hash_table: (element-type utf8 utf8) (transfer none):
2906 gi_marshalling_tests_ghashtable_utf8_none_in (GHashTable *hash_table)
2908 g_assert_cmpstr(g_hash_table_lookup(hash_table, "-1"), ==, "1");
2909 g_assert_cmpstr(g_hash_table_lookup(hash_table, "0"), ==, "0");
2910 g_assert_cmpstr(g_hash_table_lookup(hash_table, "1"), ==, "-1");
2911 g_assert_cmpstr(g_hash_table_lookup(hash_table, "2"), ==, "-2");
2915 * gi_marshalling_tests_ghashtable_utf8_none_out:
2916 * @hash_table: (out) (element-type utf8 utf8) (transfer none):
2919 gi_marshalling_tests_ghashtable_utf8_none_out (GHashTable **hash_table)
2921 static GHashTable *new_hash_table = NULL;
2923 if (new_hash_table == NULL) {
2924 new_hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2925 g_hash_table_insert(new_hash_table, "-1", "1");
2926 g_hash_table_insert(new_hash_table, "0", "0");
2927 g_hash_table_insert(new_hash_table, "1", "-1");
2928 g_hash_table_insert(new_hash_table, "2", "-2");
2931 *hash_table = new_hash_table;
2935 * gi_marshalling_tests_ghashtable_utf8_container_out:
2936 * @hash_table: (out) (element-type utf8 utf8) (transfer container):
2939 gi_marshalling_tests_ghashtable_utf8_container_out (GHashTable **hash_table)
2941 *hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2942 g_hash_table_insert(*hash_table, "-1", "1");
2943 g_hash_table_insert(*hash_table, "0", "0");
2944 g_hash_table_insert(*hash_table, "1", "-1");
2945 g_hash_table_insert(*hash_table, "2", "-2");
2949 * gi_marshalling_tests_ghashtable_utf8_full_out:
2950 * @hash_table: (out) (element-type utf8 utf8) (transfer full):
2953 gi_marshalling_tests_ghashtable_utf8_full_out (GHashTable **hash_table)
2955 *hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2956 g_hash_table_insert(*hash_table, g_strdup("-1"), g_strdup("1"));
2957 g_hash_table_insert(*hash_table, g_strdup("0"), g_strdup("0"));
2958 g_hash_table_insert(*hash_table, g_strdup("1"), g_strdup("-1"));
2959 g_hash_table_insert(*hash_table, g_strdup("2"), g_strdup("-2"));
2963 * gi_marshalling_tests_ghashtable_utf8_none_inout:
2964 * @hash_table: (inout) (element-type utf8 utf8) (transfer none):
2967 gi_marshalling_tests_ghashtable_utf8_none_inout (GHashTable **hash_table)
2969 static GHashTable *new_hash_table = NULL;
2971 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "-1"), ==, "1");
2972 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "0"), ==, "0");
2973 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "1"), ==, "-1");
2974 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "2"), ==, "-2");
2976 if (new_hash_table == NULL) {
2977 new_hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2978 g_hash_table_insert(new_hash_table, "-1", "1");
2979 g_hash_table_insert(new_hash_table, "0", "0");
2980 g_hash_table_insert(new_hash_table, "1", "1");
2983 *hash_table = new_hash_table;
2987 * gi_marshalling_tests_ghashtable_utf8_container_inout:
2988 * @hash_table: (inout) (element-type utf8 utf8) (transfer container):
2991 gi_marshalling_tests_ghashtable_utf8_container_inout (GHashTable **hash_table)
2993 GHashTable *result = g_hash_table_new(g_str_hash, g_str_equal);
2995 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "-1"), ==, "1");
2996 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "0"), ==, "0");
2997 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "1"), ==, "-1");
2998 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "2"), ==, "-2");
3000 g_hash_table_insert(result, "-1", "1");
3001 g_hash_table_insert(result, "0", "0");
3002 g_hash_table_insert(result, "1", "1");
3004 *hash_table = result;
3008 * gi_marshalling_tests_ghashtable_utf8_full_inout:
3009 * @hash_table: (inout) (element-type utf8 utf8) (transfer full):
3012 gi_marshalling_tests_ghashtable_utf8_full_inout (GHashTable **hash_table)
3014 GHashTable *result = g_hash_table_new_full(g_str_hash, g_str_equal,
3017 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "-1"), ==, "1");
3018 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "0"), ==, "0");
3019 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "1"), ==, "-1");
3020 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "2"), ==, "-2");
3022 g_hash_table_insert(result, g_strdup("-1"), g_strdup("1"));
3023 g_hash_table_insert(result, g_strdup("0"), g_strdup("0"));
3024 g_hash_table_insert(result, g_strdup("1"), g_strdup("1"));
3026 *hash_table = result;
3031 * gi_marshalling_tests_gvalue_return:
3033 * Returns: (transfer none):
3036 gi_marshalling_tests_gvalue_return (void)
3038 static GValue *value = NULL;
3040 if (value == NULL) {
3041 value = g_new0(GValue, 1);
3042 g_value_init(value, G_TYPE_INT);
3043 g_value_set_int(value, 42);
3050 * gi_marshalling_tests_gvalue_in:
3051 * @value: (transfer none):
3054 gi_marshalling_tests_gvalue_in (GValue *value)
3056 g_assert_cmpint(g_value_get_int(value), ==, 42);
3060 * gi_marshalling_tests_gvalue_int64_in:
3061 * @value: (transfer none):
3064 gi_marshalling_tests_gvalue_int64_in (GValue *value)
3066 g_assert_cmpint(g_value_get_int64(value), ==, G_MAXINT64);
3070 * gi_marshalling_tests_gvalue_in_with_type:
3071 * @value: (transfer none):
3075 gi_marshalling_tests_gvalue_in_with_type (GValue *value, GType type)
3077 g_assert(g_type_is_a(G_VALUE_TYPE(value), type));
3081 * gi_marshalling_tests_gvalue_in_enum:
3082 * @value: (transfer none):
3085 gi_marshalling_tests_gvalue_in_enum (GValue *value)
3087 g_assert(g_value_get_enum(value) == GI_MARSHALLING_TESTS_ENUM_VALUE3);
3091 * gi_marshalling_tests_gvalue_out:
3092 * @value: (out) (transfer none):
3095 gi_marshalling_tests_gvalue_out (GValue **value)
3097 static GValue *new_value = NULL;
3099 if (new_value == NULL) {
3100 new_value = g_new0(GValue, 1);
3101 g_value_init(new_value, G_TYPE_INT);
3102 g_value_set_int(new_value, 42);
3109 * gi_marshalling_tests_gvalue_int64_out:
3110 * @value: (out) (transfer none):
3113 gi_marshalling_tests_gvalue_int64_out (GValue **value)
3115 static GValue *new_value = NULL;
3117 if (new_value == NULL) {
3118 new_value = g_new0(GValue, 1);
3119 g_value_init(new_value, G_TYPE_INT64);
3120 g_value_set_int64(new_value, G_MAXINT64);
3127 * gi_marshalling_tests_gvalue_out_caller_allocates:
3128 * @value: (out) (transfer none):
3131 gi_marshalling_tests_gvalue_out_caller_allocates (GValue *value)
3133 g_value_init(value, G_TYPE_INT);
3134 g_value_set_int(value, 42);
3138 * gi_marshalling_tests_gvalue_inout:
3139 * @value: (inout) (transfer none):
3142 gi_marshalling_tests_gvalue_inout (GValue **value)
3144 g_assert_cmpint(g_value_get_int(*value), ==, 42);
3145 g_value_unset(*value);
3146 g_value_init(*value, G_TYPE_STRING);
3147 g_value_set_string(*value, "42");
3151 * gi_marshalling_tests_gvalue_flat_array:
3152 * @n_values: number of values
3153 * @values: (array length=n_values): an array containing values
3156 gi_marshalling_tests_gvalue_flat_array (guint n_values,
3157 const GValue *values)
3159 g_assert (n_values == 3);
3161 g_assert_cmpint (g_value_get_int (&values[0]), ==, 42);
3162 g_assert_cmpstr (g_value_get_string (&values[1]), ==, "42");
3163 g_assert_cmpint (g_value_get_boolean (&values[2]), ==, TRUE);
3167 * gi_marshalling_tests_return_gvalue_flat_array:
3169 * Returns: (array fixed-size=3) (transfer full): a flat GValue array
3172 gi_marshalling_tests_return_gvalue_flat_array (void)
3174 GValue *array = g_new0 (GValue, 3);
3176 g_value_init (&array[0], G_TYPE_INT);
3177 g_value_set_int (&array[0], 42);
3179 g_value_init (&array[1], G_TYPE_STRING);
3180 g_value_set_static_string (&array[1], "42");
3182 g_value_init (&array[2], G_TYPE_BOOLEAN);
3183 g_value_set_boolean (&array[2], TRUE);
3189 * gi_marshalling_tests_gvalue_flat_array_round_trip:
3190 * @one: The first GValue
3191 * @two: The second GValue
3192 * @three: The third GValue
3194 * Returns: (array fixed-size=3) (transfer full): a flat array of [@one, @two, @three]
3197 gi_marshalling_tests_gvalue_flat_array_round_trip (const GValue one,
3201 GValue *array = g_new (GValue, 3);
3210 * gi_marshalling_tests_gclosure_in:
3211 * @closure: (transfer none):
3214 gi_marshalling_tests_gclosure_in (GClosure *closure)
3216 GValue return_value = {0, };
3218 g_value_init (&return_value, G_TYPE_INT);
3220 g_closure_invoke (closure,
3225 g_assert_cmpint(g_value_get_int (&return_value), ==, 42);
3227 g_value_unset(&return_value);
3231 _closure_return_42 (void)
3237 _marshal_INT__VOID (GClosure *closure,
3238 GValue *return_value,
3239 guint n_param_values,
3240 const GValue *param_values,
3241 gpointer invocation_hint,
3242 gpointer marshal_data)
3244 typedef gint (*GMarshalFunc_INT__VOID) (void);
3245 register GMarshalFunc_INT__VOID callback;
3246 register GCClosure *cc = (GCClosure*) closure;
3248 callback = (GMarshalFunc_INT__VOID) cc->callback;
3249 g_value_set_int(return_value, callback());
3253 * gi_marshalling_tests_gclosure_return:
3255 * Return: a #GClosure
3258 gi_marshalling_tests_gclosure_return (void)
3260 GClosure *closure = g_cclosure_new ((GCallback)_closure_return_42,
3262 g_closure_set_marshal (closure, _marshal_INT__VOID);
3269 * gi_marshalling_tests_callback_return_value_only:
3270 * @callback: (scope call):
3273 gi_marshalling_tests_callback_return_value_only (GIMarshallingTestsCallbackReturnValueOnly callback)
3279 * gi_marshalling_tests_callback_one_out_parameter:
3280 * @callback: (scope call):
3284 gi_marshalling_tests_callback_one_out_parameter (GIMarshallingTestsCallbackOneOutParameter callback,
3291 * gi_marshalling_tests_callback_multiple_out_parameters:
3292 * @callback: (scope call):
3297 gi_marshalling_tests_callback_multiple_out_parameters (GIMarshallingTestsCallbackMultipleOutParameters callback,
3305 * gi_marshalling_tests_callback_return_value_and_one_out_parameter:
3306 * @callback: (scope call):
3310 gi_marshalling_tests_callback_return_value_and_one_out_parameter (GIMarshallingTestsCallbackReturnValueAndOneOutParameter callback,
3313 return callback (a);
3317 * gi_marshalling_tests_callback_return_value_and_multiple_out_parameters:
3318 * @callback: (scope call):
3323 gi_marshalling_tests_callback_return_value_and_multiple_out_parameters (GIMarshallingTestsCallbackReturnValueAndMultipleOutParameters callback,
3327 return callback (a, b);
3333 * gi_marshalling_tests_pointer_in_return:
3335 * Returns: (transfer none): The same pointer
3338 gi_marshalling_tests_pointer_in_return (gpointer pointer)
3344 gi_marshalling_tests_genum_get_type (void)
3346 static GType type = 0;
3347 if (G_UNLIKELY(type == 0)) {
3348 static const GEnumValue values[] = {
3349 { GI_MARSHALLING_TESTS_GENUM_VALUE1, "GI_MARSHALLING_TESTS_GENUM_VALUE1", "value1" },
3350 { GI_MARSHALLING_TESTS_GENUM_VALUE2, "GI_MARSHALLING_TESTS_GENUM_VALUE2", "value2" },
3351 { GI_MARSHALLING_TESTS_GENUM_VALUE3, "GI_MARSHALLING_TESTS_GENUM_VALUE3", "value3" },
3354 type = g_enum_register_static (g_intern_static_string ("GIMarshallingTestsGEnum"), values);
3360 GIMarshallingTestsGEnum
3361 gi_marshalling_tests_genum_returnv (void)
3363 return GI_MARSHALLING_TESTS_GENUM_VALUE3;
3367 gi_marshalling_tests_genum_in (GIMarshallingTestsGEnum v)
3369 g_assert_cmpint(v, ==, GI_MARSHALLING_TESTS_GENUM_VALUE3);
3373 * gi_marshalling_tests_genum_out:
3377 gi_marshalling_tests_genum_out (GIMarshallingTestsGEnum *v)
3379 *v = GI_MARSHALLING_TESTS_GENUM_VALUE3;
3383 * gi_marshalling_tests_genum_inout:
3387 gi_marshalling_tests_genum_inout (GIMarshallingTestsGEnum *v)
3389 g_assert_cmpint(*v, ==, GI_MARSHALLING_TESTS_GENUM_VALUE3);
3390 *v = GI_MARSHALLING_TESTS_GENUM_VALUE1;
3394 GIMarshallingTestsEnum
3395 gi_marshalling_tests_enum_returnv (void)
3397 return GI_MARSHALLING_TESTS_ENUM_VALUE3;
3401 gi_marshalling_tests_enum_in (GIMarshallingTestsEnum v)
3403 g_assert_cmpint(v, ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
3407 * gi_marshalling_tests_enum_out:
3411 gi_marshalling_tests_enum_out (GIMarshallingTestsEnum *v)
3413 *v = GI_MARSHALLING_TESTS_ENUM_VALUE3;
3417 * gi_marshalling_tests_enum_inout:
3421 gi_marshalling_tests_enum_inout (GIMarshallingTestsEnum *v)
3423 g_assert_cmpint(*v, ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
3424 *v = GI_MARSHALLING_TESTS_ENUM_VALUE1;
3429 gi_marshalling_tests_flags_get_type (void)
3431 static GType type = 0;
3432 if (G_UNLIKELY(type == 0)) {
3433 static const GFlagsValue values[] = {
3434 { GI_MARSHALLING_TESTS_FLAGS_VALUE1, "GI_MARSHALLING_TESTS_FLAGS_VALUE1", "value1" },
3435 { GI_MARSHALLING_TESTS_FLAGS_VALUE2, "GI_MARSHALLING_TESTS_FLAGS_VALUE2", "value2" },
3436 { GI_MARSHALLING_TESTS_FLAGS_VALUE3, "GI_MARSHALLING_TESTS_FLAGS_VALUE3", "value3" },
3437 { GI_MARSHALLING_TESTS_FLAGS_MASK, "GI_MARSHALLING_TESTS_FLAGS_MASK", "mask" },
3438 { GI_MARSHALLING_TESTS_FLAGS_MASK2, "GI_MARSHALLING_TESTS_FLAGS_MASK2", "mask2" },
3441 type = g_flags_register_static (g_intern_static_string ("GIMarshallingTestsFlags"), values);
3447 GIMarshallingTestsFlags
3448 gi_marshalling_tests_flags_returnv (void)
3450 return GI_MARSHALLING_TESTS_FLAGS_VALUE2;
3454 gi_marshalling_tests_flags_in (GIMarshallingTestsFlags v)
3456 g_assert(v == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
3460 gi_marshalling_tests_flags_in_zero (GIMarshallingTestsFlags v)
3466 * gi_marshalling_tests_flags_out:
3470 gi_marshalling_tests_flags_out (GIMarshallingTestsFlags *v)
3472 *v = GI_MARSHALLING_TESTS_FLAGS_VALUE2;
3476 * gi_marshalling_tests_flags_inout:
3480 gi_marshalling_tests_flags_inout (GIMarshallingTestsFlags *v)
3482 g_assert(*v == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
3483 *v = GI_MARSHALLING_TESTS_FLAGS_VALUE1;
3487 GIMarshallingTestsNoTypeFlags
3488 gi_marshalling_tests_no_type_flags_returnv (void)
3490 return GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
3494 gi_marshalling_tests_no_type_flags_in (GIMarshallingTestsNoTypeFlags v)
3496 g_assert(v == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
3500 gi_marshalling_tests_no_type_flags_in_zero (GIMarshallingTestsNoTypeFlags v)
3506 * gi_marshalling_tests_no_type_flags_out:
3510 gi_marshalling_tests_no_type_flags_out (GIMarshallingTestsNoTypeFlags *v)
3512 *v = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
3516 * gi_marshalling_tests_no_type_flags_inout:
3520 gi_marshalling_tests_no_type_flags_inout (GIMarshallingTestsNoTypeFlags *v)
3522 g_assert(*v == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
3523 *v = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE1;
3528 * gi_marshalling_tests_simple_struct_returnv:
3530 * Returns: (transfer none):
3532 GIMarshallingTestsSimpleStruct *
3533 gi_marshalling_tests_simple_struct_returnv (void)
3535 static GIMarshallingTestsSimpleStruct *struct_ = NULL;
3537 if (struct_ == NULL) {
3538 struct_ = g_new(GIMarshallingTestsSimpleStruct, 1);
3548 * gi_marshalling_tests_simple_struct_inv:
3549 * @struct_: (transfer none):
3552 gi_marshalling_tests_simple_struct_inv (GIMarshallingTestsSimpleStruct *struct_)
3554 g_assert_cmpint(struct_->long_, ==, 6);
3555 g_assert_cmpint(struct_->int8, ==, 7);
3559 gi_marshalling_tests_simple_struct_method (GIMarshallingTestsSimpleStruct *struct_)
3561 g_assert_cmpint(struct_->long_, ==, 6);
3562 g_assert_cmpint(struct_->int8, ==, 7);
3567 gi_marshalling_tests_pointer_struct_get_type (void)
3569 static GType type = 0;
3572 type = g_pointer_type_register_static ("GIMarshallingTestsPointerStruct");
3579 * gi_marshalling_tests_pointer_struct_returnv:
3581 * Returns: (transfer none):
3583 GIMarshallingTestsPointerStruct *
3584 gi_marshalling_tests_pointer_struct_returnv (void)
3586 static GIMarshallingTestsPointerStruct *struct_ = NULL;
3588 if (struct_ == NULL) {
3589 struct_ = g_new(GIMarshallingTestsPointerStruct, 1);
3591 struct_->long_ = 42;
3598 * gi_marshalling_tests_pointer_struct_inv:
3599 * @struct_: (transfer none):
3602 gi_marshalling_tests_pointer_struct_inv (GIMarshallingTestsPointerStruct *struct_)
3604 g_assert_cmpint(struct_->long_, ==, 42);
3607 static GIMarshallingTestsBoxedStruct *
3608 gi_marshalling_tests_boxed_struct_copy (GIMarshallingTestsBoxedStruct *struct_)
3610 GIMarshallingTestsBoxedStruct *new_struct;
3612 if (struct_ == NULL)
3615 new_struct = g_slice_new (GIMarshallingTestsBoxedStruct);
3617 *new_struct = *struct_;
3623 gi_marshalling_tests_boxed_struct_free (GIMarshallingTestsBoxedStruct *struct_)
3625 if (struct_ != NULL)
3626 g_slice_free (GIMarshallingTestsBoxedStruct, struct_);
3630 gi_marshalling_tests_boxed_struct_get_type (void)
3632 static GType type = 0;
3635 type = g_boxed_type_register_static ("GIMarshallingTestsBoxedStruct",
3636 (GBoxedCopyFunc) gi_marshalling_tests_boxed_struct_copy,
3637 (GBoxedFreeFunc) gi_marshalling_tests_boxed_struct_free);
3643 GIMarshallingTestsBoxedStruct *
3644 gi_marshalling_tests_boxed_struct_new (void)
3646 return g_slice_new0 (GIMarshallingTestsBoxedStruct);
3650 * gi_marshalling_tests_boxed_struct_returnv:
3652 * Returns: (transfer none):
3654 GIMarshallingTestsBoxedStruct *
3655 gi_marshalling_tests_boxed_struct_returnv (void)
3657 static GIMarshallingTestsBoxedStruct *struct_ = NULL;
3659 if (struct_ == NULL) {
3660 struct_ = g_new(GIMarshallingTestsBoxedStruct, 1);
3662 struct_->long_ = 42;
3663 struct_->g_strv = g_new0(gchar*, 4);
3664 struct_->g_strv[0] = g_strdup("0");
3665 struct_->g_strv[1] = g_strdup("1");
3666 struct_->g_strv[2] = g_strdup("2");
3667 struct_->g_strv[3] = NULL;
3674 * gi_marshalling_tests_boxed_struct_inv:
3675 * @struct_: (transfer none):
3678 gi_marshalling_tests_boxed_struct_inv (GIMarshallingTestsBoxedStruct *struct_)
3680 g_assert_cmpint(struct_->long_, ==, 42);
3684 * gi_marshalling_tests_boxed_struct_out:
3685 * @struct_: (out) (transfer none):
3688 gi_marshalling_tests_boxed_struct_out (GIMarshallingTestsBoxedStruct **struct_)
3690 static GIMarshallingTestsBoxedStruct *new_struct = NULL;
3692 if (new_struct == NULL) {
3693 new_struct = g_new(GIMarshallingTestsBoxedStruct, 1);
3695 new_struct->long_ = 42;
3698 *struct_ = new_struct;
3702 * gi_marshalling_tests_boxed_struct_inout:
3703 * @struct_: (inout) (transfer full):
3706 gi_marshalling_tests_boxed_struct_inout (GIMarshallingTestsBoxedStruct **struct_)
3708 g_assert_cmpint((*struct_)->long_, ==, 42);
3710 (*struct_) = g_slice_new (GIMarshallingTestsBoxedStruct);
3711 (*struct_)->long_ = 0;
3714 static GIMarshallingTestsUnion *
3715 gi_marshalling_tests_union_copy (GIMarshallingTestsUnion *union_)
3717 GIMarshallingTestsUnion *new_union;
3719 new_union = g_slice_new (GIMarshallingTestsUnion);
3721 *new_union = *union_;
3727 gi_marshalling_tests_union_free (GIMarshallingTestsUnion *union_)
3729 g_slice_free (GIMarshallingTestsUnion, union_);
3733 gi_marshalling_tests_union_get_type (void)
3735 static GType type = 0;
3738 type = g_boxed_type_register_static ("GIMarshallingTestsUnion",
3739 (GBoxedCopyFunc) gi_marshalling_tests_union_copy,
3740 (GBoxedFreeFunc) gi_marshalling_tests_union_free);
3747 * gi_marshalling_tests_union_returnv:
3749 * Returns: (transfer none):
3751 GIMarshallingTestsUnion *
3752 gi_marshalling_tests_union_returnv (void)
3754 static GIMarshallingTestsUnion *union_ = NULL;
3756 if (union_ == NULL) {
3757 union_ = g_new(GIMarshallingTestsUnion, 1);
3766 * gi_marshalling_tests_union_inv:
3767 * @union_: (transfer none):
3770 gi_marshalling_tests_union_inv (GIMarshallingTestsUnion *union_)
3772 g_assert_cmpint(union_->long_, ==, 42);
3776 gi_marshalling_tests_union_method (GIMarshallingTestsUnion *union_)
3778 g_assert_cmpint(union_->long_, ==, 42);
3789 static void gi_marshalling_tests_object_real_method_with_default_implementation (
3790 GIMarshallingTestsObject *self, gint8 in);
3792 G_DEFINE_TYPE (GIMarshallingTestsObject, gi_marshalling_tests_object, G_TYPE_OBJECT);
3795 gi_marshalling_tests_object_init (GIMarshallingTestsObject *object)
3800 gi_marshalling_tests_object_finalize (GObject *object)
3802 G_OBJECT_CLASS (gi_marshalling_tests_object_parent_class)->finalize (object);
3806 gi_marshalling_tests_object_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
3808 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3812 GI_MARSHALLING_TESTS_OBJECT (object)->int_ = g_value_get_int (value);
3815 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3821 gi_marshalling_tests_object_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
3823 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3827 g_value_set_int (value, GI_MARSHALLING_TESTS_OBJECT (object)->int_);
3830 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3836 gi_marshalling_tests_object_class_init (GIMarshallingTestsObjectClass *klass)
3838 GObjectClass* object_class = G_OBJECT_CLASS (klass);
3840 GObjectClass* parent_class = G_OBJECT_CLASS (klass);
3843 object_class->finalize = gi_marshalling_tests_object_finalize;
3844 object_class->set_property = gi_marshalling_tests_object_set_property;
3845 object_class->get_property = gi_marshalling_tests_object_get_property;
3847 g_object_class_install_property (object_class, PROP_INT_,
3848 g_param_spec_int ("int", "Integer", "An integer", G_MININT, G_MAXINT, 0,
3849 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
3851 klass->method_with_default_implementation = gi_marshalling_tests_object_real_method_with_default_implementation;
3856 gi_marshalling_tests_object_static_method (void)
3861 gi_marshalling_tests_object_method (GIMarshallingTestsObject *object)
3863 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3864 g_assert_cmpint (object->int_, ==, 42);
3868 gi_marshalling_tests_object_overridden_method (GIMarshallingTestsObject *object)
3870 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3871 g_assert_cmpint (object->int_, ==, 0);
3874 GIMarshallingTestsObject *
3875 gi_marshalling_tests_object_new (gint int_)
3877 return g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, "int", int_, NULL);
3881 * gi_marshalling_tests_object_method_array_in:
3882 * @ints: (array length=length):
3885 gi_marshalling_tests_object_method_array_in (GIMarshallingTestsObject *object, const gint *ints, gint length)
3887 g_assert_cmpint(length, ==, 4);
3888 g_assert_cmpint(ints[0], ==, -1);
3889 g_assert_cmpint(ints[1], ==, 0);
3890 g_assert_cmpint(ints[2], ==, 1);
3891 g_assert_cmpint(ints[3], ==, 2);
3895 * gi_marshalling_tests_object_method_array_out:
3896 * @ints: (out) (array length=length) (transfer none):
3899 gi_marshalling_tests_object_method_array_out (GIMarshallingTestsObject *object, gint **ints, gint *length)
3901 static gint values[] = {-1, 0, 1, 2};
3908 * gi_marshalling_tests_object_method_array_inout:
3909 * @ints: (inout) (array length=length) (transfer none):
3913 gi_marshalling_tests_object_method_array_inout (GIMarshallingTestsObject *object, gint **ints, gint *length)
3915 static gint values[] = {-2, -1, 0, 1, 2};
3917 g_assert_cmpint(*length, ==, 4);
3918 g_assert_cmpint((*ints)[0], ==, -1);
3919 g_assert_cmpint((*ints)[1], ==, 0);
3920 g_assert_cmpint((*ints)[2], ==, 1);
3921 g_assert_cmpint((*ints)[3], ==, 2);
3928 * gi_marshalling_tests_object_method_array_return:
3930 * Returns: (array length=length):
3933 gi_marshalling_tests_object_method_array_return (GIMarshallingTestsObject *object, gint *length)
3935 static gint ints[] = {-1, 0, 1, 2};
3942 * gi_marshalling_tests_object_method_int8_in:
3946 gi_marshalling_tests_object_method_int8_in (GIMarshallingTestsObject *self, gint8 in)
3948 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_in (self, in);
3952 * gi_marshalling_tests_object_method_int8_out:
3956 gi_marshalling_tests_object_method_int8_out (GIMarshallingTestsObject *self, gint8 *out)
3958 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_out (self, out);
3962 * gi_marshalling_tests_object_method_int8_arg_and_out_caller:
3963 * @out: (out caller-allocates):
3966 gi_marshalling_tests_object_method_int8_arg_and_out_caller (GIMarshallingTestsObject *self, gint8 arg, gint8 *out)
3968 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_arg_and_out_caller (self, arg, out);
3972 * gi_marshalling_tests_object_method_int8_arg_and_out_callee:
3976 gi_marshalling_tests_object_method_int8_arg_and_out_callee (GIMarshallingTestsObject *self, gint8 arg, gint8 **out)
3978 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_arg_and_out_callee (self, arg, out);
3982 * gi_marshalling_tests_object_method_str_arg_out_ret:
3983 * @out: (out caller-allocates):
3985 * Returns: (transfer none)
3988 gi_marshalling_tests_object_method_str_arg_out_ret (GIMarshallingTestsObject *self, const gchar* arg, guint *out)
3990 return GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_str_arg_out_ret (self, arg, out);
3994 * gi_marshalling_tests_object_method_with_default_implementation:
3998 gi_marshalling_tests_object_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
4000 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_with_default_implementation (self, in);
4004 gi_marshalling_tests_object_real_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
4007 g_value_init (&val, G_TYPE_INT);
4008 g_value_set_int (&val, in);
4009 g_object_set_property (G_OBJECT (self), "int", &val);
4013 * gi_marshalling_tests_object_vfunc_with_callback:
4014 * @callback: (scope call) (closure callback_data):
4015 * @callback_data: (allow-none):
4017 * Virtual: vfunc_with_callback
4020 gi_marshalling_tests_object_vfunc_with_callback (GIMarshallingTestsObject *object,
4021 GIMarshallingTestsCallbackIntInt callback,
4022 void *callback_data)
4028 _callback (int val, void *user_data)
4030 g_assert (user_data == (gpointer)0xdeadbeef);
4035 gi_marshalling_tests_object_call_vfunc_with_callback (GIMarshallingTestsObject *object)
4037 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (object)->vfunc_with_callback (object,
4039 (void *) 0xdeadbeef);
4043 * gi_marshalling_tests_object_none_return:
4045 * Returns: (transfer none):
4047 GIMarshallingTestsObject *
4048 gi_marshalling_tests_object_none_return (void)
4050 static GIMarshallingTestsObject *object = NULL;
4052 if (object == NULL) {
4053 object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4060 * gi_marshalling_tests_object_full_return:
4062 * Returns: (transfer full):
4064 GIMarshallingTestsObject *
4065 gi_marshalling_tests_object_full_return (void)
4067 return g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4071 * gi_marshalling_tests_object_none_in:
4072 * @object: (transfer none):
4075 gi_marshalling_tests_object_none_in (GIMarshallingTestsObject *object)
4077 g_assert_cmpint(object->int_, ==, 42);
4081 * gi_marshalling_tests_object_none_out:
4082 * @object: (out) (transfer none):
4085 gi_marshalling_tests_object_none_out (GIMarshallingTestsObject **object)
4087 static GIMarshallingTestsObject *new_object = NULL;
4089 if (new_object == NULL) {
4090 new_object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4093 *object = new_object;
4097 * gi_marshalling_tests_object_full_out:
4098 * @object: (out) (transfer full):
4101 gi_marshalling_tests_object_full_out (GIMarshallingTestsObject **object)
4103 *object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4107 * gi_marshalling_tests_object_none_inout:
4108 * @object: (inout) (transfer none):
4111 gi_marshalling_tests_object_none_inout (GIMarshallingTestsObject **object)
4113 static GIMarshallingTestsObject *new_object = NULL;
4115 g_assert_cmpint((*object)->int_, ==, 42);
4117 if (new_object == NULL) {
4118 new_object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4119 new_object->int_ = 0;
4122 *object = new_object;
4126 * gi_marshalling_tests_object_full_inout:
4127 * @object: (inout) (transfer full):
4130 gi_marshalling_tests_object_full_inout (GIMarshallingTestsObject **object)
4132 g_assert_cmpint((*object)->int_, ==, 42);
4134 *object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4138 * gi_marshalling_tests_object_test_int8_in:
4142 gi_marshalling_tests_object_int8_in (GIMarshallingTestsObject *object, gint8 in)
4144 gi_marshalling_tests_object_method_int8_in (object, in);
4148 * gi_marshalling_tests_object_test_int8_out:
4152 gi_marshalling_tests_object_int8_out (GIMarshallingTestsObject *object, gint8 *out)
4154 gi_marshalling_tests_object_method_int8_out (object, out);
4158 * gi_marshalling_tests_object_vfunc_return_value_only:
4161 gi_marshalling_tests_object_vfunc_return_value_only (GIMarshallingTestsObject *self)
4163 /* make sure that local variables don't get smashed */
4165 gulong local = 0x12345678;
4166 return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_only (self);
4167 g_assert_cmpint(local, ==, 0x12345678);
4168 return return_value;
4172 * gi_marshalling_tests_object_vfunc_one_out_parameter:
4176 gi_marshalling_tests_object_vfunc_one_out_parameter (GIMarshallingTestsObject *self, gfloat *a)
4178 /* make sure that local variables don't get smashed */
4179 gulong local = 0x12345678;
4180 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_one_out_parameter (self, a);
4181 g_assert_cmpint(local, ==, 0x12345678);
4185 * gi_marshalling_tests_object_vfunc_multiple_out_parameters:
4190 gi_marshalling_tests_object_vfunc_multiple_out_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b)
4192 /* make sure that local variables don't get smashed */
4193 gulong local = 0x12345678;
4194 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_multiple_out_parameters (self, a, b);
4195 g_assert_cmpint(local, ==, 0x12345678);
4199 * gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter:
4203 gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter (GIMarshallingTestsObject *self, GValue *a)
4205 /* make sure that local variables don't get smashed */
4206 gulong local = 0x12345678;
4207 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_caller_allocated_out_parameter (self, a);
4208 g_assert_cmpint(local, ==, 0x12345678);
4212 * gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter:
4216 gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter (GIMarshallingTestsObject *self, glong *a)
4218 /* make sure that local variables don't get smashed */
4219 gulong return_value;
4220 gulong local = 0x12345678;
4221 return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_one_out_parameter (self, a);
4222 g_assert_cmpint(local, ==, 0x12345678);
4223 return return_value;
4227 * gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters:
4232 gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters (GIMarshallingTestsObject *self, glong *a, glong *b)
4234 gulong return_value;
4235 gulong local = 0x12345678;
4236 return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_multiple_out_parameters (self, a, b);
4237 g_assert_cmpint(local, ==, 0x12345678);
4238 return return_value;
4242 gi_marshalling_tests_object_vfunc_meth_with_error (GIMarshallingTestsObject *self,
4246 gulong local = 0x12345678;
4247 gboolean ret = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_meth_with_err (self, x, error);
4248 g_assert_cmpint(local, ==, 0x12345678);
4252 G_DEFINE_TYPE (GIMarshallingTestsSubObject, gi_marshalling_tests_sub_object, GI_MARSHALLING_TESTS_TYPE_OBJECT);
4255 gi_marshalling_tests_sub_object_init (GIMarshallingTestsSubObject *object)
4260 gi_marshalling_tests_sub_object_finalize (GObject *object)
4262 G_OBJECT_CLASS(gi_marshalling_tests_sub_object_parent_class)->finalize(object);
4266 method_deep_hierarchy (GIMarshallingTestsObject *self, gint8 in)
4269 g_value_init (&val, G_TYPE_INT);
4270 g_value_set_int (&val, in);
4271 g_object_set_property (G_OBJECT (self), "int", &val);
4275 gi_marshalling_tests_sub_object_class_init (GIMarshallingTestsSubObjectClass *klass)
4277 G_OBJECT_CLASS(klass)->finalize = gi_marshalling_tests_sub_object_finalize;
4278 GI_MARSHALLING_TESTS_OBJECT_CLASS(klass)->method_deep_hierarchy = method_deep_hierarchy;
4282 gi_marshalling_tests_sub_object_sub_method (GIMarshallingTestsSubObject *object)
4284 g_assert_cmpint(GI_MARSHALLING_TESTS_OBJECT(object)->int_, ==, 0);
4288 gi_marshalling_tests_sub_object_overwritten_method (GIMarshallingTestsSubObject *object)
4290 g_assert_cmpint(GI_MARSHALLING_TESTS_OBJECT(object)->int_, ==, 0);
4293 G_DEFINE_TYPE (GIMarshallingTestsSubSubObject, gi_marshalling_tests_sub_sub_object, GI_MARSHALLING_TESTS_TYPE_SUB_OBJECT);
4296 gi_marshalling_tests_sub_sub_object_init (GIMarshallingTestsSubSubObject *object)
4301 gi_marshalling_tests_sub_sub_object_class_init (GIMarshallingTestsSubSubObjectClass *klass)
4308 gi_marshalling_tests_interface_class_init(void *g_iface)
4313 gi_marshalling_tests_interface_get_type(void)
4315 static GType type = 0;
4317 type = g_type_register_static_simple (G_TYPE_INTERFACE,
4318 "GIMarshallingTestsInterface",
4319 sizeof (GIMarshallingTestsInterfaceIface),
4320 (GClassInitFunc) gi_marshalling_tests_interface_class_init,
4328 * gi_marshalling_tests_interface_test_int8_in:
4332 gi_marshalling_tests_interface_test_int8_in (GIMarshallingTestsInterface *self, gint8 in)
4334 GI_MARSHALLING_TESTS_INTERFACE_GET_IFACE (self)->test_int8_in (self, in);
4338 * gi_marshalling_tests_test_interface_test_int8_in:
4342 gi_marshalling_tests_test_interface_test_int8_in (GIMarshallingTestsInterface *test_iface, gint8 in)
4344 gi_marshalling_tests_interface_test_int8_in (test_iface, in);
4349 gi_marshalling_tests_interface2_class_init(void *g_iface)
4354 gi_marshalling_tests_interface2_get_type(void)
4356 static GType type = 0;
4358 type = g_type_register_static_simple (G_TYPE_INTERFACE,
4359 "GIMarshallingTestsInterface2",
4360 sizeof (GIMarshallingTestsInterface2Iface),
4361 (GClassInitFunc) gi_marshalling_tests_interface2_class_init,
4369 gi_marshalling_tests_interface3_class_init(void *g_iface)
4374 gi_marshalling_tests_interface3_get_type(void)
4376 static GType type = 0;
4378 type = g_type_register_static_simple (G_TYPE_INTERFACE,
4379 "GIMarshallingTestsInterface3",
4380 sizeof (GIMarshallingTestsInterface3Iface),
4381 (GClassInitFunc) gi_marshalling_tests_interface3_class_init,
4389 * gi_marshalling_tests_interface3_test_variant_array_in:
4390 * @in: (array length=n_in):
4394 gi_marshalling_tests_interface3_test_variant_array_in (GIMarshallingTestsInterface3 *self,
4398 GI_MARSHALLING_TESTS_INTERFACE3_GET_IFACE (self)->test_variant_array_in (self, in, n_in);
4402 * gi_marshalling_tests_int_out_out:
4407 gi_marshalling_tests_int_out_out (gint *int0, gint *int1)
4414 * gi_marshalling_tests_int_three_in_three_out:
4423 gi_marshalling_tests_int_three_in_three_out(gint a, gint b, gint c,
4424 gint *out0, gint *out1, gint *out2)
4432 * gi_marshalling_tests_int_return_out:
4436 gi_marshalling_tests_int_return_out (gint *int_)
4445 gi_marshalling_tests_gerror(GError **error)
4447 GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4448 g_set_error_literal(error,
4450 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4451 GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4455 * gi_marshalling_tests_gerror_array_in:
4456 * @in_ints: (array zero-terminated=1):
4459 gi_marshalling_tests_gerror_array_in(gint *in_ints, GError **error)
4461 GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4462 g_set_error_literal(error,
4464 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4465 GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4469 * gi_marshalling_tests_gerror_out:
4470 * @error: (out) (allow-none) (transfer full): location for the GError.
4471 * @debug: (out) (allow-none) (transfer full): location for the debug message
4473 * Inspired by gst_message_parse_error.
4476 gi_marshalling_tests_gerror_out(GError **error, gchar **debug)
4478 GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4479 g_set_error_literal(error,
4481 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4482 GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4484 if (debug != NULL) {
4485 *debug = g_strdup (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE);
4490 * gi_marshalling_tests_gerror_out_transfer_none:
4491 * @err: (out) (allow-none) (transfer none): location for the GError.
4492 * @debug: (out) (allow-none) (transfer none): location for the debug message
4494 * A variant of gi_marshalling_tests_gerror_out() which returns data the caller
4498 gi_marshalling_tests_gerror_out_transfer_none(GError **err, const gchar **debug)
4500 static GError error = { 0,
4501 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4502 GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE };
4503 error.domain = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4505 *debug = GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE;
4509 * gi_marshalling_tests_gerror_return:
4511 * Yet another variant of gi_marshalling_tests_gerror_out().
4513 * Returns: (transfer full): a GError
4516 gi_marshalling_tests_gerror_return(void)
4518 GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4520 return g_error_new(quark,
4521 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4522 GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4525 static GIMarshallingTestsOverridesStruct *
4526 gi_marshalling_tests_overrides_struct_copy (GIMarshallingTestsOverridesStruct *struct_)
4528 GIMarshallingTestsOverridesStruct *new_struct;
4530 new_struct = g_slice_new (GIMarshallingTestsOverridesStruct);
4532 *new_struct = *struct_;
4538 gi_marshalling_tests_overrides_struct_free (GIMarshallingTestsOverridesStruct *struct_)
4540 g_slice_free (GIMarshallingTestsOverridesStruct, struct_);
4544 gi_marshalling_tests_overrides_struct_get_type (void)
4546 static GType type = 0;
4549 type = g_boxed_type_register_static ("GIMarshallingTestsOverridesStruct",
4550 (GBoxedCopyFunc) gi_marshalling_tests_overrides_struct_copy,
4551 (GBoxedFreeFunc) gi_marshalling_tests_overrides_struct_free);
4557 GIMarshallingTestsOverridesStruct *
4558 gi_marshalling_tests_overrides_struct_new (void)
4560 return g_slice_new (GIMarshallingTestsOverridesStruct);
4564 gi_marshalling_tests_overrides_struct_method (GIMarshallingTestsOverridesStruct *struct_)
4571 * gi_marshalling_tests_overrides_struct_returnv:
4573 * Returns: (transfer full):
4575 GIMarshallingTestsOverridesStruct *
4576 gi_marshalling_tests_overrides_struct_returnv (void)
4578 return gi_marshalling_tests_overrides_struct_new();
4582 G_DEFINE_TYPE (GIMarshallingTestsOverridesObject, gi_marshalling_tests_overrides_object, G_TYPE_OBJECT);
4585 gi_marshalling_tests_overrides_object_init (GIMarshallingTestsOverridesObject *object)
4590 gi_marshalling_tests_overrides_object_finalize (GObject *object)
4592 G_OBJECT_CLASS (gi_marshalling_tests_overrides_object_parent_class)->finalize (object);
4596 gi_marshalling_tests_overrides_object_class_init (GIMarshallingTestsOverridesObjectClass *klass)
4598 GObjectClass* object_class = G_OBJECT_CLASS (klass);
4600 GObjectClass* parent_class = G_OBJECT_CLASS (klass);
4603 object_class->finalize = gi_marshalling_tests_overrides_object_finalize;
4606 GIMarshallingTestsOverridesObject *
4607 gi_marshalling_tests_overrides_object_new (void)
4609 return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
4613 gi_marshalling_tests_overrides_object_method (GIMarshallingTestsOverridesObject *object)
4619 * gi_marshalling_tests_overrides_object_returnv:
4621 * Returns: (transfer full):
4623 GIMarshallingTestsOverridesObject *
4624 gi_marshalling_tests_overrides_object_returnv (void)
4626 return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
4630 * gi_marshalling_tests_filename_list_return:
4632 * Returns: (transfer none) (element-type filename): List of filenames
4635 gi_marshalling_tests_filename_list_return (void)
4641 * gi_marshalling_tests_param_spec_return:
4643 * Returns: (transfer full): a #GParamSpec
4646 gi_marshalling_tests_param_spec_return (void)
4648 return g_param_spec_string ("test-param", "test", "This is a test", "42", G_PARAM_READABLE);
4652 * gi_marshalling_tests_param_spec_out:
4656 gi_marshalling_tests_param_spec_out(GParamSpec **param)
4658 *param = g_param_spec_string("test-param", "test", "This is a test", "42", G_PARAM_READABLE);
4664 SOME_BOOLEAN_PROPERTY,
4666 SOME_UCHAR_PROPERTY,
4670 SOME_ULONG_PROPERTY,
4671 SOME_INT64_PROPERTY,
4672 SOME_UINT64_PROPERTY,
4673 SOME_FLOAT_PROPERTY,
4674 SOME_DOUBLE_PROPERTY,
4676 SOME_BOXED_STRUCT_PROPERTY,
4677 SOME_VARIANT_PROPERTY,
4680 G_DEFINE_TYPE (GIMarshallingTestsPropertiesObject, gi_marshalling_tests_properties_object, G_TYPE_OBJECT);
4683 gi_marshalling_tests_properties_object_init (GIMarshallingTestsPropertiesObject * self)
4688 gi_marshalling_tests_properties_object_finalize (GObject* obj)
4690 G_OBJECT_CLASS (gi_marshalling_tests_properties_object_parent_class)->finalize (obj);
4694 gi_marshalling_tests_properties_object_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec)
4696 GIMarshallingTestsPropertiesObject * self;
4697 self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
4698 switch (property_id) {
4699 case SOME_BOOLEAN_PROPERTY:
4700 g_value_set_boolean (value, self->some_boolean);
4702 case SOME_CHAR_PROPERTY:
4703 g_value_set_schar (value, self->some_char);
4705 case SOME_UCHAR_PROPERTY:
4706 g_value_set_uchar (value, self->some_uchar);
4708 case SOME_INT_PROPERTY:
4709 g_value_set_int (value, self->some_int);
4711 case SOME_UINT_PROPERTY:
4712 g_value_set_uint (value, self->some_uint);
4714 case SOME_LONG_PROPERTY:
4715 g_value_set_long (value, self->some_long);
4717 case SOME_ULONG_PROPERTY:
4718 g_value_set_ulong (value, self->some_ulong);
4720 case SOME_INT64_PROPERTY:
4721 g_value_set_int64 (value, self->some_int64);
4723 case SOME_UINT64_PROPERTY:
4724 g_value_set_uint64 (value, self->some_uint64);
4726 case SOME_FLOAT_PROPERTY:
4727 g_value_set_float (value, self->some_float);
4729 case SOME_DOUBLE_PROPERTY:
4730 g_value_set_double (value, self->some_double);
4732 case SOME_STRV_PROPERTY:
4733 g_value_set_boxed (value, self->some_strv);
4735 case SOME_BOXED_STRUCT_PROPERTY:
4736 g_value_set_boxed (value, self->some_boxed_struct);
4738 case SOME_VARIANT_PROPERTY:
4739 g_value_set_variant (value, self->some_variant);
4742 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
4748 gi_marshalling_tests_properties_object_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec)
4750 GIMarshallingTestsPropertiesObject * self;
4751 self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
4752 switch (property_id) {
4753 case SOME_BOOLEAN_PROPERTY:
4754 self->some_boolean = g_value_get_boolean (value);
4756 case SOME_CHAR_PROPERTY:
4757 self->some_char = g_value_get_schar (value);
4759 case SOME_UCHAR_PROPERTY:
4760 self->some_uchar = g_value_get_uchar (value);
4762 case SOME_INT_PROPERTY:
4763 self->some_int = g_value_get_int (value);
4765 case SOME_UINT_PROPERTY:
4766 self->some_uint = g_value_get_uint (value);
4768 case SOME_LONG_PROPERTY:
4769 self->some_long = g_value_get_long (value);
4771 case SOME_ULONG_PROPERTY:
4772 self->some_ulong = g_value_get_ulong (value);
4774 case SOME_INT64_PROPERTY:
4775 self->some_int64 = g_value_get_int64 (value);
4777 case SOME_UINT64_PROPERTY:
4778 self->some_uint64 = g_value_get_uint64 (value);
4780 case SOME_FLOAT_PROPERTY:
4781 self->some_float = g_value_get_float (value);
4783 case SOME_DOUBLE_PROPERTY:
4784 self->some_double = g_value_get_double (value);
4786 case SOME_STRV_PROPERTY:
4787 g_strfreev (self->some_strv);
4788 self->some_strv = g_strdupv (g_value_get_boxed (value));
4790 case SOME_BOXED_STRUCT_PROPERTY:
4791 gi_marshalling_tests_boxed_struct_free (self->some_boxed_struct);
4792 self->some_boxed_struct = gi_marshalling_tests_boxed_struct_copy (g_value_get_boxed (value));
4794 case SOME_VARIANT_PROPERTY:
4795 if (self->some_variant != NULL)
4796 g_variant_unref (self->some_variant);
4797 self->some_variant = g_value_get_variant (value);
4798 if (self->some_variant != NULL)
4799 g_variant_ref (self->some_variant);
4802 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
4808 gi_marshalling_tests_properties_object_class_init (GIMarshallingTestsPropertiesObjectClass * klass)
4810 GObjectClass* object_class = G_OBJECT_CLASS (klass);
4812 object_class->finalize = gi_marshalling_tests_properties_object_finalize;
4813 object_class->get_property = gi_marshalling_tests_properties_object_get_property;
4814 object_class->set_property = gi_marshalling_tests_properties_object_set_property;
4816 g_object_class_install_property (object_class, SOME_BOOLEAN_PROPERTY,
4817 g_param_spec_boolean ("some-boolean", "some-boolean", "some-boolean", FALSE,
4818 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4820 g_object_class_install_property (object_class, SOME_CHAR_PROPERTY,
4821 g_param_spec_char ("some-char", "some-char", "some-char", G_MININT8, G_MAXINT8, 0,
4822 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4824 g_object_class_install_property (object_class, SOME_UCHAR_PROPERTY,
4825 g_param_spec_uchar ("some-uchar", "some-uchar", "some-uchar", 0, G_MAXUINT8, 0,
4826 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4828 g_object_class_install_property (object_class, SOME_INT_PROPERTY,
4829 g_param_spec_int ("some-int", "some-int", "some-int", G_MININT, G_MAXINT, 0,
4830 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4832 g_object_class_install_property (object_class, SOME_UINT_PROPERTY,
4833 g_param_spec_uint ("some-uint", "some-uint", "some-uint", 0, G_MAXUINT, 0,
4834 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4836 g_object_class_install_property (object_class, SOME_LONG_PROPERTY,
4837 g_param_spec_long ("some-long", "some-long", "some-long", G_MINLONG, G_MAXLONG, 0,
4838 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4840 g_object_class_install_property (object_class, SOME_ULONG_PROPERTY,
4841 g_param_spec_ulong ("some-ulong", "some-ulong", "some-ulong", 0, G_MAXULONG, 0,
4842 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4844 g_object_class_install_property (object_class, SOME_INT64_PROPERTY,
4845 g_param_spec_int64 ("some-int64", "some-int64", "some-int64", G_MININT64, G_MAXINT64, 0,
4846 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4848 g_object_class_install_property (object_class, SOME_UINT64_PROPERTY,
4849 g_param_spec_uint64 ("some-uint64", "some-uint64", "some-uint64", 0, G_MAXUINT64, 0,
4850 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4852 g_object_class_install_property (object_class, SOME_FLOAT_PROPERTY,
4853 g_param_spec_float ("some-float", "some-float", "some-float", -1 * G_MAXFLOAT, G_MAXFLOAT, 0,
4854 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4856 g_object_class_install_property (object_class, SOME_DOUBLE_PROPERTY,
4857 g_param_spec_double ("some-double", "some-double", "some-double", -1 * G_MAXDOUBLE, G_MAXDOUBLE, 0,
4858 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4860 g_object_class_install_property (object_class, SOME_STRV_PROPERTY,
4861 g_param_spec_boxed ("some-strv", "some-strv", "some-strv", G_TYPE_STRV,
4862 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4864 g_object_class_install_property (object_class, SOME_BOXED_STRUCT_PROPERTY,
4865 g_param_spec_boxed ("some-boxed-struct", "some-boxed-struct", "some-boxed-struct",
4866 gi_marshalling_tests_boxed_struct_get_type(),
4867 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4869 g_object_class_install_property (object_class, SOME_VARIANT_PROPERTY,
4870 g_param_spec_variant ("some-variant", "some-variant", "some-variant",
4871 G_VARIANT_TYPE_ANY, NULL,
4872 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4875 GIMarshallingTestsPropertiesObject*
4876 gi_marshalling_tests_properties_object_new (void)
4878 return g_object_new (GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT, NULL);