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_none_out:
1069 * @utf8: (out) (transfer none):
1072 gi_marshalling_tests_utf8_none_out (gchar **utf8)
1074 *utf8 = GI_MARSHALLING_TESTS_CONSTANT_UTF8;
1078 * gi_marshalling_tests_utf8_full_out:
1079 * @utf8: (out) (transfer full):
1082 gi_marshalling_tests_utf8_full_out (gchar **utf8)
1084 *utf8 = g_strdup(GI_MARSHALLING_TESTS_CONSTANT_UTF8);
1088 * gi_marshalling_tests_utf8_dangling_out:
1089 * @utf8: (out) (transfer full):
1092 gi_marshalling_tests_utf8_dangling_out (gchar **utf8)
1094 /* Intentionally don't touch the pointer to see how
1095 the bindings handle this case. Bindings should be
1096 robust against broken C functions and can initialize
1097 even OUT vlues to NULL.
1102 * gi_marshalling_tests_utf8_none_inout:
1103 * @utf8: (inout) (transfer none):
1106 gi_marshalling_tests_utf8_none_inout (gchar **utf8)
1108 g_assert_cmpstr(GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, *utf8);
1113 * gi_marshalling_tests_utf8_full_inout:
1114 * @utf8: (inout) (transfer full):
1117 gi_marshalling_tests_utf8_full_inout (gchar **utf8)
1119 g_assert_cmpstr(GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, *utf8);
1121 *utf8 = g_strdup("");
1126 * gi_marshalling_tests_init_function:
1127 * @n_args: (inout) (allow-none): number of args
1128 * @argv: (inout) (array length=n_args) (allow-none): args
1130 * This is like gtk_init().
1133 gi_marshalling_tests_init_function (gint *n_args, char ***argv)
1141 g_assert (argv != NULL);
1142 (*argv)[*n_args] = NULL;
1147 * gi_marshalling_tests_array_fixed_int_return:
1149 * Returns: (array fixed-size=4):
1152 gi_marshalling_tests_array_fixed_int_return (void)
1154 static gint ints[] = {-1, 0, 1, 2};
1159 * gi_marshalling_tests_array_fixed_short_return:
1161 * Returns: (array fixed-size=4):
1164 gi_marshalling_tests_array_fixed_short_return (void)
1166 static gshort shorts[] = {-1, 0, 1, 2};
1171 * gi_marshalling_tests_array_fixed_int_in:
1172 * @ints: (array fixed-size=4):
1175 gi_marshalling_tests_array_fixed_int_in (const gint *ints)
1177 g_assert_cmpint(ints[0], ==, -1);
1178 g_assert_cmpint(ints[1], ==, 0);
1179 g_assert_cmpint(ints[2], ==, 1);
1180 g_assert_cmpint(ints[3], ==, 2);
1184 * gi_marshalling_tests_array_fixed_short_in:
1185 * @shorts: (array fixed-size=4):
1188 gi_marshalling_tests_array_fixed_short_in (const gshort *shorts)
1190 g_assert_cmpint(shorts[0], ==, -1);
1191 g_assert_cmpint(shorts[1], ==, 0);
1192 g_assert_cmpint(shorts[2], ==, 1);
1193 g_assert_cmpint(shorts[3], ==, 2);
1197 * gi_marshalling_tests_array_fixed_out:
1198 * @ints: (out) (array fixed-size=4) (transfer none):
1201 gi_marshalling_tests_array_fixed_out (gint **ints)
1203 static gint values[] = {-1, 0, 1, 2};
1208 * gi_marshalling_tests_array_fixed_out_struct:
1209 * @structs: (out) (array fixed-size=2) (transfer none):
1212 gi_marshalling_tests_array_fixed_out_struct (GIMarshallingTestsSimpleStruct **structs)
1214 static GIMarshallingTestsSimpleStruct *values;
1216 if (values == NULL) {
1217 values = g_new(GIMarshallingTestsSimpleStruct, 2);
1219 values[0].long_ = 7;
1222 values[1].long_ = 6;
1230 * gi_marshalling_tests_array_fixed_inout:
1231 * @ints: (inout) (array fixed-size=4) (transfer none):
1234 gi_marshalling_tests_array_fixed_inout (gint **ints)
1236 static gint values[] = {2, 1, 0, -1};
1238 g_assert_cmpint((*ints)[0], ==, -1);
1239 g_assert_cmpint((*ints)[1], ==, 0);
1240 g_assert_cmpint((*ints)[2], ==, 1);
1241 g_assert_cmpint((*ints)[3], ==, 2);
1248 * gi_marshalling_tests_array_return:
1250 * Returns: (array length=length):
1253 gi_marshalling_tests_array_return (gint *length)
1255 static gint ints[] = {-1, 0, 1, 2};
1262 * gi_marshalling_tests_array_return_etc:
1268 * Returns: (array length=length):
1271 gi_marshalling_tests_array_return_etc (gint first, gint *length, gint last, gint *sum)
1273 static gint ints[] = {-1, 0, 1, 2};
1277 *sum = first + last;
1283 * gi_marshalling_tests_array_in:
1284 * @ints: (array length=length):
1288 gi_marshalling_tests_array_in (const gint *ints, gint length)
1290 g_assert_cmpint(length, ==, 4);
1291 g_assert_cmpint(ints[0], ==, -1);
1292 g_assert_cmpint(ints[1], ==, 0);
1293 g_assert_cmpint(ints[2], ==, 1);
1294 g_assert_cmpint(ints[3], ==, 2);
1298 * gi_marshalling_tests_array_in_len_before:
1300 * @ints: (array length=length):
1303 gi_marshalling_tests_array_in_len_before (gint length, const gint *ints)
1305 gi_marshalling_tests_array_in (ints, length);
1309 * gi_marshalling_tests_array_in_len_zero_terminated:
1310 * @ints: (array length=length zero-terminated=1):
1314 gi_marshalling_tests_array_in_len_zero_terminated (const gint *ints, gint length)
1316 g_assert_cmpint(length, ==, 4);
1318 g_assert_cmpint(ints[0], ==, -1);
1319 g_assert_cmpint(ints[1], ==, 0);
1320 g_assert_cmpint(ints[2], ==, 1);
1321 g_assert_cmpint(ints[3], ==, 2);
1323 /* One past the end, null terminator */
1324 g_assert_cmpint(ints[4], ==, 0);
1328 * gi_marshalling_tests_array_string_in:
1329 * @strings: (array length=length):
1332 gi_marshalling_tests_array_string_in (const gchar **strings, gint length)
1334 g_assert_cmpint(length, ==, 2);
1335 g_assert_cmpstr(strings[0], ==, "foo");
1336 g_assert_cmpstr(strings[1], ==, "bar");
1340 * gi_marshalling_tests_array_uint8_in:
1341 * @chars: (array length=length):
1344 gi_marshalling_tests_array_uint8_in (const guint8 *chars, gint length)
1346 g_assert_cmpint(length, ==, 4);
1347 g_assert(chars[0] == 'a');
1348 g_assert(chars[1] == 'b');
1349 g_assert(chars[2] == 'c');
1350 g_assert(chars[3] == 'd');
1354 * gi_marshalling_tests_array_struct_in:
1355 * @structs: (array length=length):
1358 gi_marshalling_tests_array_struct_in (GIMarshallingTestsBoxedStruct **structs, gint length)
1360 g_assert_cmpint(length, ==, 3);
1361 g_assert_cmpint(structs[0]->long_, ==, 1);
1362 g_assert_cmpint(structs[1]->long_, ==, 2);
1363 g_assert_cmpint(structs[2]->long_, ==, 3);
1367 * gi_marshalling_tests_array_simple_struct_in:
1368 * @structs: (array length=length):
1371 gi_marshalling_tests_array_simple_struct_in (GIMarshallingTestsSimpleStruct *structs, gint length)
1373 g_assert_cmpint(length, ==, 3);
1374 g_assert_cmpint(structs[0].long_, ==, 1);
1375 g_assert_cmpint(structs[1].long_, ==, 2);
1376 g_assert_cmpint(structs[2].long_, ==, 3);
1380 * gi_marshalling_tests_multi_array_key_value_in:
1381 * @keys: (array length=length):
1382 * @values: (array length=length):
1385 gi_marshalling_tests_multi_array_key_value_in (gint length, const gchar **keys, const GValue *values)
1387 g_assert_cmpint(length, ==, 3);
1388 g_assert_cmpstr("one", ==, keys[0]);
1389 g_assert_cmpint(g_value_get_int(&values[0]), ==, 1);
1390 g_assert_cmpstr("two", ==, keys[1]);
1391 g_assert_cmpint(g_value_get_int(&values[1]), ==, 2);
1392 g_assert_cmpstr("three", ==, keys[2]);
1393 g_assert_cmpint(g_value_get_int(&values[2]), ==, 3);
1398 * gi_marshalling_tests_array_struct_take_in:
1399 * @structs: (array length=length) (transfer full):
1402 gi_marshalling_tests_array_struct_take_in (GIMarshallingTestsBoxedStruct **structs, gint length)
1404 gi_marshalling_tests_array_struct_in (structs, length);
1406 /* only really useful if run in valgrind actually */
1407 gi_marshalling_tests_boxed_struct_free (structs[0]);
1408 gi_marshalling_tests_boxed_struct_free (structs[1]);
1409 gi_marshalling_tests_boxed_struct_free (structs[2]);
1414 * gi_marshalling_tests_array_enum_in:
1415 * @_enum: (array length=length) (transfer none):
1419 gi_marshalling_tests_array_enum_in (GIMarshallingTestsEnum *v, gint length)
1421 g_assert_cmpint(length, ==, 3);
1422 g_assert_cmpint(v[0], ==, GI_MARSHALLING_TESTS_ENUM_VALUE1);
1423 g_assert_cmpint(v[1], ==, GI_MARSHALLING_TESTS_ENUM_VALUE2);
1424 g_assert_cmpint(v[2], ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
1428 * gi_marshalling_tests_array_in_guint64_len:
1429 * @ints: (array length=length) (transfer none):
1433 gi_marshalling_tests_array_in_guint64_len (const gint *ints, guint64 length)
1435 g_assert_cmpint(length, ==, 4);
1437 gi_marshalling_tests_array_in (ints, length);
1441 * gi_marshalling_tests_array_in_guint8_len:
1442 * @ints: (array length=length) (transfer none):
1446 gi_marshalling_tests_array_in_guint8_len (const gint *ints, guint8 length)
1448 g_assert_cmpint(length, ==, 4);
1450 gi_marshalling_tests_array_in (ints, length);
1454 * gi_marshalling_tests_array_out:
1455 * @ints: (out) (array length=length) (transfer none):
1458 gi_marshalling_tests_array_out (gint **ints, gint *length)
1460 static gint values[] = {-1, 0, 1, 2};
1467 * gi_marshalling_tests_array_out_etc:
1469 * @ints: (out) (array length=length) (transfer none):
1475 gi_marshalling_tests_array_out_etc (gint first, gint **ints, gint *length, gint last, gint *sum)
1477 static gint values[] = {-1, 0, 1, 2};
1481 *sum = first + last;
1487 * gi_marshalling_tests_array_inout:
1488 * @ints: (inout) (array length=length) (transfer none):
1492 gi_marshalling_tests_array_inout (gint **ints, gint *length)
1494 static gint values[] = {-2, -1, 0, 1, 2};
1496 g_assert_cmpint(*length, ==, 4);
1497 g_assert_cmpint((*ints)[0], ==, -1);
1498 g_assert_cmpint((*ints)[1], ==, 0);
1499 g_assert_cmpint((*ints)[2], ==, 1);
1500 g_assert_cmpint((*ints)[3], ==, 2);
1507 * gi_marshalling_tests_array_inout_etc:
1509 * @ints: (inout) (array length=length) (transfer none):
1515 gi_marshalling_tests_array_inout_etc (gint first, gint **ints, gint *length, gint last, gint *sum)
1517 static gint values[] = {-2, -1, 0, 1, 2};
1519 g_assert_cmpint(*length, ==, 4);
1520 g_assert_cmpint((*ints)[0], ==, -1);
1521 g_assert_cmpint((*ints)[1], ==, 0);
1522 g_assert_cmpint((*ints)[2], ==, 1);
1523 g_assert_cmpint((*ints)[3], ==, 2);
1527 *sum = first + last;
1533 * gi_marshalling_tests_array_in_nonzero_nonlen:
1538 gi_marshalling_tests_array_in_nonzero_nonlen (gint first, const guint8 *chars)
1540 g_assert(chars[0] == 'a');
1541 g_assert(chars[1] == 'b');
1542 g_assert(chars[2] == 'c');
1543 g_assert(chars[3] == 'd');
1547 * gi_marshalling_tests_array_zero_terminated_return:
1549 * Returns: (array zero-terminated=1) (transfer none):
1552 gi_marshalling_tests_array_zero_terminated_return (void)
1554 static gchar *values[] = {"0", "1", "2", NULL};
1559 * gi_marshalling_tests_array_zero_terminated_return_null:
1561 * Returns: (array zero-terminated=1) (transfer none):
1564 gi_marshalling_tests_array_zero_terminated_return_null (void)
1570 * gi_marshalling_tests_array_zero_terminated_return_struct:
1572 * Returns: (array zero-terminated=1) (transfer full):
1574 GIMarshallingTestsBoxedStruct **
1575 gi_marshalling_tests_array_zero_terminated_return_struct (void)
1577 GIMarshallingTestsBoxedStruct **ret = (GIMarshallingTestsBoxedStruct**) g_new (gpointer, 4);
1579 ret[0] = gi_marshalling_tests_boxed_struct_new ();
1582 ret[1] = gi_marshalling_tests_boxed_struct_new ();
1585 ret[2] = gi_marshalling_tests_boxed_struct_new ();
1594 * gi_marshalling_tests_array_zero_terminated_in:
1595 * @utf8s: (array zero-terminated=1) (transfer none):
1598 gi_marshalling_tests_array_zero_terminated_in (gchar **utf8s)
1600 g_assert(g_strv_length(utf8s));
1601 g_assert_cmpstr(utf8s[0], ==, "0");
1602 g_assert_cmpstr(utf8s[1], ==, "1");
1603 g_assert_cmpstr(utf8s[2], ==, "2");
1607 * gi_marshalling_tests_array_zero_terminated_out:
1608 * @utf8s: (out) (array zero-terminated=1) (transfer none):
1611 gi_marshalling_tests_array_zero_terminated_out (gchar ***utf8s)
1613 static gchar *values[] = {"0", "1", "2", NULL};
1618 * gi_marshalling_tests_array_zero_terminated_inout:
1619 * @utf8s: (inout) (array zero-terminated=1) (transfer none):
1622 gi_marshalling_tests_array_zero_terminated_inout (gchar ***utf8s)
1624 static gchar *values[] = {"-1", "0", "1", "2", NULL};
1626 g_assert(g_strv_length(*utf8s));
1627 g_assert_cmpstr((*utf8s)[0], ==, "0");
1628 g_assert_cmpstr((*utf8s)[1], ==, "1");
1629 g_assert_cmpstr((*utf8s)[2], ==, "2");
1635 * gi_marshalling_tests_array_gvariant_none_in:
1636 * @variants: (array zero-terminated=1) (transfer none):
1638 * Returns: (array zero-terminated=1) (transfer none):
1641 gi_marshalling_tests_array_gvariant_none_in (GVariant **variants)
1643 /* Use a static container to detect if someone tries to free it */
1644 static GVariant *private_container[3] = { NULL, NULL, NULL };
1646 if (private_container[0] == NULL) {
1647 private_container[0] = g_variant_new_int32 (27);
1648 private_container[1] = g_variant_new_string ("Hello");
1651 g_assert (variants != NULL);
1652 g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1653 g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1654 g_assert (variants[2] == NULL);
1656 return private_container;
1660 * gi_marshalling_tests_array_gvariant_container_in:
1661 * @variants: (array zero-terminated=1) (transfer container):
1663 * Returns: (array zero-terminated=1) (transfer container):
1666 gi_marshalling_tests_array_gvariant_container_in (GVariant **variants)
1668 GVariant **container;
1670 g_assert (variants != NULL);
1671 g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1672 g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1673 g_assert (variants[2] == NULL);
1675 container = g_new0 (GVariant*, 3);
1676 container[0] = variants[0];
1677 container[1] = variants[1];
1684 * gi_marshalling_tests_array_gvariant_full_in:
1685 * @variants: (array zero-terminated=1) (transfer full):
1687 * Returns: (array zero-terminated=1) (transfer full):
1690 gi_marshalling_tests_array_gvariant_full_in (GVariant **variants)
1692 GVariant **container;
1694 g_assert (variants != NULL);
1695 g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1696 g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1697 g_assert (variants[2] == NULL);
1699 /* To catch different behaviors we reconstruct one variant from scratch,
1700 * while leaving the other untouched. Both approaches are legal with full
1701 * transfer in and out */
1702 container = g_new0 (GVariant*, 3);
1703 container[0] = g_variant_new_int32 (g_variant_get_int32 (variants[0]));
1704 g_variant_unref (variants[0]);
1705 container[1] = variants[1];
1712 * gi_marshalling_tests_garray_int_none_return:
1714 * Returns: (element-type gint) (transfer none):
1717 gi_marshalling_tests_garray_int_none_return (void)
1719 static GArray *v = NULL;
1723 v = g_array_new (TRUE, TRUE, sizeof (gint));
1724 for (i = -1; i < 3; i++)
1725 g_array_append_val (v, i);
1732 * gi_marshalling_tests_garray_uint64_none_return:
1734 * Returns: (element-type guint64) (transfer none):
1737 gi_marshalling_tests_garray_uint64_none_return (void)
1739 static GArray *array = NULL;
1742 if (array == NULL) {
1743 array = g_array_new (TRUE, TRUE, sizeof (guint64));
1745 g_array_append_val (array, i);
1747 g_array_append_val (array, i);
1754 * gi_marshalling_tests_garray_utf8_none_return:
1756 * Returns: (element-type utf8) (transfer none):
1759 gi_marshalling_tests_garray_utf8_none_return (void)
1761 static GArray *array = NULL;
1762 static gchar *values[] = {"0", "1", "2", NULL};
1765 if (array == NULL) {
1766 array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1767 for (i = 0; values[i]; i++)
1768 g_array_append_val (array, values[i]);
1775 * gi_marshalling_tests_garray_utf8_container_return:
1777 * Returns: (element-type utf8) (transfer container):
1780 gi_marshalling_tests_garray_utf8_container_return (void)
1782 GArray *array = NULL;
1783 static gchar *values[] = {"0", "1", "2", NULL};
1786 array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1787 for (i = 0; values[i]; i++)
1788 g_array_append_val (array, values[i]);
1794 * gi_marshalling_tests_garray_utf8_full_return:
1796 * Returns: (element-type utf8) (transfer full):
1799 gi_marshalling_tests_garray_utf8_full_return (void)
1801 GArray *array = NULL;
1802 static gchar *values[] = {"0", "1", "2", NULL};
1805 array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1806 for (i = 0; values[i]; i++) {
1807 gchar *str = g_strdup (values[i]);
1808 g_array_append_val (array, str);
1815 * gi_marshalling_tests_garray_int_none_in:
1816 * @array_: (element-type gint) (transfer none):
1819 gi_marshalling_tests_garray_int_none_in (GArray *array_)
1821 g_assert_cmpint(array_->len, ==, 4);
1822 g_assert_cmpint(g_array_index (array_, gint, 0), ==, -1);
1823 g_assert_cmpint(g_array_index (array_, gint, 1), ==, 0);
1824 g_assert_cmpint(g_array_index (array_, gint, 2), ==, 1);
1825 g_assert_cmpint(g_array_index (array_, gint, 3), ==, 2);
1829 * gi_marshalling_tests_garray_uint64_none_in:
1830 * @array_: (element-type guint64) (transfer none):
1833 gi_marshalling_tests_garray_uint64_none_in (GArray *array_)
1835 g_assert_cmpint(array_->len, ==, 2);
1836 g_assert_cmpint(g_array_index (array_, guint64, 0), ==, 0);
1837 g_assert_cmpint(g_array_index (array_, guint64, 1), ==, G_MAXUINT64);
1841 * gi_marshalling_tests_garray_utf8_none_in:
1842 * @array_: (element-type utf8) (transfer none):
1845 gi_marshalling_tests_garray_utf8_none_in (GArray *array_)
1847 g_assert_cmpint(array_->len, ==, 3);
1848 g_assert_cmpstr(g_array_index (array_, gchar*, 0), ==, "0");
1849 g_assert_cmpstr(g_array_index (array_, gchar*, 1), ==, "1");
1850 g_assert_cmpstr(g_array_index (array_, gchar*, 2), ==, "2");
1854 * gi_marshalling_tests_garray_utf8_none_out:
1855 * @array_: (out) (element-type utf8) (transfer none):
1858 gi_marshalling_tests_garray_utf8_none_out (GArray **array_)
1860 static GArray *internal = NULL;
1861 static gchar *values[] = {"0", "1", "2", NULL};
1864 if (internal == NULL) {
1865 internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
1866 for (i = 0; values[i]; i++)
1867 g_array_append_val (internal, values[i]);
1874 * gi_marshalling_tests_garray_utf8_container_out:
1875 * @array_: (out) (element-type utf8) (transfer container):
1878 gi_marshalling_tests_garray_utf8_container_out (GArray **array_)
1880 static gchar *values[] = {"0", "1", "2", NULL};
1885 *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
1886 for (i = 0; values[i]; i++)
1887 g_array_append_val (*array_, values[i]);
1891 * gi_marshalling_tests_garray_utf8_full_out:
1892 * @array_: (out) (element-type utf8) (transfer full):
1895 gi_marshalling_tests_garray_utf8_full_out (GArray **array_)
1897 static gchar *values[] = {"0", "1", "2", NULL};
1902 *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
1903 for (i = 0; values[i]; i++) {
1904 gchar *str = g_strdup (values[i]);
1905 g_array_append_val (*array_, str);
1910 * gi_marshalling_tests_garray_utf8_none_inout:
1911 * @array_: (inout) (element-type utf8) (transfer none):
1914 gi_marshalling_tests_garray_utf8_none_inout (GArray **array_)
1916 static GArray *internal = NULL;
1917 static gchar *values[] = {"-2", "-1", "0", "1", NULL};
1920 g_assert_cmpint((*array_)->len, ==, 3);
1921 g_assert_cmpstr(g_array_index (*array_, gchar*, 0), ==, "0");
1922 g_assert_cmpstr(g_array_index (*array_, gchar*, 1), ==, "1");
1923 g_assert_cmpstr(g_array_index (*array_, gchar*, 2), ==, "2");
1925 if (internal == NULL) {
1926 internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
1927 for (i = 0; values[i]; i++)
1928 g_array_append_val (internal, values[i]);
1935 * gi_marshalling_tests_garray_utf8_container_inout:
1936 * @array_: (inout) (element-type utf8) (transfer container):
1939 gi_marshalling_tests_garray_utf8_container_inout (GArray **array_)
1941 static gchar *val1 = "-2";
1942 static gchar *val2 = "-1";
1943 static gchar *val3 = "0";
1944 static gchar *val4 = "1";
1947 g_assert_cmpint((*array_)->len, ==, 3);
1948 g_assert_cmpstr(g_array_index (*array_, gchar*, 0), ==, "0");
1949 g_assert_cmpstr(g_array_index (*array_, gchar*, 1), ==, "1");
1950 g_assert_cmpstr(g_array_index (*array_, gchar*, 2), ==, "2");
1952 result = g_array_new (TRUE, TRUE, sizeof (gchar *));
1953 g_array_append_val (result, val1);
1954 g_array_append_val (result, val2);
1955 g_array_append_val (result, val3);
1956 g_array_append_val (result, val4);
1962 * gi_marshalling_tests_garray_utf8_full_inout:
1963 * @array_: (inout) (element-type utf8) (transfer full):
1966 gi_marshalling_tests_garray_utf8_full_inout (GArray **array_)
1968 static gchar *val1 = "-1";
1969 static gchar *val2 = "-2";
1973 g_assert_cmpint((*array_)->len, ==, 3);
1974 g_assert_cmpstr(g_array_index (*array_, gchar*, 0), ==, "0");
1975 g_assert_cmpstr(g_array_index (*array_, gchar*, 1), ==, "1");
1976 g_assert_cmpstr(g_array_index (*array_, gchar*, 2), ==, "2");
1978 result = g_array_new (TRUE, TRUE, sizeof (gchar *));
1979 val = g_strdup (val2);
1980 g_array_append_val(result, val);
1981 val = g_strdup (val1);
1982 g_array_append_val(result, val);
1983 val = g_strdup ("0");
1984 g_array_append_val(result, val);
1985 val = g_strdup ("1");
1986 g_array_append_val(result, val);
1992 * gi_marshalling_tests_gptrarray_utf8_none_return:
1994 * Returns: (element-type utf8) (transfer none):
1997 gi_marshalling_tests_gptrarray_utf8_none_return (void)
1999 static GPtrArray *parray = NULL;
2000 static gchar *values[] = {"0", "1", "2"};
2003 if (parray == NULL) {
2004 parray = g_ptr_array_new ();
2005 for (i = 0; i < 3; i++)
2006 g_ptr_array_add (parray, (gpointer) values[i]);
2013 * gi_marshalling_tests_gptrarray_utf8_container_return:
2015 * Returns: (element-type utf8) (transfer container):
2018 gi_marshalling_tests_gptrarray_utf8_container_return (void)
2020 GPtrArray *parray = NULL;
2021 static gchar *values[] = {"0", "1", "2", NULL};
2024 parray = g_ptr_array_new ();
2025 for (i = 0; values[i]; i++)
2026 g_ptr_array_add (parray, (gpointer)values[i]);
2032 * gi_marshalling_tests_gptrarray_utf8_full_return:
2034 * Returns: (element-type utf8) (transfer full):
2037 gi_marshalling_tests_gptrarray_utf8_full_return (void)
2039 GPtrArray *parray = NULL;
2040 static gchar *values[] = {"0", "1", "2", NULL};
2043 parray = g_ptr_array_new ();
2044 for (i = 0; values[i]; i++) {
2045 gchar *str = g_strdup (values[i]);
2046 g_ptr_array_add (parray, (gpointer)str);
2053 * gi_marshalling_tests_gptrarray_utf8_none_in:
2054 * @parray_: (element-type utf8) (transfer none):
2057 gi_marshalling_tests_gptrarray_utf8_none_in (GPtrArray *parray_)
2059 g_assert_cmpint(parray_->len, ==, 3);
2060 g_assert_cmpstr(g_ptr_array_index (parray_, 0), ==, "0");
2061 g_assert_cmpstr(g_ptr_array_index (parray_, 1), ==, "1");
2062 g_assert_cmpstr(g_ptr_array_index (parray_, 2), ==, "2");
2066 * gi_marshalling_tests_gptrarray_utf8_none_out:
2067 * @parray_: (out) (element-type utf8) (transfer none):
2070 gi_marshalling_tests_gptrarray_utf8_none_out (GPtrArray **parray_)
2072 static GPtrArray *internal = NULL;
2073 static gchar *values[] = {"0", "1", "2", NULL};
2076 if (internal == NULL) {
2077 internal = g_ptr_array_new ();
2078 for (i = 0; values[i]; i++)
2079 g_ptr_array_add (internal, (gpointer)values[i]);
2082 *parray_ = internal;
2086 * gi_marshalling_tests_gptrarray_utf8_container_out:
2087 * @parray_: (out) (element-type utf8) (transfer container):
2090 gi_marshalling_tests_gptrarray_utf8_container_out (GPtrArray **parray_)
2092 static gchar *values[] = {"0", "1", "2", NULL};
2097 *parray_ = g_ptr_array_new ();
2098 for (i = 0; values[i]; i++)
2099 g_ptr_array_add (*parray_, (gpointer)values[i]);
2103 * gi_marshalling_tests_gptrarray_utf8_full_out:
2104 * @parray_: (out) (element-type utf8) (transfer full):
2107 gi_marshalling_tests_gptrarray_utf8_full_out (GPtrArray **parray_)
2109 static gchar *values[] = {"0", "1", "2", NULL};
2114 *parray_ = g_ptr_array_new ();
2115 for (i = 0; values[i]; i++) {
2116 gchar *str = g_strdup (values[i]);
2117 g_ptr_array_add (*parray_, (gpointer)str);
2122 * gi_marshalling_tests_gptrarray_utf8_none_inout:
2123 * @parray_: (inout) (element-type utf8) (transfer none):
2126 gi_marshalling_tests_gptrarray_utf8_none_inout (GPtrArray **parray_)
2128 static GPtrArray *internal = NULL;
2129 static gchar *values[] = {"-2", "-1", "0", "1", NULL};
2132 g_assert_cmpint((*parray_)->len, ==, 3);
2133 g_assert_cmpstr(g_ptr_array_index (*parray_, 0), ==, "0");
2134 g_assert_cmpstr(g_ptr_array_index (*parray_, 1), ==, "1");
2135 g_assert_cmpstr(g_ptr_array_index (*parray_, 2), ==, "2");
2137 if (internal == NULL) {
2138 internal = g_ptr_array_new ();
2139 for (i = 0; values[i]; i++)
2140 g_ptr_array_add (internal, (gpointer) values[i]);
2143 *parray_ = internal;
2147 * gi_marshalling_tests_gptrarray_utf8_container_inout:
2148 * @parray_: (inout) (element-type utf8) (transfer container):
2151 gi_marshalling_tests_gptrarray_utf8_container_inout (GPtrArray **parray_)
2153 static gchar *val1 = "-2";
2154 static gchar *val2 = "-1";
2155 static gchar *val3 = "0";
2156 static gchar *val4 = "1";
2159 g_assert_cmpint((*parray_)->len, ==, 3);
2160 g_assert_cmpstr(g_ptr_array_index (*parray_, 0), ==, "0");
2161 g_assert_cmpstr(g_ptr_array_index (*parray_, 1), ==, "1");
2162 g_assert_cmpstr(g_ptr_array_index (*parray_, 2), ==, "2");
2164 result = g_ptr_array_new ();
2165 g_ptr_array_add (result, (gpointer) val1);
2166 g_ptr_array_add (result, (gpointer) val2);
2167 g_ptr_array_add (result, (gpointer) val3);
2168 g_ptr_array_add (result, (gpointer) val4);
2174 * gi_marshalling_tests_gptrarray_utf8_full_inout:
2175 * @parray_: (inout) (element-type utf8) (transfer full):
2178 gi_marshalling_tests_gptrarray_utf8_full_inout (GPtrArray **parray_)
2180 static gchar *val1 = "-1";
2181 static gchar *val2 = "-2";
2185 g_assert_cmpint((*parray_)->len, ==, 3);
2186 g_assert_cmpstr(g_ptr_array_index (*parray_, 0), ==, "0");
2187 g_assert_cmpstr(g_ptr_array_index (*parray_, 1), ==, "1");
2188 g_assert_cmpstr(g_ptr_array_index (*parray_, 2), ==, "2");
2190 result = g_ptr_array_new ();
2191 val = g_strdup (val2);
2192 g_ptr_array_add(result, (gpointer) val);
2193 val = g_strdup (val1);
2194 g_ptr_array_add(result, (gpointer) val);
2195 val = g_strdup ("0");
2196 g_ptr_array_add(result, (gpointer) val);
2197 val = g_strdup ("1");
2198 g_ptr_array_add(result, (gpointer) val);
2204 * gi_marshalling_tests_bytearray_full_return:
2206 * Returns: (transfer full):
2209 gi_marshalling_tests_bytearray_full_return (void)
2211 GByteArray *array = NULL;
2212 guint8 data[] = {'\0', '1', '\xFF', '3'};
2214 array = g_byte_array_new ();
2215 g_byte_array_append (array, (const guint8*)data, G_N_ELEMENTS(data));
2222 * gi_marshalling_tests_bytearray_none_in:
2223 * @v: (element-type gint8) (transfer none):
2226 gi_marshalling_tests_bytearray_none_in (GByteArray *v)
2228 g_assert_cmpuint (v->len, ==, 4);
2229 g_assert_cmpuint (g_array_index (v, unsigned char, 0), ==, 0);
2230 g_assert_cmpuint (g_array_index (v, unsigned char, 1), ==, 49);
2231 g_assert_cmpuint (g_array_index (v, unsigned char, 2), ==, 0xFF);
2232 g_assert_cmpuint (g_array_index (v, unsigned char, 3), ==, 51);
2236 * gi_marshalling_tests_gbytes_full_return:
2238 * Returns: (transfer full):
2241 gi_marshalling_tests_gbytes_full_return (void)
2243 static guint8 data[] = {0, 49, 0xFF, 51};
2245 return g_bytes_new_static (data, G_N_ELEMENTS(data));
2249 * gi_marshalling_tests_gbytes_none_in:
2252 gi_marshalling_tests_gbytes_none_in (GBytes *v)
2256 data = g_bytes_get_data (v, &len);
2258 g_assert_cmpuint (len, ==, 4);
2259 g_assert_cmpuint (data[0], ==, 0);
2260 g_assert_cmpuint (data[1], ==, 49);
2261 g_assert_cmpuint (data[2], ==, 0xFF);
2262 g_assert_cmpuint (data[3], ==, 51);
2266 * gi_marshalling_tests_gstrv_return:
2268 * Returns: (transfer full): an array of strings
2271 gi_marshalling_tests_gstrv_return (void)
2273 GStrv values = g_new0 (gchar*, 4);
2274 values[0] = g_strdup ("0");
2275 values[1] = g_strdup ("1");
2276 values[2] = g_strdup ("2");
2282 * gi_marshalling_tests_gstrv_in:
2286 gi_marshalling_tests_gstrv_in (GStrv g_strv)
2288 g_assert_cmpint(g_strv_length(g_strv), ==, 3);
2289 g_assert_cmpstr(g_strv[0], ==, "0");
2290 g_assert_cmpstr(g_strv[1], ==, "1");
2291 g_assert_cmpstr(g_strv[2], ==, "2");
2295 * gi_marshalling_tests_gstrv_out:
2296 * @g_strv: (out) (transfer none):
2299 gi_marshalling_tests_gstrv_out (GStrv *g_strv)
2301 static gchar *values[] = {"0", "1", "2", NULL};
2306 * gi_marshalling_tests_gstrv_inout:
2307 * @g_strv: (inout) (transfer none):
2310 gi_marshalling_tests_gstrv_inout (GStrv *g_strv)
2312 static gchar *values[] = {"-1", "0", "1", "2", NULL};
2314 g_assert(g_strv_length(*g_strv) == 3);
2315 g_assert(strcmp((*g_strv)[0], "0") == 0);
2316 g_assert(strcmp((*g_strv)[1], "1") == 0);
2317 g_assert(strcmp((*g_strv)[2], "2") == 0);
2323 * gi_marshalling_tests_glist_int_none_return:
2325 * Returns: (element-type gint) (transfer none):
2328 gi_marshalling_tests_glist_int_none_return (void)
2330 static GList *list = NULL;
2333 list = g_list_append(list, GINT_TO_POINTER(-1));
2334 list = g_list_append(list, GINT_TO_POINTER(0));
2335 list = g_list_append(list, GINT_TO_POINTER(1));
2336 list = g_list_append(list, GINT_TO_POINTER(2));
2343 * gi_marshalling_tests_glist_uint32_none_return:
2345 * Returns: (element-type guint32) (transfer none):
2348 gi_marshalling_tests_glist_uint32_none_return (void)
2350 static GList *list = NULL;
2353 list = g_list_append(list, GUINT_TO_POINTER(0));
2354 list = g_list_append(list, GUINT_TO_POINTER(G_MAXUINT32));
2361 * gi_marshalling_tests_glist_utf8_none_return:
2363 * Returns: (element-type utf8) (transfer none):
2366 gi_marshalling_tests_glist_utf8_none_return (void)
2368 static GList *list = NULL;
2371 list = g_list_append(list, "0");
2372 list = g_list_append(list, "1");
2373 list = g_list_append(list, "2");
2380 * gi_marshalling_tests_glist_utf8_container_return:
2382 * Returns: (element-type utf8) (transfer container):
2385 gi_marshalling_tests_glist_utf8_container_return (void)
2389 list = g_list_append(list, "0");
2390 list = g_list_append(list, "1");
2391 list = g_list_append(list, "2");
2397 * gi_marshalling_tests_glist_utf8_full_return:
2399 * Returns: (element-type utf8) (transfer full):
2402 gi_marshalling_tests_glist_utf8_full_return (void)
2406 list = g_list_append(list, g_strdup("0"));
2407 list = g_list_append(list, g_strdup("1"));
2408 list = g_list_append(list, g_strdup("2"));
2414 * gi_marshalling_tests_glist_int_none_in:
2415 * @list: (element-type gint) (transfer none):
2418 gi_marshalling_tests_glist_int_none_in (GList *list)
2420 g_assert_cmpint(g_list_length(list), ==, 4);
2421 g_assert_cmpint(GPOINTER_TO_INT(g_list_nth_data(list, 0)), ==, -1);
2422 g_assert_cmpint(GPOINTER_TO_INT(g_list_nth_data(list, 1)), ==, 0);
2423 g_assert_cmpint(GPOINTER_TO_INT(g_list_nth_data(list, 2)), ==, 1);
2424 g_assert_cmpint(GPOINTER_TO_INT(g_list_nth_data(list, 3)), ==, 2);
2428 * gi_marshalling_tests_glist_uint32_none_in:
2429 * @list: (element-type guint32) (transfer none):
2432 gi_marshalling_tests_glist_uint32_none_in (GList *list)
2434 g_assert_cmpint(g_list_length(list), ==, 2);
2435 g_assert_cmpint(GPOINTER_TO_UINT(g_list_nth_data(list, 0)), ==, 0);
2436 g_assert_cmpint(GPOINTER_TO_UINT(g_list_nth_data(list, 1)), ==, G_MAXUINT32);
2440 * gi_marshalling_tests_glist_utf8_none_in:
2441 * @list: (element-type utf8) (transfer none):
2444 gi_marshalling_tests_glist_utf8_none_in (GList *list)
2446 g_assert_cmpint(g_list_length(list), ==, 3);
2447 g_assert_cmpint(strcmp(g_list_nth_data(list, 0), "0"), ==, 0);
2448 g_assert_cmpint(strcmp(g_list_nth_data(list, 1), "1"), ==, 0);
2449 g_assert_cmpint(strcmp(g_list_nth_data(list, 2), "2"), ==, 0);
2453 * gi_marshalling_tests_glist_utf8_none_out:
2454 * @list: (out) (element-type utf8) (transfer none):
2457 gi_marshalling_tests_glist_utf8_none_out (GList **list)
2459 static GList *values = NULL;
2461 if (values == NULL) {
2462 values = g_list_append(values, "0");
2463 values = g_list_append(values, "1");
2464 values = g_list_append(values, "2");
2471 * gi_marshalling_tests_glist_utf8_container_out:
2472 * @list: (out) (element-type utf8) (transfer container):
2475 gi_marshalling_tests_glist_utf8_container_out (GList **list)
2479 *list = g_list_append(*list, "0");
2480 *list = g_list_append(*list, "1");
2481 *list = g_list_append(*list, "2");
2485 * gi_marshalling_tests_glist_utf8_full_out:
2486 * @list: (out) (element-type utf8) (transfer full):
2489 gi_marshalling_tests_glist_utf8_full_out (GList **list)
2493 *list = g_list_append(*list, g_strdup("0"));
2494 *list = g_list_append(*list, g_strdup("1"));
2495 *list = g_list_append(*list, g_strdup("2"));
2499 * gi_marshalling_tests_glist_utf8_none_inout:
2500 * @list: (inout) (element-type utf8) (transfer none):
2503 gi_marshalling_tests_glist_utf8_none_inout (GList **list)
2505 static GList *values = NULL;
2507 g_assert_cmpint(g_list_length(*list), ==, 3);
2508 g_assert_cmpstr(g_list_nth_data(*list, 0), ==, "0");
2509 g_assert_cmpstr(g_list_nth_data(*list, 1), ==, "1");
2510 g_assert_cmpstr(g_list_nth_data(*list, 2), ==, "2");
2512 if (values == NULL) {
2513 values = g_list_append(values, "-2");
2514 values = g_list_append(values, "-1");
2515 values = g_list_append(values, "0");
2516 values = g_list_append(values, "1");
2523 * gi_marshalling_tests_glist_utf8_container_inout:
2524 * @list: (inout) (element-type utf8) (transfer container):
2527 gi_marshalling_tests_glist_utf8_container_inout (GList **list)
2529 GList *result = NULL;
2531 g_assert_cmpint(g_list_length(*list), ==, 3);
2532 g_assert_cmpstr(g_list_nth_data(*list, 0), ==, "0");
2533 g_assert_cmpstr(g_list_nth_data(*list, 1), ==, "1");
2534 g_assert_cmpstr(g_list_nth_data(*list, 2), ==, "2");
2536 result = g_list_prepend(result, "1");
2537 result = g_list_prepend(result, "0");
2538 result = g_list_prepend(result, "-1");
2539 result = g_list_prepend(result, "-2");
2545 * gi_marshalling_tests_glist_utf8_full_inout:
2546 * @list: (inout) (element-type utf8) (transfer full):
2549 gi_marshalling_tests_glist_utf8_full_inout (GList **list)
2551 GList *result = NULL;
2553 g_assert_cmpint(g_list_length(*list), ==, 3);
2554 g_assert_cmpstr(g_list_nth_data(*list, 0), ==, "0");
2555 g_assert_cmpstr(g_list_nth_data(*list, 1), ==, "1");
2556 g_assert_cmpstr(g_list_nth_data(*list, 2), ==, "2");
2558 result = g_list_prepend(result, g_strdup("1"));
2559 result = g_list_prepend(result, g_strdup("0"));
2560 result = g_list_prepend(result, g_strdup("-1"));
2561 result = g_list_prepend(result, g_strdup("-2"));
2568 * gi_marshalling_tests_gslist_int_none_return:
2570 * Returns: (element-type gint) (transfer none):
2573 gi_marshalling_tests_gslist_int_none_return (void)
2575 static GSList *list = NULL;
2578 list = g_slist_prepend(list, GINT_TO_POINTER(-1));
2579 list = g_slist_prepend(list, GINT_TO_POINTER(0));
2580 list = g_slist_prepend(list, GINT_TO_POINTER(1));
2581 list = g_slist_prepend(list, GINT_TO_POINTER(2));
2582 list = g_slist_reverse(list);
2589 * gi_marshalling_tests_gslist_utf8_none_return:
2591 * Returns: (element-type utf8) (transfer none):
2594 gi_marshalling_tests_gslist_utf8_none_return (void)
2596 static GSList *list = NULL;
2599 list = g_slist_prepend(list, "0");
2600 list = g_slist_prepend(list, "1");
2601 list = g_slist_prepend(list, "2");
2602 list = g_slist_reverse(list);
2609 * gi_marshalling_tests_gslist_utf8_container_return:
2611 * Returns: (element-type utf8) (transfer container):
2614 gi_marshalling_tests_gslist_utf8_container_return (void)
2616 GSList *list = NULL;
2618 list = g_slist_prepend(list, "0");
2619 list = g_slist_prepend(list, "1");
2620 list = g_slist_prepend(list, "2");
2621 list = g_slist_reverse(list);
2627 * gi_marshalling_tests_gslist_utf8_full_return:
2629 * Returns: (element-type utf8) (transfer full):
2632 gi_marshalling_tests_gslist_utf8_full_return (void)
2634 GSList *list = NULL;
2636 list = g_slist_prepend(list, g_strdup("0"));
2637 list = g_slist_prepend(list, g_strdup("1"));
2638 list = g_slist_prepend(list, g_strdup("2"));
2639 list = g_slist_reverse(list);
2645 * gi_marshalling_tests_gslist_int_none_in:
2646 * @list: (element-type gint) (transfer none):
2649 gi_marshalling_tests_gslist_int_none_in (GSList *list)
2651 g_assert_cmpint(g_slist_length(list), ==, 4);
2652 g_assert_cmpint(GPOINTER_TO_INT(g_slist_nth_data(list, 0)), ==, -1);
2653 g_assert_cmpint(GPOINTER_TO_INT(g_slist_nth_data(list, 1)), ==, 0);
2654 g_assert_cmpint(GPOINTER_TO_INT(g_slist_nth_data(list, 2)), ==, 1);
2655 g_assert_cmpint(GPOINTER_TO_INT(g_slist_nth_data(list, 3)), ==, 2);
2659 * gi_marshalling_tests_gslist_utf8_none_in:
2660 * @list: (element-type utf8) (transfer none):
2663 gi_marshalling_tests_gslist_utf8_none_in (GSList *list)
2665 g_assert_cmpint(g_slist_length(list), ==, 3);
2666 g_assert_cmpstr(g_slist_nth_data(list, 0), ==, "0");
2667 g_assert_cmpstr(g_slist_nth_data(list, 1), ==, "1");
2668 g_assert_cmpstr(g_slist_nth_data(list, 2), ==, "2");
2672 * gi_marshalling_tests_gslist_utf8_none_out:
2673 * @list: (out) (element-type utf8) (transfer none):
2676 gi_marshalling_tests_gslist_utf8_none_out (GSList **list)
2678 static GSList *values = NULL;
2680 if (values == NULL) {
2681 values = g_slist_prepend(values, "0");
2682 values = g_slist_prepend(values, "1");
2683 values = g_slist_prepend(values, "2");
2684 values = g_slist_reverse(values);
2691 * gi_marshalling_tests_gslist_utf8_container_out:
2692 * @list: (out) (element-type utf8) (transfer container):
2695 gi_marshalling_tests_gslist_utf8_container_out (GSList **list)
2699 *list = g_slist_prepend(*list, "0");
2700 *list = g_slist_prepend(*list, "1");
2701 *list = g_slist_prepend(*list, "2");
2702 *list = g_slist_reverse(*list);
2706 * gi_marshalling_tests_gslist_utf8_full_out:
2707 * @list: (out) (element-type utf8) (transfer full):
2710 gi_marshalling_tests_gslist_utf8_full_out (GSList **list)
2714 *list = g_slist_prepend(*list, g_strdup("0"));
2715 *list = g_slist_prepend(*list, g_strdup("1"));
2716 *list = g_slist_prepend(*list, g_strdup("2"));
2717 *list = g_slist_reverse(*list);
2721 * gi_marshalling_tests_gslist_utf8_none_inout:
2722 * @list: (inout) (element-type utf8) (transfer none):
2725 gi_marshalling_tests_gslist_utf8_none_inout (GSList **list)
2727 static GSList *values = NULL;
2729 g_assert_cmpint(g_slist_length(*list), ==, 3);
2730 g_assert_cmpstr(g_slist_nth_data(*list, 0), ==, "0");
2731 g_assert_cmpstr(g_slist_nth_data(*list, 1), ==, "1");
2732 g_assert_cmpstr(g_slist_nth_data(*list, 2), ==, "2");
2734 if (values == NULL) {
2735 values = g_slist_prepend(values, "-2");
2736 values = g_slist_prepend(values, "-1");
2737 values = g_slist_prepend(values, "0");
2738 values = g_slist_prepend(values, "1");
2739 values = g_slist_reverse(values);
2746 * gi_marshalling_tests_gslist_utf8_container_inout:
2747 * @list: (inout) (element-type utf8) (transfer container):
2750 gi_marshalling_tests_gslist_utf8_container_inout (GSList **list)
2752 GSList *result = NULL;
2754 g_assert_cmpint(g_slist_length(*list), ==, 3);
2755 g_assert_cmpstr(g_slist_nth_data(*list, 0), ==, "0");
2756 g_assert_cmpstr(g_slist_nth_data(*list, 1), ==, "1");
2757 g_assert_cmpstr(g_slist_nth_data(*list, 2), ==, "2");
2759 result = g_slist_prepend(result, "1");
2760 result = g_slist_prepend(result, "0");
2761 result = g_slist_prepend(result, "-1");
2762 result = g_slist_prepend(result, "-2");
2768 * gi_marshalling_tests_gslist_utf8_full_inout:
2769 * @list: (inout) (element-type utf8) (transfer full):
2772 gi_marshalling_tests_gslist_utf8_full_inout (GSList **list)
2774 GSList *result = NULL;
2776 g_assert_cmpint(g_slist_length(*list), ==, 3);
2777 g_assert_cmpstr(g_slist_nth_data(*list, 0), ==, "0");
2778 g_assert_cmpstr(g_slist_nth_data(*list, 1), ==, "1");
2779 g_assert_cmpstr(g_slist_nth_data(*list, 2), ==, "2");
2781 result = g_slist_prepend(result, g_strdup("1"));
2782 result = g_slist_prepend(result, g_strdup("0"));
2783 result = g_slist_prepend(result, g_strdup("-1"));
2784 result = g_slist_prepend(result, g_strdup("-2"));
2791 * gi_marshalling_tests_ghashtable_int_none_return:
2793 * Returns: (element-type gint gint) (transfer none):
2796 gi_marshalling_tests_ghashtable_int_none_return (void)
2798 static GHashTable *hash_table = NULL;
2800 if (hash_table == NULL) {
2801 hash_table = g_hash_table_new(NULL, NULL);
2802 g_hash_table_insert(hash_table, GINT_TO_POINTER(-1), GINT_TO_POINTER(1));
2803 g_hash_table_insert(hash_table, GINT_TO_POINTER(0), GINT_TO_POINTER(0));
2804 g_hash_table_insert(hash_table, GINT_TO_POINTER(1), GINT_TO_POINTER(-1));
2805 g_hash_table_insert(hash_table, GINT_TO_POINTER(2), GINT_TO_POINTER(-2));
2812 * gi_marshalling_tests_ghashtable_utf8_none_return:
2814 * Returns: (element-type utf8 utf8) (transfer none):
2817 gi_marshalling_tests_ghashtable_utf8_none_return (void)
2819 static GHashTable *hash_table = NULL;
2821 if (hash_table == NULL) {
2822 hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2823 g_hash_table_insert(hash_table, "-1", "1");
2824 g_hash_table_insert(hash_table, "0", "0");
2825 g_hash_table_insert(hash_table, "1", "-1");
2826 g_hash_table_insert(hash_table, "2", "-2");
2833 * gi_marshalling_tests_ghashtable_utf8_container_return:
2835 * Returns: (element-type utf8 utf8) (transfer container):
2838 gi_marshalling_tests_ghashtable_utf8_container_return (void)
2840 GHashTable *hash_table = NULL;
2842 hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2843 g_hash_table_insert(hash_table, "-1", "1");
2844 g_hash_table_insert(hash_table, "0", "0");
2845 g_hash_table_insert(hash_table, "1", "-1");
2846 g_hash_table_insert(hash_table, "2", "-2");
2852 * gi_marshalling_tests_ghashtable_utf8_full_return:
2854 * Returns: (element-type utf8 utf8) (transfer full):
2857 gi_marshalling_tests_ghashtable_utf8_full_return (void)
2859 GHashTable *hash_table = NULL;
2861 hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2862 g_hash_table_insert(hash_table, g_strdup("-1"), g_strdup("1"));
2863 g_hash_table_insert(hash_table, g_strdup("0"), g_strdup("0"));
2864 g_hash_table_insert(hash_table, g_strdup("1"), g_strdup("-1"));
2865 g_hash_table_insert(hash_table, g_strdup("2"), g_strdup("-2"));
2871 * gi_marshalling_tests_ghashtable_int_none_in:
2872 * @hash_table: (element-type gint gint) (transfer none):
2875 gi_marshalling_tests_ghashtable_int_none_in (GHashTable *hash_table)
2877 g_assert_cmpint(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(-1))), ==, 1);
2878 g_assert_cmpint(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(0))), ==, 0);
2879 g_assert_cmpint(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(1))), ==, -1);
2880 g_assert_cmpint(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(2))), ==, -2);
2884 * gi_marshalling_tests_ghashtable_utf8_none_in:
2885 * @hash_table: (element-type utf8 utf8) (transfer none):
2888 gi_marshalling_tests_ghashtable_utf8_none_in (GHashTable *hash_table)
2890 g_assert_cmpstr(g_hash_table_lookup(hash_table, "-1"), ==, "1");
2891 g_assert_cmpstr(g_hash_table_lookup(hash_table, "0"), ==, "0");
2892 g_assert_cmpstr(g_hash_table_lookup(hash_table, "1"), ==, "-1");
2893 g_assert_cmpstr(g_hash_table_lookup(hash_table, "2"), ==, "-2");
2897 * gi_marshalling_tests_ghashtable_utf8_none_out:
2898 * @hash_table: (out) (element-type utf8 utf8) (transfer none):
2901 gi_marshalling_tests_ghashtable_utf8_none_out (GHashTable **hash_table)
2903 static GHashTable *new_hash_table = NULL;
2905 if (new_hash_table == NULL) {
2906 new_hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2907 g_hash_table_insert(new_hash_table, "-1", "1");
2908 g_hash_table_insert(new_hash_table, "0", "0");
2909 g_hash_table_insert(new_hash_table, "1", "-1");
2910 g_hash_table_insert(new_hash_table, "2", "-2");
2913 *hash_table = new_hash_table;
2917 * gi_marshalling_tests_ghashtable_utf8_container_out:
2918 * @hash_table: (out) (element-type utf8 utf8) (transfer container):
2921 gi_marshalling_tests_ghashtable_utf8_container_out (GHashTable **hash_table)
2923 *hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2924 g_hash_table_insert(*hash_table, "-1", "1");
2925 g_hash_table_insert(*hash_table, "0", "0");
2926 g_hash_table_insert(*hash_table, "1", "-1");
2927 g_hash_table_insert(*hash_table, "2", "-2");
2931 * gi_marshalling_tests_ghashtable_utf8_full_out:
2932 * @hash_table: (out) (element-type utf8 utf8) (transfer full):
2935 gi_marshalling_tests_ghashtable_utf8_full_out (GHashTable **hash_table)
2937 *hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2938 g_hash_table_insert(*hash_table, g_strdup("-1"), g_strdup("1"));
2939 g_hash_table_insert(*hash_table, g_strdup("0"), g_strdup("0"));
2940 g_hash_table_insert(*hash_table, g_strdup("1"), g_strdup("-1"));
2941 g_hash_table_insert(*hash_table, g_strdup("2"), g_strdup("-2"));
2945 * gi_marshalling_tests_ghashtable_utf8_none_inout:
2946 * @hash_table: (inout) (element-type utf8 utf8) (transfer none):
2949 gi_marshalling_tests_ghashtable_utf8_none_inout (GHashTable **hash_table)
2951 static GHashTable *new_hash_table = NULL;
2953 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "-1"), ==, "1");
2954 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "0"), ==, "0");
2955 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "1"), ==, "-1");
2956 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "2"), ==, "-2");
2958 if (new_hash_table == NULL) {
2959 new_hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2960 g_hash_table_insert(new_hash_table, "-1", "1");
2961 g_hash_table_insert(new_hash_table, "0", "0");
2962 g_hash_table_insert(new_hash_table, "1", "1");
2965 *hash_table = new_hash_table;
2969 * gi_marshalling_tests_ghashtable_utf8_container_inout:
2970 * @hash_table: (inout) (element-type utf8 utf8) (transfer container):
2973 gi_marshalling_tests_ghashtable_utf8_container_inout (GHashTable **hash_table)
2975 GHashTable *result = g_hash_table_new(g_str_hash, g_str_equal);
2977 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "-1"), ==, "1");
2978 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "0"), ==, "0");
2979 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "1"), ==, "-1");
2980 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "2"), ==, "-2");
2982 g_hash_table_insert(result, "-1", "1");
2983 g_hash_table_insert(result, "0", "0");
2984 g_hash_table_insert(result, "1", "1");
2986 *hash_table = result;
2990 * gi_marshalling_tests_ghashtable_utf8_full_inout:
2991 * @hash_table: (inout) (element-type utf8 utf8) (transfer full):
2994 gi_marshalling_tests_ghashtable_utf8_full_inout (GHashTable **hash_table)
2996 GHashTable *result = g_hash_table_new_full(g_str_hash, g_str_equal,
2999 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "-1"), ==, "1");
3000 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "0"), ==, "0");
3001 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "1"), ==, "-1");
3002 g_assert_cmpstr(g_hash_table_lookup(*hash_table, "2"), ==, "-2");
3004 g_hash_table_insert(result, g_strdup("-1"), g_strdup("1"));
3005 g_hash_table_insert(result, g_strdup("0"), g_strdup("0"));
3006 g_hash_table_insert(result, g_strdup("1"), g_strdup("1"));
3008 *hash_table = result;
3013 * gi_marshalling_tests_gvalue_return:
3015 * Returns: (transfer none):
3018 gi_marshalling_tests_gvalue_return (void)
3020 static GValue *value = NULL;
3022 if (value == NULL) {
3023 value = g_new0(GValue, 1);
3024 g_value_init(value, G_TYPE_INT);
3025 g_value_set_int(value, 42);
3032 * gi_marshalling_tests_gvalue_in:
3033 * @value: (transfer none):
3036 gi_marshalling_tests_gvalue_in (GValue *value)
3038 g_assert_cmpint(g_value_get_int(value), ==, 42);
3042 * gi_marshalling_tests_gvalue_int64_in:
3043 * @value: (transfer none):
3046 gi_marshalling_tests_gvalue_int64_in (GValue *value)
3048 g_assert_cmpint(g_value_get_int64(value), ==, G_MAXINT64);
3052 * gi_marshalling_tests_gvalue_in_with_type:
3053 * @value: (transfer none):
3057 gi_marshalling_tests_gvalue_in_with_type (GValue *value, GType type)
3059 g_assert(g_type_is_a(G_VALUE_TYPE(value), type));
3063 * gi_marshalling_tests_gvalue_in_enum:
3064 * @value: (transfer none):
3067 gi_marshalling_tests_gvalue_in_enum (GValue *value)
3069 g_assert(g_value_get_enum(value) == GI_MARSHALLING_TESTS_ENUM_VALUE3);
3073 * gi_marshalling_tests_gvalue_out:
3074 * @value: (out) (transfer none):
3077 gi_marshalling_tests_gvalue_out (GValue **value)
3079 static GValue *new_value = NULL;
3081 if (new_value == NULL) {
3082 new_value = g_new0(GValue, 1);
3083 g_value_init(new_value, G_TYPE_INT);
3084 g_value_set_int(new_value, 42);
3091 * gi_marshalling_tests_gvalue_int64_out:
3092 * @value: (out) (transfer none):
3095 gi_marshalling_tests_gvalue_int64_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_INT64);
3102 g_value_set_int64(new_value, G_MAXINT64);
3109 * gi_marshalling_tests_gvalue_out_caller_allocates:
3110 * @value: (out) (transfer none):
3113 gi_marshalling_tests_gvalue_out_caller_allocates (GValue *value)
3115 g_value_init(value, G_TYPE_INT);
3116 g_value_set_int(value, 42);
3120 * gi_marshalling_tests_gvalue_inout:
3121 * @value: (inout) (transfer none):
3124 gi_marshalling_tests_gvalue_inout (GValue **value)
3126 g_assert_cmpint(g_value_get_int(*value), ==, 42);
3127 g_value_unset(*value);
3128 g_value_init(*value, G_TYPE_STRING);
3129 g_value_set_string(*value, "42");
3133 * gi_marshalling_tests_gvalue_flat_array:
3134 * @n_values: number of values
3135 * @values: (array length=n_values): an array containing values
3138 gi_marshalling_tests_gvalue_flat_array (guint n_values,
3139 const GValue *values)
3141 g_assert (n_values == 3);
3143 g_assert_cmpint (g_value_get_int (&values[0]), ==, 42);
3144 g_assert_cmpstr (g_value_get_string (&values[1]), ==, "42");
3145 g_assert_cmpint (g_value_get_boolean (&values[2]), ==, TRUE);
3149 * gi_marshalling_tests_return_gvalue_flat_array:
3151 * Returns: (array fixed-size=3) (transfer full): a flat GValue array
3154 gi_marshalling_tests_return_gvalue_flat_array (void)
3156 GValue *array = g_new0 (GValue, 3);
3158 g_value_init (&array[0], G_TYPE_INT);
3159 g_value_set_int (&array[0], 42);
3161 g_value_init (&array[1], G_TYPE_STRING);
3162 g_value_set_static_string (&array[1], "42");
3164 g_value_init (&array[2], G_TYPE_BOOLEAN);
3165 g_value_set_boolean (&array[2], TRUE);
3171 * gi_marshalling_tests_gvalue_flat_array_round_trip:
3172 * @one: The first GValue
3173 * @two: The second GValue
3174 * @three: The third GValue
3176 * Returns: (array fixed-size=3) (transfer full): a flat array of [@one, @two, @three]
3179 gi_marshalling_tests_gvalue_flat_array_round_trip (const GValue one,
3183 GValue *array = g_new (GValue, 3);
3192 * gi_marshalling_tests_gclosure_in:
3193 * @closure: (transfer none):
3196 gi_marshalling_tests_gclosure_in (GClosure *closure)
3198 GValue return_value = {0, };
3200 g_value_init (&return_value, G_TYPE_INT);
3202 g_closure_invoke (closure,
3207 g_assert_cmpint(g_value_get_int (&return_value), ==, 42);
3209 g_value_unset(&return_value);
3213 _closure_return_42 (void)
3219 _marshal_INT__VOID (GClosure *closure,
3220 GValue *return_value,
3221 guint n_param_values,
3222 const GValue *param_values,
3223 gpointer invocation_hint,
3224 gpointer marshal_data)
3226 typedef gint (*GMarshalFunc_INT__VOID) (void);
3227 register GMarshalFunc_INT__VOID callback;
3228 register GCClosure *cc = (GCClosure*) closure;
3230 callback = (GMarshalFunc_INT__VOID) cc->callback;
3231 g_value_set_int(return_value, callback());
3235 * gi_marshalling_tests_gclosure_return:
3237 * Return: a #GClosure
3240 gi_marshalling_tests_gclosure_return (void)
3242 GClosure *closure = g_cclosure_new ((GCallback)_closure_return_42,
3244 g_closure_set_marshal (closure, _marshal_INT__VOID);
3251 * gi_marshalling_tests_callback_return_value_only:
3252 * @callback: (scope call):
3255 gi_marshalling_tests_callback_return_value_only (GIMarshallingTestsCallbackReturnValueOnly callback)
3261 * gi_marshalling_tests_callback_one_out_parameter:
3262 * @callback: (scope call):
3266 gi_marshalling_tests_callback_one_out_parameter (GIMarshallingTestsCallbackOneOutParameter callback,
3273 * gi_marshalling_tests_callback_multiple_out_parameters:
3274 * @callback: (scope call):
3279 gi_marshalling_tests_callback_multiple_out_parameters (GIMarshallingTestsCallbackMultipleOutParameters callback,
3287 * gi_marshalling_tests_callback_return_value_and_one_out_parameter:
3288 * @callback: (scope call):
3292 gi_marshalling_tests_callback_return_value_and_one_out_parameter (GIMarshallingTestsCallbackReturnValueAndOneOutParameter callback,
3295 return callback (a);
3299 * gi_marshalling_tests_callback_return_value_and_multiple_out_parameters:
3300 * @callback: (scope call):
3305 gi_marshalling_tests_callback_return_value_and_multiple_out_parameters (GIMarshallingTestsCallbackReturnValueAndMultipleOutParameters callback,
3309 return callback (a, b);
3315 * gi_marshalling_tests_pointer_in_return:
3317 * Returns: (transfer none): The same pointer
3320 gi_marshalling_tests_pointer_in_return (gpointer pointer)
3326 gi_marshalling_tests_genum_get_type (void)
3328 static GType type = 0;
3329 if (G_UNLIKELY(type == 0)) {
3330 static const GEnumValue values[] = {
3331 { GI_MARSHALLING_TESTS_GENUM_VALUE1, "GI_MARSHALLING_TESTS_GENUM_VALUE1", "value1" },
3332 { GI_MARSHALLING_TESTS_GENUM_VALUE2, "GI_MARSHALLING_TESTS_GENUM_VALUE2", "value2" },
3333 { GI_MARSHALLING_TESTS_GENUM_VALUE3, "GI_MARSHALLING_TESTS_GENUM_VALUE3", "value3" },
3336 type = g_enum_register_static (g_intern_static_string ("GIMarshallingTestsGEnum"), values);
3342 GIMarshallingTestsGEnum
3343 gi_marshalling_tests_genum_returnv (void)
3345 return GI_MARSHALLING_TESTS_GENUM_VALUE3;
3349 gi_marshalling_tests_genum_in (GIMarshallingTestsGEnum v)
3351 g_assert_cmpint(v, ==, GI_MARSHALLING_TESTS_GENUM_VALUE3);
3355 * gi_marshalling_tests_genum_out:
3359 gi_marshalling_tests_genum_out (GIMarshallingTestsGEnum *v)
3361 *v = GI_MARSHALLING_TESTS_GENUM_VALUE3;
3365 * gi_marshalling_tests_genum_inout:
3369 gi_marshalling_tests_genum_inout (GIMarshallingTestsGEnum *v)
3371 g_assert_cmpint(*v, ==, GI_MARSHALLING_TESTS_GENUM_VALUE3);
3372 *v = GI_MARSHALLING_TESTS_GENUM_VALUE1;
3376 GIMarshallingTestsEnum
3377 gi_marshalling_tests_enum_returnv (void)
3379 return GI_MARSHALLING_TESTS_ENUM_VALUE3;
3383 gi_marshalling_tests_enum_in (GIMarshallingTestsEnum v)
3385 g_assert_cmpint(v, ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
3389 * gi_marshalling_tests_enum_out:
3393 gi_marshalling_tests_enum_out (GIMarshallingTestsEnum *v)
3395 *v = GI_MARSHALLING_TESTS_ENUM_VALUE3;
3399 * gi_marshalling_tests_enum_inout:
3403 gi_marshalling_tests_enum_inout (GIMarshallingTestsEnum *v)
3405 g_assert_cmpint(*v, ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
3406 *v = GI_MARSHALLING_TESTS_ENUM_VALUE1;
3411 gi_marshalling_tests_flags_get_type (void)
3413 static GType type = 0;
3414 if (G_UNLIKELY(type == 0)) {
3415 static const GFlagsValue values[] = {
3416 { GI_MARSHALLING_TESTS_FLAGS_VALUE1, "GI_MARSHALLING_TESTS_FLAGS_VALUE1", "value1" },
3417 { GI_MARSHALLING_TESTS_FLAGS_VALUE2, "GI_MARSHALLING_TESTS_FLAGS_VALUE2", "value2" },
3418 { GI_MARSHALLING_TESTS_FLAGS_VALUE3, "GI_MARSHALLING_TESTS_FLAGS_VALUE3", "value3" },
3419 { GI_MARSHALLING_TESTS_FLAGS_MASK, "GI_MARSHALLING_TESTS_FLAGS_MASK", "mask" },
3420 { GI_MARSHALLING_TESTS_FLAGS_MASK2, "GI_MARSHALLING_TESTS_FLAGS_MASK2", "mask2" },
3423 type = g_flags_register_static (g_intern_static_string ("GIMarshallingTestsFlags"), values);
3429 GIMarshallingTestsFlags
3430 gi_marshalling_tests_flags_returnv (void)
3432 return GI_MARSHALLING_TESTS_FLAGS_VALUE2;
3436 gi_marshalling_tests_flags_in (GIMarshallingTestsFlags v)
3438 g_assert(v == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
3442 gi_marshalling_tests_flags_in_zero (GIMarshallingTestsFlags v)
3448 * gi_marshalling_tests_flags_out:
3452 gi_marshalling_tests_flags_out (GIMarshallingTestsFlags *v)
3454 *v = GI_MARSHALLING_TESTS_FLAGS_VALUE2;
3458 * gi_marshalling_tests_flags_inout:
3462 gi_marshalling_tests_flags_inout (GIMarshallingTestsFlags *v)
3464 g_assert(*v == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
3465 *v = GI_MARSHALLING_TESTS_FLAGS_VALUE1;
3469 GIMarshallingTestsNoTypeFlags
3470 gi_marshalling_tests_no_type_flags_returnv (void)
3472 return GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
3476 gi_marshalling_tests_no_type_flags_in (GIMarshallingTestsNoTypeFlags v)
3478 g_assert(v == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
3482 gi_marshalling_tests_no_type_flags_in_zero (GIMarshallingTestsNoTypeFlags v)
3488 * gi_marshalling_tests_no_type_flags_out:
3492 gi_marshalling_tests_no_type_flags_out (GIMarshallingTestsNoTypeFlags *v)
3494 *v = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
3498 * gi_marshalling_tests_no_type_flags_inout:
3502 gi_marshalling_tests_no_type_flags_inout (GIMarshallingTestsNoTypeFlags *v)
3504 g_assert(*v == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
3505 *v = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE1;
3510 * gi_marshalling_tests_simple_struct_returnv:
3512 * Returns: (transfer none):
3514 GIMarshallingTestsSimpleStruct *
3515 gi_marshalling_tests_simple_struct_returnv (void)
3517 static GIMarshallingTestsSimpleStruct *struct_ = NULL;
3519 if (struct_ == NULL) {
3520 struct_ = g_new(GIMarshallingTestsSimpleStruct, 1);
3530 * gi_marshalling_tests_simple_struct_inv:
3531 * @struct_: (transfer none):
3534 gi_marshalling_tests_simple_struct_inv (GIMarshallingTestsSimpleStruct *struct_)
3536 g_assert_cmpint(struct_->long_, ==, 6);
3537 g_assert_cmpint(struct_->int8, ==, 7);
3541 gi_marshalling_tests_simple_struct_method (GIMarshallingTestsSimpleStruct *struct_)
3543 g_assert_cmpint(struct_->long_, ==, 6);
3544 g_assert_cmpint(struct_->int8, ==, 7);
3549 gi_marshalling_tests_pointer_struct_get_type (void)
3551 static GType type = 0;
3554 type = g_pointer_type_register_static ("GIMarshallingTestsPointerStruct");
3561 * gi_marshalling_tests_pointer_struct_returnv:
3563 * Returns: (transfer none):
3565 GIMarshallingTestsPointerStruct *
3566 gi_marshalling_tests_pointer_struct_returnv (void)
3568 static GIMarshallingTestsPointerStruct *struct_ = NULL;
3570 if (struct_ == NULL) {
3571 struct_ = g_new(GIMarshallingTestsPointerStruct, 1);
3573 struct_->long_ = 42;
3580 * gi_marshalling_tests_pointer_struct_inv:
3581 * @struct_: (transfer none):
3584 gi_marshalling_tests_pointer_struct_inv (GIMarshallingTestsPointerStruct *struct_)
3586 g_assert_cmpint(struct_->long_, ==, 42);
3589 static GIMarshallingTestsBoxedStruct *
3590 gi_marshalling_tests_boxed_struct_copy (GIMarshallingTestsBoxedStruct *struct_)
3592 GIMarshallingTestsBoxedStruct *new_struct;
3594 if (struct_ == NULL)
3597 new_struct = g_slice_new (GIMarshallingTestsBoxedStruct);
3599 *new_struct = *struct_;
3605 gi_marshalling_tests_boxed_struct_free (GIMarshallingTestsBoxedStruct *struct_)
3607 if (struct_ != NULL)
3608 g_slice_free (GIMarshallingTestsBoxedStruct, struct_);
3612 gi_marshalling_tests_boxed_struct_get_type (void)
3614 static GType type = 0;
3617 type = g_boxed_type_register_static ("GIMarshallingTestsBoxedStruct",
3618 (GBoxedCopyFunc) gi_marshalling_tests_boxed_struct_copy,
3619 (GBoxedFreeFunc) gi_marshalling_tests_boxed_struct_free);
3625 GIMarshallingTestsBoxedStruct *
3626 gi_marshalling_tests_boxed_struct_new (void)
3628 return g_slice_new0 (GIMarshallingTestsBoxedStruct);
3632 * gi_marshalling_tests_boxed_struct_returnv:
3634 * Returns: (transfer none):
3636 GIMarshallingTestsBoxedStruct *
3637 gi_marshalling_tests_boxed_struct_returnv (void)
3639 static GIMarshallingTestsBoxedStruct *struct_ = NULL;
3641 if (struct_ == NULL) {
3642 struct_ = g_new(GIMarshallingTestsBoxedStruct, 1);
3644 struct_->long_ = 42;
3645 struct_->g_strv = g_new0(gchar*, 4);
3646 struct_->g_strv[0] = g_strdup("0");
3647 struct_->g_strv[1] = g_strdup("1");
3648 struct_->g_strv[2] = g_strdup("2");
3649 struct_->g_strv[3] = NULL;
3656 * gi_marshalling_tests_boxed_struct_inv:
3657 * @struct_: (transfer none):
3660 gi_marshalling_tests_boxed_struct_inv (GIMarshallingTestsBoxedStruct *struct_)
3662 g_assert_cmpint(struct_->long_, ==, 42);
3666 * gi_marshalling_tests_boxed_struct_out:
3667 * @struct_: (out) (transfer none):
3670 gi_marshalling_tests_boxed_struct_out (GIMarshallingTestsBoxedStruct **struct_)
3672 static GIMarshallingTestsBoxedStruct *new_struct = NULL;
3674 if (new_struct == NULL) {
3675 new_struct = g_new(GIMarshallingTestsBoxedStruct, 1);
3677 new_struct->long_ = 42;
3680 *struct_ = new_struct;
3684 * gi_marshalling_tests_boxed_struct_inout:
3685 * @struct_: (inout) (transfer full):
3688 gi_marshalling_tests_boxed_struct_inout (GIMarshallingTestsBoxedStruct **struct_)
3690 g_assert_cmpint((*struct_)->long_, ==, 42);
3692 (*struct_) = g_slice_new (GIMarshallingTestsBoxedStruct);
3693 (*struct_)->long_ = 0;
3696 static GIMarshallingTestsUnion *
3697 gi_marshalling_tests_union_copy (GIMarshallingTestsUnion *union_)
3699 GIMarshallingTestsUnion *new_union;
3701 new_union = g_slice_new (GIMarshallingTestsUnion);
3703 *new_union = *union_;
3709 gi_marshalling_tests_union_free (GIMarshallingTestsUnion *union_)
3711 g_slice_free (GIMarshallingTestsUnion, union_);
3715 gi_marshalling_tests_union_get_type (void)
3717 static GType type = 0;
3720 type = g_boxed_type_register_static ("GIMarshallingTestsUnion",
3721 (GBoxedCopyFunc) gi_marshalling_tests_union_copy,
3722 (GBoxedFreeFunc) gi_marshalling_tests_union_free);
3729 * gi_marshalling_tests_union_returnv:
3731 * Returns: (transfer none):
3733 GIMarshallingTestsUnion *
3734 gi_marshalling_tests_union_returnv (void)
3736 static GIMarshallingTestsUnion *union_ = NULL;
3738 if (union_ == NULL) {
3739 union_ = g_new(GIMarshallingTestsUnion, 1);
3748 * gi_marshalling_tests_union_inv:
3749 * @union_: (transfer none):
3752 gi_marshalling_tests_union_inv (GIMarshallingTestsUnion *union_)
3754 g_assert_cmpint(union_->long_, ==, 42);
3758 gi_marshalling_tests_union_method (GIMarshallingTestsUnion *union_)
3760 g_assert_cmpint(union_->long_, ==, 42);
3771 static void gi_marshalling_tests_object_real_method_with_default_implementation (
3772 GIMarshallingTestsObject *self, gint8 in);
3774 G_DEFINE_TYPE (GIMarshallingTestsObject, gi_marshalling_tests_object, G_TYPE_OBJECT);
3777 gi_marshalling_tests_object_init (GIMarshallingTestsObject *object)
3782 gi_marshalling_tests_object_finalize (GObject *object)
3784 G_OBJECT_CLASS (gi_marshalling_tests_object_parent_class)->finalize (object);
3788 gi_marshalling_tests_object_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
3790 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3794 GI_MARSHALLING_TESTS_OBJECT (object)->int_ = g_value_get_int (value);
3797 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3803 gi_marshalling_tests_object_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
3805 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3809 g_value_set_int (value, GI_MARSHALLING_TESTS_OBJECT (object)->int_);
3812 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3818 gi_marshalling_tests_object_class_init (GIMarshallingTestsObjectClass *klass)
3820 GObjectClass* object_class = G_OBJECT_CLASS (klass);
3822 GObjectClass* parent_class = G_OBJECT_CLASS (klass);
3825 object_class->finalize = gi_marshalling_tests_object_finalize;
3826 object_class->set_property = gi_marshalling_tests_object_set_property;
3827 object_class->get_property = gi_marshalling_tests_object_get_property;
3829 g_object_class_install_property (object_class, PROP_INT_,
3830 g_param_spec_int ("int", "Integer", "An integer", G_MININT, G_MAXINT, 0,
3831 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
3833 klass->method_with_default_implementation = gi_marshalling_tests_object_real_method_with_default_implementation;
3838 gi_marshalling_tests_object_static_method (void)
3843 gi_marshalling_tests_object_method (GIMarshallingTestsObject *object)
3845 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3846 g_assert_cmpint (object->int_, ==, 42);
3850 gi_marshalling_tests_object_overridden_method (GIMarshallingTestsObject *object)
3852 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3853 g_assert_cmpint (object->int_, ==, 0);
3856 GIMarshallingTestsObject *
3857 gi_marshalling_tests_object_new (gint int_)
3859 return g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, "int", int_, NULL);
3863 * gi_marshalling_tests_object_method_array_in:
3864 * @ints: (array length=length):
3867 gi_marshalling_tests_object_method_array_in (GIMarshallingTestsObject *object, const gint *ints, gint length)
3869 g_assert_cmpint(length, ==, 4);
3870 g_assert_cmpint(ints[0], ==, -1);
3871 g_assert_cmpint(ints[1], ==, 0);
3872 g_assert_cmpint(ints[2], ==, 1);
3873 g_assert_cmpint(ints[3], ==, 2);
3877 * gi_marshalling_tests_object_method_array_out:
3878 * @ints: (out) (array length=length) (transfer none):
3881 gi_marshalling_tests_object_method_array_out (GIMarshallingTestsObject *object, gint **ints, gint *length)
3883 static gint values[] = {-1, 0, 1, 2};
3890 * gi_marshalling_tests_object_method_array_inout:
3891 * @ints: (inout) (array length=length) (transfer none):
3895 gi_marshalling_tests_object_method_array_inout (GIMarshallingTestsObject *object, gint **ints, gint *length)
3897 static gint values[] = {-2, -1, 0, 1, 2};
3899 g_assert_cmpint(*length, ==, 4);
3900 g_assert_cmpint((*ints)[0], ==, -1);
3901 g_assert_cmpint((*ints)[1], ==, 0);
3902 g_assert_cmpint((*ints)[2], ==, 1);
3903 g_assert_cmpint((*ints)[3], ==, 2);
3910 * gi_marshalling_tests_object_method_array_return:
3912 * Returns: (array length=length):
3915 gi_marshalling_tests_object_method_array_return (GIMarshallingTestsObject *object, gint *length)
3917 static gint ints[] = {-1, 0, 1, 2};
3924 * gi_marshalling_tests_object_method_int8_in:
3928 gi_marshalling_tests_object_method_int8_in (GIMarshallingTestsObject *self, gint8 in)
3930 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_in (self, in);
3934 * gi_marshalling_tests_object_method_int8_out:
3938 gi_marshalling_tests_object_method_int8_out (GIMarshallingTestsObject *self, gint8 *out)
3940 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_out (self, out);
3944 * gi_marshalling_tests_object_method_with_default_implementation:
3948 gi_marshalling_tests_object_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
3950 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_with_default_implementation (self, in);
3954 gi_marshalling_tests_object_real_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
3957 g_value_init (&val, G_TYPE_INT);
3958 g_value_set_int (&val, in);
3959 g_object_set_property (G_OBJECT (self), "int", &val);
3963 * gi_marshalling_tests_object_vfunc_with_callback:
3964 * @callback: (scope call) (closure callback_data):
3965 * @callback_data: (allow-none):
3967 * Virtual: vfunc_with_callback
3970 gi_marshalling_tests_object_vfunc_with_callback (GIMarshallingTestsObject *object,
3971 GIMarshallingTestsCallbackIntInt callback,
3972 void *callback_data)
3978 _callback (int val, void *user_data)
3980 g_assert (user_data == (gpointer)0xdeadbeef);
3985 gi_marshalling_tests_object_call_vfunc_with_callback (GIMarshallingTestsObject *object)
3987 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (object)->vfunc_with_callback (object,
3989 (void *) 0xdeadbeef);
3993 * gi_marshalling_tests_object_none_return:
3995 * Returns: (transfer none):
3997 GIMarshallingTestsObject *
3998 gi_marshalling_tests_object_none_return (void)
4000 static GIMarshallingTestsObject *object = NULL;
4002 if (object == NULL) {
4003 object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4010 * gi_marshalling_tests_object_full_return:
4012 * Returns: (transfer full):
4014 GIMarshallingTestsObject *
4015 gi_marshalling_tests_object_full_return (void)
4017 return g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4021 * gi_marshalling_tests_object_none_in:
4022 * @object: (transfer none):
4025 gi_marshalling_tests_object_none_in (GIMarshallingTestsObject *object)
4027 g_assert_cmpint(object->int_, ==, 42);
4031 * gi_marshalling_tests_object_none_out:
4032 * @object: (out) (transfer none):
4035 gi_marshalling_tests_object_none_out (GIMarshallingTestsObject **object)
4037 static GIMarshallingTestsObject *new_object = NULL;
4039 if (new_object == NULL) {
4040 new_object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4043 *object = new_object;
4047 * gi_marshalling_tests_object_full_out:
4048 * @object: (out) (transfer full):
4051 gi_marshalling_tests_object_full_out (GIMarshallingTestsObject **object)
4053 *object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4057 * gi_marshalling_tests_object_none_inout:
4058 * @object: (inout) (transfer none):
4061 gi_marshalling_tests_object_none_inout (GIMarshallingTestsObject **object)
4063 static GIMarshallingTestsObject *new_object = NULL;
4065 g_assert_cmpint((*object)->int_, ==, 42);
4067 if (new_object == NULL) {
4068 new_object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4069 new_object->int_ = 0;
4072 *object = new_object;
4076 * gi_marshalling_tests_object_full_inout:
4077 * @object: (inout) (transfer full):
4080 gi_marshalling_tests_object_full_inout (GIMarshallingTestsObject **object)
4082 g_assert_cmpint((*object)->int_, ==, 42);
4084 *object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4088 * gi_marshalling_tests_object_test_int8_in:
4092 gi_marshalling_tests_object_int8_in (GIMarshallingTestsObject *object, gint8 in)
4094 gi_marshalling_tests_object_method_int8_in (object, in);
4098 * gi_marshalling_tests_object_test_int8_out:
4102 gi_marshalling_tests_object_int8_out (GIMarshallingTestsObject *object, gint8 *out)
4104 gi_marshalling_tests_object_method_int8_out (object, out);
4108 * gi_marshalling_tests_object_vfunc_return_value_only:
4111 gi_marshalling_tests_object_vfunc_return_value_only (GIMarshallingTestsObject *self)
4113 /* make sure that local variables don't get smashed */
4115 gulong local = 0x12345678;
4116 return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_only (self);
4117 g_assert_cmpint(local, ==, 0x12345678);
4118 return return_value;
4122 * gi_marshalling_tests_object_vfunc_one_out_parameter:
4126 gi_marshalling_tests_object_vfunc_one_out_parameter (GIMarshallingTestsObject *self, gfloat *a)
4128 /* make sure that local variables don't get smashed */
4129 gulong local = 0x12345678;
4130 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_one_out_parameter (self, a);
4131 g_assert_cmpint(local, ==, 0x12345678);
4135 * gi_marshalling_tests_object_vfunc_multiple_out_parameters:
4140 gi_marshalling_tests_object_vfunc_multiple_out_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b)
4142 /* make sure that local variables don't get smashed */
4143 gulong local = 0x12345678;
4144 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_multiple_out_parameters (self, a, b);
4145 g_assert_cmpint(local, ==, 0x12345678);
4149 * gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter:
4153 gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter (GIMarshallingTestsObject *self, GValue *a)
4155 /* make sure that local variables don't get smashed */
4156 gulong local = 0x12345678;
4157 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_caller_allocated_out_parameter (self, a);
4158 g_assert_cmpint(local, ==, 0x12345678);
4162 * gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter:
4166 gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter (GIMarshallingTestsObject *self, glong *a)
4168 /* make sure that local variables don't get smashed */
4169 gulong return_value;
4170 gulong local = 0x12345678;
4171 return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_one_out_parameter (self, a);
4172 g_assert_cmpint(local, ==, 0x12345678);
4173 return return_value;
4177 * gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters:
4182 gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters (GIMarshallingTestsObject *self, glong *a, glong *b)
4184 gulong return_value;
4185 gulong local = 0x12345678;
4186 return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_multiple_out_parameters (self, a, b);
4187 g_assert_cmpint(local, ==, 0x12345678);
4188 return return_value;
4192 gi_marshalling_tests_object_vfunc_meth_with_error (GIMarshallingTestsObject *self,
4196 gulong local = 0x12345678;
4197 gboolean ret = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_meth_with_err (self, x, error);
4198 g_assert_cmpint(local, ==, 0x12345678);
4202 G_DEFINE_TYPE (GIMarshallingTestsSubObject, gi_marshalling_tests_sub_object, GI_MARSHALLING_TESTS_TYPE_OBJECT);
4205 gi_marshalling_tests_sub_object_init (GIMarshallingTestsSubObject *object)
4210 gi_marshalling_tests_sub_object_finalize (GObject *object)
4212 G_OBJECT_CLASS(gi_marshalling_tests_sub_object_parent_class)->finalize(object);
4216 method_deep_hierarchy (GIMarshallingTestsObject *self, gint8 in)
4219 g_value_init (&val, G_TYPE_INT);
4220 g_value_set_int (&val, in);
4221 g_object_set_property (G_OBJECT (self), "int", &val);
4225 gi_marshalling_tests_sub_object_class_init (GIMarshallingTestsSubObjectClass *klass)
4227 G_OBJECT_CLASS(klass)->finalize = gi_marshalling_tests_sub_object_finalize;
4228 GI_MARSHALLING_TESTS_OBJECT_CLASS(klass)->method_deep_hierarchy = method_deep_hierarchy;
4232 gi_marshalling_tests_sub_object_sub_method (GIMarshallingTestsSubObject *object)
4234 g_assert_cmpint(GI_MARSHALLING_TESTS_OBJECT(object)->int_, ==, 0);
4238 gi_marshalling_tests_sub_object_overwritten_method (GIMarshallingTestsSubObject *object)
4240 g_assert_cmpint(GI_MARSHALLING_TESTS_OBJECT(object)->int_, ==, 0);
4243 G_DEFINE_TYPE (GIMarshallingTestsSubSubObject, gi_marshalling_tests_sub_sub_object, GI_MARSHALLING_TESTS_TYPE_SUB_OBJECT);
4246 gi_marshalling_tests_sub_sub_object_init (GIMarshallingTestsSubSubObject *object)
4251 gi_marshalling_tests_sub_sub_object_class_init (GIMarshallingTestsSubSubObjectClass *klass)
4258 gi_marshalling_tests_interface_class_init(void *g_iface)
4263 gi_marshalling_tests_interface_get_type(void)
4265 static GType type = 0;
4267 type = g_type_register_static_simple (G_TYPE_INTERFACE,
4268 "GIMarshallingTestsInterface",
4269 sizeof (GIMarshallingTestsInterfaceIface),
4270 (GClassInitFunc) gi_marshalling_tests_interface_class_init,
4278 * gi_marshalling_tests_interface_test_int8_in:
4282 gi_marshalling_tests_interface_test_int8_in (GIMarshallingTestsInterface *self, gint8 in)
4284 GI_MARSHALLING_TESTS_INTERFACE_GET_IFACE (self)->test_int8_in (self, in);
4288 * gi_marshalling_tests_test_interface_test_int8_in:
4292 gi_marshalling_tests_test_interface_test_int8_in (GIMarshallingTestsInterface *test_iface, gint8 in)
4294 gi_marshalling_tests_interface_test_int8_in (test_iface, in);
4299 gi_marshalling_tests_interface2_class_init(void *g_iface)
4304 gi_marshalling_tests_interface2_get_type(void)
4306 static GType type = 0;
4308 type = g_type_register_static_simple (G_TYPE_INTERFACE,
4309 "GIMarshallingTestsInterface2",
4310 sizeof (GIMarshallingTestsInterface2Iface),
4311 (GClassInitFunc) gi_marshalling_tests_interface2_class_init,
4319 gi_marshalling_tests_interface3_class_init(void *g_iface)
4324 gi_marshalling_tests_interface3_get_type(void)
4326 static GType type = 0;
4328 type = g_type_register_static_simple (G_TYPE_INTERFACE,
4329 "GIMarshallingTestsInterface3",
4330 sizeof (GIMarshallingTestsInterface3Iface),
4331 (GClassInitFunc) gi_marshalling_tests_interface3_class_init,
4339 * gi_marshalling_tests_interface3_test_variant_array_in:
4340 * @in: (array length=n_in):
4344 gi_marshalling_tests_interface3_test_variant_array_in (GIMarshallingTestsInterface3 *self,
4348 GI_MARSHALLING_TESTS_INTERFACE3_GET_IFACE (self)->test_variant_array_in (self, in, n_in);
4352 * gi_marshalling_tests_int_out_out:
4357 gi_marshalling_tests_int_out_out (gint *int0, gint *int1)
4364 * gi_marshalling_tests_int_three_in_three_out:
4373 gi_marshalling_tests_int_three_in_three_out(gint a, gint b, gint c,
4374 gint *out0, gint *out1, gint *out2)
4382 * gi_marshalling_tests_int_return_out:
4386 gi_marshalling_tests_int_return_out (gint *int_)
4395 gi_marshalling_tests_gerror(GError **error)
4397 GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4398 g_set_error_literal(error,
4400 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4401 GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4405 * gi_marshalling_tests_gerror_array_in:
4406 * @in_ints: (array zero-terminated=1):
4409 gi_marshalling_tests_gerror_array_in(gint *in_ints, GError **error)
4411 GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4412 g_set_error_literal(error,
4414 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4415 GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4419 * gi_marshalling_tests_gerror_out:
4420 * @error: (out) (allow-none) (transfer full): location for the GError.
4421 * @debug: (out) (allow-none) (transfer full): location for the debug message
4423 * Inspired by gst_message_parse_error.
4426 gi_marshalling_tests_gerror_out(GError **error, gchar **debug)
4428 GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4429 g_set_error_literal(error,
4431 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4432 GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4434 if (debug != NULL) {
4435 *debug = g_strdup (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE);
4440 * gi_marshalling_tests_gerror_out_transfer_none:
4441 * @err: (out) (allow-none) (transfer none): location for the GError.
4442 * @debug: (out) (allow-none) (transfer none): location for the debug message
4444 * A variant of gi_marshalling_tests_gerror_out() which returns data the caller
4448 gi_marshalling_tests_gerror_out_transfer_none(GError **err, const gchar **debug)
4450 static GError error = { 0,
4451 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4452 GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE };
4453 error.domain = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4455 *debug = GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE;
4459 * gi_marshalling_tests_gerror_return:
4461 * Yet another variant of gi_marshalling_tests_gerror_out().
4463 * Returns: (transfer full): a GError
4466 gi_marshalling_tests_gerror_return(void)
4468 GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4470 return g_error_new(quark,
4471 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4472 GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4475 static GIMarshallingTestsOverridesStruct *
4476 gi_marshalling_tests_overrides_struct_copy (GIMarshallingTestsOverridesStruct *struct_)
4478 GIMarshallingTestsOverridesStruct *new_struct;
4480 new_struct = g_slice_new (GIMarshallingTestsOverridesStruct);
4482 *new_struct = *struct_;
4488 gi_marshalling_tests_overrides_struct_free (GIMarshallingTestsOverridesStruct *struct_)
4490 g_slice_free (GIMarshallingTestsOverridesStruct, struct_);
4494 gi_marshalling_tests_overrides_struct_get_type (void)
4496 static GType type = 0;
4499 type = g_boxed_type_register_static ("GIMarshallingTestsOverridesStruct",
4500 (GBoxedCopyFunc) gi_marshalling_tests_overrides_struct_copy,
4501 (GBoxedFreeFunc) gi_marshalling_tests_overrides_struct_free);
4507 GIMarshallingTestsOverridesStruct *
4508 gi_marshalling_tests_overrides_struct_new (void)
4510 return g_slice_new (GIMarshallingTestsOverridesStruct);
4514 gi_marshalling_tests_overrides_struct_method (GIMarshallingTestsOverridesStruct *struct_)
4521 * gi_marshalling_tests_overrides_struct_returnv:
4523 * Returns: (transfer full):
4525 GIMarshallingTestsOverridesStruct *
4526 gi_marshalling_tests_overrides_struct_returnv (void)
4528 return gi_marshalling_tests_overrides_struct_new();
4532 G_DEFINE_TYPE (GIMarshallingTestsOverridesObject, gi_marshalling_tests_overrides_object, G_TYPE_OBJECT);
4535 gi_marshalling_tests_overrides_object_init (GIMarshallingTestsOverridesObject *object)
4540 gi_marshalling_tests_overrides_object_finalize (GObject *object)
4542 G_OBJECT_CLASS (gi_marshalling_tests_overrides_object_parent_class)->finalize (object);
4546 gi_marshalling_tests_overrides_object_class_init (GIMarshallingTestsOverridesObjectClass *klass)
4548 GObjectClass* object_class = G_OBJECT_CLASS (klass);
4550 GObjectClass* parent_class = G_OBJECT_CLASS (klass);
4553 object_class->finalize = gi_marshalling_tests_overrides_object_finalize;
4556 GIMarshallingTestsOverridesObject *
4557 gi_marshalling_tests_overrides_object_new (void)
4559 return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
4563 gi_marshalling_tests_overrides_object_method (GIMarshallingTestsOverridesObject *object)
4569 * gi_marshalling_tests_overrides_object_returnv:
4571 * Returns: (transfer full):
4573 GIMarshallingTestsOverridesObject *
4574 gi_marshalling_tests_overrides_object_returnv (void)
4576 return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
4580 * gi_marshalling_tests_filename_list_return:
4582 * Returns: (transfer none) (element-type filename): List of filenames
4585 gi_marshalling_tests_filename_list_return (void)
4591 * gi_marshalling_tests_param_spec_return:
4593 * Returns: (transfer full): a #GParamSpec
4596 gi_marshalling_tests_param_spec_return (void)
4598 return g_param_spec_string ("test-param", "test", "This is a test", "42", G_PARAM_READABLE);
4602 * gi_marshalling_tests_param_spec_out:
4606 gi_marshalling_tests_param_spec_out(GParamSpec **param)
4608 *param = g_param_spec_string("test-param", "test", "This is a test", "42", G_PARAM_READABLE);
4614 SOME_BOOLEAN_PROPERTY,
4616 SOME_UCHAR_PROPERTY,
4620 SOME_ULONG_PROPERTY,
4621 SOME_INT64_PROPERTY,
4622 SOME_UINT64_PROPERTY,
4623 SOME_FLOAT_PROPERTY,
4624 SOME_DOUBLE_PROPERTY,
4626 SOME_BOXED_STRUCT_PROPERTY,
4627 SOME_VARIANT_PROPERTY,
4630 G_DEFINE_TYPE (GIMarshallingTestsPropertiesObject, gi_marshalling_tests_properties_object, G_TYPE_OBJECT);
4633 gi_marshalling_tests_properties_object_init (GIMarshallingTestsPropertiesObject * self)
4638 gi_marshalling_tests_properties_object_finalize (GObject* obj)
4640 G_OBJECT_CLASS (gi_marshalling_tests_properties_object_parent_class)->finalize (obj);
4644 gi_marshalling_tests_properties_object_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec)
4646 GIMarshallingTestsPropertiesObject * self;
4647 self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
4648 switch (property_id) {
4649 case SOME_BOOLEAN_PROPERTY:
4650 g_value_set_boolean (value, self->some_boolean);
4652 case SOME_CHAR_PROPERTY:
4653 g_value_set_schar (value, self->some_char);
4655 case SOME_UCHAR_PROPERTY:
4656 g_value_set_uchar (value, self->some_uchar);
4658 case SOME_INT_PROPERTY:
4659 g_value_set_int (value, self->some_int);
4661 case SOME_UINT_PROPERTY:
4662 g_value_set_uint (value, self->some_uint);
4664 case SOME_LONG_PROPERTY:
4665 g_value_set_long (value, self->some_long);
4667 case SOME_ULONG_PROPERTY:
4668 g_value_set_ulong (value, self->some_ulong);
4670 case SOME_INT64_PROPERTY:
4671 g_value_set_int64 (value, self->some_int64);
4673 case SOME_UINT64_PROPERTY:
4674 g_value_set_uint64 (value, self->some_uint64);
4676 case SOME_FLOAT_PROPERTY:
4677 g_value_set_float (value, self->some_float);
4679 case SOME_DOUBLE_PROPERTY:
4680 g_value_set_double (value, self->some_double);
4682 case SOME_STRV_PROPERTY:
4683 g_value_set_boxed (value, self->some_strv);
4685 case SOME_BOXED_STRUCT_PROPERTY:
4686 g_value_set_boxed (value, self->some_boxed_struct);
4688 case SOME_VARIANT_PROPERTY:
4689 g_value_set_variant (value, self->some_variant);
4692 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
4698 gi_marshalling_tests_properties_object_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec)
4700 GIMarshallingTestsPropertiesObject * self;
4701 self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
4702 switch (property_id) {
4703 case SOME_BOOLEAN_PROPERTY:
4704 self->some_boolean = g_value_get_boolean (value);
4706 case SOME_CHAR_PROPERTY:
4707 self->some_char = g_value_get_schar (value);
4709 case SOME_UCHAR_PROPERTY:
4710 self->some_uchar = g_value_get_uchar (value);
4712 case SOME_INT_PROPERTY:
4713 self->some_int = g_value_get_int (value);
4715 case SOME_UINT_PROPERTY:
4716 self->some_uint = g_value_get_uint (value);
4718 case SOME_LONG_PROPERTY:
4719 self->some_long = g_value_get_long (value);
4721 case SOME_ULONG_PROPERTY:
4722 self->some_ulong = g_value_get_ulong (value);
4724 case SOME_INT64_PROPERTY:
4725 self->some_int64 = g_value_get_int64 (value);
4727 case SOME_UINT64_PROPERTY:
4728 self->some_uint64 = g_value_get_uint64 (value);
4730 case SOME_FLOAT_PROPERTY:
4731 self->some_float = g_value_get_float (value);
4733 case SOME_DOUBLE_PROPERTY:
4734 self->some_double = g_value_get_double (value);
4736 case SOME_STRV_PROPERTY:
4737 g_strfreev (self->some_strv);
4738 self->some_strv = g_strdupv (g_value_get_boxed (value));
4740 case SOME_BOXED_STRUCT_PROPERTY:
4741 gi_marshalling_tests_boxed_struct_free (self->some_boxed_struct);
4742 self->some_boxed_struct = gi_marshalling_tests_boxed_struct_copy (g_value_get_boxed (value));
4744 case SOME_VARIANT_PROPERTY:
4745 if (self->some_variant != NULL)
4746 g_variant_unref (self->some_variant);
4747 self->some_variant = g_value_get_variant (value);
4748 if (self->some_variant != NULL)
4749 g_variant_ref (self->some_variant);
4752 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
4758 gi_marshalling_tests_properties_object_class_init (GIMarshallingTestsPropertiesObjectClass * klass)
4760 GObjectClass* object_class = G_OBJECT_CLASS (klass);
4762 object_class->finalize = gi_marshalling_tests_properties_object_finalize;
4763 object_class->get_property = gi_marshalling_tests_properties_object_get_property;
4764 object_class->set_property = gi_marshalling_tests_properties_object_set_property;
4766 g_object_class_install_property (object_class, SOME_BOOLEAN_PROPERTY,
4767 g_param_spec_boolean ("some-boolean", "some-boolean", "some-boolean", FALSE,
4768 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4770 g_object_class_install_property (object_class, SOME_CHAR_PROPERTY,
4771 g_param_spec_char ("some-char", "some-char", "some-char", G_MININT8, G_MAXINT8, 0,
4772 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4774 g_object_class_install_property (object_class, SOME_UCHAR_PROPERTY,
4775 g_param_spec_uchar ("some-uchar", "some-uchar", "some-uchar", 0, G_MAXUINT8, 0,
4776 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4778 g_object_class_install_property (object_class, SOME_INT_PROPERTY,
4779 g_param_spec_int ("some-int", "some-int", "some-int", G_MININT, G_MAXINT, 0,
4780 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4782 g_object_class_install_property (object_class, SOME_UINT_PROPERTY,
4783 g_param_spec_uint ("some-uint", "some-uint", "some-uint", 0, G_MAXUINT, 0,
4784 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4786 g_object_class_install_property (object_class, SOME_LONG_PROPERTY,
4787 g_param_spec_long ("some-long", "some-long", "some-long", G_MINLONG, G_MAXLONG, 0,
4788 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4790 g_object_class_install_property (object_class, SOME_ULONG_PROPERTY,
4791 g_param_spec_ulong ("some-ulong", "some-ulong", "some-ulong", 0, G_MAXULONG, 0,
4792 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4794 g_object_class_install_property (object_class, SOME_INT64_PROPERTY,
4795 g_param_spec_int64 ("some-int64", "some-int64", "some-int64", G_MININT64, G_MAXINT64, 0,
4796 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4798 g_object_class_install_property (object_class, SOME_UINT64_PROPERTY,
4799 g_param_spec_uint64 ("some-uint64", "some-uint64", "some-uint64", 0, G_MAXUINT64, 0,
4800 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4802 g_object_class_install_property (object_class, SOME_FLOAT_PROPERTY,
4803 g_param_spec_float ("some-float", "some-float", "some-float", -1 * G_MAXFLOAT, G_MAXFLOAT, 0,
4804 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4806 g_object_class_install_property (object_class, SOME_DOUBLE_PROPERTY,
4807 g_param_spec_double ("some-double", "some-double", "some-double", -1 * G_MAXDOUBLE, G_MAXDOUBLE, 0,
4808 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4810 g_object_class_install_property (object_class, SOME_STRV_PROPERTY,
4811 g_param_spec_boxed ("some-strv", "some-strv", "some-strv", G_TYPE_STRV,
4812 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4814 g_object_class_install_property (object_class, SOME_BOXED_STRUCT_PROPERTY,
4815 g_param_spec_boxed ("some-boxed-struct", "some-boxed-struct", "some-boxed-struct",
4816 gi_marshalling_tests_boxed_struct_get_type(),
4817 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4819 g_object_class_install_property (object_class, SOME_VARIANT_PROPERTY,
4820 g_param_spec_variant ("some-variant", "some-variant", "some-variant",
4821 G_VARIANT_TYPE_ANY, NULL,
4822 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4825 GIMarshallingTestsPropertiesObject*
4826 gi_marshalling_tests_properties_object_new (void)
4828 return g_object_new (GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT, NULL);