1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2 *vim: tabstop=4 shiftwidth=4 expandtab
5 /* This file gets installed, so we can't assume config.h is available */
10 #include "gimarshallingtests.h"
14 static void gi_marshalling_tests_boxed_struct_free (GIMarshallingTestsBoxedStruct *v);
19 gi_marshalling_tests_boolean_return_true (void)
25 gi_marshalling_tests_boolean_return_false (void)
31 gi_marshalling_tests_boolean_in_true (gboolean v)
37 gi_marshalling_tests_boolean_in_false (gboolean v)
39 g_assert (v == FALSE);
43 * gi_marshalling_tests_boolean_out_true:
47 gi_marshalling_tests_boolean_out_true (gboolean *v)
53 * gi_marshalling_tests_boolean_out_false:
57 gi_marshalling_tests_boolean_out_false (gboolean *v)
63 * gi_marshalling_tests_boolean_inout_true_false:
67 gi_marshalling_tests_boolean_inout_true_false (gboolean *v)
69 g_assert (*v == TRUE);
74 * gi_marshalling_tests_boolean_inout_false_true:
78 gi_marshalling_tests_boolean_inout_false_true (gboolean *v)
80 g_assert (*v == FALSE);
88 gi_marshalling_tests_int8_return_max (void)
94 gi_marshalling_tests_int8_return_min (void)
100 gi_marshalling_tests_int8_in_max (gint8 v)
102 g_assert_cmpint (v, ==, G_MAXINT8);
106 gi_marshalling_tests_int8_in_min (gint8 v)
108 g_assert_cmpint (v, ==, G_MININT8);
112 * gi_marshalling_tests_int8_out_max:
116 gi_marshalling_tests_int8_out_max (gint8 *v)
122 * gi_marshalling_tests_int8_out_min:
126 gi_marshalling_tests_int8_out_min (gint8 *v)
132 * gi_marshalling_tests_int8_inout_max_min:
136 gi_marshalling_tests_int8_inout_max_min (gint8 *v)
138 g_assert_cmpint (*v, ==, G_MAXINT8);
143 * gi_marshalling_tests_int8_inout_min_max:
147 gi_marshalling_tests_int8_inout_min_max (gint8 *v)
149 g_assert_cmpint (*v, ==, G_MININT8);
155 gi_marshalling_tests_uint8_return (void)
161 gi_marshalling_tests_uint8_in (guint8 v)
163 g_assert_cmpuint (v, ==, G_MAXUINT8);
167 * gi_marshalling_tests_uint8_out:
171 gi_marshalling_tests_uint8_out (guint8 *v)
177 * gi_marshalling_tests_uint8_inout:
181 gi_marshalling_tests_uint8_inout (guint8 *v)
183 g_assert_cmpuint (*v, ==, G_MAXUINT8);
189 gi_marshalling_tests_int16_return_max (void)
195 gi_marshalling_tests_int16_return_min (void)
201 gi_marshalling_tests_int16_in_max (gint16 v)
203 g_assert_cmpint (v, ==, G_MAXINT16);
207 gi_marshalling_tests_int16_in_min (gint16 v)
209 g_assert_cmpint (v, ==, G_MININT16);
213 * gi_marshalling_tests_int16_out_max:
217 gi_marshalling_tests_int16_out_max (gint16 *v)
223 * gi_marshalling_tests_int16_out_min:
227 gi_marshalling_tests_int16_out_min (gint16 *v)
233 * gi_marshalling_tests_int16_inout_max_min:
237 gi_marshalling_tests_int16_inout_max_min (gint16 *v)
239 g_assert_cmpint (*v, ==, G_MAXINT16);
244 * gi_marshalling_tests_int16_inout_min_max:
248 gi_marshalling_tests_int16_inout_min_max (gint16 *v)
250 g_assert_cmpint (*v, ==, G_MININT16);
256 gi_marshalling_tests_uint16_return (void)
262 gi_marshalling_tests_uint16_in (guint16 v)
264 g_assert_cmpuint (v, ==, G_MAXUINT16);
268 * gi_marshalling_tests_uint16_out:
272 gi_marshalling_tests_uint16_out (guint16 *v)
278 * gi_marshalling_tests_uint16_inout:
282 gi_marshalling_tests_uint16_inout (guint16 *v)
284 g_assert_cmpuint (*v, ==, G_MAXUINT16);
290 gi_marshalling_tests_int32_return_max (void)
296 gi_marshalling_tests_int32_return_min (void)
302 gi_marshalling_tests_int32_in_max (gint32 v)
304 g_assert_cmpint (v, ==, G_MAXINT32);
308 gi_marshalling_tests_int32_in_min (gint32 v)
310 g_assert_cmpint (v, ==, G_MININT32);
314 * gi_marshalling_tests_int32_out_max:
318 gi_marshalling_tests_int32_out_max (gint32 *v)
324 * gi_marshalling_tests_int32_out_min:
328 gi_marshalling_tests_int32_out_min (gint32 *v)
334 * gi_marshalling_tests_int32_inout_max_min:
338 gi_marshalling_tests_int32_inout_max_min (gint32 *v)
340 g_assert_cmpint (*v, ==, G_MAXINT32);
345 * gi_marshalling_tests_int32_inout_min_max:
349 gi_marshalling_tests_int32_inout_min_max (gint32 *v)
351 g_assert_cmpint (*v, ==, G_MININT32);
357 gi_marshalling_tests_uint32_return (void)
363 gi_marshalling_tests_uint32_in (guint32 v)
365 g_assert_cmpuint (v, ==, G_MAXUINT32);
369 * gi_marshalling_tests_uint32_out:
373 gi_marshalling_tests_uint32_out (guint32 *v)
379 * gi_marshalling_tests_uint32_inout:
383 gi_marshalling_tests_uint32_inout (guint32 *v)
385 g_assert_cmpuint (*v, ==, G_MAXUINT32);
391 gi_marshalling_tests_int64_return_max (void)
397 gi_marshalling_tests_int64_return_min (void)
403 gi_marshalling_tests_int64_in_max (gint64 v)
405 g_assert_cmpint (v, ==, G_MAXINT64);
409 gi_marshalling_tests_int64_in_min (gint64 v)
411 g_assert_cmpint (v, ==, G_MININT64);
415 * gi_marshalling_tests_int64_out_max:
419 gi_marshalling_tests_int64_out_max (gint64 *v)
425 * gi_marshalling_tests_int64_out_min:
429 gi_marshalling_tests_int64_out_min (gint64 *v)
435 * gi_marshalling_tests_int64_inout_max_min:
439 gi_marshalling_tests_int64_inout_max_min (gint64 *v)
441 g_assert_cmpint (*v, ==, G_MAXINT64);
446 * gi_marshalling_tests_int64_inout_min_max:
450 gi_marshalling_tests_int64_inout_min_max (gint64 *v)
452 g_assert_cmpint (*v, ==, G_MININT64);
458 gi_marshalling_tests_uint64_return (void)
464 gi_marshalling_tests_uint64_in (guint64 v)
466 g_assert_cmpuint (v, ==, G_MAXUINT64);
470 * gi_marshalling_tests_uint64_out:
474 gi_marshalling_tests_uint64_out (guint64 *v)
480 * gi_marshalling_tests_uint64_inout:
484 gi_marshalling_tests_uint64_inout (guint64 *v)
486 g_assert_cmpuint (*v, ==, G_MAXUINT64);
492 gi_marshalling_tests_short_return_max (void)
498 gi_marshalling_tests_short_return_min (void)
504 gi_marshalling_tests_short_in_max (gshort short_)
506 g_assert_cmpint (short_, ==, G_MAXSHORT);
510 gi_marshalling_tests_short_in_min (gshort short_)
512 g_assert_cmpint (short_, ==, G_MINSHORT);
516 * gi_marshalling_tests_short_out_max:
520 gi_marshalling_tests_short_out_max (gshort *short_)
522 *short_ = G_MAXSHORT;
526 * gi_marshalling_tests_short_out_min:
530 gi_marshalling_tests_short_out_min (gshort *short_)
532 *short_ = G_MINSHORT;
536 * gi_marshalling_tests_short_inout_max_min:
540 gi_marshalling_tests_short_inout_max_min (gshort *short_)
542 g_assert_cmpint (*short_, ==, G_MAXSHORT);
543 *short_ = G_MINSHORT;
547 * gi_marshalling_tests_short_inout_min_max:
551 gi_marshalling_tests_short_inout_min_max (gshort *short_)
553 g_assert_cmpint (*short_, ==, G_MINSHORT);
554 *short_ = G_MAXSHORT;
559 gi_marshalling_tests_ushort_return (void)
565 gi_marshalling_tests_ushort_in (gushort ushort_)
567 g_assert_cmpuint (ushort_, ==, G_MAXUSHORT);
571 * gi_marshalling_tests_ushort_out:
575 gi_marshalling_tests_ushort_out (gushort *ushort_)
577 *ushort_ = G_MAXUSHORT;
581 * gi_marshalling_tests_ushort_inout:
585 gi_marshalling_tests_ushort_inout (gushort *ushort_)
587 g_assert_cmpuint (*ushort_, ==, G_MAXUSHORT);
593 gi_marshalling_tests_int_return_max (void)
599 gi_marshalling_tests_int_return_min (void)
605 gi_marshalling_tests_int_in_max (gint int_)
607 g_assert_cmpint (int_, ==, G_MAXINT);
611 gi_marshalling_tests_int_in_min (gint int_)
613 g_assert_cmpint (int_, ==, G_MININT);
617 * gi_marshalling_tests_int_out_max:
621 gi_marshalling_tests_int_out_max (gint *int_)
627 * gi_marshalling_tests_int_out_min:
631 gi_marshalling_tests_int_out_min (gint *int_)
637 * gi_marshalling_tests_int_inout_max_min:
641 gi_marshalling_tests_int_inout_max_min (gint *int_)
643 g_assert_cmpint (*int_, ==, G_MAXINT);
648 * gi_marshalling_tests_int_inout_min_max:
652 gi_marshalling_tests_int_inout_min_max (gint *int_)
654 g_assert_cmpint (*int_, ==, G_MININT);
660 gi_marshalling_tests_uint_return (void)
666 gi_marshalling_tests_uint_in (guint uint_)
668 g_assert_cmpuint (uint_, ==, G_MAXUINT);
672 * gi_marshalling_tests_uint_out:
676 gi_marshalling_tests_uint_out (guint *uint_)
682 * gi_marshalling_tests_uint_inout:
686 gi_marshalling_tests_uint_inout (guint *uint_)
688 g_assert_cmpuint (*uint_, ==, G_MAXUINT);
694 gi_marshalling_tests_long_return_max (void)
700 gi_marshalling_tests_long_return_min (void)
706 gi_marshalling_tests_long_in_max (glong long_)
708 g_assert_cmpint (long_, ==, G_MAXLONG);
712 gi_marshalling_tests_long_in_min (glong long_)
714 g_assert_cmpint (long_, ==, G_MINLONG);
718 * gi_marshalling_tests_long_out_max:
722 gi_marshalling_tests_long_out_max (glong *long_)
728 * gi_marshalling_tests_long_out_min:
732 gi_marshalling_tests_long_out_min (glong *long_)
738 * gi_marshalling_tests_long_inout_max_min:
742 gi_marshalling_tests_long_inout_max_min (glong *long_)
744 g_assert_cmpint (*long_, ==, G_MAXLONG);
749 * gi_marshalling_tests_long_inout_min_max:
753 gi_marshalling_tests_long_inout_min_max (glong *long_)
755 g_assert_cmpint (*long_, ==, G_MINLONG);
761 gi_marshalling_tests_ulong_return (void)
767 gi_marshalling_tests_ulong_in (gulong ulong_)
769 g_assert_cmpuint (ulong_, ==, G_MAXULONG);
773 * gi_marshalling_tests_ulong_out:
777 gi_marshalling_tests_ulong_out (gulong *ulong_)
779 *ulong_ = G_MAXULONG;
783 * gi_marshalling_tests_ulong_inout:
787 gi_marshalling_tests_ulong_inout (gulong *ulong_)
789 g_assert_cmpuint (*ulong_, ==, G_MAXULONG);
795 gi_marshalling_tests_ssize_return_max (void)
801 gi_marshalling_tests_ssize_return_min (void)
807 gi_marshalling_tests_ssize_in_max (gssize ssize)
809 g_assert_cmpint (ssize, ==, G_MAXSSIZE);
813 gi_marshalling_tests_ssize_in_min (gssize ssize)
815 g_assert_cmpint (ssize, ==, G_MINSSIZE);
819 * gi_marshalling_tests_ssize_out_max:
823 gi_marshalling_tests_ssize_out_max (gssize *ssize)
829 * gi_marshalling_tests_ssize_out_min:
833 gi_marshalling_tests_ssize_out_min (gssize *ssize)
839 * gi_marshalling_tests_ssize_inout_max_min:
843 gi_marshalling_tests_ssize_inout_max_min (gssize *ssize)
845 g_assert_cmpint (*ssize, ==, G_MAXSSIZE);
850 * gi_marshalling_tests_ssize_inout_min_max:
854 gi_marshalling_tests_ssize_inout_min_max (gssize *ssize)
856 g_assert_cmpint (*ssize, ==, G_MINSSIZE);
862 gi_marshalling_tests_size_return (void)
868 gi_marshalling_tests_size_in (gsize size)
870 g_assert_cmpuint (size, ==, G_MAXSIZE);
874 * gi_marshalling_tests_size_out:
878 gi_marshalling_tests_size_out (gsize *size)
884 * gi_marshalling_tests_size_inout:
888 gi_marshalling_tests_size_inout (gsize *size)
890 g_assert_cmpuint (*size, ==, G_MAXSIZE);
896 gi_marshalling_tests_float_return (void)
902 gi_marshalling_tests_float_in (gfloat v)
904 g_assert_cmpfloat (v, ==, G_MAXFLOAT);
908 * gi_marshalling_tests_float_out:
912 gi_marshalling_tests_float_out (gfloat *v)
918 * gi_marshalling_tests_float_inout:
922 gi_marshalling_tests_float_inout (gfloat *v)
924 g_assert_cmpfloat (*v, ==, G_MAXFLOAT);
930 gi_marshalling_tests_double_return (void)
936 gi_marshalling_tests_double_in (gdouble v)
938 g_assert_cmpfloat (v, ==, G_MAXDOUBLE);
942 * gi_marshalling_tests_double_out:
946 gi_marshalling_tests_double_out (gdouble *v)
952 * gi_marshalling_tests_double_inout:
956 gi_marshalling_tests_double_inout (gdouble *v)
958 g_assert_cmpfloat (*v, ==, G_MAXDOUBLE);
964 gi_marshalling_tests_time_t_return (void)
970 gi_marshalling_tests_time_t_in (time_t v)
972 g_assert_cmpuint (v, ==, 1234567890);
976 * gi_marshalling_tests_time_t_out:
980 gi_marshalling_tests_time_t_out (time_t *v)
986 * gi_marshalling_tests_time_t_inout:
990 gi_marshalling_tests_time_t_inout (time_t *v)
992 g_assert_cmpuint (*v, ==, 1234567890);
998 gi_marshalling_tests_gtype_return (void)
1004 gi_marshalling_tests_gtype_string_return (void)
1006 return G_TYPE_STRING;
1010 gi_marshalling_tests_gtype_in (GType gtype)
1012 g_assert (gtype == G_TYPE_NONE);
1016 gi_marshalling_tests_gtype_string_in (GType gtype)
1018 g_assert (gtype == G_TYPE_STRING);
1023 * gi_marshalling_tests_gtype_out:
1027 gi_marshalling_tests_gtype_out (GType *gtype)
1029 *gtype = G_TYPE_NONE;
1033 * gi_marshalling_tests_gtype_string_out:
1037 gi_marshalling_tests_gtype_string_out (GType *gtype)
1039 *gtype = G_TYPE_STRING;
1043 * gi_marshalling_tests_gtype_inout:
1047 gi_marshalling_tests_gtype_inout (GType *gtype)
1049 g_assert (*gtype == G_TYPE_NONE);
1050 *gtype = G_TYPE_INT;
1055 gi_marshalling_tests_utf8_none_return (void)
1057 return GI_MARSHALLING_TESTS_CONSTANT_UTF8;
1061 gi_marshalling_tests_utf8_full_return (void)
1063 return g_strdup (GI_MARSHALLING_TESTS_CONSTANT_UTF8);
1067 gi_marshalling_tests_utf8_none_in (const gchar *utf8)
1069 g_assert_cmpstr (GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, utf8);
1073 * gi_marshalling_tests_utf8_as_uint8array_in:
1074 * @array: (array length=len) (element-type guint8): Byte data that happens to be UTF-8
1077 * Takes data that happens to be UTF-8 as a byte array, to test
1078 * binding conversion from their string type (e.g. JavaScript's
1082 gi_marshalling_tests_utf8_as_uint8array_in (const guint8 *array, gsize len)
1084 gsize orig_len = strlen (GI_MARSHALLING_TESTS_CONSTANT_UTF8);
1085 g_assert_cmpint (orig_len, ==, len);
1086 g_assert (memcmp (GI_MARSHALLING_TESTS_CONSTANT_UTF8, array, len) == 0);
1090 * gi_marshalling_tests_utf8_none_out:
1091 * @utf8: (out) (transfer none):
1094 gi_marshalling_tests_utf8_none_out (const gchar **utf8)
1096 *utf8 = GI_MARSHALLING_TESTS_CONSTANT_UTF8;
1100 * gi_marshalling_tests_utf8_full_out:
1101 * @utf8: (out) (transfer full):
1104 gi_marshalling_tests_utf8_full_out (gchar **utf8)
1106 *utf8 = g_strdup (GI_MARSHALLING_TESTS_CONSTANT_UTF8);
1110 * gi_marshalling_tests_utf8_dangling_out:
1111 * @utf8: (out) (transfer full):
1114 gi_marshalling_tests_utf8_dangling_out (gchar **utf8 G_GNUC_UNUSED)
1116 /* Intentionally don't touch the pointer to see how
1117 the bindings handle this case. Bindings should be
1118 robust against broken C functions and can initialize
1119 even OUT vlues to NULL.
1124 * gi_marshalling_tests_utf8_none_inout:
1125 * @utf8: (inout) (transfer none):
1128 gi_marshalling_tests_utf8_none_inout (const gchar **utf8)
1130 g_assert_cmpstr (GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, *utf8);
1135 * gi_marshalling_tests_utf8_full_inout:
1136 * @utf8: (inout) (transfer full):
1139 gi_marshalling_tests_utf8_full_inout (gchar **utf8)
1141 g_assert_cmpstr (GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, *utf8);
1143 *utf8 = g_strdup ("");
1148 * gi_marshalling_tests_init_function:
1149 * @n_args: (inout) (allow-none): number of args
1150 * @argv: (inout) (array length=n_args) (allow-none): args
1152 * This is like gtk_init().
1155 gi_marshalling_tests_init_function (gint *n_args, char ***argv)
1163 g_assert (argv != NULL);
1164 /* we have transfer ownership full, so we need to free the element ourself */
1165 g_free ((*argv)[*n_args]);
1166 (*argv)[*n_args] = NULL;
1171 * gi_marshalling_tests_array_fixed_int_return:
1173 * Returns: (array fixed-size=4):
1176 gi_marshalling_tests_array_fixed_int_return (void)
1178 static gint ints[] = { -1, 0, 1, 2 };
1183 * gi_marshalling_tests_array_fixed_short_return:
1185 * Returns: (array fixed-size=4):
1188 gi_marshalling_tests_array_fixed_short_return (void)
1190 static gshort shorts[] = { -1, 0, 1, 2 };
1195 * gi_marshalling_tests_array_fixed_int_in:
1196 * @ints: (array fixed-size=4):
1199 gi_marshalling_tests_array_fixed_int_in (const gint *ints)
1201 g_assert_cmpint (ints[0], ==, -1);
1202 g_assert_cmpint (ints[1], ==, 0);
1203 g_assert_cmpint (ints[2], ==, 1);
1204 g_assert_cmpint (ints[3], ==, 2);
1208 * gi_marshalling_tests_array_fixed_short_in:
1209 * @shorts: (array fixed-size=4):
1212 gi_marshalling_tests_array_fixed_short_in (const gshort *shorts)
1214 g_assert_cmpint (shorts[0], ==, -1);
1215 g_assert_cmpint (shorts[1], ==, 0);
1216 g_assert_cmpint (shorts[2], ==, 1);
1217 g_assert_cmpint (shorts[3], ==, 2);
1221 * gi_marshalling_tests_array_fixed_out:
1222 * @ints: (out) (array fixed-size=4) (transfer none):
1225 gi_marshalling_tests_array_fixed_out (gint **ints)
1227 static gint values[] = { -1, 0, 1, 2 };
1232 * gi_marshalling_tests_array_fixed_out_struct:
1233 * @structs: (out) (array fixed-size=2) (transfer none):
1236 gi_marshalling_tests_array_fixed_out_struct (GIMarshallingTestsSimpleStruct **structs)
1238 static GIMarshallingTestsSimpleStruct *values;
1242 values = g_new (GIMarshallingTestsSimpleStruct, 2);
1244 values[0].long_ = 7;
1247 values[1].long_ = 6;
1255 * gi_marshalling_tests_array_fixed_inout:
1256 * @ints: (inout) (array fixed-size=4) (transfer none):
1259 gi_marshalling_tests_array_fixed_inout (gint **ints)
1261 static gint values[] = { 2, 1, 0, -1 };
1263 g_assert_cmpint ((*ints)[0], ==, -1);
1264 g_assert_cmpint ((*ints)[1], ==, 0);
1265 g_assert_cmpint ((*ints)[2], ==, 1);
1266 g_assert_cmpint ((*ints)[3], ==, 2);
1273 * gi_marshalling_tests_array_return:
1275 * Returns: (array length=length):
1278 gi_marshalling_tests_array_return (gint *length)
1280 static gint ints[] = { -1, 0, 1, 2 };
1287 * gi_marshalling_tests_array_return_etc:
1293 * Returns: (array length=length):
1296 gi_marshalling_tests_array_return_etc (gint first, gint *length, gint last, gint *sum)
1298 static gint ints[] = { -1, 0, 1, 2 };
1302 *sum = first + last;
1308 * gi_marshalling_tests_array_in:
1309 * @ints: (array length=length):
1313 gi_marshalling_tests_array_in (const gint *ints, gint length)
1315 g_assert_cmpint (length, ==, 4);
1316 g_assert_cmpint (ints[0], ==, -1);
1317 g_assert_cmpint (ints[1], ==, 0);
1318 g_assert_cmpint (ints[2], ==, 1);
1319 g_assert_cmpint (ints[3], ==, 2);
1323 * gi_marshalling_tests_array_in_len_before:
1325 * @ints: (array length=length):
1328 gi_marshalling_tests_array_in_len_before (gint length, const gint *ints)
1330 gi_marshalling_tests_array_in (ints, length);
1334 * gi_marshalling_tests_array_in_len_zero_terminated:
1335 * @ints: (array length=length zero-terminated):
1339 gi_marshalling_tests_array_in_len_zero_terminated (const gint *ints, gint length)
1341 g_assert_cmpint (length, ==, 4);
1343 g_assert_cmpint (ints[0], ==, -1);
1344 g_assert_cmpint (ints[1], ==, 0);
1345 g_assert_cmpint (ints[2], ==, 1);
1346 g_assert_cmpint (ints[3], ==, 2);
1348 /* One past the end, null terminator */
1349 g_assert_cmpint (ints[4], ==, 0);
1353 * gi_marshalling_tests_array_string_in:
1354 * @strings: (array length=length):
1357 gi_marshalling_tests_array_string_in (const gchar **strings, gint length)
1359 g_assert_cmpint (length, ==, 2);
1360 g_assert_cmpstr (strings[0], ==, "foo");
1361 g_assert_cmpstr (strings[1], ==, "bar");
1365 * gi_marshalling_tests_array_uint8_in:
1366 * @chars: (array length=length):
1369 gi_marshalling_tests_array_uint8_in (const guint8 *chars, gint length)
1371 g_assert_cmpint (length, ==, 4);
1372 g_assert (chars[0] == 'a');
1373 g_assert (chars[1] == 'b');
1374 g_assert (chars[2] == 'c');
1375 g_assert (chars[3] == 'd');
1379 * gi_marshalling_tests_array_int64_in:
1380 * @ints: (array length=length):
1384 gi_marshalling_tests_array_int64_in (const gint64 *ints, gint length)
1386 g_assert_cmpint (length, ==, 4);
1387 g_assert_cmpint (ints[0], ==, -1);
1388 g_assert_cmpint (ints[1], ==, 0);
1389 g_assert_cmpint (ints[2], ==, 1);
1390 g_assert_cmpint (ints[3], ==, 2);
1394 * gi_marshalling_tests_array_uint64_in:
1395 * @ints: (array length=length):
1399 gi_marshalling_tests_array_uint64_in (const guint64 *ints, gint length)
1401 g_assert_cmpint (length, ==, 4);
1402 g_assert_cmpint (ints[0], ==, -1);
1403 g_assert_cmpint (ints[1], ==, 0);
1404 g_assert_cmpint (ints[2], ==, 1);
1405 g_assert_cmpint (ints[3], ==, 2);
1409 * gi_marshalling_tests_array_unichar_in:
1410 * @chars: (array length=length):
1414 gi_marshalling_tests_array_unichar_in (const gunichar *chars, gint length)
1417 static const gunichar expected[] = GI_MARSHALLING_TESTS_CONSTANT_UCS4;
1418 g_assert_cmpint (length, ==, 12);
1419 for (ix = 0; ix < length; ix++)
1420 g_assert_cmpuint (chars[ix], ==, expected[ix]);
1424 * gi_marshalling_tests_array_bool_in:
1425 * @bools: (array length=length):
1429 gi_marshalling_tests_array_bool_in (const gboolean *bools, gint length)
1431 g_assert_cmpint (length, ==, 4);
1432 g_assert_cmpint (bools[0], ==, TRUE);
1433 g_assert_cmpint (bools[1], ==, FALSE);
1434 g_assert_cmpint (bools[2], ==, TRUE);
1435 g_assert_cmpint (bools[3], ==, TRUE);
1439 * gi_marshalling_tests_array_struct_in:
1440 * @structs: (array length=length):
1443 gi_marshalling_tests_array_struct_in (GIMarshallingTestsBoxedStruct **structs, gint length)
1445 g_assert_cmpint (length, ==, 3);
1446 g_assert_cmpint (structs[0]->long_, ==, 1);
1447 g_assert_cmpint (structs[1]->long_, ==, 2);
1448 g_assert_cmpint (structs[2]->long_, ==, 3);
1452 * gi_marshalling_tests_array_struct_value_in:
1453 * @structs: (array length=length):
1456 gi_marshalling_tests_array_struct_value_in (GIMarshallingTestsBoxedStruct *structs, gint length)
1458 g_assert_cmpint (length, ==, 3);
1459 g_assert_cmpint (structs[0].long_, ==, 1);
1460 g_assert_cmpint (structs[1].long_, ==, 2);
1461 g_assert_cmpint (structs[2].long_, ==, 3);
1465 * gi_marshalling_tests_array_simple_struct_in:
1466 * @structs: (array length=length):
1469 gi_marshalling_tests_array_simple_struct_in (GIMarshallingTestsSimpleStruct *structs, gint length)
1471 g_assert_cmpint (length, ==, 3);
1472 g_assert_cmpint (structs[0].long_, ==, 1);
1473 g_assert_cmpint (structs[1].long_, ==, 2);
1474 g_assert_cmpint (structs[2].long_, ==, 3);
1478 * gi_marshalling_tests_multi_array_key_value_in:
1479 * @keys: (array length=length):
1480 * @values: (array length=length):
1483 gi_marshalling_tests_multi_array_key_value_in (gint length, const gchar **keys, const GValue *values)
1485 g_assert_cmpint (length, ==, 3);
1486 g_assert_cmpstr ("one", ==, keys[0]);
1487 g_assert_cmpint (g_value_get_int (&values[0]), ==, 1);
1488 g_assert_cmpstr ("two", ==, keys[1]);
1489 g_assert_cmpint (g_value_get_int (&values[1]), ==, 2);
1490 g_assert_cmpstr ("three", ==, keys[2]);
1491 g_assert_cmpint (g_value_get_int (&values[2]), ==, 3);
1496 * gi_marshalling_tests_array_struct_take_in:
1497 * @structs: (array length=length) (transfer full):
1500 gi_marshalling_tests_array_struct_take_in (GIMarshallingTestsBoxedStruct **structs, gint length)
1502 gi_marshalling_tests_array_struct_in (structs, length);
1504 /* only really useful if run in valgrind actually */
1505 gi_marshalling_tests_boxed_struct_free (structs[0]);
1506 gi_marshalling_tests_boxed_struct_free (structs[1]);
1507 gi_marshalling_tests_boxed_struct_free (structs[2]);
1512 * gi_marshalling_tests_array_enum_in:
1513 * @_enum: (array length=length) (transfer none):
1517 gi_marshalling_tests_array_enum_in (GIMarshallingTestsEnum *v, gint length)
1519 g_assert_cmpint (length, ==, 3);
1520 g_assert_cmpint (v[0], ==, GI_MARSHALLING_TESTS_ENUM_VALUE1);
1521 g_assert_cmpint (v[1], ==, GI_MARSHALLING_TESTS_ENUM_VALUE2);
1522 g_assert_cmpint (v[2], ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
1526 * gi_marshalling_tests_array_in_guint64_len:
1527 * @ints: (array length=length) (transfer none):
1531 gi_marshalling_tests_array_in_guint64_len (const gint *ints, guint64 length)
1533 g_assert_cmpint (length, ==, 4);
1535 gi_marshalling_tests_array_in (ints, length);
1539 * gi_marshalling_tests_array_in_guint8_len:
1540 * @ints: (array length=length) (transfer none):
1544 gi_marshalling_tests_array_in_guint8_len (const gint *ints, guint8 length)
1546 g_assert_cmpint (length, ==, 4);
1548 gi_marshalling_tests_array_in (ints, length);
1552 * gi_marshalling_tests_array_out:
1553 * @ints: (out) (array length=length) (transfer none):
1556 gi_marshalling_tests_array_out (gint **ints, gint *length)
1558 static gint values[] = { -1, 0, 1, 2 };
1565 * gi_marshalling_tests_array_out_etc:
1567 * @ints: (out) (array length=length) (transfer none):
1573 gi_marshalling_tests_array_out_etc (gint first, gint **ints, gint *length, gint last, gint *sum)
1575 static gint values[] = { -1, 0, 1, 2 };
1579 *sum = first + last;
1585 * gi_marshalling_tests_array_bool_out:
1586 * @bools: (out) (array length=length) (transfer none):
1589 gi_marshalling_tests_array_bool_out (const gboolean **bools, gint *length)
1591 static const gboolean values[] = { TRUE, FALSE, TRUE, TRUE };
1598 * gi_marshalling_tests_array_unichar_out:
1599 * @chars: (out) (array length=length) (transfer none):
1602 gi_marshalling_tests_array_unichar_out (const gunichar **chars, gint *length)
1604 static const gunichar values[] = GI_MARSHALLING_TESTS_CONSTANT_UCS4;
1610 * gi_marshalling_tests_array_inout:
1611 * @ints: (inout) (array length=length) (transfer none):
1615 gi_marshalling_tests_array_inout (gint **ints, gint *length)
1617 static gint values[] = { -2, -1, 0, 1, 2 };
1619 g_assert_cmpint (*length, ==, 4);
1620 g_assert_cmpint ((*ints)[0], ==, -1);
1621 g_assert_cmpint ((*ints)[1], ==, 0);
1622 g_assert_cmpint ((*ints)[2], ==, 1);
1623 g_assert_cmpint ((*ints)[3], ==, 2);
1630 * gi_marshalling_tests_array_inout_etc:
1632 * @ints: (inout) (array length=length) (transfer none):
1638 gi_marshalling_tests_array_inout_etc (gint first, gint **ints, gint *length, gint last, gint *sum)
1640 static gint values[] = { -2, -1, 0, 1, 2 };
1642 g_assert_cmpint (*length, ==, 4);
1643 g_assert_cmpint ((*ints)[0], ==, -1);
1644 g_assert_cmpint ((*ints)[1], ==, 0);
1645 g_assert_cmpint ((*ints)[2], ==, 1);
1646 g_assert_cmpint ((*ints)[3], ==, 2);
1650 *sum = first + last;
1656 * gi_marshalling_tests_array_in_nonzero_nonlen:
1661 gi_marshalling_tests_array_in_nonzero_nonlen (gint first G_GNUC_UNUSED,
1662 const guint8 *chars)
1664 g_assert (chars[0] == 'a');
1665 g_assert (chars[1] == 'b');
1666 g_assert (chars[2] == 'c');
1667 g_assert (chars[3] == 'd');
1671 * gi_marshalling_tests_array_zero_terminated_return:
1673 * Returns: (array zero-terminated) (transfer none):
1676 gi_marshalling_tests_array_zero_terminated_return (void)
1678 static const gchar *values[] = { "0", "1", "2", NULL };
1683 * gi_marshalling_tests_array_zero_terminated_return_null:
1685 * Returns: (array zero-terminated) (transfer none):
1688 gi_marshalling_tests_array_zero_terminated_return_null (void)
1694 * gi_marshalling_tests_array_zero_terminated_return_struct:
1696 * Returns: (array zero-terminated) (transfer full):
1698 GIMarshallingTestsBoxedStruct **
1699 gi_marshalling_tests_array_zero_terminated_return_struct (void)
1701 GIMarshallingTestsBoxedStruct **ret = (GIMarshallingTestsBoxedStruct **) g_new (gpointer, 4);
1703 ret[0] = gi_marshalling_tests_boxed_struct_new ();
1706 ret[1] = gi_marshalling_tests_boxed_struct_new ();
1709 ret[2] = gi_marshalling_tests_boxed_struct_new ();
1718 * gi_marshalling_tests_array_zero_terminated_return_unichar:
1720 * Returns: (array zero-terminated) (transfer full):
1723 gi_marshalling_tests_array_zero_terminated_return_unichar (void)
1725 static const gunichar value[] = GI_MARSHALLING_TESTS_CONSTANT_UCS4;
1726 gunichar *retval = g_new0(gunichar, 13);
1727 memcpy (retval, value, 12 * sizeof (gunichar));
1732 * gi_marshalling_tests_array_zero_terminated_in:
1733 * @utf8s: (array zero-terminated) (transfer none):
1736 gi_marshalling_tests_array_zero_terminated_in (gchar **utf8s)
1738 g_assert (g_strv_length (utf8s));
1739 g_assert_cmpstr (utf8s[0], ==, "0");
1740 g_assert_cmpstr (utf8s[1], ==, "1");
1741 g_assert_cmpstr (utf8s[2], ==, "2");
1745 * gi_marshalling_tests_array_zero_terminated_out:
1746 * @utf8s: (out) (array zero-terminated) (transfer none):
1749 gi_marshalling_tests_array_zero_terminated_out (const gchar ***utf8s)
1751 static const gchar *values[] = { "0", "1", "2", NULL };
1756 * gi_marshalling_tests_array_zero_terminated_inout:
1757 * @utf8s: (inout) (array zero-terminated) (transfer none):
1760 gi_marshalling_tests_array_zero_terminated_inout (const gchar ***utf8s)
1762 static const gchar *values[] = { "-1", "0", "1", "2", NULL };
1764 g_assert (g_strv_length ((gchar **) (*utf8s)));
1765 g_assert_cmpstr ((*utf8s)[0], ==, "0");
1766 g_assert_cmpstr ((*utf8s)[1], ==, "1");
1767 g_assert_cmpstr ((*utf8s)[2], ==, "2");
1773 * gi_marshalling_tests_array_gvariant_none_in:
1774 * @variants: (array zero-terminated) (transfer none):
1776 * Returns: (array zero-terminated) (transfer none):
1779 gi_marshalling_tests_array_gvariant_none_in (GVariant **variants)
1781 /* Use a static container to detect if someone tries to free it */
1782 static GVariant *private_container[3] = { NULL, NULL, NULL };
1784 if (private_container[0] == NULL)
1786 private_container[0] = g_variant_new_int32 (27);
1787 private_container[1] = g_variant_new_string ("Hello");
1790 g_assert (variants != NULL);
1791 g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1792 g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1793 g_assert (variants[2] == NULL);
1795 return private_container;
1799 * gi_marshalling_tests_array_gvariant_container_in:
1800 * @variants: (array zero-terminated) (transfer container):
1802 * Returns: (array zero-terminated) (transfer container):
1805 gi_marshalling_tests_array_gvariant_container_in (GVariant **variants)
1807 GVariant **container;
1809 g_assert (variants != NULL);
1810 g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1811 g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1812 g_assert (variants[2] == NULL);
1814 container = g_new0 (GVariant *, 3);
1815 container[0] = variants[0];
1816 container[1] = variants[1];
1823 * gi_marshalling_tests_array_gvariant_full_in:
1824 * @variants: (array zero-terminated) (transfer full):
1826 * Returns: (array zero-terminated) (transfer full):
1829 gi_marshalling_tests_array_gvariant_full_in (GVariant **variants)
1831 GVariant **container;
1833 g_assert (variants != NULL);
1834 g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1835 g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1836 g_assert (variants[2] == NULL);
1838 /* To catch different behaviors we reconstruct one variant from scratch,
1839 * while leaving the other untouched. Both approaches are legal with full
1840 * transfer in and out */
1841 container = g_new0 (GVariant *, 3);
1842 container[0] = g_variant_new_int32 (g_variant_get_int32 (variants[0]));
1843 g_variant_unref (variants[0]);
1844 container[1] = variants[1];
1851 * gi_marshalling_tests_garray_int_none_return:
1853 * Returns: (element-type gint) (transfer none):
1856 gi_marshalling_tests_garray_int_none_return (void)
1858 static GArray *v = NULL;
1863 v = g_array_new (TRUE, TRUE, sizeof (gint));
1864 for (i = -1; i < 3; i++)
1865 g_array_append_val (v, i);
1872 * gi_marshalling_tests_garray_uint64_none_return:
1874 * Returns: (element-type guint64) (transfer none):
1877 gi_marshalling_tests_garray_uint64_none_return (void)
1879 static GArray *array = NULL;
1884 array = g_array_new (TRUE, TRUE, sizeof (guint64));
1886 g_array_append_val (array, i);
1888 g_array_append_val (array, i);
1895 * gi_marshalling_tests_garray_utf8_none_return:
1897 * Returns: (element-type utf8) (transfer none):
1900 gi_marshalling_tests_garray_utf8_none_return (void)
1902 static GArray *array = NULL;
1903 static const gchar *values[] = { "0", "1", "2", NULL };
1908 array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1909 for (i = 0; values[i]; i++)
1910 g_array_append_val (array, values[i]);
1917 * gi_marshalling_tests_garray_utf8_container_return:
1919 * Returns: (element-type utf8) (transfer container):
1922 gi_marshalling_tests_garray_utf8_container_return (void)
1924 GArray *array = NULL;
1925 static const gchar *values[] = { "0", "1", "2", NULL };
1928 array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1929 for (i = 0; values[i]; i++)
1930 g_array_append_val (array, values[i]);
1936 * gi_marshalling_tests_garray_utf8_full_return:
1938 * Returns: (element-type utf8) (transfer full):
1941 gi_marshalling_tests_garray_utf8_full_return (void)
1943 GArray *array = NULL;
1944 static const gchar *values[] = { "0", "1", "2", NULL };
1947 array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1948 for (i = 0; values[i]; i++)
1950 gchar *str = g_strdup (values[i]);
1951 g_array_append_val (array, str);
1958 * gi_marshalling_tests_garray_boxed_struct_full_return:
1960 * Returns: (element-type GIMarshallingTestsBoxedStruct) (transfer full):
1963 gi_marshalling_tests_garray_boxed_struct_full_return (void)
1965 GArray *array = NULL;
1966 static const glong long_values[] = { 42, 43, 44 };
1969 array = g_array_new (TRUE, TRUE, sizeof (GIMarshallingTestsBoxedStruct));
1970 for (i = 0; i < 3; i++)
1972 GIMarshallingTestsBoxedStruct *new_struct = gi_marshalling_tests_boxed_struct_new ();
1973 new_struct->long_ = long_values[i];
1974 g_array_append_val (array, *new_struct);
1981 * gi_marshalling_tests_garray_int_none_in:
1982 * @array_: (element-type gint) (transfer none):
1985 gi_marshalling_tests_garray_int_none_in (GArray *array_)
1987 g_assert_cmpint (array_->len, ==, 4);
1988 g_assert_cmpint (g_array_index (array_, gint, 0), ==, -1);
1989 g_assert_cmpint (g_array_index (array_, gint, 1), ==, 0);
1990 g_assert_cmpint (g_array_index (array_, gint, 2), ==, 1);
1991 g_assert_cmpint (g_array_index (array_, gint, 3), ==, 2);
1995 * gi_marshalling_tests_garray_uint64_none_in:
1996 * @array_: (element-type guint64) (transfer none):
1999 gi_marshalling_tests_garray_uint64_none_in (GArray *array_)
2001 g_assert_cmpint (array_->len, ==, 2);
2002 g_assert_cmpint (g_array_index (array_, guint64, 0), ==, 0);
2003 g_assert_cmpint (g_array_index (array_, guint64, 1), ==, G_MAXUINT64);
2007 * gi_marshalling_tests_garray_utf8_none_in:
2008 * @array_: (element-type utf8) (transfer none):
2011 gi_marshalling_tests_garray_utf8_none_in (GArray *array_)
2013 g_assert_cmpint (array_->len, ==, 3);
2014 g_assert_cmpstr (g_array_index (array_, gchar *, 0), ==, "0");
2015 g_assert_cmpstr (g_array_index (array_, gchar *, 1), ==, "1");
2016 g_assert_cmpstr (g_array_index (array_, gchar *, 2), ==, "2");
2020 * gi_marshalling_tests_garray_utf8_none_out:
2021 * @array_: (out) (element-type utf8) (transfer none):
2024 gi_marshalling_tests_garray_utf8_none_out (GArray **array_)
2026 static GArray *internal = NULL;
2027 static const gchar *values[] = { "0", "1", "2", NULL };
2030 if (internal == NULL)
2032 internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
2033 for (i = 0; values[i]; i++)
2034 g_array_append_val (internal, values[i]);
2041 * gi_marshalling_tests_garray_utf8_container_out:
2042 * @array_: (out) (element-type utf8) (transfer container):
2045 gi_marshalling_tests_garray_utf8_container_out (GArray **array_)
2047 static const gchar *values[] = { "0", "1", "2", NULL };
2052 *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
2053 for (i = 0; values[i]; i++)
2054 g_array_append_val (*array_, values[i]);
2058 * gi_marshalling_tests_garray_utf8_full_out:
2059 * @array_: (out) (element-type utf8) (transfer full):
2062 gi_marshalling_tests_garray_utf8_full_out (GArray **array_)
2064 static const gchar *values[] = { "0", "1", "2", NULL };
2069 *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
2070 for (i = 0; values[i]; i++)
2072 gchar *str = g_strdup (values[i]);
2073 g_array_append_val (*array_, str);
2078 * gi_marshalling_tests_garray_utf8_full_out_caller_allocated:
2079 * @array_: (out caller-allocates) (array) (element-type utf8) (transfer full):
2082 gi_marshalling_tests_garray_utf8_full_out_caller_allocated (GArray *array_)
2084 static const gchar *values[] = { "0", "1", "2", NULL };
2087 g_array_set_size (array_, 0);
2088 for (i = 0; values[i]; i++)
2090 gchar *str = g_strdup (values[i]);
2091 g_array_append_val (array_, str);
2096 * gi_marshalling_tests_garray_utf8_none_inout:
2097 * @array_: (inout) (element-type utf8) (transfer none):
2100 gi_marshalling_tests_garray_utf8_none_inout (GArray **array_)
2102 static GArray *internal = NULL;
2103 static const gchar *values[] = { "-2", "-1", "0", "1", NULL };
2106 g_assert_cmpint ((*array_)->len, ==, 3);
2107 g_assert_cmpstr (g_array_index (*array_, gchar *, 0), ==, "0");
2108 g_assert_cmpstr (g_array_index (*array_, gchar *, 1), ==, "1");
2109 g_assert_cmpstr (g_array_index (*array_, gchar *, 2), ==, "2");
2111 if (internal == NULL)
2113 internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
2114 for (i = 0; values[i]; i++)
2115 g_array_append_val (internal, values[i]);
2122 * gi_marshalling_tests_garray_utf8_container_inout:
2123 * @array_: (inout) (element-type utf8) (transfer container):
2126 gi_marshalling_tests_garray_utf8_container_inout (GArray **array_)
2128 static const gchar *val1 = "-2";
2129 static const gchar *val2 = "-1";
2130 static const gchar *val3 = "0";
2131 static const gchar *val4 = "1";
2134 g_assert_cmpint ((*array_)->len, ==, 3);
2135 g_assert_cmpstr (g_array_index (*array_, gchar *, 0), ==, "0");
2136 g_assert_cmpstr (g_array_index (*array_, gchar *, 1), ==, "1");
2137 g_assert_cmpstr (g_array_index (*array_, gchar *, 2), ==, "2");
2139 result = g_array_new (TRUE, TRUE, sizeof (gchar *));
2140 g_array_append_val (result, val1);
2141 g_array_append_val (result, val2);
2142 g_array_append_val (result, val3);
2143 g_array_append_val (result, val4);
2145 g_array_unref (*array_);
2150 * gi_marshalling_tests_garray_utf8_full_inout:
2151 * @array_: (inout) (element-type utf8) (transfer full):
2154 gi_marshalling_tests_garray_utf8_full_inout (GArray **array_)
2156 static const gchar *val1 = "-1";
2157 static const gchar *val2 = "-2";
2161 g_assert_cmpint ((*array_)->len, ==, 3);
2162 g_assert_cmpstr (g_array_index (*array_, gchar *, 0), ==, "0");
2163 g_assert_cmpstr (g_array_index (*array_, gchar *, 1), ==, "1");
2164 g_assert_cmpstr (g_array_index (*array_, gchar *, 2), ==, "2");
2166 result = g_array_new (TRUE, TRUE, sizeof (gchar *));
2167 val = g_strdup (val2);
2168 g_array_append_val (result, val);
2169 val = g_strdup (val1);
2170 g_array_append_val (result, val);
2171 val = g_strdup ("0");
2172 g_array_append_val (result, val);
2173 val = g_strdup ("1");
2174 g_array_append_val (result, val);
2176 g_array_unref (*array_);
2181 * gi_marshalling_tests_garray_bool_none_in:
2182 * @array_: (element-type gboolean) (transfer none):
2185 gi_marshalling_tests_garray_bool_none_in (GArray *array_)
2187 g_assert_cmpint (array_->len, ==, 4);
2188 g_assert_cmpint (g_array_index (array_, gboolean, 0), ==, TRUE);
2189 g_assert_cmpint (g_array_index (array_, gboolean, 1), ==, FALSE);
2190 g_assert_cmpint (g_array_index (array_, gboolean, 2), ==, TRUE);
2191 g_assert_cmpint (g_array_index (array_, gboolean, 3), ==, TRUE);
2195 * gi_marshalling_tests_garray_unichar_none_in:
2196 * @array_: (element-type gunichar) (transfer none):
2199 gi_marshalling_tests_garray_unichar_none_in (GArray *array_)
2202 static const gunichar expected[] = GI_MARSHALLING_TESTS_CONSTANT_UCS4;
2203 g_assert_cmpint (array_->len, ==, 12);
2204 for (ix = 0; ix < array_->len; ix++)
2205 g_assert_cmpuint (g_array_index (array_, gunichar, ix), ==, expected[ix]);
2209 * gi_marshalling_tests_gptrarray_utf8_none_return:
2211 * Returns: (element-type utf8) (transfer none):
2214 gi_marshalling_tests_gptrarray_utf8_none_return (void)
2216 static GPtrArray *parray = NULL;
2217 static const gchar *values[] = { "0", "1", "2" };
2222 parray = g_ptr_array_new ();
2223 for (i = 0; i < 3; i++)
2224 g_ptr_array_add (parray, (gpointer) values[i]);
2231 * gi_marshalling_tests_gptrarray_utf8_container_return:
2233 * Returns: (element-type utf8) (transfer container):
2236 gi_marshalling_tests_gptrarray_utf8_container_return (void)
2238 GPtrArray *parray = NULL;
2239 static const gchar *values[] = { "0", "1", "2", NULL };
2242 parray = g_ptr_array_new ();
2243 for (i = 0; values[i]; i++)
2244 g_ptr_array_add (parray, (gpointer) values[i]);
2250 * gi_marshalling_tests_gptrarray_utf8_full_return:
2252 * Returns: (element-type utf8) (transfer full):
2255 gi_marshalling_tests_gptrarray_utf8_full_return (void)
2257 GPtrArray *parray = NULL;
2258 static const gchar *values[] = { "0", "1", "2", NULL };
2261 parray = g_ptr_array_new ();
2262 for (i = 0; values[i]; i++)
2264 gchar *str = g_strdup (values[i]);
2265 g_ptr_array_add (parray, (gpointer) str);
2272 * gi_marshalling_tests_gptrarray_boxed_struct_full_return:
2274 * Returns: (element-type GIMarshallingTestsBoxedStruct) (transfer full):
2277 gi_marshalling_tests_gptrarray_boxed_struct_full_return (void)
2279 GPtrArray *parray = NULL;
2280 static const glong long_values[] = { 42, 43, 44 };
2283 parray = g_ptr_array_new ();
2284 for (i = 0; i < 3; i++)
2286 GIMarshallingTestsBoxedStruct *new_struct = gi_marshalling_tests_boxed_struct_new ();
2287 new_struct->long_ = long_values[i];
2288 g_ptr_array_add (parray, (gpointer) new_struct);
2295 * gi_marshalling_tests_gptrarray_utf8_none_in:
2296 * @parray_: (element-type utf8) (transfer none):
2299 gi_marshalling_tests_gptrarray_utf8_none_in (GPtrArray *parray_)
2301 g_assert_cmpint (parray_->len, ==, 3);
2302 g_assert_cmpstr (g_ptr_array_index (parray_, 0), ==, "0");
2303 g_assert_cmpstr (g_ptr_array_index (parray_, 1), ==, "1");
2304 g_assert_cmpstr (g_ptr_array_index (parray_, 2), ==, "2");
2308 * gi_marshalling_tests_gptrarray_utf8_none_out:
2309 * @parray_: (out) (element-type utf8) (transfer none):
2312 gi_marshalling_tests_gptrarray_utf8_none_out (GPtrArray **parray_)
2314 static GPtrArray *internal = NULL;
2315 static const gchar *values[] = { "0", "1", "2", NULL };
2318 if (internal == NULL)
2320 internal = g_ptr_array_new ();
2321 for (i = 0; values[i]; i++)
2322 g_ptr_array_add (internal, (gpointer) values[i]);
2325 *parray_ = internal;
2329 * gi_marshalling_tests_gptrarray_utf8_container_out:
2330 * @parray_: (out) (element-type utf8) (transfer container):
2333 gi_marshalling_tests_gptrarray_utf8_container_out (GPtrArray **parray_)
2335 static const gchar *values[] = { "0", "1", "2", NULL };
2340 *parray_ = g_ptr_array_new ();
2341 for (i = 0; values[i]; i++)
2342 g_ptr_array_add (*parray_, (gpointer) values[i]);
2346 * gi_marshalling_tests_gptrarray_utf8_full_out:
2347 * @parray_: (out) (element-type utf8) (transfer full):
2350 gi_marshalling_tests_gptrarray_utf8_full_out (GPtrArray **parray_)
2352 static const gchar *values[] = { "0", "1", "2", NULL };
2357 *parray_ = g_ptr_array_new ();
2358 for (i = 0; values[i]; i++)
2360 gchar *str = g_strdup (values[i]);
2361 g_ptr_array_add (*parray_, (gpointer) str);
2366 * gi_marshalling_tests_gptrarray_utf8_none_inout:
2367 * @parray_: (inout) (element-type utf8) (transfer none):
2370 gi_marshalling_tests_gptrarray_utf8_none_inout (GPtrArray **parray_)
2372 static GPtrArray *internal = NULL;
2373 static const gchar *values[] = { "-2", "-1", "0", "1", NULL };
2376 g_assert_cmpint ((*parray_)->len, ==, 3);
2377 g_assert_cmpstr (g_ptr_array_index (*parray_, 0), ==, "0");
2378 g_assert_cmpstr (g_ptr_array_index (*parray_, 1), ==, "1");
2379 g_assert_cmpstr (g_ptr_array_index (*parray_, 2), ==, "2");
2381 if (internal == NULL)
2383 internal = g_ptr_array_new ();
2384 for (i = 0; values[i]; i++)
2385 g_ptr_array_add (internal, (gpointer) values[i]);
2388 *parray_ = internal;
2392 * gi_marshalling_tests_gptrarray_utf8_container_inout:
2393 * @parray_: (inout) (element-type utf8) (transfer container):
2396 gi_marshalling_tests_gptrarray_utf8_container_inout (GPtrArray **parray_)
2398 static const gchar *val1 = "-2";
2399 static const gchar *val2 = "-1";
2400 static const gchar *val3 = "0";
2401 static const gchar *val4 = "1";
2404 g_assert_cmpint ((*parray_)->len, ==, 3);
2405 g_assert_cmpstr (g_ptr_array_index (*parray_, 0), ==, "0");
2406 g_assert_cmpstr (g_ptr_array_index (*parray_, 1), ==, "1");
2407 g_assert_cmpstr (g_ptr_array_index (*parray_, 2), ==, "2");
2409 result = g_ptr_array_new ();
2410 g_ptr_array_add (result, (gpointer) val1);
2411 g_ptr_array_add (result, (gpointer) val2);
2412 g_ptr_array_add (result, (gpointer) val3);
2413 g_ptr_array_add (result, (gpointer) val4);
2415 g_ptr_array_unref (*parray_);
2420 * gi_marshalling_tests_gptrarray_utf8_full_inout:
2421 * @parray_: (inout) (element-type utf8) (transfer full):
2424 gi_marshalling_tests_gptrarray_utf8_full_inout (GPtrArray **parray_)
2426 static const gchar *val1 = "-1";
2427 static const gchar *val2 = "-2";
2431 g_assert_cmpint ((*parray_)->len, ==, 3);
2432 g_assert_cmpstr (g_ptr_array_index (*parray_, 0), ==, "0");
2433 g_assert_cmpstr (g_ptr_array_index (*parray_, 1), ==, "1");
2434 g_assert_cmpstr (g_ptr_array_index (*parray_, 2), ==, "2");
2436 result = g_ptr_array_new ();
2437 val = g_strdup (val2);
2438 g_ptr_array_add (result, (gpointer) val);
2439 val = g_strdup (val1);
2440 g_ptr_array_add (result, (gpointer) val);
2441 val = g_strdup ("0");
2442 g_ptr_array_add (result, (gpointer) val);
2443 val = g_strdup ("1");
2444 g_ptr_array_add (result, (gpointer) val);
2446 g_ptr_array_unref (*parray_);
2451 * gi_marshalling_tests_bytearray_full_return:
2453 * Returns: (transfer full):
2456 gi_marshalling_tests_bytearray_full_return (void)
2458 GByteArray *array = NULL;
2459 guint8 data[] = { '\0', '1', '\xFF', '3' };
2461 array = g_byte_array_new ();
2462 g_byte_array_append (array, (const guint8 *) data, G_N_ELEMENTS (data));
2469 * gi_marshalling_tests_bytearray_none_in:
2470 * @v: (element-type gint8) (transfer none):
2473 gi_marshalling_tests_bytearray_none_in (GByteArray *v)
2475 g_assert_cmpuint (v->len, ==, 4);
2476 g_assert_cmpuint (g_array_index (v, unsigned char, 0), ==, 0);
2477 g_assert_cmpuint (g_array_index (v, unsigned char, 1), ==, 49);
2478 g_assert_cmpuint (g_array_index (v, unsigned char, 2), ==, 0xFF);
2479 g_assert_cmpuint (g_array_index (v, unsigned char, 3), ==, 51);
2483 * gi_marshalling_tests_gbytes_full_return:
2485 * Returns: (transfer full):
2488 gi_marshalling_tests_gbytes_full_return (void)
2490 static guint8 data[] = { 0, 49, 0xFF, 51 };
2492 return g_bytes_new_static (data, G_N_ELEMENTS (data));
2496 * gi_marshalling_tests_gbytes_none_in:
2499 gi_marshalling_tests_gbytes_none_in (GBytes *v)
2503 data = g_bytes_get_data (v, &len);
2505 g_assert_cmpuint (len, ==, 4);
2506 g_assert_cmpuint (data[0], ==, 0);
2507 g_assert_cmpuint (data[1], ==, 49);
2508 g_assert_cmpuint (data[2], ==, 0xFF);
2509 g_assert_cmpuint (data[3], ==, 51);
2513 * gi_marshalling_tests_gstrv_return:
2515 * Returns: (transfer full): an array of strings
2518 gi_marshalling_tests_gstrv_return (void)
2520 GStrv values = g_new0 (gchar *, 4);
2521 values[0] = g_strdup ("0");
2522 values[1] = g_strdup ("1");
2523 values[2] = g_strdup ("2");
2529 * gi_marshalling_tests_gstrv_in:
2533 gi_marshalling_tests_gstrv_in (GStrv g_strv)
2535 g_assert_cmpint (g_strv_length (g_strv), ==, 3);
2536 g_assert_cmpstr (g_strv[0], ==, "0");
2537 g_assert_cmpstr (g_strv[1], ==, "1");
2538 g_assert_cmpstr (g_strv[2], ==, "2");
2542 * gi_marshalling_tests_gstrv_out:
2543 * @g_strv: (out) (transfer none):
2546 gi_marshalling_tests_gstrv_out (GStrv *g_strv)
2548 static const gchar *values[] = { "0", "1", "2", NULL };
2549 *g_strv = (gchar **) values;
2553 * gi_marshalling_tests_gstrv_inout:
2554 * @g_strv: (inout) (transfer none):
2557 gi_marshalling_tests_gstrv_inout (GStrv *g_strv)
2559 static const gchar *values[] = { "-1", "0", "1", "2", NULL };
2561 g_assert (g_strv_length (*g_strv) == 3);
2562 g_assert (strcmp ((*g_strv)[0], "0") == 0);
2563 g_assert (strcmp ((*g_strv)[1], "1") == 0);
2564 g_assert (strcmp ((*g_strv)[2], "2") == 0);
2566 *g_strv = (gchar **) values;
2570 * gi_marshalling_tests_glist_int_none_return:
2572 * Returns: (element-type gint) (transfer none):
2575 gi_marshalling_tests_glist_int_none_return (void)
2577 static GList *list = NULL;
2581 list = g_list_append (list, GINT_TO_POINTER (-1));
2582 list = g_list_append (list, GINT_TO_POINTER (0));
2583 list = g_list_append (list, GINT_TO_POINTER (1));
2584 list = g_list_append (list, GINT_TO_POINTER (2));
2591 * gi_marshalling_tests_glist_uint32_none_return:
2593 * Returns: (element-type guint32) (transfer none):
2596 gi_marshalling_tests_glist_uint32_none_return (void)
2598 static GList *list = NULL;
2602 list = g_list_append (list, GUINT_TO_POINTER (0));
2603 list = g_list_append (list, GUINT_TO_POINTER (G_MAXUINT32));
2610 * gi_marshalling_tests_glist_utf8_none_return:
2612 * Returns: (element-type utf8) (transfer none):
2615 gi_marshalling_tests_glist_utf8_none_return (void)
2617 static GList *list = NULL;
2621 list = g_list_append (list, (gpointer) "0");
2622 list = g_list_append (list, (gpointer) "1");
2623 list = g_list_append (list, (gpointer) "2");
2630 * gi_marshalling_tests_glist_utf8_container_return:
2632 * Returns: (element-type utf8) (transfer container):
2635 gi_marshalling_tests_glist_utf8_container_return (void)
2639 list = g_list_append (list, (gpointer) "0");
2640 list = g_list_append (list, (gpointer) "1");
2641 list = g_list_append (list, (gpointer) "2");
2647 * gi_marshalling_tests_glist_utf8_full_return:
2649 * Returns: (element-type utf8) (transfer full):
2652 gi_marshalling_tests_glist_utf8_full_return (void)
2656 list = g_list_append (list, g_strdup ("0"));
2657 list = g_list_append (list, g_strdup ("1"));
2658 list = g_list_append (list, g_strdup ("2"));
2664 * gi_marshalling_tests_glist_int_none_in:
2665 * @list: (element-type gint) (transfer none):
2668 gi_marshalling_tests_glist_int_none_in (GList *list)
2670 g_assert_cmpint (g_list_length (list), ==, 4);
2671 g_assert_cmpint (GPOINTER_TO_INT (g_list_nth_data (list, 0)), ==, -1);
2672 g_assert_cmpint (GPOINTER_TO_INT (g_list_nth_data (list, 1)), ==, 0);
2673 g_assert_cmpint (GPOINTER_TO_INT (g_list_nth_data (list, 2)), ==, 1);
2674 g_assert_cmpint (GPOINTER_TO_INT (g_list_nth_data (list, 3)), ==, 2);
2678 * gi_marshalling_tests_glist_uint32_none_in:
2679 * @list: (element-type guint32) (transfer none):
2682 gi_marshalling_tests_glist_uint32_none_in (GList *list)
2684 g_assert_cmpint (g_list_length (list), ==, 2);
2685 g_assert_cmpint (GPOINTER_TO_UINT (g_list_nth_data (list, 0)), ==, 0);
2686 g_assert_cmpint (GPOINTER_TO_UINT (g_list_nth_data (list, 1)), ==, G_MAXUINT32);
2690 * gi_marshalling_tests_glist_utf8_none_in:
2691 * @list: (element-type utf8) (transfer none):
2694 gi_marshalling_tests_glist_utf8_none_in (GList *list)
2696 g_assert_cmpint (g_list_length (list), ==, 3);
2697 g_assert_cmpint (strcmp (g_list_nth_data (list, 0), "0"), ==, 0);
2698 g_assert_cmpint (strcmp (g_list_nth_data (list, 1), "1"), ==, 0);
2699 g_assert_cmpint (strcmp (g_list_nth_data (list, 2), "2"), ==, 0);
2703 * gi_marshalling_tests_glist_utf8_none_out:
2704 * @list: (out) (element-type utf8) (transfer none):
2707 gi_marshalling_tests_glist_utf8_none_out (GList **list)
2709 static GList *values = NULL;
2713 values = g_list_append (values, (gpointer) "0");
2714 values = g_list_append (values, (gpointer) "1");
2715 values = g_list_append (values, (gpointer) "2");
2722 * gi_marshalling_tests_glist_utf8_container_out:
2723 * @list: (out) (element-type utf8) (transfer container):
2726 gi_marshalling_tests_glist_utf8_container_out (GList **list)
2730 *list = g_list_append (*list, (gpointer) "0");
2731 *list = g_list_append (*list, (gpointer) "1");
2732 *list = g_list_append (*list, (gpointer) "2");
2736 * gi_marshalling_tests_glist_utf8_full_out:
2737 * @list: (out) (element-type utf8) (transfer full):
2740 gi_marshalling_tests_glist_utf8_full_out (GList **list)
2744 *list = g_list_append (*list, g_strdup ("0"));
2745 *list = g_list_append (*list, g_strdup ("1"));
2746 *list = g_list_append (*list, g_strdup ("2"));
2750 * gi_marshalling_tests_glist_utf8_none_inout:
2751 * @list: (inout) (element-type utf8) (transfer none):
2754 gi_marshalling_tests_glist_utf8_none_inout (GList **list)
2756 static GList *values = NULL;
2758 g_assert_cmpint (g_list_length (*list), ==, 3);
2759 g_assert_cmpstr (g_list_nth_data (*list, 0), ==, "0");
2760 g_assert_cmpstr (g_list_nth_data (*list, 1), ==, "1");
2761 g_assert_cmpstr (g_list_nth_data (*list, 2), ==, "2");
2765 values = g_list_append (values, (gpointer) "-2");
2766 values = g_list_append (values, (gpointer) "-1");
2767 values = g_list_append (values, (gpointer) "0");
2768 values = g_list_append (values, (gpointer) "1");
2775 * gi_marshalling_tests_glist_utf8_container_inout:
2776 * @list: (inout) (element-type utf8) (transfer container):
2779 gi_marshalling_tests_glist_utf8_container_inout (GList **list)
2781 GList *result = NULL;
2783 g_assert_cmpint (g_list_length (*list), ==, 3);
2784 g_assert_cmpstr (g_list_nth_data (*list, 0), ==, "0");
2785 g_assert_cmpstr (g_list_nth_data (*list, 1), ==, "1");
2786 g_assert_cmpstr (g_list_nth_data (*list, 2), ==, "2");
2788 result = g_list_prepend (result, (gpointer) "1");
2789 result = g_list_prepend (result, (gpointer) "0");
2790 result = g_list_prepend (result, (gpointer) "-1");
2791 result = g_list_prepend (result, (gpointer) "-2");
2793 g_list_free (*list);
2798 * gi_marshalling_tests_glist_utf8_full_inout:
2799 * @list: (inout) (element-type utf8) (transfer full):
2802 gi_marshalling_tests_glist_utf8_full_inout (GList **list)
2804 GList *result = NULL;
2806 g_assert_cmpint (g_list_length (*list), ==, 3);
2807 g_assert_cmpstr (g_list_nth_data (*list, 0), ==, "0");
2808 g_assert_cmpstr (g_list_nth_data (*list, 1), ==, "1");
2809 g_assert_cmpstr (g_list_nth_data (*list, 2), ==, "2");
2811 result = g_list_prepend (result, g_strdup ("1"));
2812 result = g_list_prepend (result, g_strdup ("0"));
2813 result = g_list_prepend (result, g_strdup ("-1"));
2814 result = g_list_prepend (result, g_strdup ("-2"));
2816 g_list_free_full (*list, g_free);
2822 * gi_marshalling_tests_gslist_int_none_return:
2824 * Returns: (element-type gint) (transfer none):
2827 gi_marshalling_tests_gslist_int_none_return (void)
2829 static GSList *list = NULL;
2833 list = g_slist_prepend (list, GINT_TO_POINTER (-1));
2834 list = g_slist_prepend (list, GINT_TO_POINTER (0));
2835 list = g_slist_prepend (list, GINT_TO_POINTER (1));
2836 list = g_slist_prepend (list, GINT_TO_POINTER (2));
2837 list = g_slist_reverse (list);
2844 * gi_marshalling_tests_gslist_utf8_none_return:
2846 * Returns: (element-type utf8) (transfer none):
2849 gi_marshalling_tests_gslist_utf8_none_return (void)
2851 static GSList *list = NULL;
2855 list = g_slist_prepend (list, (gpointer) "0");
2856 list = g_slist_prepend (list, (gpointer) "1");
2857 list = g_slist_prepend (list, (gpointer) "2");
2858 list = g_slist_reverse (list);
2865 * gi_marshalling_tests_gslist_utf8_container_return:
2867 * Returns: (element-type utf8) (transfer container):
2870 gi_marshalling_tests_gslist_utf8_container_return (void)
2872 GSList *list = NULL;
2874 list = g_slist_prepend (list, (gpointer) "0");
2875 list = g_slist_prepend (list, (gpointer) "1");
2876 list = g_slist_prepend (list, (gpointer) "2");
2877 list = g_slist_reverse (list);
2883 * gi_marshalling_tests_gslist_utf8_full_return:
2885 * Returns: (element-type utf8) (transfer full):
2888 gi_marshalling_tests_gslist_utf8_full_return (void)
2890 GSList *list = NULL;
2892 list = g_slist_prepend (list, g_strdup ("0"));
2893 list = g_slist_prepend (list, g_strdup ("1"));
2894 list = g_slist_prepend (list, g_strdup ("2"));
2895 list = g_slist_reverse (list);
2901 * gi_marshalling_tests_gslist_int_none_in:
2902 * @list: (element-type gint) (transfer none):
2905 gi_marshalling_tests_gslist_int_none_in (GSList *list)
2907 g_assert_cmpint (g_slist_length (list), ==, 4);
2908 g_assert_cmpint (GPOINTER_TO_INT (g_slist_nth_data (list, 0)), ==, -1);
2909 g_assert_cmpint (GPOINTER_TO_INT (g_slist_nth_data (list, 1)), ==, 0);
2910 g_assert_cmpint (GPOINTER_TO_INT (g_slist_nth_data (list, 2)), ==, 1);
2911 g_assert_cmpint (GPOINTER_TO_INT (g_slist_nth_data (list, 3)), ==, 2);
2915 * gi_marshalling_tests_gslist_utf8_none_in:
2916 * @list: (element-type utf8) (transfer none):
2919 gi_marshalling_tests_gslist_utf8_none_in (GSList *list)
2921 g_assert_cmpint (g_slist_length (list), ==, 3);
2922 g_assert_cmpstr (g_slist_nth_data (list, 0), ==, "0");
2923 g_assert_cmpstr (g_slist_nth_data (list, 1), ==, "1");
2924 g_assert_cmpstr (g_slist_nth_data (list, 2), ==, "2");
2928 * gi_marshalling_tests_gslist_utf8_none_out:
2929 * @list: (out) (element-type utf8) (transfer none):
2932 gi_marshalling_tests_gslist_utf8_none_out (GSList **list)
2934 static GSList *values = NULL;
2938 values = g_slist_prepend (values, (gpointer) "0");
2939 values = g_slist_prepend (values, (gpointer) "1");
2940 values = g_slist_prepend (values, (gpointer) "2");
2941 values = g_slist_reverse (values);
2948 * gi_marshalling_tests_gslist_utf8_container_out:
2949 * @list: (out) (element-type utf8) (transfer container):
2952 gi_marshalling_tests_gslist_utf8_container_out (GSList **list)
2956 *list = g_slist_prepend (*list, (gpointer) "0");
2957 *list = g_slist_prepend (*list, (gpointer) "1");
2958 *list = g_slist_prepend (*list, (gpointer) "2");
2959 *list = g_slist_reverse (*list);
2963 * gi_marshalling_tests_gslist_utf8_full_out:
2964 * @list: (out) (element-type utf8) (transfer full):
2967 gi_marshalling_tests_gslist_utf8_full_out (GSList **list)
2971 *list = g_slist_prepend (*list, g_strdup ("0"));
2972 *list = g_slist_prepend (*list, g_strdup ("1"));
2973 *list = g_slist_prepend (*list, g_strdup ("2"));
2974 *list = g_slist_reverse (*list);
2978 * gi_marshalling_tests_gslist_utf8_none_inout:
2979 * @list: (inout) (element-type utf8) (transfer none):
2982 gi_marshalling_tests_gslist_utf8_none_inout (GSList **list)
2984 static GSList *values = NULL;
2986 g_assert_cmpint (g_slist_length (*list), ==, 3);
2987 g_assert_cmpstr (g_slist_nth_data (*list, 0), ==, "0");
2988 g_assert_cmpstr (g_slist_nth_data (*list, 1), ==, "1");
2989 g_assert_cmpstr (g_slist_nth_data (*list, 2), ==, "2");
2993 values = g_slist_prepend (values, (gpointer) "-2");
2994 values = g_slist_prepend (values, (gpointer) "-1");
2995 values = g_slist_prepend (values, (gpointer) "0");
2996 values = g_slist_prepend (values, (gpointer) "1");
2997 values = g_slist_reverse (values);
3004 * gi_marshalling_tests_gslist_utf8_container_inout:
3005 * @list: (inout) (element-type utf8) (transfer container):
3008 gi_marshalling_tests_gslist_utf8_container_inout (GSList **list)
3010 GSList *result = NULL;
3012 g_assert_cmpint (g_slist_length (*list), ==, 3);
3013 g_assert_cmpstr (g_slist_nth_data (*list, 0), ==, "0");
3014 g_assert_cmpstr (g_slist_nth_data (*list, 1), ==, "1");
3015 g_assert_cmpstr (g_slist_nth_data (*list, 2), ==, "2");
3017 result = g_slist_prepend (result, (gpointer) "1");
3018 result = g_slist_prepend (result, (gpointer) "0");
3019 result = g_slist_prepend (result, (gpointer) "-1");
3020 result = g_slist_prepend (result, (gpointer) "-2");
3022 g_slist_free (*list);
3027 * gi_marshalling_tests_gslist_utf8_full_inout:
3028 * @list: (inout) (element-type utf8) (transfer full):
3031 gi_marshalling_tests_gslist_utf8_full_inout (GSList **list)
3033 GSList *result = NULL;
3035 g_assert_cmpint (g_slist_length (*list), ==, 3);
3036 g_assert_cmpstr (g_slist_nth_data (*list, 0), ==, "0");
3037 g_assert_cmpstr (g_slist_nth_data (*list, 1), ==, "1");
3038 g_assert_cmpstr (g_slist_nth_data (*list, 2), ==, "2");
3040 result = g_slist_prepend (result, g_strdup ("1"));
3041 result = g_slist_prepend (result, g_strdup ("0"));
3042 result = g_slist_prepend (result, g_strdup ("-1"));
3043 result = g_slist_prepend (result, g_strdup ("-2"));
3045 g_slist_free_full (*list, g_free);
3051 * gi_marshalling_tests_ghashtable_int_none_return:
3053 * Returns: (element-type gint gint) (transfer none):
3056 gi_marshalling_tests_ghashtable_int_none_return (void)
3058 static GHashTable *hash_table = NULL;
3060 if (hash_table == NULL)
3062 hash_table = g_hash_table_new (NULL, NULL);
3063 g_hash_table_insert (hash_table, GINT_TO_POINTER (-1), GINT_TO_POINTER (1));
3064 g_hash_table_insert (hash_table, GINT_TO_POINTER (0), GINT_TO_POINTER (0));
3065 g_hash_table_insert (hash_table, GINT_TO_POINTER (1), GINT_TO_POINTER (-1));
3066 g_hash_table_insert (hash_table, GINT_TO_POINTER (2), GINT_TO_POINTER (-2));
3073 * gi_marshalling_tests_ghashtable_utf8_none_return:
3075 * Returns: (element-type utf8 utf8) (transfer none):
3078 gi_marshalling_tests_ghashtable_utf8_none_return (void)
3080 static GHashTable *hash_table = NULL;
3082 if (hash_table == NULL)
3084 hash_table = g_hash_table_new (g_str_hash, g_str_equal);
3085 g_hash_table_insert (hash_table, (gpointer) "-1", (gpointer) "1");
3086 g_hash_table_insert (hash_table, (gpointer) "0", (gpointer) "0");
3087 g_hash_table_insert (hash_table, (gpointer) "1", (gpointer) "-1");
3088 g_hash_table_insert (hash_table, (gpointer) "2", (gpointer) "-2");
3095 * gi_marshalling_tests_ghashtable_utf8_container_return:
3097 * Returns: (element-type utf8 utf8) (transfer container):
3100 gi_marshalling_tests_ghashtable_utf8_container_return (void)
3102 GHashTable *hash_table = NULL;
3104 hash_table = g_hash_table_new (g_str_hash, g_str_equal);
3105 g_hash_table_insert (hash_table, (gpointer) "-1", (gpointer) "1");
3106 g_hash_table_insert (hash_table, (gpointer) "0", (gpointer) "0");
3107 g_hash_table_insert (hash_table, (gpointer) "1", (gpointer) "-1");
3108 g_hash_table_insert (hash_table, (gpointer) "2", (gpointer) "-2");
3114 * gi_marshalling_tests_ghashtable_utf8_full_return:
3116 * Returns: (element-type utf8 utf8) (transfer full):
3119 gi_marshalling_tests_ghashtable_utf8_full_return (void)
3121 GHashTable *hash_table = NULL;
3123 hash_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
3124 g_hash_table_insert (hash_table, g_strdup ("-1"), g_strdup ("1"));
3125 g_hash_table_insert (hash_table, g_strdup ("0"), g_strdup ("0"));
3126 g_hash_table_insert (hash_table, g_strdup ("1"), g_strdup ("-1"));
3127 g_hash_table_insert (hash_table, g_strdup ("2"), g_strdup ("-2"));
3133 * gi_marshalling_tests_ghashtable_int_none_in:
3134 * @hash_table: (element-type gint gint) (transfer none):
3137 gi_marshalling_tests_ghashtable_int_none_in (GHashTable *hash_table)
3139 g_assert_cmpint (GPOINTER_TO_INT (g_hash_table_lookup (hash_table, GINT_TO_POINTER (-1))), ==, 1);
3140 g_assert_cmpint (GPOINTER_TO_INT (g_hash_table_lookup (hash_table, GINT_TO_POINTER (0))), ==, 0);
3141 g_assert_cmpint (GPOINTER_TO_INT (g_hash_table_lookup (hash_table, GINT_TO_POINTER (1))), ==, -1);
3142 g_assert_cmpint (GPOINTER_TO_INT (g_hash_table_lookup (hash_table, GINT_TO_POINTER (2))), ==, -2);
3146 * gi_marshalling_tests_ghashtable_utf8_none_in:
3147 * @hash_table: (element-type utf8 utf8) (transfer none):
3150 gi_marshalling_tests_ghashtable_utf8_none_in (GHashTable *hash_table)
3152 g_assert_cmpstr (g_hash_table_lookup (hash_table, "-1"), ==, "1");
3153 g_assert_cmpstr (g_hash_table_lookup (hash_table, "0"), ==, "0");
3154 g_assert_cmpstr (g_hash_table_lookup (hash_table, "1"), ==, "-1");
3155 g_assert_cmpstr (g_hash_table_lookup (hash_table, "2"), ==, "-2");
3159 * gi_marshalling_tests_ghashtable_double_in:
3160 * @hash_table: (element-type utf8 double) (transfer none):
3162 * Meant to test a value type that doesn't fit inside a pointer.
3165 gi_marshalling_tests_ghashtable_double_in (GHashTable *hash_table)
3169 value = g_hash_table_lookup (hash_table, "-1");
3170 g_assert_cmpfloat (*value, ==, -0.1);
3171 value = g_hash_table_lookup (hash_table, "0");
3172 g_assert_cmpfloat (*value, ==, 0.0);
3173 value = g_hash_table_lookup (hash_table, "1");
3174 g_assert_cmpfloat (*value, ==, 0.1);
3175 value = g_hash_table_lookup (hash_table, "2");
3176 g_assert_cmpfloat (*value, ==, 0.2);
3180 * gi_marshalling_tests_ghashtable_float_in:
3181 * @hash_table: (element-type utf8 float) (transfer none):
3183 * Meant to test a value type that doesn't fit inside a pointer.
3186 gi_marshalling_tests_ghashtable_float_in (GHashTable *hash_table)
3190 value = g_hash_table_lookup (hash_table, "-1");
3191 g_assert_cmpfloat (*value, ==, -0.1f);
3192 value = g_hash_table_lookup (hash_table, "0");
3193 g_assert_cmpfloat (*value, ==, 0.0f);
3194 value = g_hash_table_lookup (hash_table, "1");
3195 g_assert_cmpfloat (*value, ==, 0.1f);
3196 value = g_hash_table_lookup (hash_table, "2");
3197 g_assert_cmpfloat (*value, ==, 0.2f);
3201 * gi_marshalling_tests_ghashtable_int64_in:
3202 * @hash_table: (element-type utf8 gint64) (transfer none):
3204 * Meant to test a value type that doesn't fit inside a pointer.
3207 gi_marshalling_tests_ghashtable_int64_in (GHashTable *hash_table)
3211 value = g_hash_table_lookup (hash_table, "-1");
3212 g_assert_cmpint (*value, ==, -1);
3213 value = g_hash_table_lookup (hash_table, "0");
3214 g_assert_cmpint (*value, ==, 0);
3215 value = g_hash_table_lookup (hash_table, "1");
3216 g_assert_cmpint (*value, ==, 1);
3217 value = g_hash_table_lookup (hash_table, "2");
3218 g_assert_cmpint (*value, ==, (gint64) G_MAXUINT32 + 1);
3222 * gi_marshalling_tests_ghashtable_uint64_in:
3223 * @hash_table: (element-type utf8 guint64) (transfer none):
3225 * Meant to test a value type that doesn't fit inside a pointer.
3228 gi_marshalling_tests_ghashtable_uint64_in (GHashTable *hash_table)
3232 value = g_hash_table_lookup (hash_table, "-1");
3233 g_assert_cmpuint (*value, ==, (guint64) G_MAXUINT32 + 1);
3234 value = g_hash_table_lookup (hash_table, "0");
3235 g_assert_cmpuint (*value, ==, 0);
3236 value = g_hash_table_lookup (hash_table, "1");
3237 g_assert_cmpuint (*value, ==, 1);
3238 value = g_hash_table_lookup (hash_table, "2");
3239 g_assert_cmpuint (*value, ==, 2);
3243 * gi_marshalling_tests_ghashtable_utf8_none_out:
3244 * @hash_table: (out) (element-type utf8 utf8) (transfer none):
3247 gi_marshalling_tests_ghashtable_utf8_none_out (GHashTable **hash_table)
3249 static GHashTable *new_hash_table = NULL;
3251 if (new_hash_table == NULL)
3253 new_hash_table = g_hash_table_new (g_str_hash, g_str_equal);
3254 g_hash_table_insert (new_hash_table, (gpointer) "-1", (gpointer) "1");
3255 g_hash_table_insert (new_hash_table, (gpointer) "0", (gpointer) "0");
3256 g_hash_table_insert (new_hash_table, (gpointer) "1", (gpointer) "-1");
3257 g_hash_table_insert (new_hash_table, (gpointer) "2", (gpointer) "-2");
3260 *hash_table = new_hash_table;
3264 * gi_marshalling_tests_ghashtable_utf8_container_out:
3265 * @hash_table: (out) (element-type utf8 utf8) (transfer container):
3268 gi_marshalling_tests_ghashtable_utf8_container_out (GHashTable **hash_table)
3270 *hash_table = g_hash_table_new (g_str_hash, g_str_equal);
3271 g_hash_table_insert (*hash_table, (gpointer) "-1", (gpointer) "1");
3272 g_hash_table_insert (*hash_table, (gpointer) "0", (gpointer) "0");
3273 g_hash_table_insert (*hash_table, (gpointer) "1", (gpointer) "-1");
3274 g_hash_table_insert (*hash_table, (gpointer) "2", (gpointer) "-2");
3278 * gi_marshalling_tests_ghashtable_utf8_full_out:
3279 * @hash_table: (out) (element-type utf8 utf8) (transfer full):
3282 gi_marshalling_tests_ghashtable_utf8_full_out (GHashTable **hash_table)
3284 *hash_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
3285 g_hash_table_insert (*hash_table, g_strdup ("-1"), g_strdup ("1"));
3286 g_hash_table_insert (*hash_table, g_strdup ("0"), g_strdup ("0"));
3287 g_hash_table_insert (*hash_table, g_strdup ("1"), g_strdup ("-1"));
3288 g_hash_table_insert (*hash_table, g_strdup ("2"), g_strdup ("-2"));
3292 * gi_marshalling_tests_ghashtable_utf8_none_inout:
3293 * @hash_table: (inout) (element-type utf8 utf8) (transfer none):
3296 gi_marshalling_tests_ghashtable_utf8_none_inout (GHashTable **hash_table)
3298 static GHashTable *new_hash_table = NULL;
3300 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "-1"), ==, "1");
3301 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "0"), ==, "0");
3302 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "1"), ==, "-1");
3303 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "2"), ==, "-2");
3305 if (new_hash_table == NULL)
3307 new_hash_table = g_hash_table_new (g_str_hash, g_str_equal);
3308 g_hash_table_insert (new_hash_table, (gpointer) "-1", (gpointer) "1");
3309 g_hash_table_insert (new_hash_table, (gpointer) "0", (gpointer) "0");
3310 g_hash_table_insert (new_hash_table, (gpointer) "1", (gpointer) "1");
3313 *hash_table = new_hash_table;
3317 * gi_marshalling_tests_ghashtable_utf8_container_inout:
3318 * @hash_table: (inout) (element-type utf8 utf8) (transfer container):
3321 gi_marshalling_tests_ghashtable_utf8_container_inout (GHashTable **hash_table)
3323 GHashTable *result = g_hash_table_new (g_str_hash, g_str_equal);
3325 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "-1"), ==, "1");
3326 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "0"), ==, "0");
3327 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "1"), ==, "-1");
3328 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "2"), ==, "-2");
3330 g_hash_table_insert (result, (gpointer) "-1", (gpointer) "1");
3331 g_hash_table_insert (result, (gpointer) "0", (gpointer) "0");
3332 g_hash_table_insert (result, (gpointer) "1", (gpointer) "1");
3334 g_hash_table_unref (*hash_table);
3335 *hash_table = result;
3339 * gi_marshalling_tests_ghashtable_utf8_full_inout:
3340 * @hash_table: (inout) (element-type utf8 utf8) (transfer full):
3343 gi_marshalling_tests_ghashtable_utf8_full_inout (GHashTable **hash_table)
3345 GHashTable *result = g_hash_table_new_full (g_str_hash, g_str_equal,
3348 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "-1"), ==, "1");
3349 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "0"), ==, "0");
3350 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "1"), ==, "-1");
3351 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "2"), ==, "-2");
3353 g_hash_table_insert (result, g_strdup ("-1"), g_strdup ("1"));
3354 g_hash_table_insert (result, g_strdup ("0"), g_strdup ("0"));
3355 g_hash_table_insert (result, g_strdup ("1"), g_strdup ("1"));
3357 g_hash_table_unref (*hash_table);
3358 *hash_table = result;
3363 * gi_marshalling_tests_gvalue_return:
3365 * Returns: (transfer none):
3368 gi_marshalling_tests_gvalue_return (void)
3370 static GValue *value = NULL;
3374 value = g_new0 (GValue, 1);
3375 g_value_init (value, G_TYPE_INT);
3376 g_value_set_int (value, 42);
3383 * gi_marshalling_tests_gvalue_in:
3384 * @value: (transfer none):
3387 gi_marshalling_tests_gvalue_in (GValue *value)
3389 g_assert_cmpint (g_value_get_int (value), ==, 42);
3393 * gi_marshalling_tests_gvalue_int64_in:
3394 * @value: (transfer none):
3397 gi_marshalling_tests_gvalue_int64_in (GValue *value)
3399 g_assert_cmpint (g_value_get_int64 (value), ==, G_MAXINT64);
3403 * gi_marshalling_tests_gvalue_in_with_type:
3404 * @value: (transfer none):
3408 gi_marshalling_tests_gvalue_in_with_type (GValue *value, GType type)
3410 g_assert (g_type_is_a (G_VALUE_TYPE (value), type));
3414 * gi_marshalling_tests_gvalue_in_with_modification:
3415 * @value: (transfer none):
3417 * Expects a GValue passed by reference which is then modified by
3421 gi_marshalling_tests_gvalue_in_with_modification (GValue *value)
3423 g_assert_cmpint (g_value_get_int (value), ==, 42);
3424 g_value_set_int (value, 24);
3428 * gi_marshalling_tests_gvalue_in_enum:
3429 * @value: (transfer none):
3432 gi_marshalling_tests_gvalue_in_enum (GValue *value)
3434 g_assert (g_value_get_enum (value) == GI_MARSHALLING_TESTS_ENUM_VALUE3);
3438 * gi_marshalling_tests_gvalue_out:
3439 * @value: (out) (transfer none):
3442 gi_marshalling_tests_gvalue_out (GValue **value)
3444 static GValue *new_value = NULL;
3446 if (new_value == NULL)
3448 new_value = g_new0 (GValue, 1);
3449 g_value_init (new_value, G_TYPE_INT);
3450 g_value_set_int (new_value, 42);
3457 * gi_marshalling_tests_gvalue_int64_out:
3458 * @value: (out) (transfer none):
3461 gi_marshalling_tests_gvalue_int64_out (GValue **value)
3463 static GValue *new_value = NULL;
3465 if (new_value == NULL)
3467 new_value = g_new0 (GValue, 1);
3468 g_value_init (new_value, G_TYPE_INT64);
3469 g_value_set_int64 (new_value, G_MAXINT64);
3476 * gi_marshalling_tests_gvalue_out_caller_allocates:
3477 * @value: (out) (transfer none):
3480 gi_marshalling_tests_gvalue_out_caller_allocates (GValue *value)
3482 g_value_init (value, G_TYPE_INT);
3483 g_value_set_int (value, 42);
3487 * gi_marshalling_tests_gvalue_inout:
3488 * @value: (inout) (transfer none):
3491 gi_marshalling_tests_gvalue_inout (GValue **value)
3493 g_assert_cmpint (g_value_get_int (*value), ==, 42);
3494 g_value_unset (*value);
3495 g_value_init (*value, G_TYPE_STRING);
3496 g_value_set_string (*value, "42");
3500 * gi_marshalling_tests_gvalue_flat_array:
3501 * @n_values: number of values
3502 * @values: (array length=n_values): an array containing values
3505 gi_marshalling_tests_gvalue_flat_array (guint n_values, const GValue *values)
3507 g_assert (n_values == 3);
3509 g_assert_cmpint (g_value_get_int (&values[0]), ==, 42);
3510 g_assert_cmpstr (g_value_get_string (&values[1]), ==, "42");
3511 g_assert_cmpint (g_value_get_boolean (&values[2]), ==, TRUE);
3515 * gi_marshalling_tests_return_gvalue_flat_array:
3517 * Returns: (array fixed-size=3) (transfer full): a flat GValue array
3520 gi_marshalling_tests_return_gvalue_flat_array (void)
3522 GValue *array = g_new0 (GValue, 3);
3524 g_value_init (&array[0], G_TYPE_INT);
3525 g_value_set_int (&array[0], 42);
3527 g_value_init (&array[1], G_TYPE_STRING);
3528 g_value_set_static_string (&array[1], "42");
3530 g_value_init (&array[2], G_TYPE_BOOLEAN);
3531 g_value_set_boolean (&array[2], TRUE);
3537 * gi_marshalling_tests_gvalue_flat_array_round_trip:
3538 * @one: The first GValue
3539 * @two: The second GValue
3540 * @three: The third GValue
3542 * Returns: (array fixed-size=3) (transfer full): a flat array of [@one, @two, @three]
3545 gi_marshalling_tests_gvalue_flat_array_round_trip (const GValue one, const GValue two, const GValue three)
3547 GValue *array = g_new (GValue, 3);
3556 * gi_marshalling_tests_gclosure_in:
3557 * @closure: (transfer none):
3560 gi_marshalling_tests_gclosure_in (GClosure *closure)
3562 GValue return_value = { 0, };
3564 g_value_init (&return_value, G_TYPE_INT);
3566 g_closure_invoke (closure, &return_value, 0, NULL, NULL);
3568 g_assert_cmpint (g_value_get_int (&return_value), ==, 42);
3570 g_value_unset (&return_value);
3574 _closure_return_42 (void)
3580 _marshal_INT__VOID (GClosure *closure,
3581 GValue *return_value,
3582 guint n_param_values G_GNUC_UNUSED,
3583 const GValue *param_values G_GNUC_UNUSED,
3584 gpointer invocation_hint G_GNUC_UNUSED,
3585 gpointer marshal_data G_GNUC_UNUSED)
3587 typedef gint (*GMarshalFunc_INT__VOID) (void);
3588 register GMarshalFunc_INT__VOID callback;
3589 register GCClosure *cc = (GCClosure *) closure;
3591 callback = (GMarshalFunc_INT__VOID) cc->callback;
3592 g_value_set_int (return_value, callback ());
3596 * gi_marshalling_tests_gclosure_return:
3598 * Return: a #GClosure
3601 gi_marshalling_tests_gclosure_return (void)
3603 GClosure *closure = g_cclosure_new ((GCallback) _closure_return_42,
3605 g_closure_set_marshal (closure, _marshal_INT__VOID);
3612 * gi_marshalling_tests_callback_return_value_only:
3613 * @callback: (scope call):
3615 glong gi_marshalling_tests_callback_return_value_only (GIMarshallingTestsCallbackReturnValueOnly callback)
3621 * gi_marshalling_tests_callback_one_out_parameter:
3622 * @callback: (scope call):
3625 void gi_marshalling_tests_callback_one_out_parameter (GIMarshallingTestsCallbackOneOutParameter callback, gfloat *a)
3631 * gi_marshalling_tests_callback_multiple_out_parameters:
3632 * @callback: (scope call):
3637 gi_marshalling_tests_callback_multiple_out_parameters
3638 (GIMarshallingTestsCallbackMultipleOutParameters callback, gfloat *a, gfloat *b)
3644 * gi_marshalling_tests_callback_return_value_and_one_out_parameter:
3645 * @callback: (scope call):
3649 gi_marshalling_tests_callback_return_value_and_one_out_parameter
3650 (GIMarshallingTestsCallbackReturnValueAndOneOutParameter callback, glong *a)
3652 return callback (a);
3656 * gi_marshalling_tests_callback_return_value_and_multiple_out_parameters:
3657 * @callback: (scope call):
3662 gi_marshalling_tests_callback_return_value_and_multiple_out_parameters
3663 (GIMarshallingTestsCallbackReturnValueAndMultipleOutParameters callback, glong *a, glong *b)
3665 return callback (a, b);
3671 * gi_marshalling_tests_pointer_in_return:
3673 * Returns: The same pointer
3676 gi_marshalling_tests_pointer_in_return (gpointer pointer)
3682 gi_marshalling_tests_genum_get_type (void)
3684 static GType type = 0;
3685 if (G_UNLIKELY (type == 0))
3687 static const GEnumValue values[] = {
3688 {GI_MARSHALLING_TESTS_GENUM_VALUE1,
3689 "GI_MARSHALLING_TESTS_GENUM_VALUE1", "value1"},
3690 {GI_MARSHALLING_TESTS_GENUM_VALUE2,
3691 "GI_MARSHALLING_TESTS_GENUM_VALUE2", "value2"},
3692 {GI_MARSHALLING_TESTS_GENUM_VALUE3,
3693 "GI_MARSHALLING_TESTS_GENUM_VALUE3", "value3"},
3696 type = g_enum_register_static (g_intern_static_string ("GIMarshallingTestsGEnum"), values);
3702 GIMarshallingTestsGEnum
3703 gi_marshalling_tests_genum_returnv (void)
3705 return GI_MARSHALLING_TESTS_GENUM_VALUE3;
3709 gi_marshalling_tests_genum_in (GIMarshallingTestsGEnum v)
3711 g_assert_cmpint (v, ==, GI_MARSHALLING_TESTS_GENUM_VALUE3);
3715 * gi_marshalling_tests_genum_out:
3719 gi_marshalling_tests_genum_out (GIMarshallingTestsGEnum *v)
3721 *v = GI_MARSHALLING_TESTS_GENUM_VALUE3;
3725 * gi_marshalling_tests_genum_inout:
3729 gi_marshalling_tests_genum_inout (GIMarshallingTestsGEnum *v)
3731 g_assert_cmpint (*v, ==, GI_MARSHALLING_TESTS_GENUM_VALUE3);
3732 *v = GI_MARSHALLING_TESTS_GENUM_VALUE1;
3736 GIMarshallingTestsEnum
3737 gi_marshalling_tests_enum_returnv (void)
3739 return GI_MARSHALLING_TESTS_ENUM_VALUE3;
3743 gi_marshalling_tests_enum_in (GIMarshallingTestsEnum v)
3745 g_assert_cmpint (v, ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
3749 * gi_marshalling_tests_enum_out:
3753 gi_marshalling_tests_enum_out (GIMarshallingTestsEnum *v)
3755 *v = GI_MARSHALLING_TESTS_ENUM_VALUE3;
3759 * gi_marshalling_tests_enum_inout:
3763 gi_marshalling_tests_enum_inout (GIMarshallingTestsEnum *v)
3765 g_assert_cmpint (*v, ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
3766 *v = GI_MARSHALLING_TESTS_ENUM_VALUE1;
3771 gi_marshalling_tests_flags_get_type (void)
3773 static GType type = 0;
3774 if (G_UNLIKELY (type == 0))
3776 static const GFlagsValue values[] = {
3777 {GI_MARSHALLING_TESTS_FLAGS_VALUE1,
3778 "GI_MARSHALLING_TESTS_FLAGS_VALUE1", "value1"},
3779 {GI_MARSHALLING_TESTS_FLAGS_VALUE2,
3780 "GI_MARSHALLING_TESTS_FLAGS_VALUE2", "value2"},
3781 {GI_MARSHALLING_TESTS_FLAGS_VALUE3,
3782 "GI_MARSHALLING_TESTS_FLAGS_VALUE3", "value3"},
3783 {GI_MARSHALLING_TESTS_FLAGS_MASK, "GI_MARSHALLING_TESTS_FLAGS_MASK",
3785 {GI_MARSHALLING_TESTS_FLAGS_MASK2, "GI_MARSHALLING_TESTS_FLAGS_MASK2",
3789 type = g_flags_register_static (g_intern_static_string ("GIMarshallingTestsFlags"), values);
3795 GIMarshallingTestsFlags
3796 gi_marshalling_tests_flags_returnv (void)
3798 return GI_MARSHALLING_TESTS_FLAGS_VALUE2;
3802 gi_marshalling_tests_flags_in (GIMarshallingTestsFlags v)
3804 g_assert (v == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
3808 gi_marshalling_tests_flags_in_zero (GIMarshallingTestsFlags v)
3814 * gi_marshalling_tests_flags_out:
3818 gi_marshalling_tests_flags_out (GIMarshallingTestsFlags *v)
3820 *v = GI_MARSHALLING_TESTS_FLAGS_VALUE2;
3824 * gi_marshalling_tests_flags_inout:
3828 gi_marshalling_tests_flags_inout (GIMarshallingTestsFlags *v)
3830 g_assert (*v == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
3831 *v = GI_MARSHALLING_TESTS_FLAGS_VALUE1;
3835 GIMarshallingTestsNoTypeFlags
3836 gi_marshalling_tests_no_type_flags_returnv (void)
3838 return GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
3842 gi_marshalling_tests_no_type_flags_in (GIMarshallingTestsNoTypeFlags v)
3844 g_assert (v == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
3848 gi_marshalling_tests_no_type_flags_in_zero (GIMarshallingTestsNoTypeFlags v)
3854 * gi_marshalling_tests_no_type_flags_out:
3858 gi_marshalling_tests_no_type_flags_out (GIMarshallingTestsNoTypeFlags *v)
3860 *v = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
3864 * gi_marshalling_tests_no_type_flags_inout:
3868 gi_marshalling_tests_no_type_flags_inout (GIMarshallingTestsNoTypeFlags *v)
3870 g_assert (*v == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
3871 *v = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE1;
3876 * gi_marshalling_tests_simple_struct_returnv:
3878 * Returns: (transfer none):
3880 GIMarshallingTestsSimpleStruct *
3881 gi_marshalling_tests_simple_struct_returnv (void)
3883 static GIMarshallingTestsSimpleStruct *struct_ = NULL;
3885 if (struct_ == NULL)
3887 struct_ = g_new (GIMarshallingTestsSimpleStruct, 1);
3897 * gi_marshalling_tests_simple_struct_inv:
3898 * @struct_: (transfer none):
3901 gi_marshalling_tests_simple_struct_inv (GIMarshallingTestsSimpleStruct *struct_)
3903 g_assert_cmpint (struct_->long_, ==, 6);
3904 g_assert_cmpint (struct_->int8, ==, 7);
3908 gi_marshalling_tests_simple_struct_method (GIMarshallingTestsSimpleStruct *struct_)
3910 g_assert_cmpint (struct_->long_, ==, 6);
3911 g_assert_cmpint (struct_->int8, ==, 7);
3916 gi_marshalling_tests_pointer_struct_get_type (void)
3918 static GType type = 0;
3922 type = g_pointer_type_register_static ("GIMarshallingTestsPointerStruct");
3929 * gi_marshalling_tests_pointer_struct_returnv:
3931 * Returns: (transfer none):
3933 GIMarshallingTestsPointerStruct *
3934 gi_marshalling_tests_pointer_struct_returnv (void)
3936 static GIMarshallingTestsPointerStruct *struct_ = NULL;
3938 if (struct_ == NULL)
3940 struct_ = g_new (GIMarshallingTestsPointerStruct, 1);
3942 struct_->long_ = 42;
3949 * gi_marshalling_tests_pointer_struct_inv:
3950 * @struct_: (transfer none):
3953 gi_marshalling_tests_pointer_struct_inv (GIMarshallingTestsPointerStruct *struct_)
3955 g_assert_cmpint (struct_->long_, ==, 42);
3958 static GIMarshallingTestsBoxedStruct *
3959 gi_marshalling_tests_boxed_struct_copy (GIMarshallingTestsBoxedStruct *struct_)
3961 GIMarshallingTestsBoxedStruct *new_struct;
3963 if (struct_ == NULL)
3966 new_struct = g_slice_new (GIMarshallingTestsBoxedStruct);
3968 *new_struct = *struct_;
3969 new_struct->string_ = g_strdup (struct_->string_);
3975 gi_marshalling_tests_boxed_struct_free (GIMarshallingTestsBoxedStruct *struct_)
3977 if (struct_ != NULL)
3979 g_free (struct_->string_);
3980 g_slice_free (GIMarshallingTestsBoxedStruct, struct_);
3985 gi_marshalling_tests_boxed_struct_get_type (void)
3987 static GType type = 0;
3991 type = g_boxed_type_register_static ("GIMarshallingTestsBoxedStruct",
3993 gi_marshalling_tests_boxed_struct_copy,
3994 (GBoxedFreeFunc) gi_marshalling_tests_boxed_struct_free);
4001 gi_marshalling_tests_boxed_glist_get_type (void)
4003 static GType type = 0;
4007 type = g_boxed_type_register_static ("GIMarshallingTestsBoxedGList",
4008 (GBoxedCopyFunc) g_list_copy, (GBoxedFreeFunc) g_list_free);
4014 GIMarshallingTestsBoxedStruct *
4015 gi_marshalling_tests_boxed_struct_new (void)
4017 return g_slice_new0 (GIMarshallingTestsBoxedStruct);
4021 * gi_marshalling_tests_boxed_struct_returnv:
4023 * Returns: (transfer none):
4025 GIMarshallingTestsBoxedStruct *
4026 gi_marshalling_tests_boxed_struct_returnv (void)
4028 static GIMarshallingTestsBoxedStruct *struct_ = NULL;
4030 if (struct_ == NULL)
4032 struct_ = g_new (GIMarshallingTestsBoxedStruct, 1);
4034 struct_->long_ = 42;
4035 struct_->string_ = g_strdup ("hello");
4036 struct_->g_strv = g_new0 (gchar *, 4);
4037 struct_->g_strv[0] = g_strdup ("0");
4038 struct_->g_strv[1] = g_strdup ("1");
4039 struct_->g_strv[2] = g_strdup ("2");
4040 struct_->g_strv[3] = NULL;
4047 * gi_marshalling_tests_boxed_struct_inv:
4048 * @struct_: (transfer none):
4051 gi_marshalling_tests_boxed_struct_inv (GIMarshallingTestsBoxedStruct *struct_)
4053 g_assert_cmpint (struct_->long_, ==, 42);
4057 * gi_marshalling_tests_boxed_struct_out:
4058 * @struct_: (out) (transfer none):
4061 gi_marshalling_tests_boxed_struct_out (GIMarshallingTestsBoxedStruct **struct_)
4063 static GIMarshallingTestsBoxedStruct *new_struct = NULL;
4065 if (new_struct == NULL)
4067 new_struct = g_new0 (GIMarshallingTestsBoxedStruct, 1);
4069 new_struct->long_ = 42;
4072 *struct_ = new_struct;
4076 * gi_marshalling_tests_boxed_struct_inout:
4077 * @struct_: (inout) (transfer full):
4080 gi_marshalling_tests_boxed_struct_inout (GIMarshallingTestsBoxedStruct **struct_)
4082 g_assert_cmpint ((*struct_)->long_, ==, 42);
4084 g_boxed_free (gi_marshalling_tests_boxed_struct_get_type(), *struct_);
4085 (*struct_) = g_slice_new0 (GIMarshallingTestsBoxedStruct);
4086 (*struct_)->long_ = 0;
4089 static GIMarshallingTestsUnion *
4090 gi_marshalling_tests_union_copy (GIMarshallingTestsUnion *union_)
4092 GIMarshallingTestsUnion *new_union;
4094 new_union = g_slice_new (GIMarshallingTestsUnion);
4096 *new_union = *union_;
4102 gi_marshalling_tests_union_free (GIMarshallingTestsUnion *union_)
4104 g_slice_free (GIMarshallingTestsUnion, union_);
4108 gi_marshalling_tests_union_get_type (void)
4110 static GType type = 0;
4114 type = g_boxed_type_register_static ("GIMarshallingTestsUnion",
4116 gi_marshalling_tests_union_copy,
4117 (GBoxedFreeFunc) gi_marshalling_tests_union_free);
4124 * gi_marshalling_tests_union_returnv:
4126 * Returns: (transfer none):
4128 GIMarshallingTestsUnion *
4129 gi_marshalling_tests_union_returnv (void)
4131 static GIMarshallingTestsUnion *union_ = NULL;
4135 union_ = g_new (GIMarshallingTestsUnion, 1);
4144 * gi_marshalling_tests_union_inv:
4145 * @union_: (transfer none):
4148 gi_marshalling_tests_union_inv (GIMarshallingTestsUnion *union_)
4150 g_assert_cmpint (union_->long_, ==, 42);
4154 gi_marshalling_tests_union_method (GIMarshallingTestsUnion *union_)
4156 g_assert_cmpint (union_->long_, ==, 42);
4168 gi_marshalling_tests_object_real_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in);
4170 G_DEFINE_TYPE (GIMarshallingTestsObject, gi_marshalling_tests_object, G_TYPE_OBJECT);
4173 gi_marshalling_tests_object_init (GIMarshallingTestsObject *self G_GNUC_UNUSED)
4178 gi_marshalling_tests_object_finalize (GObject *object)
4180 G_OBJECT_CLASS (gi_marshalling_tests_object_parent_class)->finalize (object);
4184 gi_marshalling_tests_object_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
4186 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
4191 GI_MARSHALLING_TESTS_OBJECT (object)->int_ = g_value_get_int (value);
4194 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
4200 gi_marshalling_tests_object_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
4202 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
4207 g_value_set_int (value, GI_MARSHALLING_TESTS_OBJECT (object)->int_);
4210 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
4216 gi_marshalling_tests_object_class_init (GIMarshallingTestsObjectClass *klass)
4218 GObjectClass *object_class = G_OBJECT_CLASS (klass);
4220 GObjectClass *parent_class = G_OBJECT_CLASS (klass);
4223 object_class->finalize = gi_marshalling_tests_object_finalize;
4224 object_class->set_property = gi_marshalling_tests_object_set_property;
4225 object_class->get_property = gi_marshalling_tests_object_get_property;
4227 g_object_class_install_property (object_class, PROP_INT_,
4228 g_param_spec_int ("int", "Integer",
4229 "An integer", G_MININT,
4231 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4233 klass->method_with_default_implementation = gi_marshalling_tests_object_real_method_with_default_implementation;
4238 gi_marshalling_tests_object_static_method (void)
4243 gi_marshalling_tests_object_method (GIMarshallingTestsObject *object)
4245 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
4246 g_assert_cmpint (object->int_, ==, 42);
4250 gi_marshalling_tests_object_overridden_method (GIMarshallingTestsObject *object)
4252 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
4253 g_assert_cmpint (object->int_, ==, 0);
4256 GIMarshallingTestsObject *
4257 gi_marshalling_tests_object_new (gint int_)
4259 return g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, "int", int_, NULL);
4262 GIMarshallingTestsObject *
4263 gi_marshalling_tests_object_new_fail (gint int_ G_GNUC_UNUSED,
4266 g_return_val_if_fail (error == NULL || *error == NULL, NULL);
4268 g_set_error_literal (error,
4269 g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN),
4270 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4271 GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4277 * gi_marshalling_tests_object_method_array_in:
4278 * @ints: (array length=length):
4281 gi_marshalling_tests_object_method_array_in (GIMarshallingTestsObject *self G_GNUC_UNUSED,
4285 g_assert_cmpint (length, ==, 4);
4286 g_assert_cmpint (ints[0], ==, -1);
4287 g_assert_cmpint (ints[1], ==, 0);
4288 g_assert_cmpint (ints[2], ==, 1);
4289 g_assert_cmpint (ints[3], ==, 2);
4293 * gi_marshalling_tests_object_method_array_out:
4294 * @ints: (out) (array length=length) (transfer none):
4297 gi_marshalling_tests_object_method_array_out (GIMarshallingTestsObject *self G_GNUC_UNUSED,
4301 static gint values[] = { -1, 0, 1, 2 };
4308 * gi_marshalling_tests_object_method_array_inout:
4309 * @ints: (inout) (array length=length) (transfer none):
4313 gi_marshalling_tests_object_method_array_inout (GIMarshallingTestsObject *self G_GNUC_UNUSED,
4317 static gint values[] = { -2, -1, 0, 1, 2 };
4319 g_assert_cmpint (*length, ==, 4);
4320 g_assert_cmpint ((*ints)[0], ==, -1);
4321 g_assert_cmpint ((*ints)[1], ==, 0);
4322 g_assert_cmpint ((*ints)[2], ==, 1);
4323 g_assert_cmpint ((*ints)[3], ==, 2);
4330 * gi_marshalling_tests_object_method_array_return:
4332 * Returns: (array length=length):
4335 gi_marshalling_tests_object_method_array_return (GIMarshallingTestsObject *self G_GNUC_UNUSED,
4338 static gint ints[] = { -1, 0, 1, 2 };
4345 * gi_marshalling_tests_object_method_int8_in:
4349 gi_marshalling_tests_object_method_int8_in (GIMarshallingTestsObject *self, gint8 in)
4351 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_in (self, in);
4355 * gi_marshalling_tests_object_method_int8_out:
4359 gi_marshalling_tests_object_method_int8_out (GIMarshallingTestsObject *self, gint8 *out)
4361 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_out (self, out);
4365 * gi_marshalling_tests_object_method_int8_arg_and_out_caller:
4366 * @out: (out caller-allocates):
4369 gi_marshalling_tests_object_method_int8_arg_and_out_caller (GIMarshallingTestsObject *self, gint8 arg, gint8 *out)
4371 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_arg_and_out_caller (self, arg, out);
4375 * gi_marshalling_tests_object_method_int8_arg_and_out_callee:
4379 gi_marshalling_tests_object_method_int8_arg_and_out_callee (GIMarshallingTestsObject *self, gint8 arg, gint8 **out)
4381 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_arg_and_out_callee (self, arg, out);
4385 * gi_marshalling_tests_object_method_str_arg_out_ret:
4386 * @out: (out caller-allocates):
4388 * Returns: (transfer none)
4391 gi_marshalling_tests_object_method_str_arg_out_ret (GIMarshallingTestsObject *self, const gchar *arg, guint *out)
4393 return GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_str_arg_out_ret (self, arg, out);
4397 * gi_marshalling_tests_object_method_with_default_implementation:
4400 void gi_marshalling_tests_object_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
4402 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_with_default_implementation (self, in);
4406 gi_marshalling_tests_object_real_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
4408 GValue val = { 0, };
4409 g_value_init (&val, G_TYPE_INT);
4410 g_value_set_int (&val, in);
4411 g_object_set_property (G_OBJECT (self), "int", &val);
4415 * gi_marshalling_tests_object_vfunc_with_callback: (virtual vfunc_with_callback)
4416 * @callback: (scope call) (closure callback_data):
4417 * @callback_data: (allow-none):
4420 gi_marshalling_tests_object_vfunc_with_callback (GIMarshallingTestsObject *self G_GNUC_UNUSED,
4421 GIMarshallingTestsCallbackIntInt callback G_GNUC_UNUSED,
4422 void *callback_data G_GNUC_UNUSED)
4428 _callback (int val, void *user_data)
4430 g_assert (user_data == (gpointer) 0xdeadbeef);
4435 gi_marshalling_tests_object_call_vfunc_with_callback (GIMarshallingTestsObject *object)
4437 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (object)->vfunc_with_callback (object, _callback, (void *) 0xdeadbeef);
4441 * gi_marshalling_tests_object_none_return:
4443 * Returns: (transfer none):
4445 GIMarshallingTestsObject *
4446 gi_marshalling_tests_object_none_return (void)
4448 static GIMarshallingTestsObject *object = NULL;
4452 object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4459 * gi_marshalling_tests_object_full_return:
4461 * Returns: (transfer full):
4463 GIMarshallingTestsObject *
4464 gi_marshalling_tests_object_full_return (void)
4466 return g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4470 * gi_marshalling_tests_object_none_in:
4471 * @object: (transfer none):
4474 gi_marshalling_tests_object_none_in (GIMarshallingTestsObject *object)
4476 g_assert_cmpint (object->int_, ==, 42);
4480 * gi_marshalling_tests_object_none_out:
4481 * @object: (out) (transfer none):
4484 gi_marshalling_tests_object_none_out (GIMarshallingTestsObject **object)
4486 static GIMarshallingTestsObject *new_object = NULL;
4488 if (new_object == NULL)
4490 new_object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4493 *object = new_object;
4497 * gi_marshalling_tests_object_full_out:
4498 * @object: (out) (transfer full):
4501 gi_marshalling_tests_object_full_out (GIMarshallingTestsObject **object)
4503 *object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4507 * gi_marshalling_tests_object_none_inout:
4508 * @object: (inout) (transfer none):
4511 gi_marshalling_tests_object_none_inout (GIMarshallingTestsObject **object)
4513 static GIMarshallingTestsObject *new_object = NULL;
4515 g_assert_cmpint ((*object)->int_, ==, 42);
4517 if (new_object == NULL)
4519 new_object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4520 new_object->int_ = 0;
4523 *object = new_object;
4527 * gi_marshalling_tests_object_full_inout:
4528 * @object: (inout) (transfer full):
4531 gi_marshalling_tests_object_full_inout (GIMarshallingTestsObject **object)
4533 g_assert_cmpint ((*object)->int_, ==, 42);
4535 g_object_unref (*object);
4536 *object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4540 * gi_marshalling_tests_object_int8_in:
4544 gi_marshalling_tests_object_int8_in (GIMarshallingTestsObject *object, gint8 in)
4546 gi_marshalling_tests_object_method_int8_in (object, in);
4550 * gi_marshalling_tests_object_int8_out:
4554 gi_marshalling_tests_object_int8_out (GIMarshallingTestsObject *object, gint8 *out)
4556 gi_marshalling_tests_object_method_int8_out (object, out);
4560 * gi_marshalling_tests_object_vfunc_return_value_only:
4563 gi_marshalling_tests_object_vfunc_return_value_only (GIMarshallingTestsObject *self)
4565 /* make sure that local variables don't get smashed */
4567 gulong local = 0x12345678;
4568 return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_only (self);
4569 g_assert_cmpint (local, ==, 0x12345678);
4570 return return_value;
4574 * gi_marshalling_tests_object_vfunc_one_out_parameter:
4578 gi_marshalling_tests_object_vfunc_one_out_parameter (GIMarshallingTestsObject *self, gfloat *a)
4580 /* make sure that local variables don't get smashed */
4581 gulong local = 0x12345678;
4582 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_one_out_parameter (self, a);
4583 g_assert_cmpint (local, ==, 0x12345678);
4587 * gi_marshalling_tests_object_vfunc_multiple_out_parameters:
4591 void gi_marshalling_tests_object_vfunc_multiple_out_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b)
4593 /* make sure that local variables don't get smashed */
4594 gulong local = 0x12345678;
4595 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_multiple_out_parameters (self, a, b);
4596 g_assert_cmpint (local, ==, 0x12345678);
4600 * gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter:
4603 void gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter (GIMarshallingTestsObject *self, GValue *a)
4605 /* make sure that local variables don't get smashed */
4606 gulong local = 0x12345678;
4607 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_caller_allocated_out_parameter (self, a);
4608 g_assert_cmpint (local, ==, 0x12345678);
4612 * gi_marshalling_tests_object_vfunc_array_out_parameter:
4613 * @a: (out) (array zero-terminated):
4615 void gi_marshalling_tests_object_vfunc_array_out_parameter (GIMarshallingTestsObject *self, gfloat **a)
4617 /* make sure that local variables don't get smashed */
4618 gulong local = 0x12345678;
4619 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_array_out_parameter (self, a);
4620 g_assert_cmpint (local, ==, 0x12345678);
4624 * gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter:
4627 glong gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter (GIMarshallingTestsObject *self, glong *a)
4629 /* make sure that local variables don't get smashed */
4630 gulong return_value;
4631 gulong local = 0x12345678;
4632 return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_one_out_parameter (self, a);
4633 g_assert_cmpint (local, ==, 0x12345678);
4634 return return_value;
4638 * gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters:
4643 gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters
4644 (GIMarshallingTestsObject *self, glong *a, glong *b)
4646 gulong return_value;
4647 gulong local = 0x12345678;
4649 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_multiple_out_parameters (self, a, b);
4650 g_assert_cmpint (local, ==, 0x12345678);
4651 return return_value;
4655 * gi_marshalling_tests_callback_owned_boxed:
4656 * @callback: (scope call) (closure callback_data):
4657 * @callback_data: (allow-none):
4660 gi_marshalling_tests_callback_owned_boxed (GIMarshallingTestsCallbackOwnedBoxed callback,
4661 void *callback_data)
4663 static GIMarshallingTestsBoxedStruct *box = NULL;
4667 box = gi_marshalling_tests_boxed_struct_new ();
4669 callback (box, callback_data);
4675 gi_marshalling_tests_object_vfunc_meth_with_error (GIMarshallingTestsObject *self, gint x, GError **error)
4677 gulong local = 0x12345678;
4678 gboolean ret = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_meth_with_err (self,
4681 g_assert_cmpint (local, ==, 0x12345678);
4686 * gi_marshalling_tests_object_vfunc_return_enum:
4688 GIMarshallingTestsEnum
4689 gi_marshalling_tests_object_vfunc_return_enum (GIMarshallingTestsObject *self)
4691 /* make sure that local variables don't get smashed */
4692 GIMarshallingTestsEnum return_value;
4693 glong local = 0x12345678;
4694 return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_enum (self);
4695 g_assert_cmpint (local, ==, 0x12345678);
4696 return return_value;
4700 * gi_marshalling_tests_object_vfunc_out_enum:
4704 gi_marshalling_tests_object_vfunc_out_enum (GIMarshallingTestsObject *self, GIMarshallingTestsEnum *_enum)
4706 /* make sure that local variables don't get smashed */
4707 gulong local = 0x12345678;
4708 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_out_enum (self, _enum);
4709 g_assert_cmpint (local, ==, 0x12345678);
4715 * The following (get_ref_info_for_*) methods are designed to call vfuncs related
4716 * to object argument marshaling. They do not pass the resulting objects through them
4717 * as regular vfunc wrapper method do, but rather return reference count and floating
4718 * information back to the callers. This is useful because callers can do testing of
4719 * expected reference counts in isolation and from the perspective of C. This is important
4720 * because if there are bugs in the reverse marshaling, they can obfuscate or compound
4721 * bugs in marshaling from the vfuncs.
4725 * gi_marshalling_tests_object_get_ref_info_for_vfunc_return_object_transfer_none:
4726 * @ref_count: (out): Ref count of the object returned from the vfunc directly after vfunc call.
4727 * @is_floating: (out): Floating state object returned from the vfunc directly after vfunc call.
4730 gi_marshalling_tests_object_get_ref_info_for_vfunc_return_object_transfer_none
4731 (GIMarshallingTestsObject *self, guint *ref_count, gboolean *is_floating)
4733 GObject *object = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_object_transfer_none (self);
4734 *ref_count = object->ref_count;
4735 *is_floating = g_object_is_floating (object);
4737 /* Attempt to sink and unref the returned object and avoid any potential leaks */
4738 g_object_ref_sink (object);
4739 g_object_unref (object);
4743 * gi_marshalling_tests_object_get_ref_info_for_vfunc_return_object_transfer_full:
4744 * @ref_count: (out): Ref count of the object returned from the vfunc directly after vfunc call.
4745 * @is_floating: (out): Floating state object returned from the vfunc directly after vfunc call.
4748 gi_marshalling_tests_object_get_ref_info_for_vfunc_return_object_transfer_full
4749 (GIMarshallingTestsObject *self, guint *ref_count, gboolean *is_floating)
4751 GObject *object = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_object_transfer_full (self);
4752 *ref_count = object->ref_count;
4753 *is_floating = g_object_is_floating (object);
4754 g_object_unref (object);
4758 * gi_marshalling_tests_object_get_ref_info_for_vfunc_out_object_transfer_none:
4759 * @ref_count: (out): Ref count of the object returned from the vfunc directly after vfunc call.
4760 * @is_floating: (out): Floating state object returned from the vfunc directly after vfunc call.
4763 gi_marshalling_tests_object_get_ref_info_for_vfunc_out_object_transfer_none
4764 (GIMarshallingTestsObject *self, guint *ref_count, gboolean *is_floating)
4766 GObject *object = NULL;
4767 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_out_object_transfer_none (self, &object);
4768 *ref_count = object->ref_count;
4769 *is_floating = g_object_is_floating (object);
4771 /* Attempt to sink and unref the returned object and avoid any potential leaks */
4772 g_object_ref_sink (object);
4773 g_object_unref (object);
4777 * gi_marshalling_tests_object_get_ref_info_for_vfunc_out_object_transfer_full:
4778 * @ref_count: (out): Ref count of the object returned from the vfunc directly after vfunc call.
4779 * @is_floating: (out): Floating state object returned from the vfunc directly after vfunc call.
4782 gi_marshalling_tests_object_get_ref_info_for_vfunc_out_object_transfer_full
4783 (GIMarshallingTestsObject *self, guint *ref_count, gboolean *is_floating)
4785 GObject *object = NULL;
4786 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_out_object_transfer_full (self, &object);
4787 *ref_count = object->ref_count;
4788 *is_floating = g_object_is_floating (object);
4789 g_object_unref (object);
4793 _vfunc_in_object_destroy_callback (gboolean *destroy_called,
4794 GObject *where_the_object_was G_GNUC_UNUSED)
4796 *destroy_called = TRUE;
4800 * gi_marshalling_tests_object_get_ref_info_for_vfunc_in_object_transfer_none:
4801 * @type: GType of object to create and pass as in argument to the vfunc
4802 * @ref_count: (out): Ref count of the in object directly after vfunc call.
4803 * @is_floating: (out): Floating state of in object directly after vfunc call.
4805 * Calls vfunc_in_object_transfer_none with a new object of the given type.
4808 gi_marshalling_tests_object_get_ref_info_for_vfunc_in_object_transfer_none
4809 (GIMarshallingTestsObject *self, GType type, guint *ref_count, gboolean *is_floating)
4811 static gboolean destroy_called;
4813 destroy_called = FALSE;
4815 object = g_object_new (type, NULL);
4816 g_object_weak_ref (object, (GWeakNotify) _vfunc_in_object_destroy_callback, &destroy_called);
4818 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_in_object_transfer_none (self, object);
4822 *is_floating = FALSE;
4826 *ref_count = object->ref_count;
4827 *is_floating = g_object_is_floating (object);
4828 g_object_unref (object);
4834 * gi_marshalling_tests_object_get_ref_info_for_vfunc_in_object_transfer_full:
4835 * @type: GType of object to create and pass as in argument to the vfunc
4836 * @ref_count: (out): Ref count of the in object directly after vfunc call.
4837 * @is_floating: (out): Floating state of in object directly after vfunc call.
4840 gi_marshalling_tests_object_get_ref_info_for_vfunc_in_object_transfer_full
4841 (GIMarshallingTestsObject *self, GType type, guint *ref_count, gboolean *is_floating)
4843 static gboolean destroy_called;
4845 destroy_called = FALSE;
4847 object = g_object_new (type, NULL);
4848 g_object_weak_ref (object, (GWeakNotify) _vfunc_in_object_destroy_callback, &destroy_called);
4850 /* Calling the vfunc takes ownership of the object, so we use a weak_ref to determine
4851 * if the object gets destroyed after the call and appropriately return 0 as the ref count.
4853 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_in_object_transfer_full (self, object);
4857 *is_floating = FALSE;
4861 *ref_count = object->ref_count;
4862 *is_floating = g_object_is_floating (object);
4867 G_DEFINE_TYPE (GIMarshallingTestsSubObject, gi_marshalling_tests_sub_object, GI_MARSHALLING_TESTS_TYPE_OBJECT);
4870 gi_marshalling_tests_sub_object_init (GIMarshallingTestsSubObject *self G_GNUC_UNUSED)
4875 gi_marshalling_tests_sub_object_finalize (GObject *object)
4877 G_OBJECT_CLASS (gi_marshalling_tests_sub_object_parent_class)->finalize (object);
4881 method_deep_hierarchy (GIMarshallingTestsObject *self, gint8 in)
4883 GValue val = { 0, };
4884 g_value_init (&val, G_TYPE_INT);
4885 g_value_set_int (&val, in);
4886 g_object_set_property (G_OBJECT (self), "int", &val);
4890 gi_marshalling_tests_sub_object_class_init (GIMarshallingTestsSubObjectClass *klass)
4892 G_OBJECT_CLASS (klass)->finalize = gi_marshalling_tests_sub_object_finalize;
4893 GI_MARSHALLING_TESTS_OBJECT_CLASS (klass)->method_deep_hierarchy = method_deep_hierarchy;
4897 gi_marshalling_tests_sub_object_sub_method (GIMarshallingTestsSubObject *object)
4899 g_assert_cmpint (GI_MARSHALLING_TESTS_OBJECT (object)->int_, ==, 0);
4902 void gi_marshalling_tests_sub_object_overwritten_method (GIMarshallingTestsSubObject *object)
4904 g_assert_cmpint (GI_MARSHALLING_TESTS_OBJECT (object)->int_, ==, 0);
4907 G_DEFINE_TYPE (GIMarshallingTestsSubSubObject,
4908 gi_marshalling_tests_sub_sub_object, GI_MARSHALLING_TESTS_TYPE_SUB_OBJECT);
4911 gi_marshalling_tests_sub_sub_object_init (GIMarshallingTestsSubSubObject *self G_GNUC_UNUSED)
4915 static void gi_marshalling_tests_sub_sub_object_class_init (GIMarshallingTestsSubSubObjectClass *klass G_GNUC_UNUSED)
4922 gi_marshalling_tests_interface_class_init (void *g_iface G_GNUC_UNUSED,
4923 void *data G_GNUC_UNUSED)
4928 gi_marshalling_tests_interface_get_type (void)
4930 static GType type = 0;
4933 /* Not adding prerequisite here for test purposes */
4934 type = g_type_register_static_simple (G_TYPE_INTERFACE,
4935 "GIMarshallingTestsInterface",
4937 (GIMarshallingTestsInterfaceIface),
4938 (GClassInitFunc) gi_marshalling_tests_interface_class_init, 0, NULL, 0);
4945 * gi_marshalling_tests_interface_test_int8_in:
4949 gi_marshalling_tests_interface_test_int8_in (GIMarshallingTestsInterface *self, gint8 in)
4951 GI_MARSHALLING_TESTS_INTERFACE_GET_IFACE (self)->test_int8_in (self, in);
4955 * gi_marshalling_tests_test_interface_test_int8_in:
4959 gi_marshalling_tests_test_interface_test_int8_in (GIMarshallingTestsInterface *test_iface, gint8 in)
4961 gi_marshalling_tests_interface_test_int8_in (test_iface, in);
4965 static void test_interface_init (GIMarshallingTestsInterfaceIface *iface);
4967 G_DEFINE_TYPE_WITH_CODE (GIMarshallingTestsInterfaceImpl, gi_marshalling_tests_interface_impl, G_TYPE_OBJECT,
4968 G_IMPLEMENT_INTERFACE(GI_MARSHALLING_TESTS_TYPE_INTERFACE, test_interface_init))
4971 gi_marshalling_tests_interface_impl_test_int8_in (GIMarshallingTestsInterface *self G_GNUC_UNUSED,
4972 gint8 in G_GNUC_UNUSED)
4976 static void test_interface_init (GIMarshallingTestsInterfaceIface *iface)
4978 iface->test_int8_in = gi_marshalling_tests_interface_impl_test_int8_in;
4982 gi_marshalling_tests_interface_impl_init (GIMarshallingTestsInterfaceImpl *self G_GNUC_UNUSED)
4987 gi_marshalling_tests_interface_impl_class_init (GIMarshallingTestsInterfaceImplClass *klass G_GNUC_UNUSED)
4992 * gi_marshalling_tests_interface_impl_get_as_interface:
4994 * Returns: (transfer none):
4996 GIMarshallingTestsInterface *
4997 gi_marshalling_tests_interface_impl_get_as_interface (GIMarshallingTestsInterfaceImpl *self)
4999 return (GIMarshallingTestsInterface *) self;
5003 gi_marshalling_tests_interface2_class_init (void *g_iface G_GNUC_UNUSED,
5004 void *data G_GNUC_UNUSED)
5009 gi_marshalling_tests_interface2_get_type (void)
5011 static GType type = 0;
5014 type = g_type_register_static_simple (G_TYPE_INTERFACE,
5015 "GIMarshallingTestsInterface2",
5017 (GIMarshallingTestsInterface2Iface),
5018 (GClassInitFunc) gi_marshalling_tests_interface2_class_init, 0, NULL, 0);
5025 gi_marshalling_tests_interface3_class_init (void *g_iface G_GNUC_UNUSED,
5026 void *data G_GNUC_UNUSED)
5031 gi_marshalling_tests_interface3_get_type (void)
5033 static GType type = 0;
5036 type = g_type_register_static_simple (G_TYPE_INTERFACE,
5037 "GIMarshallingTestsInterface3",
5039 (GIMarshallingTestsInterface3Iface),
5040 (GClassInitFunc) gi_marshalling_tests_interface3_class_init, 0, NULL, 0);
5047 * gi_marshalling_tests_interface3_test_variant_array_in:
5048 * @in: (array length=n_in):
5052 gi_marshalling_tests_interface3_test_variant_array_in
5053 (GIMarshallingTestsInterface3 *self, GVariant **in, gsize n_in)
5055 GI_MARSHALLING_TESTS_INTERFACE3_GET_IFACE (self)->test_variant_array_in (self, in, n_in);
5059 * gi_marshalling_tests_int_out_out:
5064 gi_marshalling_tests_int_out_out (gint *int0, gint *int1)
5071 * gi_marshalling_tests_int_three_in_three_out:
5080 gi_marshalling_tests_int_three_in_three_out (gint a, gint b, gint c, gint *out0, gint *out1, gint *out2)
5088 * gi_marshalling_tests_int_return_out:
5092 gi_marshalling_tests_int_return_out (gint *int_)
5099 * gi_marshalling_tests_int_two_in_utf8_two_in_with_allow_none:
5100 * @a: (in): Must be 1
5101 * @b: (in): Must be 2
5102 * @c: (in) (allow-none): Must be "3" or NULL
5103 * @d: (in) (allow-none): Must be "4" or NULL
5106 gi_marshalling_tests_int_two_in_utf8_two_in_with_allow_none (gint a, gint b, const gchar *c, const gchar *d)
5108 g_assert_cmpint (a, ==, 1);
5109 g_assert_cmpint (b, ==, 2);
5111 g_assert_cmpstr (c, ==, "3");
5113 g_assert_cmpstr (d, ==, "4");
5117 * gi_marshalling_tests_int_one_in_utf8_two_in_one_allows_none:
5118 * @a: (in): Must be 1
5119 * @b: (in) (allow-none): Must be "2" or NULL
5120 * @c: (in): Must be "3"
5123 gi_marshalling_tests_int_one_in_utf8_two_in_one_allows_none (gint a, const gchar *b, const gchar *c)
5125 g_assert_cmpint (a, ==, 1);
5127 g_assert_cmpstr (b, ==, "2");
5128 g_assert_cmpstr (c, ==, "3");
5132 * gi_marshalling_tests_array_in_utf8_two_in:
5133 * @ints: (array length=length):
5135 * @a: (in) (allow-none): Must be "1" or NULL
5136 * @b: (in) (allow-none): Must be "2" or NULL
5139 gi_marshalling_tests_array_in_utf8_two_in (const gint *ints, gint length, const gchar *a, const gchar *b)
5141 g_assert_cmpint (length, ==, 4);
5142 g_assert_cmpint (ints[0], ==, -1);
5143 g_assert_cmpint (ints[1], ==, 0);
5144 g_assert_cmpint (ints[2], ==, 1);
5145 g_assert_cmpint (ints[3], ==, 2);
5148 g_assert_cmpstr (a, ==, "1");
5150 g_assert_cmpstr (b, ==, "2");
5154 * gi_marshalling_tests_array_in_utf8_two_in_out_of_order:
5156 * @a: (in) (allow-none): Must be "1" or NULL
5157 * @ints: (array length=length):
5158 * @b: (in) (allow-none): Must be "2" or NULL
5161 gi_marshalling_tests_array_in_utf8_two_in_out_of_order (gint length, const gchar *a, const gint *ints, const gchar *b)
5163 g_assert_cmpint (length, ==, 4);
5164 g_assert_cmpint (ints[0], ==, -1);
5165 g_assert_cmpint (ints[1], ==, 0);
5166 g_assert_cmpint (ints[2], ==, 1);
5167 g_assert_cmpint (ints[3], ==, 2);
5170 g_assert_cmpstr (a, ==, "1");
5172 g_assert_cmpstr (b, ==, "2");
5178 gi_marshalling_tests_gerror (GError **error)
5180 GQuark quark = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
5181 g_set_error_literal (error, quark,
5182 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE, GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
5186 * gi_marshalling_tests_gerror_array_in:
5187 * @in_ints: (array zero-terminated):
5190 gi_marshalling_tests_gerror_array_in (gint *in_ints G_GNUC_UNUSED,
5193 GQuark quark = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
5194 g_set_error_literal (error, quark,
5195 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE, GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
5199 * gi_marshalling_tests_gerror_out:
5200 * @error: (out) (allow-none) (transfer full): location for the GError.
5201 * @debug: (out) (allow-none) (transfer full): location for the debug message
5203 * Inspired by gst_message_parse_error.
5206 gi_marshalling_tests_gerror_out (GError **error, gchar **debug)
5208 GQuark quark = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
5209 g_set_error_literal (error, quark,
5210 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE, GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
5214 *debug = g_strdup (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE);
5219 * gi_marshalling_tests_gerror_out_transfer_none:
5220 * @err: (out) (allow-none) (transfer none): location for the GError.
5221 * @debug: (out) (allow-none) (transfer none): location for the debug message
5223 * A variant of gi_marshalling_tests_gerror_out() which returns data the caller
5227 gi_marshalling_tests_gerror_out_transfer_none (GError **err, const gchar **debug)
5229 static GError error = { 0,
5230 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
5231 (gchar *) GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE
5233 error.domain = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
5235 *debug = GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE;
5239 * gi_marshalling_tests_gerror_return:
5241 * Yet another variant of gi_marshalling_tests_gerror_out().
5243 * Returns: (transfer full): a GError
5246 gi_marshalling_tests_gerror_return (void)
5248 GQuark quark = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
5250 return g_error_new_literal (quark, GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE, GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
5253 static GIMarshallingTestsOverridesStruct *
5254 gi_marshalling_tests_overrides_struct_copy (GIMarshallingTestsOverridesStruct *struct_)
5256 GIMarshallingTestsOverridesStruct *new_struct;
5258 new_struct = g_slice_new (GIMarshallingTestsOverridesStruct);
5260 *new_struct = *struct_;
5266 gi_marshalling_tests_overrides_struct_free (GIMarshallingTestsOverridesStruct *struct_)
5268 g_slice_free (GIMarshallingTestsOverridesStruct, struct_);
5272 gi_marshalling_tests_overrides_struct_get_type (void)
5274 static GType type = 0;
5279 g_boxed_type_register_static ("GIMarshallingTestsOverridesStruct",
5281 gi_marshalling_tests_overrides_struct_copy,
5282 (GBoxedFreeFunc) gi_marshalling_tests_overrides_struct_free);
5288 GIMarshallingTestsOverridesStruct *
5289 gi_marshalling_tests_overrides_struct_new (void)
5291 return g_slice_new (GIMarshallingTestsOverridesStruct);
5294 glong gi_marshalling_tests_overrides_struct_method (GIMarshallingTestsOverridesStruct *self G_GNUC_UNUSED)
5301 * gi_marshalling_tests_overrides_struct_returnv:
5303 * Returns: (transfer full):
5305 GIMarshallingTestsOverridesStruct *
5306 gi_marshalling_tests_overrides_struct_returnv (void)
5308 return gi_marshalling_tests_overrides_struct_new ();
5312 G_DEFINE_TYPE (GIMarshallingTestsOverridesObject, gi_marshalling_tests_overrides_object, G_TYPE_OBJECT);
5315 gi_marshalling_tests_overrides_object_init (GIMarshallingTestsOverridesObject *self G_GNUC_UNUSED)
5320 gi_marshalling_tests_overrides_object_finalize (GObject *object)
5322 G_OBJECT_CLASS (gi_marshalling_tests_overrides_object_parent_class)->finalize (object);
5325 static void gi_marshalling_tests_overrides_object_class_init (GIMarshallingTestsOverridesObjectClass *klass)
5327 GObjectClass *object_class = G_OBJECT_CLASS (klass);
5329 GObjectClass *parent_class = G_OBJECT_CLASS (klass);
5332 object_class->finalize = gi_marshalling_tests_overrides_object_finalize;
5335 GIMarshallingTestsOverridesObject *
5336 gi_marshalling_tests_overrides_object_new (void)
5338 return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
5341 glong gi_marshalling_tests_overrides_object_method (GIMarshallingTestsOverridesObject *self G_GNUC_UNUSED)
5347 * gi_marshalling_tests_overrides_object_returnv:
5349 * Returns: (transfer full):
5351 GIMarshallingTestsOverridesObject *
5352 gi_marshalling_tests_overrides_object_returnv (void)
5354 return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
5358 * gi_marshalling_tests_filename_list_return:
5360 * Returns: (transfer none) (element-type filename): List of filenames
5363 gi_marshalling_tests_filename_list_return (void)
5369 * gi_marshalling_tests_param_spec_in_bool:
5372 gi_marshalling_tests_param_spec_in_bool (const GParamSpec *param)
5374 g_assert (G_IS_PARAM_SPEC (param));
5375 g_assert_cmpint (G_PARAM_SPEC_VALUE_TYPE (param), ==, G_TYPE_BOOLEAN);
5376 g_assert_cmpstr (g_param_spec_get_name ((GParamSpec *) param), ==, "mybool");
5380 * gi_marshalling_tests_param_spec_return:
5382 * Returns: (transfer full): a #GParamSpec
5385 gi_marshalling_tests_param_spec_return (void)
5387 return g_param_spec_string ("test-param", "test", "This is a test", "42", G_PARAM_READABLE);
5391 * gi_marshalling_tests_param_spec_out:
5395 gi_marshalling_tests_param_spec_out (GParamSpec **param)
5397 *param = g_param_spec_string ("test-param", "test", "This is a test", "42", G_PARAM_READABLE);
5404 SOME_BOOLEAN_PROPERTY,
5406 SOME_UCHAR_PROPERTY,
5410 SOME_ULONG_PROPERTY,
5411 SOME_INT64_PROPERTY,
5412 SOME_UINT64_PROPERTY,
5413 SOME_FLOAT_PROPERTY,
5414 SOME_DOUBLE_PROPERTY,
5416 SOME_BOXED_STRUCT_PROPERTY,
5417 SOME_VARIANT_PROPERTY,
5418 SOME_BOXED_GLIST_PROPERTY,
5419 SOME_GVALUE_PROPERTY,
5420 SOME_OBJECT_PROPERTY,
5421 SOME_FLAGS_PROPERTY,
5423 SOME_BYTE_ARRAY_PROPERTY,
5424 SOME_READONLY_PROPERTY,
5427 G_DEFINE_TYPE (GIMarshallingTestsPropertiesObject, gi_marshalling_tests_properties_object, G_TYPE_OBJECT);
5429 static void gi_marshalling_tests_properties_object_init (GIMarshallingTestsPropertiesObject *self G_GNUC_UNUSED)
5434 gi_marshalling_tests_properties_object_finalize (GObject *obj)
5436 GIMarshallingTestsPropertiesObject *self;
5437 self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (obj);
5439 if (self->some_gvalue) {
5440 g_boxed_free (G_TYPE_VALUE, self->some_gvalue);
5441 self->some_gvalue = NULL;
5444 g_clear_pointer (&self->some_strv, g_strfreev);
5445 g_clear_pointer (&self->some_boxed_struct, gi_marshalling_tests_boxed_struct_free);
5446 g_clear_pointer (&self->some_variant, g_variant_unref);
5447 g_clear_pointer (&self->some_boxed_glist, g_list_free);
5448 g_clear_object (&self->some_object);
5450 G_OBJECT_CLASS (gi_marshalling_tests_properties_object_parent_class)->finalize (obj);
5454 gi_marshalling_tests_properties_object_get_property (GObject *object,
5455 guint property_id, GValue *value, GParamSpec *pspec)
5457 GIMarshallingTestsPropertiesObject *self;
5458 self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
5459 switch (property_id)
5461 case SOME_BOOLEAN_PROPERTY:
5462 g_value_set_boolean (value, self->some_boolean);
5464 case SOME_CHAR_PROPERTY:
5465 g_value_set_schar (value, self->some_char);
5467 case SOME_UCHAR_PROPERTY:
5468 g_value_set_uchar (value, self->some_uchar);
5470 case SOME_INT_PROPERTY:
5471 g_value_set_int (value, self->some_int);
5473 case SOME_UINT_PROPERTY:
5474 g_value_set_uint (value, self->some_uint);
5476 case SOME_LONG_PROPERTY:
5477 g_value_set_long (value, self->some_long);
5479 case SOME_ULONG_PROPERTY:
5480 g_value_set_ulong (value, self->some_ulong);
5482 case SOME_INT64_PROPERTY:
5483 g_value_set_int64 (value, self->some_int64);
5485 case SOME_UINT64_PROPERTY:
5486 g_value_set_uint64 (value, self->some_uint64);
5488 case SOME_FLOAT_PROPERTY:
5489 g_value_set_float (value, self->some_float);
5491 case SOME_DOUBLE_PROPERTY:
5492 g_value_set_double (value, self->some_double);
5494 case SOME_STRV_PROPERTY:
5495 g_value_set_boxed (value, self->some_strv);
5497 case SOME_BOXED_STRUCT_PROPERTY:
5498 g_value_set_boxed (value, self->some_boxed_struct);
5500 case SOME_BOXED_GLIST_PROPERTY:
5501 g_value_set_boxed (value, self->some_boxed_glist);
5503 case SOME_GVALUE_PROPERTY:
5504 g_value_set_boxed (value, self->some_gvalue);
5506 case SOME_VARIANT_PROPERTY:
5507 g_value_set_variant (value, self->some_variant);
5509 case SOME_OBJECT_PROPERTY:
5510 g_value_set_object (value, self->some_object);
5512 case SOME_FLAGS_PROPERTY:
5513 g_value_set_flags (value, self->some_flags);
5515 case SOME_ENUM_PROPERTY:
5516 g_value_set_enum (value, self->some_enum);
5518 case SOME_BYTE_ARRAY_PROPERTY:
5519 g_value_set_boxed (value, self->some_byte_array);
5521 case SOME_READONLY_PROPERTY:
5522 g_value_set_int (value, 42);
5525 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
5531 gi_marshalling_tests_properties_object_set_property (GObject *object,
5532 guint property_id, const GValue *value, GParamSpec *pspec)
5534 GIMarshallingTestsPropertiesObject *self;
5535 self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
5536 switch (property_id)
5538 case SOME_BOOLEAN_PROPERTY:
5539 self->some_boolean = g_value_get_boolean (value);
5541 case SOME_CHAR_PROPERTY:
5542 self->some_char = g_value_get_schar (value);
5544 case SOME_UCHAR_PROPERTY:
5545 self->some_uchar = g_value_get_uchar (value);
5547 case SOME_INT_PROPERTY:
5548 self->some_int = g_value_get_int (value);
5550 case SOME_UINT_PROPERTY:
5551 self->some_uint = g_value_get_uint (value);
5553 case SOME_LONG_PROPERTY:
5554 self->some_long = g_value_get_long (value);
5556 case SOME_ULONG_PROPERTY:
5557 self->some_ulong = g_value_get_ulong (value);
5559 case SOME_INT64_PROPERTY:
5560 self->some_int64 = g_value_get_int64 (value);
5562 case SOME_UINT64_PROPERTY:
5563 self->some_uint64 = g_value_get_uint64 (value);
5565 case SOME_FLOAT_PROPERTY:
5566 self->some_float = g_value_get_float (value);
5568 case SOME_DOUBLE_PROPERTY:
5569 self->some_double = g_value_get_double (value);
5571 case SOME_STRV_PROPERTY:
5572 g_strfreev (self->some_strv);
5573 self->some_strv = g_strdupv (g_value_get_boxed (value));
5575 case SOME_BOXED_STRUCT_PROPERTY:
5576 gi_marshalling_tests_boxed_struct_free (self->some_boxed_struct);
5577 self->some_boxed_struct = gi_marshalling_tests_boxed_struct_copy (g_value_get_boxed (value));
5579 case SOME_BOXED_GLIST_PROPERTY:
5580 g_list_free (self->some_boxed_glist);
5581 self->some_boxed_glist = g_list_copy (g_value_get_boxed (value));
5583 case SOME_GVALUE_PROPERTY:
5584 if (self->some_gvalue)
5585 g_boxed_free (G_TYPE_VALUE, self->some_gvalue);
5586 self->some_gvalue = g_value_dup_boxed (value);
5588 case SOME_VARIANT_PROPERTY:
5589 if (self->some_variant != NULL)
5590 g_variant_unref (self->some_variant);
5591 self->some_variant = g_value_get_variant (value);
5592 if (self->some_variant != NULL)
5593 g_variant_ref (self->some_variant);
5595 case SOME_OBJECT_PROPERTY:
5596 if (self->some_object != NULL)
5597 g_object_unref (self->some_object);
5598 self->some_object = g_value_dup_object (value);
5600 case SOME_FLAGS_PROPERTY:
5601 self->some_flags = g_value_get_flags (value);
5603 case SOME_ENUM_PROPERTY:
5604 self->some_enum = g_value_get_enum (value);
5606 case SOME_BYTE_ARRAY_PROPERTY:
5607 if (self->some_byte_array != NULL)
5608 g_byte_array_unref (self->some_byte_array);
5609 self->some_byte_array = g_value_dup_boxed (value);
5612 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
5617 static void gi_marshalling_tests_properties_object_class_init (GIMarshallingTestsPropertiesObjectClass *klass)
5619 GObjectClass *object_class = G_OBJECT_CLASS (klass);
5621 object_class->finalize = gi_marshalling_tests_properties_object_finalize;
5622 object_class->get_property = gi_marshalling_tests_properties_object_get_property;
5623 object_class->set_property = gi_marshalling_tests_properties_object_set_property;
5625 g_object_class_install_property (object_class, SOME_BOOLEAN_PROPERTY,
5626 g_param_spec_boolean ("some-boolean",
5630 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5632 g_object_class_install_property (object_class, SOME_CHAR_PROPERTY,
5633 g_param_spec_char ("some-char",
5635 "some-char", G_MININT8,
5637 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5639 g_object_class_install_property (object_class, SOME_UCHAR_PROPERTY,
5640 g_param_spec_uchar ("some-uchar",
5644 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5646 g_object_class_install_property (object_class, SOME_INT_PROPERTY,
5647 g_param_spec_int ("some-int", "some-int",
5648 "some-int", G_MININT,
5650 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5652 g_object_class_install_property (object_class, SOME_UINT_PROPERTY,
5653 g_param_spec_uint ("some-uint",
5657 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5659 g_object_class_install_property (object_class, SOME_LONG_PROPERTY,
5660 g_param_spec_long ("some-long",
5662 "some-long", G_MINLONG,
5664 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5666 g_object_class_install_property (object_class, SOME_ULONG_PROPERTY,
5667 g_param_spec_ulong ("some-ulong",
5671 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5673 g_object_class_install_property (object_class, SOME_INT64_PROPERTY,
5674 g_param_spec_int64 ("some-int64",
5677 G_MININT64, G_MAXINT64,
5678 0, G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5680 g_object_class_install_property (object_class, SOME_UINT64_PROPERTY,
5681 g_param_spec_uint64 ("some-uint64",
5685 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5687 g_object_class_install_property (object_class, SOME_FLOAT_PROPERTY,
5688 g_param_spec_float ("some-float",
5693 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5695 g_object_class_install_property (object_class, SOME_DOUBLE_PROPERTY,
5696 g_param_spec_double ("some-double",
5701 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5703 g_object_class_install_property (object_class, SOME_STRV_PROPERTY,
5704 g_param_spec_boxed ("some-strv",
5708 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5710 g_object_class_install_property (object_class, SOME_BOXED_STRUCT_PROPERTY,
5711 g_param_spec_boxed ("some-boxed-struct",
5712 "some-boxed-struct",
5713 "some-boxed-struct",
5714 gi_marshalling_tests_boxed_struct_get_type
5715 (), G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5718 * GIMarshallingTestsPropertiesObject:some-boxed-glist: (type GLib.List(gint)) (transfer none):
5720 g_object_class_install_property (object_class, SOME_BOXED_GLIST_PROPERTY,
5721 g_param_spec_boxed ("some-boxed-glist",
5724 gi_marshalling_tests_boxed_glist_get_type
5725 (), G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5727 g_object_class_install_property (object_class, SOME_GVALUE_PROPERTY,
5728 g_param_spec_boxed ("some-gvalue",
5732 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
5734 g_object_class_install_property (object_class, SOME_VARIANT_PROPERTY,
5735 g_param_spec_variant ("some-variant",
5740 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5742 g_object_class_install_property (object_class, SOME_OBJECT_PROPERTY,
5743 g_param_spec_object ("some-object",
5747 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5749 g_object_class_install_property (object_class, SOME_FLAGS_PROPERTY,
5750 g_param_spec_flags ("some-flags",
5753 GI_MARSHALLING_TESTS_TYPE_FLAGS,
5754 GI_MARSHALLING_TESTS_FLAGS_VALUE1,
5755 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5757 g_object_class_install_property (object_class, SOME_ENUM_PROPERTY,
5758 g_param_spec_enum ("some-enum",
5761 GI_MARSHALLING_TESTS_TYPE_GENUM,
5762 GI_MARSHALLING_TESTS_GENUM_VALUE1,
5763 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5765 g_object_class_install_property (object_class, SOME_BYTE_ARRAY_PROPERTY,
5766 g_param_spec_boxed ("some-byte-array",
5770 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
5772 g_object_class_install_property (object_class, SOME_READONLY_PROPERTY,
5773 g_param_spec_int ("some-readonly",
5776 G_MININT, G_MAXINT, 0,
5780 GIMarshallingTestsPropertiesObject *
5781 gi_marshalling_tests_properties_object_new (void)
5783 return g_object_new (GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT, NULL);