gimarshallingtests: Add a utf8-in-bytearray test
[platform/upstream/gobject-introspection.git] / tests / gimarshallingtests.c
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2  * vim: tabstop=4 shiftwidth=4 expandtab
3  */
4
5 #include "gimarshallingtests.h"
6
7 #include <string.h>
8
9 static void gi_marshalling_tests_boxed_struct_free (GIMarshallingTestsBoxedStruct *v);
10
11 /* Booleans */
12
13 gboolean
14 gi_marshalling_tests_boolean_return_true (void)
15 {
16     return TRUE;
17 }
18
19 gboolean
20 gi_marshalling_tests_boolean_return_false (void)
21 {
22     return FALSE;
23 }
24
25 void
26 gi_marshalling_tests_boolean_in_true (gboolean v)
27 {
28     g_assert (v == TRUE);
29 }
30
31 void
32 gi_marshalling_tests_boolean_in_false (gboolean v)
33 {
34     g_assert (v == FALSE);
35 }
36
37 /**
38  * gi_marshalling_tests_boolean_out_true:
39  * @v: (out):
40  */
41 void
42 gi_marshalling_tests_boolean_out_true (gboolean *v)
43 {
44     *v = TRUE;
45 }
46
47 /**
48  * gi_marshalling_tests_boolean_out_false:
49  * @v: (out):
50  */
51 void
52 gi_marshalling_tests_boolean_out_false (gboolean *v)
53 {
54     *v = FALSE;
55 }
56
57 /**
58  * gi_marshalling_tests_boolean_inout_true_false:
59  * @v: (inout):
60  */
61 void
62 gi_marshalling_tests_boolean_inout_true_false (gboolean *v)
63 {
64     g_assert (*v == TRUE);
65     *v = FALSE;
66 }
67
68 /**
69  * gi_marshalling_tests_boolean_inout_false_true:
70  * @v: (inout):
71  */
72 void
73 gi_marshalling_tests_boolean_inout_false_true (gboolean *v)
74 {
75     g_assert (*v == FALSE);
76     *v = TRUE;
77 }
78
79
80 /* Integers */
81
82 gint8
83 gi_marshalling_tests_int8_return_max (void)
84 {
85     return G_MAXINT8;
86 }
87
88 gint8
89 gi_marshalling_tests_int8_return_min (void)
90 {
91     return G_MININT8;
92 }
93
94 void
95 gi_marshalling_tests_int8_in_max (gint8 v)
96 {
97     g_assert_cmpint(v, ==, G_MAXINT8);
98 }
99
100 void
101 gi_marshalling_tests_int8_in_min (gint8 v)
102 {
103     g_assert_cmpint(v, ==, G_MININT8);
104 }
105
106 /**
107  * gi_marshalling_tests_int8_out_max:
108  * @v: (out):
109  */
110 void
111 gi_marshalling_tests_int8_out_max (gint8 *v)
112 {
113     *v = G_MAXINT8;
114 }
115
116 /**
117  * gi_marshalling_tests_int8_out_min:
118  * @v: (out):
119  */
120 void
121 gi_marshalling_tests_int8_out_min (gint8 *v)
122 {
123     *v = G_MININT8;
124 }
125
126 /**
127  * gi_marshalling_tests_int8_inout_max_min:
128  * @v: (inout):
129  */
130 void
131 gi_marshalling_tests_int8_inout_max_min (gint8 *v)
132 {
133     g_assert_cmpint(*v, ==, G_MAXINT8);
134     *v = G_MININT8;
135 }
136
137 /**
138  * gi_marshalling_tests_int8_inout_min_max:
139  * @v: (inout):
140  */
141 void
142 gi_marshalling_tests_int8_inout_min_max (gint8 *v)
143 {
144     g_assert_cmpint(*v, ==, G_MININT8);
145     *v = G_MAXINT8;
146 }
147
148
149 guint8
150 gi_marshalling_tests_uint8_return (void)
151 {
152     return G_MAXUINT8;
153 }
154
155 void
156 gi_marshalling_tests_uint8_in (guint8 v)
157 {
158     g_assert_cmpuint(v, ==, G_MAXUINT8);
159 }
160
161 /**
162  * gi_marshalling_tests_uint8_out:
163  * @v: (out):
164  */
165 void
166 gi_marshalling_tests_uint8_out (guint8 *v)
167 {
168     *v = G_MAXUINT8;
169 }
170
171 /**
172  * gi_marshalling_tests_uint8_inout:
173  * @v: (inout):
174  */
175 void
176 gi_marshalling_tests_uint8_inout (guint8 *v)
177 {
178     g_assert_cmpuint(*v, ==, G_MAXUINT8);
179     *v = 0;
180 }
181
182
183 gint16
184 gi_marshalling_tests_int16_return_max (void)
185 {
186     return G_MAXINT16;
187 }
188
189 gint16
190 gi_marshalling_tests_int16_return_min (void)
191 {
192     return G_MININT16;
193 }
194
195 void
196 gi_marshalling_tests_int16_in_max (gint16 v)
197 {
198     g_assert_cmpint(v, ==, G_MAXINT16);
199 }
200
201 void
202 gi_marshalling_tests_int16_in_min (gint16 v)
203 {
204     g_assert_cmpint(v, ==, G_MININT16);
205 }
206
207 /**
208  * gi_marshalling_tests_int16_out_max:
209  * @v: (out):
210  */
211 void
212 gi_marshalling_tests_int16_out_max (gint16 *v)
213 {
214     *v = G_MAXINT16;
215 }
216
217 /**
218  * gi_marshalling_tests_int16_out_min:
219  * @v: (out):
220  */
221 void
222 gi_marshalling_tests_int16_out_min (gint16 *v)
223 {
224     *v = G_MININT16;
225 }
226
227 /**
228  * gi_marshalling_tests_int16_inout_max_min:
229  * @v: (inout):
230  */
231 void
232 gi_marshalling_tests_int16_inout_max_min (gint16 *v)
233 {
234     g_assert_cmpint(*v, ==, G_MAXINT16);
235     *v = G_MININT16;
236 }
237
238 /**
239  * gi_marshalling_tests_int16_inout_min_max:
240  * @v: (inout):
241  */
242 void
243 gi_marshalling_tests_int16_inout_min_max (gint16 *v)
244 {
245     g_assert_cmpint(*v, ==, G_MININT16);
246     *v = G_MAXINT16;
247 }
248
249
250 guint16
251 gi_marshalling_tests_uint16_return (void)
252 {
253     return G_MAXUINT16;
254 }
255
256 void
257 gi_marshalling_tests_uint16_in (guint16 v)
258 {
259     g_assert_cmpuint(v, ==, G_MAXUINT16);
260 }
261
262 /**
263  * gi_marshalling_tests_uint16_out:
264  * @v: (out):
265  */
266 void
267 gi_marshalling_tests_uint16_out (guint16 *v)
268 {
269     *v = G_MAXUINT16;
270 }
271
272 /**
273  * gi_marshalling_tests_uint16_inout:
274  * @v: (inout):
275  */
276 void
277 gi_marshalling_tests_uint16_inout (guint16 *v)
278 {
279     g_assert_cmpuint(*v, ==, G_MAXUINT16);
280     *v = 0;
281 }
282
283
284 gint32
285 gi_marshalling_tests_int32_return_max (void)
286 {
287     return G_MAXINT32;
288 }
289
290 gint32
291 gi_marshalling_tests_int32_return_min (void)
292 {
293     return G_MININT32;
294 }
295
296 void
297 gi_marshalling_tests_int32_in_max (gint32 v)
298 {
299     g_assert_cmpint(v, ==, G_MAXINT32);
300 }
301
302 void
303 gi_marshalling_tests_int32_in_min (gint32 v)
304 {
305     g_assert_cmpint(v, ==, G_MININT32);
306 }
307
308 /**
309  * gi_marshalling_tests_int32_out_max:
310  * @v: (out):
311  */
312 void
313 gi_marshalling_tests_int32_out_max (gint32 *v)
314 {
315     *v = G_MAXINT32;
316 }
317
318 /**
319  * gi_marshalling_tests_int32_out_min:
320  * @v: (out):
321  */
322 void
323 gi_marshalling_tests_int32_out_min (gint32 *v)
324 {
325     *v = G_MININT32;
326 }
327
328 /**
329  * gi_marshalling_tests_int32_inout_max_min:
330  * @v: (inout):
331  */
332 void
333 gi_marshalling_tests_int32_inout_max_min (gint32 *v)
334 {
335     g_assert_cmpint(*v, ==, G_MAXINT32);
336     *v = G_MININT32;
337 }
338
339 /**
340  * gi_marshalling_tests_int32_inout_min_max:
341  * @v: (inout):
342  */
343 void
344 gi_marshalling_tests_int32_inout_min_max (gint32 *v)
345 {
346     g_assert_cmpint(*v, ==, G_MININT32);
347     *v = G_MAXINT32;
348 }
349
350
351 guint32
352 gi_marshalling_tests_uint32_return (void)
353 {
354     return G_MAXUINT32;
355 }
356
357 void
358 gi_marshalling_tests_uint32_in (guint32 v)
359 {
360     g_assert_cmpuint(v, ==, G_MAXUINT32);
361 }
362
363 /**
364  * gi_marshalling_tests_uint32_out:
365  * @v: (out):
366  */
367 void
368 gi_marshalling_tests_uint32_out (guint32 *v)
369 {
370     *v = G_MAXUINT32;
371 }
372
373 /**
374  * gi_marshalling_tests_uint32_inout:
375  * @v: (inout):
376  */
377 void
378 gi_marshalling_tests_uint32_inout (guint32 *v)
379 {
380     g_assert_cmpuint(*v, ==, G_MAXUINT32);
381     *v = 0;
382 }
383
384
385 gint64
386 gi_marshalling_tests_int64_return_max (void)
387 {
388     return G_MAXINT64;
389 }
390
391 gint64
392 gi_marshalling_tests_int64_return_min (void)
393 {
394     return G_MININT64;
395 }
396
397 void
398 gi_marshalling_tests_int64_in_max (gint64 v)
399 {
400     g_assert_cmpint(v, ==, G_MAXINT64);
401 }
402
403 void
404 gi_marshalling_tests_int64_in_min (gint64 v)
405 {
406     g_assert_cmpint(v, ==, G_MININT64);
407 }
408
409 /**
410  * gi_marshalling_tests_int64_out_max:
411  * @v: (out):
412  */
413 void
414 gi_marshalling_tests_int64_out_max (gint64 *v)
415 {
416     *v = G_MAXINT64;
417 }
418
419 /**
420  * gi_marshalling_tests_int64_out_min:
421  * @v: (out):
422  */
423 void
424 gi_marshalling_tests_int64_out_min (gint64 *v)
425 {
426     *v = G_MININT64;
427 }
428
429 /**
430  * gi_marshalling_tests_int64_inout_max_min:
431  * @v: (inout):
432  */
433 void
434 gi_marshalling_tests_int64_inout_max_min (gint64 *v)
435 {
436     g_assert_cmpint(*v, ==, G_MAXINT64);
437     *v = G_MININT64;
438 }
439
440 /**
441  * gi_marshalling_tests_int64_inout_min_max:
442  * @v: (inout):
443  */
444 void
445 gi_marshalling_tests_int64_inout_min_max (gint64 *v)
446 {
447     g_assert_cmpint(*v, ==, G_MININT64);
448     *v = G_MAXINT64;
449 }
450
451
452 guint64
453 gi_marshalling_tests_uint64_return (void)
454 {
455     return G_MAXUINT64;
456 }
457
458 void
459 gi_marshalling_tests_uint64_in (guint64 v)
460 {
461     g_assert_cmpuint(v, ==, G_MAXUINT64);
462 }
463
464 /**
465  * gi_marshalling_tests_uint64_out:
466  * @v: (out):
467  */
468 void
469 gi_marshalling_tests_uint64_out (guint64 *v)
470 {
471     *v = G_MAXUINT64;
472 }
473
474 /**
475  * gi_marshalling_tests_uint64_inout:
476  * @v: (inout):
477  */
478 void
479 gi_marshalling_tests_uint64_inout (guint64 *v)
480 {
481     g_assert_cmpuint(*v, ==, G_MAXUINT64);
482     *v = 0;
483 }
484
485
486 gshort
487 gi_marshalling_tests_short_return_max (void)
488 {
489     return G_MAXSHORT;
490 }
491
492 gshort
493 gi_marshalling_tests_short_return_min (void)
494 {
495     return G_MINSHORT;
496 }
497
498 void
499 gi_marshalling_tests_short_in_max (gshort short_)
500 {
501     g_assert_cmpint(short_, ==, G_MAXSHORT);
502 }
503
504 void
505 gi_marshalling_tests_short_in_min (gshort short_)
506 {
507     g_assert_cmpint(short_, ==, G_MINSHORT);
508 }
509
510 /**
511  * gi_marshalling_tests_short_out_max:
512  * @short_: (out):
513  */
514 void
515 gi_marshalling_tests_short_out_max (gshort *short_)
516 {
517     *short_ = G_MAXSHORT;
518 }
519
520 /**
521  * gi_marshalling_tests_short_out_min:
522  * @short_: (out):
523  */
524 void
525 gi_marshalling_tests_short_out_min (gshort *short_)
526 {
527     *short_ = G_MINSHORT;
528 }
529
530 /**
531  * gi_marshalling_tests_short_inout_max_min:
532  * @short_: (inout):
533  */
534 void
535 gi_marshalling_tests_short_inout_max_min (gshort *short_)
536 {
537     g_assert_cmpint(*short_, ==, G_MAXSHORT);
538     *short_ = G_MINSHORT;
539 }
540
541 /**
542  * gi_marshalling_tests_short_inout_min_max:
543  * @short_: (inout):
544  */
545 void
546 gi_marshalling_tests_short_inout_min_max (gshort *short_)
547 {
548     g_assert_cmpint(*short_, ==, G_MINSHORT);
549     *short_ = G_MAXSHORT;
550 }
551
552
553 gushort
554 gi_marshalling_tests_ushort_return (void)
555 {
556     return G_MAXUSHORT;
557 }
558
559 void
560 gi_marshalling_tests_ushort_in (gushort ushort_)
561 {
562     g_assert_cmpuint(ushort_, ==, G_MAXUSHORT);
563 }
564
565 /**
566  * gi_marshalling_tests_ushort_out:
567  * @ushort_: (out):
568  */
569 void
570 gi_marshalling_tests_ushort_out (gushort *ushort_)
571 {
572     *ushort_ = G_MAXUSHORT;
573 }
574
575 /**
576  * gi_marshalling_tests_ushort_inout:
577  * @ushort_: (inout):
578  */
579 void
580 gi_marshalling_tests_ushort_inout (gushort *ushort_)
581 {
582     g_assert_cmpuint(*ushort_, ==, G_MAXUSHORT);
583     *ushort_ = 0;
584 }
585
586
587 gint
588 gi_marshalling_tests_int_return_max (void)
589 {
590     return G_MAXINT;
591 }
592
593 gint
594 gi_marshalling_tests_int_return_min (void)
595 {
596     return G_MININT;
597 }
598
599 void
600 gi_marshalling_tests_int_in_max (gint int_)
601 {
602     g_assert_cmpint(int_, ==, G_MAXINT);
603 }
604
605 void
606 gi_marshalling_tests_int_in_min (gint int_)
607 {
608     g_assert_cmpint(int_, ==, G_MININT);
609 }
610
611 /**
612  * gi_marshalling_tests_int_out_max:
613  * @int_: (out):
614  */
615 void
616 gi_marshalling_tests_int_out_max (gint *int_)
617 {
618     *int_ = G_MAXINT;
619 }
620
621 /**
622  * gi_marshalling_tests_int_out_min:
623  * @int_: (out):
624  */
625 void
626 gi_marshalling_tests_int_out_min (gint *int_)
627 {
628     *int_ = G_MININT;
629 }
630
631 /**
632  * gi_marshalling_tests_int_inout_max_min:
633  * @int_: (inout):
634  */
635 void
636 gi_marshalling_tests_int_inout_max_min (gint *int_)
637 {
638     g_assert_cmpint(*int_, ==, G_MAXINT);
639     *int_ = G_MININT;
640 }
641
642 /**
643  * gi_marshalling_tests_int_inout_min_max:
644  * @int_: (inout):
645  */
646 void
647 gi_marshalling_tests_int_inout_min_max (gint *int_)
648 {
649     g_assert_cmpint(*int_, ==, G_MININT);
650     *int_ = G_MAXINT;
651 }
652
653
654 guint
655 gi_marshalling_tests_uint_return (void)
656 {
657     return G_MAXUINT;
658 }
659
660 void
661 gi_marshalling_tests_uint_in (guint uint_)
662 {
663     g_assert_cmpuint(uint_, ==, G_MAXUINT);
664 }
665
666 /**
667  * gi_marshalling_tests_uint_out:
668  * @uint_: (out):
669  */
670 void
671 gi_marshalling_tests_uint_out (guint *uint_)
672 {
673     *uint_ = G_MAXUINT;
674 }
675
676 /**
677  * gi_marshalling_tests_uint_inout:
678  * @uint_: (inout):
679  */
680 void
681 gi_marshalling_tests_uint_inout (guint *uint_)
682 {
683     g_assert_cmpuint(*uint_, ==, G_MAXUINT);
684     *uint_ = 0;
685 }
686
687
688 glong
689 gi_marshalling_tests_long_return_max (void)
690 {
691     return G_MAXLONG;
692 }
693
694 glong
695 gi_marshalling_tests_long_return_min (void)
696 {
697     return G_MINLONG;
698 }
699
700 void
701 gi_marshalling_tests_long_in_max (glong long_)
702 {
703     g_assert_cmpint(long_, ==, G_MAXLONG);
704 }
705
706 void
707 gi_marshalling_tests_long_in_min (glong long_)
708 {
709     g_assert_cmpint(long_, ==, G_MINLONG);
710 }
711
712 /**
713  * gi_marshalling_tests_long_out_max:
714  * @long_: (out):
715  */
716 void
717 gi_marshalling_tests_long_out_max (glong *long_)
718 {
719     *long_ = G_MAXLONG;
720 }
721
722 /**
723  * gi_marshalling_tests_long_out_min:
724  * @long_: (out):
725  */
726 void
727 gi_marshalling_tests_long_out_min (glong *long_)
728 {
729     *long_ = G_MINLONG;
730 }
731
732 /**
733  * gi_marshalling_tests_long_inout_max_min:
734  * @long_: (inout):
735  */
736 void
737 gi_marshalling_tests_long_inout_max_min (glong *long_)
738 {
739     g_assert_cmpint(*long_, ==, G_MAXLONG);
740     *long_ = G_MINLONG;
741 }
742
743 /**
744  * gi_marshalling_tests_long_inout_min_max:
745  * @long_: (inout):
746  */
747 void
748 gi_marshalling_tests_long_inout_min_max (glong *long_)
749 {
750     g_assert_cmpint(*long_, ==, G_MINLONG);
751     *long_ = G_MAXLONG;
752 }
753
754
755 gulong
756 gi_marshalling_tests_ulong_return (void)
757 {
758     return G_MAXULONG;
759 }
760
761 void
762 gi_marshalling_tests_ulong_in (gulong ulong_)
763 {
764     g_assert_cmpuint(ulong_, ==, G_MAXULONG);
765 }
766
767 /**
768  * gi_marshalling_tests_ulong_out:
769  * @ulong_: (out):
770  */
771 void
772 gi_marshalling_tests_ulong_out (gulong *ulong_)
773 {
774     *ulong_ = G_MAXULONG;
775 }
776
777 /**
778  * gi_marshalling_tests_ulong_inout:
779  * @ulong_: (inout):
780  */
781 void
782 gi_marshalling_tests_ulong_inout (gulong *ulong_)
783 {
784     g_assert_cmpuint(*ulong_, ==, G_MAXULONG);
785     *ulong_ = 0;
786 }
787
788
789 gssize
790 gi_marshalling_tests_ssize_return_max (void)
791 {
792     return G_MAXSSIZE;
793 }
794
795 gssize
796 gi_marshalling_tests_ssize_return_min (void)
797 {
798     return G_MINSSIZE;
799 }
800
801 void
802 gi_marshalling_tests_ssize_in_max (gssize ssize)
803 {
804     g_assert_cmpint(ssize, ==, G_MAXSSIZE);
805 }
806
807 void
808 gi_marshalling_tests_ssize_in_min (gssize ssize)
809 {
810     g_assert_cmpint(ssize, ==, G_MINSSIZE);
811 }
812
813 /**
814  * gi_marshalling_tests_ssize_out_max:
815  * @ssize: (out):
816  */
817 void
818 gi_marshalling_tests_ssize_out_max (gssize *ssize)
819 {
820     *ssize = G_MAXSSIZE;
821 }
822
823 /**
824  * gi_marshalling_tests_ssize_out_min:
825  * @ssize: (out):
826  */
827 void
828 gi_marshalling_tests_ssize_out_min (gssize *ssize)
829 {
830     *ssize = G_MINSSIZE;
831 }
832
833 /**
834  * gi_marshalling_tests_ssize_inout_max_min:
835  * @ssize: (inout):
836  */
837 void
838 gi_marshalling_tests_ssize_inout_max_min (gssize *ssize)
839 {
840     g_assert_cmpint(*ssize, ==, G_MAXSSIZE);
841     *ssize = G_MINSSIZE;
842 }
843
844 /**
845  * gi_marshalling_tests_ssize_inout_min_max:
846  * @ssize: (inout):
847  */
848 void
849 gi_marshalling_tests_ssize_inout_min_max (gssize *ssize)
850 {
851     g_assert_cmpint(*ssize, ==, G_MINSSIZE);
852     *ssize = G_MAXSSIZE;
853 }
854
855
856 gsize
857 gi_marshalling_tests_size_return (void)
858 {
859     return G_MAXSIZE;
860 }
861
862 void
863 gi_marshalling_tests_size_in (gsize size)
864 {
865     g_assert_cmpuint(size, ==, G_MAXSIZE);
866 }
867
868 /**
869  * gi_marshalling_tests_size_out:
870  * @size: (out):
871  */
872 void
873 gi_marshalling_tests_size_out (gsize *size)
874 {
875     *size = G_MAXSIZE;
876 }
877
878 /**
879  * gi_marshalling_tests_size_inout:
880  * @size: (inout):
881  */
882 void
883 gi_marshalling_tests_size_inout (gsize *size)
884 {
885     g_assert_cmpuint(*size, ==, G_MAXSIZE);
886     *size = 0;
887 }
888
889
890 gfloat
891 gi_marshalling_tests_float_return (void)
892 {
893     return G_MAXFLOAT;
894 }
895
896 void
897 gi_marshalling_tests_float_in (gfloat v)
898 {
899     g_assert_cmpfloat(v, ==, G_MAXFLOAT);
900 }
901
902 /**
903  * gi_marshalling_tests_float_out:
904  * @v: (out):
905  */
906 void
907 gi_marshalling_tests_float_out (gfloat *v)
908 {
909     *v = G_MAXFLOAT;
910 }
911
912 /**
913  * gi_marshalling_tests_float_inout:
914  * @v: (inout):
915  */
916 void
917 gi_marshalling_tests_float_inout (gfloat *v)
918 {
919     g_assert_cmpfloat(*v, ==, G_MAXFLOAT);
920     *v = G_MINFLOAT;
921 }
922
923
924 gdouble
925 gi_marshalling_tests_double_return (void)
926 {
927     return G_MAXDOUBLE;
928 }
929
930 void
931 gi_marshalling_tests_double_in (gdouble v)
932 {
933     g_assert_cmpfloat(v, ==, G_MAXDOUBLE);
934 }
935
936 /**
937  * gi_marshalling_tests_double_out:
938  * @v: (out):
939  */
940 void
941 gi_marshalling_tests_double_out (gdouble *v)
942 {
943     *v = G_MAXDOUBLE;
944 }
945
946 /**
947  * gi_marshalling_tests_double_inout:
948  * @v: (inout):
949  */
950 void
951 gi_marshalling_tests_double_inout (gdouble *v)
952 {
953     g_assert_cmpfloat(*v, ==, G_MAXDOUBLE);
954     *v = G_MINDOUBLE;
955 }
956
957
958 time_t
959 gi_marshalling_tests_time_t_return (void)
960 {
961     return 1234567890;
962 }
963
964 void
965 gi_marshalling_tests_time_t_in (time_t v)
966 {
967     g_assert_cmpuint(v, ==, 1234567890);
968 }
969
970 /**
971  * gi_marshalling_tests_time_t_out:
972  * @v: (out):
973  */
974 void
975 gi_marshalling_tests_time_t_out (time_t *v)
976 {
977     *v = 1234567890;
978 }
979
980 /**
981  * gi_marshalling_tests_time_t_inout:
982  * @v: (inout):
983  */
984 void
985 gi_marshalling_tests_time_t_inout (time_t *v)
986 {
987     g_assert_cmpuint(*v, ==, 1234567890);
988     *v = 0;
989 }
990
991
992 GType
993 gi_marshalling_tests_gtype_return (void)
994 {
995     return G_TYPE_NONE;
996 }
997
998 GType
999 gi_marshalling_tests_gtype_string_return (void)
1000 {
1001     return G_TYPE_STRING;
1002 }
1003
1004 void
1005 gi_marshalling_tests_gtype_in (GType gtype)
1006 {
1007     g_assert(gtype == G_TYPE_NONE);
1008 }
1009
1010 void
1011 gi_marshalling_tests_gtype_string_in (GType gtype)
1012 {
1013     g_assert(gtype == G_TYPE_STRING);
1014 }
1015
1016
1017 /**
1018  * gi_marshalling_tests_gtype_out:
1019  * @gtype: (out):
1020  */
1021 void
1022 gi_marshalling_tests_gtype_out (GType *gtype)
1023 {
1024     *gtype = G_TYPE_NONE;
1025 }
1026
1027 /**
1028  * gi_marshalling_tests_gtype_string_out:
1029  * @gtype: (out):
1030  */
1031 void
1032 gi_marshalling_tests_gtype_string_out (GType *gtype)
1033 {
1034     *gtype = G_TYPE_STRING;
1035 }
1036
1037 /**
1038  * gi_marshalling_tests_gtype_inout:
1039  * @gtype: (inout):
1040  */
1041 void
1042 gi_marshalling_tests_gtype_inout (GType *gtype)
1043 {
1044     g_assert(*gtype == G_TYPE_NONE);
1045     *gtype = G_TYPE_INT;
1046 }
1047
1048
1049 const gchar *
1050 gi_marshalling_tests_utf8_none_return (void)
1051 {
1052     return GI_MARSHALLING_TESTS_CONSTANT_UTF8;
1053 }
1054
1055 gchar *
1056 gi_marshalling_tests_utf8_full_return (void)
1057 {
1058     return g_strdup(GI_MARSHALLING_TESTS_CONSTANT_UTF8);
1059 }
1060
1061 void
1062 gi_marshalling_tests_utf8_none_in (const gchar *utf8)
1063 {
1064     g_assert_cmpstr(GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, utf8);
1065 }
1066
1067 /**
1068  * gi_marshalling_tests_utf8_as_uint8array_in:
1069  * @array: (array length=len) (element-type guint8): Byte data that happens to be UTF-8
1070  * @len: Length
1071  *
1072  * Takes data that happens to be UTF-8 as a byte array, to test
1073  * binding conversion from their string type (e.g. JavaScript's
1074  * UTF-16) to UTF-8.
1075  */
1076 void
1077 gi_marshalling_tests_utf8_as_uint8array_in (const guint8 *array,
1078                                             gsize         len)
1079 {
1080   gsize orig_len = strlen (GI_MARSHALLING_TESTS_CONSTANT_UTF8);
1081   g_assert_cmpint (orig_len, ==, len);
1082   g_assert (memcmp (GI_MARSHALLING_TESTS_CONSTANT_UTF8, array, len) == 0);
1083 }
1084
1085 /**
1086  * gi_marshalling_tests_utf8_none_out:
1087  * @utf8: (out) (transfer none):
1088  */
1089 void
1090 gi_marshalling_tests_utf8_none_out (gchar **utf8)
1091 {
1092     *utf8 = GI_MARSHALLING_TESTS_CONSTANT_UTF8;
1093 }
1094
1095 /**
1096  * gi_marshalling_tests_utf8_full_out:
1097  * @utf8: (out) (transfer full):
1098  */
1099 void
1100 gi_marshalling_tests_utf8_full_out (gchar **utf8)
1101 {
1102     *utf8 = g_strdup(GI_MARSHALLING_TESTS_CONSTANT_UTF8);
1103 }
1104
1105 /**
1106  * gi_marshalling_tests_utf8_dangling_out:
1107  * @utf8: (out) (transfer full):
1108  */
1109 void
1110 gi_marshalling_tests_utf8_dangling_out (gchar **utf8)
1111 {
1112     /* Intentionally don't touch the pointer to see how
1113        the bindings handle this case.  Bindings should be
1114        robust against broken C functions and can initialize
1115        even OUT vlues to NULL.
1116     */
1117 }
1118
1119 /**
1120  * gi_marshalling_tests_utf8_none_inout:
1121  * @utf8: (inout) (transfer none):
1122  */
1123 void
1124 gi_marshalling_tests_utf8_none_inout (gchar **utf8)
1125 {
1126     g_assert_cmpstr(GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, *utf8);
1127     *utf8 = "";
1128 }
1129
1130 /**
1131  * gi_marshalling_tests_utf8_full_inout:
1132  * @utf8: (inout) (transfer full):
1133  */
1134 void
1135 gi_marshalling_tests_utf8_full_inout (gchar **utf8)
1136 {
1137     g_assert_cmpstr(GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, *utf8);
1138     g_free(*utf8);
1139     *utf8 = g_strdup("");
1140 }
1141
1142
1143 /**
1144  * gi_marshalling_tests_init_function:
1145  * @n_args: (inout) (allow-none): number of args
1146  * @argv: (inout) (array length=n_args) (allow-none): args
1147  *
1148  * This is like gtk_init().
1149  */
1150 gboolean
1151 gi_marshalling_tests_init_function (gint *n_args, char ***argv)
1152 {
1153     if (n_args == NULL)
1154         return TRUE;
1155
1156     if (*n_args == 0)
1157         return TRUE;
1158     (*n_args)--;
1159     g_assert (argv != NULL);
1160     (*argv)[*n_args] = NULL;
1161     return TRUE;
1162 }
1163
1164 /**
1165  * gi_marshalling_tests_array_fixed_int_return:
1166  *
1167  * Returns: (array fixed-size=4):
1168  */
1169 const gint *
1170 gi_marshalling_tests_array_fixed_int_return (void)
1171 {
1172     static gint ints[] = {-1, 0, 1, 2};
1173     return ints;
1174 }
1175
1176 /**
1177  * gi_marshalling_tests_array_fixed_short_return:
1178  *
1179  * Returns: (array fixed-size=4):
1180  */
1181 const gshort *
1182 gi_marshalling_tests_array_fixed_short_return (void)
1183 {
1184     static gshort shorts[] = {-1, 0, 1, 2};
1185     return shorts;
1186 }
1187
1188 /**
1189  * gi_marshalling_tests_array_fixed_int_in:
1190  * @ints: (array fixed-size=4):
1191  */
1192 void
1193 gi_marshalling_tests_array_fixed_int_in (const gint *ints)
1194 {
1195     g_assert_cmpint(ints[0], ==, -1);
1196     g_assert_cmpint(ints[1], ==, 0);
1197     g_assert_cmpint(ints[2], ==, 1);
1198     g_assert_cmpint(ints[3], ==, 2);
1199 }
1200
1201 /**
1202  * gi_marshalling_tests_array_fixed_short_in:
1203  * @shorts: (array fixed-size=4):
1204  */
1205 void
1206 gi_marshalling_tests_array_fixed_short_in (const gshort *shorts)
1207 {
1208     g_assert_cmpint(shorts[0], ==, -1);
1209     g_assert_cmpint(shorts[1], ==, 0);
1210     g_assert_cmpint(shorts[2], ==, 1);
1211     g_assert_cmpint(shorts[3], ==, 2);
1212 }
1213
1214 /**
1215  * gi_marshalling_tests_array_fixed_out:
1216  * @ints: (out) (array fixed-size=4) (transfer none):
1217  */
1218 void
1219 gi_marshalling_tests_array_fixed_out (gint **ints)
1220 {
1221     static gint values[] = {-1, 0, 1, 2};
1222     *ints = values;
1223 }
1224
1225 /**
1226  * gi_marshalling_tests_array_fixed_out_struct:
1227  * @structs: (out) (array fixed-size=2) (transfer none):
1228  */
1229 void
1230 gi_marshalling_tests_array_fixed_out_struct (GIMarshallingTestsSimpleStruct **structs)
1231 {
1232     static GIMarshallingTestsSimpleStruct *values;
1233
1234     if (values == NULL) {
1235         values = g_new(GIMarshallingTestsSimpleStruct, 2);
1236
1237         values[0].long_ = 7;
1238         values[0].int8 = 6;
1239
1240         values[1].long_ = 6;
1241         values[1].int8 = 7;
1242     }
1243
1244     *structs = values;
1245 }
1246
1247 /**
1248  * gi_marshalling_tests_array_fixed_inout:
1249  * @ints: (inout) (array fixed-size=4) (transfer none):
1250  */
1251 void
1252 gi_marshalling_tests_array_fixed_inout (gint **ints)
1253 {
1254     static gint values[] = {2, 1, 0, -1};
1255
1256     g_assert_cmpint((*ints)[0], ==, -1);
1257     g_assert_cmpint((*ints)[1], ==, 0);
1258     g_assert_cmpint((*ints)[2], ==, 1);
1259     g_assert_cmpint((*ints)[3], ==, 2);
1260
1261     *ints = values;
1262 }
1263
1264
1265 /**
1266  * gi_marshalling_tests_array_return:
1267  *
1268  * Returns: (array length=length):
1269  */
1270 const gint *
1271 gi_marshalling_tests_array_return (gint *length)
1272 {
1273     static gint ints[] = {-1, 0, 1, 2};
1274
1275     *length = 4;
1276     return ints;
1277 }
1278
1279 /**
1280  * gi_marshalling_tests_array_return_etc:
1281  * @first:
1282  * @length: (out):
1283  * @last:
1284  * @sum: (out):
1285  *
1286  * Returns: (array length=length):
1287  */
1288 const gint *
1289 gi_marshalling_tests_array_return_etc (gint first, gint *length, gint last, gint *sum)
1290 {
1291     static gint ints[] = {-1, 0, 1, 2};
1292
1293     ints[0] = first;
1294     ints[3] = last;
1295     *sum = first + last;
1296     *length = 4;
1297     return ints;
1298 }
1299
1300 /**
1301  * gi_marshalling_tests_array_in:
1302  * @ints: (array length=length):
1303  * @length:
1304  */
1305 void
1306 gi_marshalling_tests_array_in (const gint *ints, gint length)
1307 {
1308     g_assert_cmpint(length, ==, 4);
1309     g_assert_cmpint(ints[0], ==, -1);
1310     g_assert_cmpint(ints[1], ==, 0);
1311     g_assert_cmpint(ints[2], ==, 1);
1312     g_assert_cmpint(ints[3], ==, 2);
1313 }
1314
1315 /**
1316  * gi_marshalling_tests_array_in_len_before:
1317  * @length:
1318  * @ints: (array length=length):
1319  */
1320 void
1321 gi_marshalling_tests_array_in_len_before (gint length, const gint *ints)
1322 {
1323     gi_marshalling_tests_array_in (ints, length);
1324 }
1325
1326 /**
1327  * gi_marshalling_tests_array_in_len_zero_terminated:
1328  * @ints: (array length=length zero-terminated=1):
1329  * @length:
1330  */
1331 void
1332 gi_marshalling_tests_array_in_len_zero_terminated (const gint *ints, gint length)
1333 {
1334     g_assert_cmpint(length, ==, 4);
1335
1336     g_assert_cmpint(ints[0], ==, -1);
1337     g_assert_cmpint(ints[1], ==, 0);
1338     g_assert_cmpint(ints[2], ==, 1);
1339     g_assert_cmpint(ints[3], ==, 2);
1340
1341     /* One past the end, null terminator */
1342     g_assert_cmpint(ints[4], ==, 0);
1343 }
1344
1345 /**
1346  * gi_marshalling_tests_array_string_in:
1347  * @strings: (array length=length):
1348  */
1349 void
1350 gi_marshalling_tests_array_string_in (const gchar **strings, gint length)
1351 {
1352     g_assert_cmpint(length, ==, 2);
1353     g_assert_cmpstr(strings[0], ==, "foo");
1354     g_assert_cmpstr(strings[1], ==, "bar");
1355 }
1356
1357 /**
1358  * gi_marshalling_tests_array_uint8_in:
1359  * @chars: (array length=length):
1360  */
1361 void
1362 gi_marshalling_tests_array_uint8_in (const guint8 *chars, gint length)
1363 {
1364     g_assert_cmpint(length, ==, 4);
1365     g_assert(chars[0] == 'a');
1366     g_assert(chars[1] == 'b');
1367     g_assert(chars[2] == 'c');
1368     g_assert(chars[3] == 'd');
1369 }
1370
1371 /**
1372  * gi_marshalling_tests_array_struct_in:
1373  * @structs: (array length=length):
1374  */
1375 void
1376 gi_marshalling_tests_array_struct_in (GIMarshallingTestsBoxedStruct **structs, gint length)
1377 {
1378     g_assert_cmpint(length, ==, 3);
1379     g_assert_cmpint(structs[0]->long_, ==, 1);
1380     g_assert_cmpint(structs[1]->long_, ==, 2);
1381     g_assert_cmpint(structs[2]->long_, ==, 3);
1382 }
1383
1384 /**
1385  * gi_marshalling_tests_array_simple_struct_in:
1386  * @structs: (array length=length):
1387  */
1388 void
1389 gi_marshalling_tests_array_simple_struct_in (GIMarshallingTestsSimpleStruct *structs, gint length)
1390 {
1391     g_assert_cmpint(length, ==, 3);
1392     g_assert_cmpint(structs[0].long_, ==, 1);
1393     g_assert_cmpint(structs[1].long_, ==, 2);
1394     g_assert_cmpint(structs[2].long_, ==, 3);
1395 }
1396
1397 /**
1398  * gi_marshalling_tests_multi_array_key_value_in:
1399  * @keys: (array length=length):
1400  * @values: (array length=length):
1401  */
1402 void
1403 gi_marshalling_tests_multi_array_key_value_in (gint length, const gchar **keys, const GValue *values)
1404 {
1405     g_assert_cmpint(length, ==, 3);
1406     g_assert_cmpstr("one", ==, keys[0]);
1407     g_assert_cmpint(g_value_get_int(&values[0]), ==, 1);
1408     g_assert_cmpstr("two", ==, keys[1]);
1409     g_assert_cmpint(g_value_get_int(&values[1]), ==, 2);
1410     g_assert_cmpstr("three", ==, keys[2]);
1411     g_assert_cmpint(g_value_get_int(&values[2]), ==, 3);
1412
1413 }
1414
1415 /**
1416  * gi_marshalling_tests_array_struct_take_in:
1417  * @structs: (array length=length) (transfer full):
1418  */
1419 void
1420 gi_marshalling_tests_array_struct_take_in (GIMarshallingTestsBoxedStruct **structs, gint length)
1421 {
1422     gi_marshalling_tests_array_struct_in (structs, length);
1423
1424     /* only really useful if run in valgrind actually */
1425     gi_marshalling_tests_boxed_struct_free (structs[0]);
1426     gi_marshalling_tests_boxed_struct_free (structs[1]);
1427     gi_marshalling_tests_boxed_struct_free (structs[2]);
1428     g_free (structs);
1429 }
1430
1431 /**
1432  * gi_marshalling_tests_array_enum_in:
1433  * @_enum: (array length=length) (transfer none):
1434  * @length:
1435  */
1436 void
1437 gi_marshalling_tests_array_enum_in (GIMarshallingTestsEnum *v, gint length)
1438 {
1439     g_assert_cmpint(length, ==, 3);
1440     g_assert_cmpint(v[0], ==, GI_MARSHALLING_TESTS_ENUM_VALUE1);
1441     g_assert_cmpint(v[1], ==, GI_MARSHALLING_TESTS_ENUM_VALUE2);
1442     g_assert_cmpint(v[2], ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
1443 }
1444
1445 /**
1446  * gi_marshalling_tests_array_in_guint64_len:
1447  * @ints: (array length=length) (transfer none):
1448  * @length:
1449  */
1450 void
1451 gi_marshalling_tests_array_in_guint64_len (const gint *ints, guint64 length)
1452 {
1453     g_assert_cmpint(length, ==, 4);
1454
1455     gi_marshalling_tests_array_in (ints, length);
1456 }
1457
1458 /**
1459  * gi_marshalling_tests_array_in_guint8_len:
1460  * @ints: (array length=length) (transfer none):
1461  * @length:
1462  */
1463 void
1464 gi_marshalling_tests_array_in_guint8_len (const gint *ints, guint8 length)
1465 {
1466     g_assert_cmpint(length, ==, 4);
1467
1468     gi_marshalling_tests_array_in (ints, length);
1469 }
1470
1471 /**
1472  * gi_marshalling_tests_array_out:
1473  * @ints: (out) (array length=length) (transfer none):
1474  */
1475 void
1476 gi_marshalling_tests_array_out (gint **ints, gint *length)
1477 {
1478     static gint values[] = {-1, 0, 1, 2};
1479
1480     *length = 4;
1481     *ints = values;
1482 }
1483
1484 /**
1485  * gi_marshalling_tests_array_out_etc:
1486  * @first:
1487  * @ints: (out) (array length=length) (transfer none):
1488  * @length: (out):
1489  * @last:
1490  * @sum: (out):
1491  */
1492 void
1493 gi_marshalling_tests_array_out_etc (gint first, gint **ints, gint *length, gint last, gint *sum)
1494 {
1495     static gint values[] = {-1, 0, 1, 2};
1496
1497     values[0] = first;
1498     values[3] = last;
1499     *sum = first + last;
1500     *length = 4;
1501     *ints = values;
1502 }
1503
1504 /**
1505  * gi_marshalling_tests_array_inout:
1506  * @ints: (inout) (array length=length) (transfer none):
1507  * @length: (inout):
1508  */
1509 void
1510 gi_marshalling_tests_array_inout (gint **ints, gint *length)
1511 {
1512     static gint values[] = {-2, -1, 0, 1, 2};
1513
1514     g_assert_cmpint(*length, ==, 4);
1515     g_assert_cmpint((*ints)[0], ==, -1);
1516     g_assert_cmpint((*ints)[1], ==, 0);
1517     g_assert_cmpint((*ints)[2], ==, 1);
1518     g_assert_cmpint((*ints)[3], ==, 2);
1519
1520     *length = 5;
1521     *ints = values;
1522 }
1523
1524 /**
1525  * gi_marshalling_tests_array_inout_etc:
1526  * @first:
1527  * @ints: (inout) (array length=length) (transfer none):
1528  * @length: (inout):
1529  * @last:
1530  * @sum: (out):
1531  */
1532 void
1533 gi_marshalling_tests_array_inout_etc (gint first, gint **ints, gint *length, gint last, gint *sum)
1534 {
1535     static gint values[] = {-2, -1, 0, 1, 2};
1536
1537     g_assert_cmpint(*length, ==, 4);
1538     g_assert_cmpint((*ints)[0], ==, -1);
1539     g_assert_cmpint((*ints)[1], ==, 0);
1540     g_assert_cmpint((*ints)[2], ==, 1);
1541     g_assert_cmpint((*ints)[3], ==, 2);
1542
1543     values[0] = first;
1544     values[4] = last;
1545     *sum = first + last;
1546     *length = 5;
1547     *ints = values;
1548 }
1549
1550 /**
1551  * gi_marshalling_tests_array_in_nonzero_nonlen:
1552  * @first:
1553  * @chars: (array):
1554  */
1555 void
1556 gi_marshalling_tests_array_in_nonzero_nonlen (gint first, const guint8 *chars)
1557 {
1558     g_assert(chars[0] == 'a');
1559     g_assert(chars[1] == 'b');
1560     g_assert(chars[2] == 'c');
1561     g_assert(chars[3] == 'd');
1562 }
1563
1564 /**
1565  * gi_marshalling_tests_array_zero_terminated_return:
1566  *
1567  * Returns: (array zero-terminated=1) (transfer none):
1568  */
1569 gchar **
1570 gi_marshalling_tests_array_zero_terminated_return (void)
1571 {
1572     static gchar *values[] = {"0", "1", "2", NULL};
1573     return values;
1574 }
1575
1576 /**
1577  * gi_marshalling_tests_array_zero_terminated_return_null:
1578  *
1579  * Returns: (array zero-terminated=1) (transfer none):
1580  */
1581 gchar **
1582 gi_marshalling_tests_array_zero_terminated_return_null (void)
1583 {
1584     return NULL;
1585 }
1586
1587 /**
1588  * gi_marshalling_tests_array_zero_terminated_return_struct:
1589  *
1590  * Returns: (array zero-terminated=1) (transfer full):
1591  */
1592 GIMarshallingTestsBoxedStruct **
1593 gi_marshalling_tests_array_zero_terminated_return_struct (void)
1594 {
1595     GIMarshallingTestsBoxedStruct **ret = (GIMarshallingTestsBoxedStruct**) g_new (gpointer, 4);
1596
1597     ret[0] = gi_marshalling_tests_boxed_struct_new ();
1598     ret[0]->long_ = 42;
1599
1600     ret[1] = gi_marshalling_tests_boxed_struct_new ();
1601     ret[1]->long_ = 43;
1602
1603     ret[2] = gi_marshalling_tests_boxed_struct_new ();
1604     ret[2]->long_ = 44;
1605
1606     ret[3] = NULL;
1607
1608     return ret;
1609 }
1610
1611 /**
1612  * gi_marshalling_tests_array_zero_terminated_in:
1613  * @utf8s: (array zero-terminated=1) (transfer none):
1614  */
1615 void
1616 gi_marshalling_tests_array_zero_terminated_in (gchar **utf8s)
1617 {
1618     g_assert(g_strv_length(utf8s));
1619     g_assert_cmpstr(utf8s[0], ==, "0");
1620     g_assert_cmpstr(utf8s[1], ==, "1");
1621     g_assert_cmpstr(utf8s[2], ==, "2");
1622 }
1623
1624 /**
1625  * gi_marshalling_tests_array_zero_terminated_out:
1626  * @utf8s: (out) (array zero-terminated=1) (transfer none):
1627  */
1628 void
1629 gi_marshalling_tests_array_zero_terminated_out (gchar ***utf8s)
1630 {
1631     static gchar *values[] = {"0", "1", "2", NULL};
1632     *utf8s = values;
1633 }
1634
1635 /**
1636  * gi_marshalling_tests_array_zero_terminated_inout:
1637  * @utf8s: (inout) (array zero-terminated=1) (transfer none):
1638  */
1639 void
1640 gi_marshalling_tests_array_zero_terminated_inout (gchar ***utf8s)
1641 {
1642     static gchar *values[] = {"-1", "0", "1", "2", NULL};
1643
1644     g_assert(g_strv_length(*utf8s));
1645     g_assert_cmpstr((*utf8s)[0], ==, "0");
1646     g_assert_cmpstr((*utf8s)[1], ==, "1");
1647     g_assert_cmpstr((*utf8s)[2], ==, "2");
1648
1649     *utf8s = values;
1650 }
1651
1652 /**
1653  * gi_marshalling_tests_array_gvariant_none_in:
1654  * @variants: (array zero-terminated=1) (transfer none):
1655  *
1656  * Returns: (array zero-terminated=1) (transfer none):
1657  */
1658 GVariant **
1659 gi_marshalling_tests_array_gvariant_none_in (GVariant **variants)
1660 {
1661     /* Use a static container to detect if someone tries to free it */
1662     static GVariant *private_container[3] = { NULL, NULL, NULL };
1663     
1664     if (private_container[0] == NULL) {
1665       private_container[0] = g_variant_new_int32 (27);
1666       private_container[1] = g_variant_new_string ("Hello");
1667     }
1668
1669     g_assert (variants != NULL);
1670     g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1671     g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1672     g_assert (variants[2] == NULL);
1673
1674     return private_container;
1675 }
1676
1677 /**
1678  * gi_marshalling_tests_array_gvariant_container_in:
1679  * @variants: (array zero-terminated=1) (transfer container):
1680  *
1681  * Returns: (array zero-terminated=1) (transfer container):
1682  */
1683 GVariant **
1684 gi_marshalling_tests_array_gvariant_container_in (GVariant **variants)
1685 {
1686     GVariant **container;
1687
1688     g_assert (variants != NULL);
1689     g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1690     g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1691     g_assert (variants[2] == NULL);
1692     
1693     container = g_new0 (GVariant*, 3);
1694     container[0] = variants[0];
1695     container[1] = variants[1];
1696     g_free (variants);
1697     
1698     return container;
1699 }
1700
1701 /**
1702  * gi_marshalling_tests_array_gvariant_full_in:
1703  * @variants: (array zero-terminated=1) (transfer full):
1704  *
1705  * Returns: (array zero-terminated=1) (transfer full):
1706  */
1707 GVariant **
1708 gi_marshalling_tests_array_gvariant_full_in (GVariant **variants)
1709 {
1710     GVariant **container;
1711
1712     g_assert (variants != NULL);
1713     g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1714     g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1715     g_assert (variants[2] == NULL);
1716     
1717     /* To catch different behaviors we reconstruct one variant from scratch,
1718      * while leaving the other untouched. Both approaches are legal with full
1719      * transfer in and out */
1720     container = g_new0 (GVariant*, 3);
1721     container[0] = g_variant_new_int32 (g_variant_get_int32 (variants[0]));
1722     g_variant_unref (variants[0]);
1723     container[1] = variants[1];
1724     g_free (variants);
1725
1726     return container;
1727 }
1728
1729 /**
1730  * gi_marshalling_tests_garray_int_none_return:
1731  *
1732  * Returns: (element-type gint) (transfer none):
1733  */
1734 GArray *
1735 gi_marshalling_tests_garray_int_none_return (void)
1736 {
1737     static GArray *v = NULL;
1738     gint i;
1739
1740     if (v == NULL) {
1741         v = g_array_new (TRUE, TRUE, sizeof (gint));
1742         for (i = -1; i < 3; i++)
1743             g_array_append_val (v, i);
1744     }
1745
1746     return v;
1747 }
1748
1749 /**
1750  * gi_marshalling_tests_garray_uint64_none_return:
1751  *
1752  * Returns: (element-type guint64) (transfer none):
1753  */
1754 GArray *
1755 gi_marshalling_tests_garray_uint64_none_return (void)
1756 {
1757     static GArray *array = NULL;
1758     guint64 i;
1759
1760     if (array == NULL) {
1761         array = g_array_new (TRUE, TRUE, sizeof (guint64));
1762         i = 0;
1763         g_array_append_val (array, i);
1764         i = G_MAXUINT64;
1765         g_array_append_val (array, i);
1766     }
1767
1768     return array;
1769 }
1770
1771 /**
1772  * gi_marshalling_tests_garray_utf8_none_return:
1773  *
1774  * Returns: (element-type utf8) (transfer none):
1775  */
1776 GArray *
1777 gi_marshalling_tests_garray_utf8_none_return (void)
1778 {
1779     static GArray *array = NULL;
1780     static gchar *values[] = {"0", "1", "2", NULL};
1781     gint i;
1782
1783     if (array == NULL) {
1784         array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1785         for (i = 0; values[i]; i++)
1786             g_array_append_val (array, values[i]);
1787     }
1788
1789     return array;
1790 }
1791
1792 /**
1793  * gi_marshalling_tests_garray_utf8_container_return:
1794  *
1795  * Returns: (element-type utf8) (transfer container):
1796  */
1797 GArray *
1798 gi_marshalling_tests_garray_utf8_container_return (void)
1799 {
1800     GArray *array = NULL;
1801     static gchar *values[] = {"0", "1", "2", NULL};
1802     gint i;
1803
1804     array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1805     for (i = 0; values[i]; i++)
1806         g_array_append_val (array, values[i]);
1807
1808     return array;
1809 }
1810
1811 /**
1812  * gi_marshalling_tests_garray_utf8_full_return:
1813  *
1814  * Returns: (element-type utf8) (transfer full):
1815  */
1816 GArray *
1817 gi_marshalling_tests_garray_utf8_full_return (void)
1818 {
1819     GArray *array = NULL;
1820     static gchar *values[] = {"0", "1", "2", NULL};
1821     gint i;
1822
1823     array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1824     for (i = 0; values[i]; i++) {
1825         gchar *str = g_strdup (values[i]);
1826         g_array_append_val (array, str);
1827     }
1828
1829     return array;
1830 }
1831
1832 /**
1833  * gi_marshalling_tests_garray_int_none_in:
1834  * @array_: (element-type gint) (transfer none):
1835  */
1836 void
1837 gi_marshalling_tests_garray_int_none_in (GArray *array_)
1838 {
1839     g_assert_cmpint(array_->len, ==, 4);
1840     g_assert_cmpint(g_array_index (array_, gint, 0), ==, -1);
1841     g_assert_cmpint(g_array_index (array_, gint, 1), ==, 0);
1842     g_assert_cmpint(g_array_index (array_, gint, 2), ==, 1);
1843     g_assert_cmpint(g_array_index (array_, gint, 3), ==, 2);
1844 }
1845
1846 /**
1847  * gi_marshalling_tests_garray_uint64_none_in:
1848  * @array_: (element-type guint64) (transfer none):
1849  */
1850 void
1851 gi_marshalling_tests_garray_uint64_none_in (GArray *array_)
1852 {
1853     g_assert_cmpint(array_->len, ==, 2);
1854     g_assert_cmpint(g_array_index (array_, guint64, 0), ==, 0);
1855     g_assert_cmpint(g_array_index (array_, guint64, 1), ==, G_MAXUINT64);
1856 }
1857
1858 /**
1859  * gi_marshalling_tests_garray_utf8_none_in:
1860  * @array_: (element-type utf8) (transfer none):
1861  */
1862 void
1863 gi_marshalling_tests_garray_utf8_none_in (GArray *array_)
1864 {
1865     g_assert_cmpint(array_->len, ==, 3);
1866     g_assert_cmpstr(g_array_index (array_, gchar*, 0), ==, "0");
1867     g_assert_cmpstr(g_array_index (array_, gchar*, 1), ==, "1");
1868     g_assert_cmpstr(g_array_index (array_, gchar*, 2), ==, "2");
1869 }
1870
1871 /**
1872  * gi_marshalling_tests_garray_utf8_none_out:
1873  * @array_: (out) (element-type utf8) (transfer none):
1874  */
1875 void
1876 gi_marshalling_tests_garray_utf8_none_out (GArray **array_)
1877 {
1878     static GArray *internal = NULL;
1879     static gchar *values[] = {"0", "1", "2", NULL};
1880     gint i;
1881
1882     if (internal == NULL) {
1883         internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
1884         for (i = 0; values[i]; i++)
1885             g_array_append_val (internal, values[i]);
1886     }
1887
1888     *array_ = internal;
1889 }
1890
1891 /**
1892  * gi_marshalling_tests_garray_utf8_container_out:
1893  * @array_: (out) (element-type utf8) (transfer container):
1894  */
1895 void
1896 gi_marshalling_tests_garray_utf8_container_out (GArray **array_)
1897 {
1898     static gchar *values[] = {"0", "1", "2", NULL};
1899     gint i;
1900
1901     *array_ = NULL;
1902
1903     *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
1904     for (i = 0; values[i]; i++)
1905         g_array_append_val (*array_, values[i]);
1906 }
1907
1908 /**
1909  * gi_marshalling_tests_garray_utf8_full_out:
1910  * @array_: (out) (element-type utf8) (transfer full):
1911  */
1912 void
1913 gi_marshalling_tests_garray_utf8_full_out (GArray **array_)
1914 {
1915     static gchar *values[] = {"0", "1", "2", NULL};
1916     gint i;
1917
1918     *array_ = NULL;
1919
1920     *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
1921     for (i = 0; values[i]; i++) {
1922         gchar *str = g_strdup (values[i]);
1923         g_array_append_val (*array_, str);
1924     }
1925 }
1926
1927 /**
1928  * gi_marshalling_tests_garray_utf8_none_inout:
1929  * @array_: (inout) (element-type utf8) (transfer none):
1930  */
1931 void
1932 gi_marshalling_tests_garray_utf8_none_inout (GArray **array_)
1933 {
1934     static GArray *internal = NULL;
1935     static gchar *values[] = {"-2", "-1", "0", "1", NULL};
1936     gint i;
1937
1938     g_assert_cmpint((*array_)->len, ==, 3);
1939     g_assert_cmpstr(g_array_index (*array_, gchar*, 0), ==, "0");
1940     g_assert_cmpstr(g_array_index (*array_, gchar*, 1), ==, "1");
1941     g_assert_cmpstr(g_array_index (*array_, gchar*, 2), ==, "2");
1942
1943     if (internal == NULL) {
1944         internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
1945         for (i = 0; values[i]; i++)
1946             g_array_append_val (internal, values[i]);
1947     }
1948
1949     *array_ = internal;
1950 }
1951
1952 /**
1953  * gi_marshalling_tests_garray_utf8_container_inout:
1954  * @array_: (inout) (element-type utf8) (transfer container):
1955  */
1956 void
1957 gi_marshalling_tests_garray_utf8_container_inout (GArray **array_)
1958 {
1959     static gchar *val1 = "-2";
1960     static gchar *val2 = "-1";
1961     static gchar *val3 = "0";
1962     static gchar *val4 = "1";
1963     GArray *result;
1964
1965     g_assert_cmpint((*array_)->len, ==, 3);
1966     g_assert_cmpstr(g_array_index (*array_, gchar*, 0), ==, "0");
1967     g_assert_cmpstr(g_array_index (*array_, gchar*, 1), ==, "1");
1968     g_assert_cmpstr(g_array_index (*array_, gchar*, 2), ==, "2");
1969
1970     result = g_array_new (TRUE, TRUE, sizeof (gchar *));
1971     g_array_append_val (result, val1);
1972     g_array_append_val (result, val2);
1973     g_array_append_val (result, val3);
1974     g_array_append_val (result, val4);
1975
1976     *array_ = result;
1977 }
1978
1979 /**
1980  * gi_marshalling_tests_garray_utf8_full_inout:
1981  * @array_: (inout) (element-type utf8) (transfer full):
1982  */
1983 void
1984 gi_marshalling_tests_garray_utf8_full_inout (GArray **array_)
1985 {
1986     static gchar *val1 = "-1";
1987     static gchar *val2 = "-2";
1988     gchar *val;
1989     GArray *result;
1990
1991     g_assert_cmpint((*array_)->len, ==, 3);
1992     g_assert_cmpstr(g_array_index (*array_, gchar*, 0), ==, "0");
1993     g_assert_cmpstr(g_array_index (*array_, gchar*, 1), ==, "1");
1994     g_assert_cmpstr(g_array_index (*array_, gchar*, 2), ==, "2");
1995
1996     result = g_array_new (TRUE, TRUE, sizeof (gchar *));
1997     val = g_strdup (val2);
1998     g_array_append_val(result, val);
1999     val = g_strdup (val1);
2000     g_array_append_val(result, val);
2001     val = g_strdup ("0");
2002     g_array_append_val(result, val);
2003     val = g_strdup ("1");
2004     g_array_append_val(result, val);
2005
2006     *array_ = result;
2007 }
2008
2009 /**
2010  * gi_marshalling_tests_gptrarray_utf8_none_return:
2011  *
2012  * Returns: (element-type utf8) (transfer none):
2013  */
2014 GPtrArray *
2015 gi_marshalling_tests_gptrarray_utf8_none_return (void)
2016 {
2017     static GPtrArray *parray = NULL;
2018     static gchar *values[] = {"0", "1", "2"};
2019     gint i;
2020
2021     if (parray == NULL) {
2022         parray = g_ptr_array_new ();
2023         for (i = 0; i < 3; i++)
2024             g_ptr_array_add (parray, (gpointer) values[i]);
2025     }
2026
2027     return parray;
2028 }
2029
2030 /**
2031  * gi_marshalling_tests_gptrarray_utf8_container_return:
2032  *
2033  * Returns: (element-type utf8) (transfer container):
2034  */
2035 GPtrArray *
2036 gi_marshalling_tests_gptrarray_utf8_container_return (void)
2037 {
2038     GPtrArray *parray = NULL;
2039     static gchar *values[] = {"0", "1", "2", NULL};
2040     gint i;
2041
2042     parray = g_ptr_array_new ();
2043     for (i = 0; values[i]; i++)
2044         g_ptr_array_add (parray, (gpointer)values[i]);
2045
2046     return parray;
2047 }
2048
2049 /**
2050  * gi_marshalling_tests_gptrarray_utf8_full_return:
2051  *
2052  * Returns: (element-type utf8) (transfer full):
2053  */
2054 GPtrArray *
2055 gi_marshalling_tests_gptrarray_utf8_full_return (void)
2056 {
2057     GPtrArray *parray = NULL;
2058     static gchar *values[] = {"0", "1", "2", NULL};
2059     gint i;
2060
2061     parray = g_ptr_array_new ();
2062     for (i = 0; values[i]; i++) {
2063         gchar *str = g_strdup (values[i]);
2064         g_ptr_array_add (parray, (gpointer)str);
2065     }
2066
2067     return parray;
2068 }
2069
2070 /**
2071  * gi_marshalling_tests_gptrarray_utf8_none_in:
2072  * @parray_: (element-type utf8) (transfer none):
2073  */
2074 void
2075 gi_marshalling_tests_gptrarray_utf8_none_in (GPtrArray *parray_)
2076 {
2077     g_assert_cmpint(parray_->len, ==, 3);
2078     g_assert_cmpstr(g_ptr_array_index (parray_, 0), ==, "0");
2079     g_assert_cmpstr(g_ptr_array_index (parray_, 1), ==, "1");
2080     g_assert_cmpstr(g_ptr_array_index (parray_, 2), ==, "2");
2081 }
2082
2083 /**
2084  * gi_marshalling_tests_gptrarray_utf8_none_out:
2085  * @parray_: (out) (element-type utf8) (transfer none):
2086  */
2087 void
2088 gi_marshalling_tests_gptrarray_utf8_none_out (GPtrArray **parray_)
2089 {
2090     static GPtrArray *internal = NULL;
2091     static gchar *values[] = {"0", "1", "2", NULL};
2092     gint i;
2093
2094     if (internal == NULL) {
2095         internal = g_ptr_array_new ();
2096         for (i = 0; values[i]; i++)
2097             g_ptr_array_add (internal, (gpointer)values[i]);
2098     }
2099
2100     *parray_ = internal;
2101 }
2102
2103 /**
2104  * gi_marshalling_tests_gptrarray_utf8_container_out:
2105  * @parray_: (out) (element-type utf8) (transfer container):
2106  */
2107 void
2108 gi_marshalling_tests_gptrarray_utf8_container_out (GPtrArray **parray_)
2109 {
2110     static gchar *values[] = {"0", "1", "2", NULL};
2111     gint i;
2112
2113     *parray_ = NULL;
2114
2115     *parray_ = g_ptr_array_new ();
2116     for (i = 0; values[i]; i++)
2117         g_ptr_array_add (*parray_, (gpointer)values[i]);
2118 }
2119
2120 /**
2121  * gi_marshalling_tests_gptrarray_utf8_full_out:
2122  * @parray_: (out) (element-type utf8) (transfer full):
2123  */
2124 void
2125 gi_marshalling_tests_gptrarray_utf8_full_out (GPtrArray **parray_)
2126 {
2127     static gchar *values[] = {"0", "1", "2", NULL};
2128     gint i;
2129
2130     *parray_ = NULL;
2131
2132     *parray_ = g_ptr_array_new ();
2133     for (i = 0; values[i]; i++) {
2134         gchar *str = g_strdup (values[i]);
2135         g_ptr_array_add (*parray_, (gpointer)str);
2136     }
2137 }
2138
2139 /**
2140  * gi_marshalling_tests_gptrarray_utf8_none_inout:
2141  * @parray_: (inout) (element-type utf8) (transfer none):
2142  */
2143 void
2144 gi_marshalling_tests_gptrarray_utf8_none_inout (GPtrArray **parray_)
2145 {
2146     static GPtrArray *internal = NULL;
2147     static gchar *values[] = {"-2", "-1", "0", "1", NULL};
2148     gint i;
2149
2150     g_assert_cmpint((*parray_)->len, ==, 3);
2151     g_assert_cmpstr(g_ptr_array_index (*parray_, 0), ==, "0");
2152     g_assert_cmpstr(g_ptr_array_index (*parray_, 1), ==, "1");
2153     g_assert_cmpstr(g_ptr_array_index (*parray_, 2), ==, "2");
2154
2155     if (internal == NULL) {
2156         internal = g_ptr_array_new ();
2157         for (i = 0; values[i]; i++)
2158             g_ptr_array_add (internal, (gpointer) values[i]);
2159     }
2160
2161     *parray_ = internal;
2162 }
2163
2164 /**
2165  * gi_marshalling_tests_gptrarray_utf8_container_inout:
2166  * @parray_: (inout) (element-type utf8) (transfer container):
2167  */
2168 void
2169 gi_marshalling_tests_gptrarray_utf8_container_inout (GPtrArray **parray_)
2170 {
2171     static gchar *val1 = "-2";
2172     static gchar *val2 = "-1";
2173     static gchar *val3 = "0";
2174     static gchar *val4 = "1";
2175     GPtrArray *result;
2176
2177     g_assert_cmpint((*parray_)->len, ==, 3);
2178     g_assert_cmpstr(g_ptr_array_index (*parray_, 0), ==, "0");
2179     g_assert_cmpstr(g_ptr_array_index (*parray_, 1), ==, "1");
2180     g_assert_cmpstr(g_ptr_array_index (*parray_, 2), ==, "2");
2181
2182     result = g_ptr_array_new ();
2183     g_ptr_array_add (result, (gpointer) val1);
2184     g_ptr_array_add (result, (gpointer) val2);
2185     g_ptr_array_add (result, (gpointer) val3);
2186     g_ptr_array_add (result, (gpointer) val4);
2187
2188     *parray_ = result;
2189 }
2190
2191 /**
2192  * gi_marshalling_tests_gptrarray_utf8_full_inout:
2193  * @parray_: (inout) (element-type utf8) (transfer full):
2194  */
2195 void
2196 gi_marshalling_tests_gptrarray_utf8_full_inout (GPtrArray **parray_)
2197 {
2198     static gchar *val1 = "-1";
2199     static gchar *val2 = "-2";
2200     gchar *val;
2201     GPtrArray *result;
2202
2203     g_assert_cmpint((*parray_)->len, ==, 3);
2204     g_assert_cmpstr(g_ptr_array_index (*parray_, 0), ==, "0");
2205     g_assert_cmpstr(g_ptr_array_index (*parray_, 1), ==, "1");
2206     g_assert_cmpstr(g_ptr_array_index (*parray_, 2), ==, "2");
2207
2208     result = g_ptr_array_new ();
2209     val = g_strdup (val2);
2210     g_ptr_array_add(result, (gpointer) val);
2211     val = g_strdup (val1);
2212     g_ptr_array_add(result, (gpointer) val);
2213     val = g_strdup ("0");
2214     g_ptr_array_add(result, (gpointer) val);
2215     val = g_strdup ("1");
2216     g_ptr_array_add(result, (gpointer) val);
2217
2218     *parray_ = result;
2219 }
2220
2221 /**
2222  * gi_marshalling_tests_bytearray_full_return:
2223  *
2224  * Returns: (transfer full):
2225  */
2226 GByteArray *
2227 gi_marshalling_tests_bytearray_full_return (void)
2228 {
2229     GByteArray *array = NULL;
2230     guint8 data[] = {'\0', '1', '\xFF', '3'};
2231
2232     array = g_byte_array_new ();
2233     g_byte_array_append (array, (const guint8*)data, G_N_ELEMENTS(data));
2234
2235     return array;
2236
2237 }
2238
2239 /**
2240  * gi_marshalling_tests_bytearray_none_in:
2241  * @v: (element-type gint8) (transfer none):
2242  */
2243 void
2244 gi_marshalling_tests_bytearray_none_in (GByteArray *v)
2245 {
2246     g_assert_cmpuint (v->len, ==, 4);
2247     g_assert_cmpuint (g_array_index (v, unsigned char, 0), ==, 0);
2248     g_assert_cmpuint (g_array_index (v, unsigned char, 1), ==, 49);
2249     g_assert_cmpuint (g_array_index (v, unsigned char, 2), ==, 0xFF);
2250     g_assert_cmpuint (g_array_index (v, unsigned char, 3), ==, 51);
2251 }
2252
2253 /**
2254  * gi_marshalling_tests_gbytes_full_return:
2255  *
2256  * Returns: (transfer full):
2257  */
2258 GBytes *
2259 gi_marshalling_tests_gbytes_full_return (void)
2260 {
2261   static guint8 data[] = {0, 49, 0xFF, 51};
2262
2263   return g_bytes_new_static (data, G_N_ELEMENTS(data));
2264 }
2265
2266 /**
2267  * gi_marshalling_tests_gbytes_none_in:
2268  */
2269 void
2270 gi_marshalling_tests_gbytes_none_in (GBytes *v)
2271 {
2272   const guint8 *data;
2273   gsize len;
2274   data = g_bytes_get_data (v, &len);
2275
2276   g_assert_cmpuint (len, ==, 4);
2277   g_assert_cmpuint (data[0], ==, 0);
2278   g_assert_cmpuint (data[1], ==, 49);
2279   g_assert_cmpuint (data[2], ==, 0xFF);
2280   g_assert_cmpuint (data[3], ==, 51);
2281 }
2282
2283 /**
2284  * gi_marshalling_tests_gstrv_return:
2285  *
2286  * Returns: (transfer full): an array of strings
2287  */
2288 GStrv
2289 gi_marshalling_tests_gstrv_return (void)
2290 {
2291     GStrv values = g_new0 (gchar*, 4);
2292     values[0] = g_strdup ("0");
2293     values[1] = g_strdup ("1");
2294     values[2] = g_strdup ("2");
2295     values[3] = NULL;
2296     return values;
2297 }
2298
2299 /**
2300  * gi_marshalling_tests_gstrv_in:
2301  * @g_strv:
2302  */
2303 void
2304 gi_marshalling_tests_gstrv_in (GStrv g_strv)
2305 {
2306     g_assert_cmpint(g_strv_length(g_strv), ==, 3);
2307     g_assert_cmpstr(g_strv[0], ==, "0");
2308     g_assert_cmpstr(g_strv[1], ==, "1");
2309     g_assert_cmpstr(g_strv[2], ==, "2");
2310 }
2311
2312 /**
2313  * gi_marshalling_tests_gstrv_out:
2314  * @g_strv: (out) (transfer none):
2315  */
2316 void
2317 gi_marshalling_tests_gstrv_out (GStrv *g_strv)
2318 {
2319     static gchar *values[] = {"0", "1", "2", NULL};
2320     *g_strv = values;
2321 }
2322
2323 /**
2324  * gi_marshalling_tests_gstrv_inout:
2325  * @g_strv: (inout) (transfer none):
2326  */
2327 void
2328 gi_marshalling_tests_gstrv_inout (GStrv *g_strv)
2329 {
2330     static gchar *values[] = {"-1", "0", "1", "2", NULL};
2331
2332     g_assert(g_strv_length(*g_strv) == 3);
2333     g_assert(strcmp((*g_strv)[0], "0") == 0);
2334     g_assert(strcmp((*g_strv)[1], "1") == 0);
2335     g_assert(strcmp((*g_strv)[2], "2") == 0);
2336
2337     *g_strv = values;
2338 }
2339
2340 /**
2341  * gi_marshalling_tests_glist_int_none_return:
2342  *
2343  * Returns: (element-type gint) (transfer none):
2344  */
2345 GList *
2346 gi_marshalling_tests_glist_int_none_return (void)
2347 {
2348     static GList *list = NULL;
2349
2350     if (list == NULL) {
2351         list = g_list_append(list, GINT_TO_POINTER(-1));
2352         list = g_list_append(list, GINT_TO_POINTER(0));
2353         list = g_list_append(list, GINT_TO_POINTER(1));
2354         list = g_list_append(list, GINT_TO_POINTER(2));
2355     }
2356
2357     return list;
2358 }
2359
2360 /**
2361  * gi_marshalling_tests_glist_uint32_none_return:
2362  *
2363  * Returns: (element-type guint32) (transfer none):
2364  */
2365 GList *
2366 gi_marshalling_tests_glist_uint32_none_return (void)
2367 {
2368     static GList *list = NULL;
2369
2370     if (list == NULL) {
2371         list = g_list_append(list, GUINT_TO_POINTER(0));
2372         list = g_list_append(list, GUINT_TO_POINTER(G_MAXUINT32));
2373     }
2374
2375     return list;
2376 }
2377
2378 /**
2379  * gi_marshalling_tests_glist_utf8_none_return:
2380  *
2381  * Returns: (element-type utf8) (transfer none):
2382  */
2383 GList *
2384 gi_marshalling_tests_glist_utf8_none_return (void)
2385 {
2386     static GList *list = NULL;
2387
2388     if (list == NULL) {
2389         list = g_list_append(list, "0");
2390         list = g_list_append(list, "1");
2391         list = g_list_append(list, "2");
2392     }
2393
2394     return list;
2395 }
2396
2397 /**
2398  * gi_marshalling_tests_glist_utf8_container_return:
2399  *
2400  * Returns: (element-type utf8) (transfer container):
2401  */
2402 GList *
2403 gi_marshalling_tests_glist_utf8_container_return (void)
2404 {
2405     GList *list = NULL;
2406
2407     list = g_list_append(list, "0");
2408     list = g_list_append(list, "1");
2409     list = g_list_append(list, "2");
2410
2411     return list;
2412 }
2413
2414 /**
2415  * gi_marshalling_tests_glist_utf8_full_return:
2416  *
2417  * Returns: (element-type utf8) (transfer full):
2418  */
2419 GList *
2420 gi_marshalling_tests_glist_utf8_full_return (void)
2421 {
2422     GList *list = NULL;
2423
2424     list = g_list_append(list, g_strdup("0"));
2425     list = g_list_append(list, g_strdup("1"));
2426     list = g_list_append(list, g_strdup("2"));
2427
2428     return list;
2429 }
2430
2431 /**
2432  * gi_marshalling_tests_glist_int_none_in:
2433  * @list: (element-type gint) (transfer none):
2434  */
2435 void
2436 gi_marshalling_tests_glist_int_none_in (GList *list)
2437 {
2438     g_assert_cmpint(g_list_length(list), ==, 4);
2439     g_assert_cmpint(GPOINTER_TO_INT(g_list_nth_data(list, 0)), ==, -1);
2440     g_assert_cmpint(GPOINTER_TO_INT(g_list_nth_data(list, 1)), ==, 0);
2441     g_assert_cmpint(GPOINTER_TO_INT(g_list_nth_data(list, 2)), ==, 1);
2442     g_assert_cmpint(GPOINTER_TO_INT(g_list_nth_data(list, 3)), ==, 2);
2443 }
2444
2445 /**
2446  * gi_marshalling_tests_glist_uint32_none_in:
2447  * @list: (element-type guint32) (transfer none):
2448  */
2449 void
2450 gi_marshalling_tests_glist_uint32_none_in (GList *list)
2451 {
2452     g_assert_cmpint(g_list_length(list), ==, 2);
2453     g_assert_cmpint(GPOINTER_TO_UINT(g_list_nth_data(list, 0)), ==, 0);
2454     g_assert_cmpint(GPOINTER_TO_UINT(g_list_nth_data(list, 1)), ==, G_MAXUINT32);
2455 }
2456
2457 /**
2458  * gi_marshalling_tests_glist_utf8_none_in:
2459  * @list: (element-type utf8) (transfer none):
2460  */
2461 void
2462 gi_marshalling_tests_glist_utf8_none_in (GList *list)
2463 {
2464     g_assert_cmpint(g_list_length(list), ==, 3);
2465     g_assert_cmpint(strcmp(g_list_nth_data(list, 0), "0"), ==, 0);
2466     g_assert_cmpint(strcmp(g_list_nth_data(list, 1), "1"), ==, 0);
2467     g_assert_cmpint(strcmp(g_list_nth_data(list, 2), "2"), ==, 0);
2468 }
2469
2470 /**
2471  * gi_marshalling_tests_glist_utf8_none_out:
2472  * @list: (out) (element-type utf8) (transfer none):
2473  */
2474 void
2475 gi_marshalling_tests_glist_utf8_none_out (GList **list)
2476 {
2477     static GList *values = NULL;
2478
2479     if (values == NULL) {
2480         values = g_list_append(values, "0");
2481         values = g_list_append(values, "1");
2482         values = g_list_append(values, "2");
2483     }
2484
2485     *list = values;
2486 }
2487
2488 /**
2489  * gi_marshalling_tests_glist_utf8_container_out:
2490  * @list: (out) (element-type utf8) (transfer container):
2491  */
2492 void
2493 gi_marshalling_tests_glist_utf8_container_out (GList **list)
2494 {
2495     *list = NULL;
2496
2497     *list = g_list_append(*list, "0");
2498     *list = g_list_append(*list, "1");
2499     *list = g_list_append(*list, "2");
2500 }
2501
2502 /**
2503  * gi_marshalling_tests_glist_utf8_full_out:
2504  * @list: (out) (element-type utf8) (transfer full):
2505  */
2506 void
2507 gi_marshalling_tests_glist_utf8_full_out (GList **list)
2508 {
2509     *list = NULL;
2510
2511     *list = g_list_append(*list, g_strdup("0"));
2512     *list = g_list_append(*list, g_strdup("1"));
2513     *list = g_list_append(*list, g_strdup("2"));
2514 }
2515
2516 /**
2517  * gi_marshalling_tests_glist_utf8_none_inout:
2518  * @list: (inout) (element-type utf8) (transfer none):
2519  */
2520 void
2521 gi_marshalling_tests_glist_utf8_none_inout (GList **list)
2522 {
2523     static GList *values = NULL;
2524
2525     g_assert_cmpint(g_list_length(*list), ==, 3);
2526     g_assert_cmpstr(g_list_nth_data(*list, 0), ==, "0");
2527     g_assert_cmpstr(g_list_nth_data(*list, 1), ==, "1");
2528     g_assert_cmpstr(g_list_nth_data(*list, 2), ==, "2");
2529
2530     if (values == NULL) {
2531         values = g_list_append(values, "-2");
2532         values = g_list_append(values, "-1");
2533         values = g_list_append(values, "0");
2534         values = g_list_append(values, "1");
2535     }
2536
2537     *list = values;
2538 }
2539
2540 /**
2541  * gi_marshalling_tests_glist_utf8_container_inout:
2542  * @list: (inout) (element-type utf8) (transfer container):
2543  */
2544 void
2545 gi_marshalling_tests_glist_utf8_container_inout (GList **list)
2546 {
2547     GList *result = NULL;
2548
2549     g_assert_cmpint(g_list_length(*list), ==, 3);
2550     g_assert_cmpstr(g_list_nth_data(*list, 0), ==, "0");
2551     g_assert_cmpstr(g_list_nth_data(*list, 1), ==, "1");
2552     g_assert_cmpstr(g_list_nth_data(*list, 2), ==, "2");
2553
2554     result = g_list_prepend(result, "1");
2555     result = g_list_prepend(result, "0");
2556     result = g_list_prepend(result, "-1");
2557     result = g_list_prepend(result, "-2");
2558
2559     *list = result;
2560 }
2561
2562 /**
2563  * gi_marshalling_tests_glist_utf8_full_inout:
2564  * @list: (inout) (element-type utf8) (transfer full):
2565  */
2566 void
2567 gi_marshalling_tests_glist_utf8_full_inout (GList **list)
2568 {
2569     GList *result = NULL;
2570
2571     g_assert_cmpint(g_list_length(*list), ==, 3);
2572     g_assert_cmpstr(g_list_nth_data(*list, 0), ==, "0");
2573     g_assert_cmpstr(g_list_nth_data(*list, 1), ==, "1");
2574     g_assert_cmpstr(g_list_nth_data(*list, 2), ==, "2");
2575
2576     result = g_list_prepend(result, g_strdup("1"));
2577     result = g_list_prepend(result, g_strdup("0"));
2578     result = g_list_prepend(result, g_strdup("-1"));
2579     result = g_list_prepend(result, g_strdup("-2"));
2580
2581     *list = result;
2582 }
2583
2584
2585 /**
2586  * gi_marshalling_tests_gslist_int_none_return:
2587  *
2588  * Returns: (element-type gint) (transfer none):
2589  */
2590 GSList *
2591 gi_marshalling_tests_gslist_int_none_return (void)
2592 {
2593     static GSList *list = NULL;
2594
2595     if (list == NULL) {
2596         list = g_slist_prepend(list, GINT_TO_POINTER(-1));
2597         list = g_slist_prepend(list, GINT_TO_POINTER(0));
2598         list = g_slist_prepend(list, GINT_TO_POINTER(1));
2599         list = g_slist_prepend(list, GINT_TO_POINTER(2));
2600         list = g_slist_reverse(list);
2601     }
2602
2603     return list;
2604 }
2605
2606 /**
2607  * gi_marshalling_tests_gslist_utf8_none_return:
2608  *
2609  * Returns: (element-type utf8) (transfer none):
2610  */
2611 GSList *
2612 gi_marshalling_tests_gslist_utf8_none_return (void)
2613 {
2614     static GSList *list = NULL;
2615
2616     if (list == NULL) {
2617         list = g_slist_prepend(list, "0");
2618         list = g_slist_prepend(list, "1");
2619         list = g_slist_prepend(list, "2");
2620         list = g_slist_reverse(list);
2621     }
2622
2623     return list;
2624 }
2625
2626 /**
2627  * gi_marshalling_tests_gslist_utf8_container_return:
2628  *
2629  * Returns: (element-type utf8) (transfer container):
2630  */
2631 GSList *
2632 gi_marshalling_tests_gslist_utf8_container_return (void)
2633 {
2634     GSList *list = NULL;
2635
2636     list = g_slist_prepend(list, "0");
2637     list = g_slist_prepend(list, "1");
2638     list = g_slist_prepend(list, "2");
2639     list = g_slist_reverse(list);
2640
2641     return list;
2642 }
2643
2644 /**
2645  * gi_marshalling_tests_gslist_utf8_full_return:
2646  *
2647  * Returns: (element-type utf8) (transfer full):
2648  */
2649 GSList *
2650 gi_marshalling_tests_gslist_utf8_full_return (void)
2651 {
2652     GSList *list = NULL;
2653
2654     list = g_slist_prepend(list, g_strdup("0"));
2655     list = g_slist_prepend(list, g_strdup("1"));
2656     list = g_slist_prepend(list, g_strdup("2"));
2657     list = g_slist_reverse(list);
2658
2659     return list;
2660 }
2661
2662 /**
2663  * gi_marshalling_tests_gslist_int_none_in:
2664  * @list: (element-type gint) (transfer none):
2665  */
2666 void
2667 gi_marshalling_tests_gslist_int_none_in (GSList *list)
2668 {
2669     g_assert_cmpint(g_slist_length(list), ==, 4);
2670     g_assert_cmpint(GPOINTER_TO_INT(g_slist_nth_data(list, 0)), ==, -1);
2671     g_assert_cmpint(GPOINTER_TO_INT(g_slist_nth_data(list, 1)), ==, 0);
2672     g_assert_cmpint(GPOINTER_TO_INT(g_slist_nth_data(list, 2)), ==, 1);
2673     g_assert_cmpint(GPOINTER_TO_INT(g_slist_nth_data(list, 3)), ==, 2);
2674 }
2675
2676 /**
2677  * gi_marshalling_tests_gslist_utf8_none_in:
2678  * @list: (element-type utf8) (transfer none):
2679  */
2680 void
2681 gi_marshalling_tests_gslist_utf8_none_in (GSList *list)
2682 {
2683     g_assert_cmpint(g_slist_length(list), ==, 3);
2684     g_assert_cmpstr(g_slist_nth_data(list, 0), ==, "0");
2685     g_assert_cmpstr(g_slist_nth_data(list, 1), ==, "1");
2686     g_assert_cmpstr(g_slist_nth_data(list, 2), ==, "2");
2687 }
2688
2689 /**
2690  * gi_marshalling_tests_gslist_utf8_none_out:
2691  * @list: (out) (element-type utf8) (transfer none):
2692  */
2693 void
2694 gi_marshalling_tests_gslist_utf8_none_out (GSList **list)
2695 {
2696     static GSList *values = NULL;
2697
2698     if (values == NULL) {
2699         values = g_slist_prepend(values, "0");
2700         values = g_slist_prepend(values, "1");
2701         values = g_slist_prepend(values, "2");
2702         values = g_slist_reverse(values);
2703     }
2704
2705     *list = values;
2706 }
2707
2708 /**
2709  * gi_marshalling_tests_gslist_utf8_container_out:
2710  * @list: (out) (element-type utf8) (transfer container):
2711  */
2712 void
2713 gi_marshalling_tests_gslist_utf8_container_out (GSList **list)
2714 {
2715     *list = NULL;
2716
2717     *list = g_slist_prepend(*list, "0");
2718     *list = g_slist_prepend(*list, "1");
2719     *list = g_slist_prepend(*list, "2");
2720     *list = g_slist_reverse(*list);
2721 }
2722
2723 /**
2724  * gi_marshalling_tests_gslist_utf8_full_out:
2725  * @list: (out) (element-type utf8) (transfer full):
2726  */
2727 void
2728 gi_marshalling_tests_gslist_utf8_full_out (GSList **list)
2729 {
2730     *list = NULL;
2731
2732     *list = g_slist_prepend(*list, g_strdup("0"));
2733     *list = g_slist_prepend(*list, g_strdup("1"));
2734     *list = g_slist_prepend(*list, g_strdup("2"));
2735     *list = g_slist_reverse(*list);
2736 }
2737
2738 /**
2739  * gi_marshalling_tests_gslist_utf8_none_inout:
2740  * @list: (inout) (element-type utf8) (transfer none):
2741  */
2742 void
2743 gi_marshalling_tests_gslist_utf8_none_inout (GSList **list)
2744 {
2745     static GSList *values = NULL;
2746
2747     g_assert_cmpint(g_slist_length(*list), ==, 3);
2748     g_assert_cmpstr(g_slist_nth_data(*list, 0), ==, "0");
2749     g_assert_cmpstr(g_slist_nth_data(*list, 1), ==, "1");
2750     g_assert_cmpstr(g_slist_nth_data(*list, 2), ==, "2");
2751
2752     if (values == NULL) {
2753         values = g_slist_prepend(values, "-2");
2754         values = g_slist_prepend(values, "-1");
2755         values = g_slist_prepend(values, "0");
2756         values = g_slist_prepend(values, "1");
2757         values = g_slist_reverse(values);
2758     }
2759
2760     *list = values;
2761 }
2762
2763 /**
2764  * gi_marshalling_tests_gslist_utf8_container_inout:
2765  * @list: (inout) (element-type utf8) (transfer container):
2766  */
2767 void
2768 gi_marshalling_tests_gslist_utf8_container_inout (GSList **list)
2769 {
2770     GSList *result = NULL;
2771
2772     g_assert_cmpint(g_slist_length(*list), ==, 3);
2773     g_assert_cmpstr(g_slist_nth_data(*list, 0), ==, "0");
2774     g_assert_cmpstr(g_slist_nth_data(*list, 1), ==, "1");
2775     g_assert_cmpstr(g_slist_nth_data(*list, 2), ==, "2");
2776
2777     result = g_slist_prepend(result, "1");
2778     result = g_slist_prepend(result, "0");
2779     result = g_slist_prepend(result, "-1");
2780     result = g_slist_prepend(result, "-2");
2781
2782     *list = result;
2783 }
2784
2785 /**
2786  * gi_marshalling_tests_gslist_utf8_full_inout:
2787  * @list: (inout) (element-type utf8) (transfer full):
2788  */
2789 void
2790 gi_marshalling_tests_gslist_utf8_full_inout (GSList **list)
2791 {
2792     GSList *result = NULL;
2793
2794     g_assert_cmpint(g_slist_length(*list), ==, 3);
2795     g_assert_cmpstr(g_slist_nth_data(*list, 0), ==, "0");
2796     g_assert_cmpstr(g_slist_nth_data(*list, 1), ==, "1");
2797     g_assert_cmpstr(g_slist_nth_data(*list, 2), ==, "2");
2798
2799     result = g_slist_prepend(result, g_strdup("1"));
2800     result = g_slist_prepend(result, g_strdup("0"));
2801     result = g_slist_prepend(result, g_strdup("-1"));
2802     result = g_slist_prepend(result, g_strdup("-2"));
2803
2804     *list = result;
2805 }
2806
2807
2808 /**
2809  * gi_marshalling_tests_ghashtable_int_none_return:
2810  *
2811  * Returns: (element-type gint gint) (transfer none):
2812  */
2813 GHashTable *
2814 gi_marshalling_tests_ghashtable_int_none_return (void)
2815 {
2816     static GHashTable *hash_table = NULL;
2817
2818     if (hash_table == NULL) {
2819         hash_table = g_hash_table_new(NULL, NULL);
2820         g_hash_table_insert(hash_table, GINT_TO_POINTER(-1), GINT_TO_POINTER(1));
2821         g_hash_table_insert(hash_table, GINT_TO_POINTER(0), GINT_TO_POINTER(0));
2822         g_hash_table_insert(hash_table, GINT_TO_POINTER(1), GINT_TO_POINTER(-1));
2823         g_hash_table_insert(hash_table, GINT_TO_POINTER(2), GINT_TO_POINTER(-2));
2824     }
2825
2826     return hash_table;
2827 }
2828
2829 /**
2830  * gi_marshalling_tests_ghashtable_utf8_none_return:
2831  *
2832  * Returns: (element-type utf8 utf8) (transfer none):
2833  */
2834 GHashTable *
2835 gi_marshalling_tests_ghashtable_utf8_none_return (void)
2836 {
2837     static GHashTable *hash_table = NULL;
2838
2839     if (hash_table == NULL) {
2840         hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2841         g_hash_table_insert(hash_table, "-1", "1");
2842         g_hash_table_insert(hash_table, "0", "0");
2843         g_hash_table_insert(hash_table, "1", "-1");
2844         g_hash_table_insert(hash_table, "2", "-2");
2845     }
2846
2847     return hash_table;
2848 }
2849
2850 /**
2851  * gi_marshalling_tests_ghashtable_utf8_container_return:
2852  *
2853  * Returns: (element-type utf8 utf8) (transfer container):
2854  */
2855 GHashTable *
2856 gi_marshalling_tests_ghashtable_utf8_container_return (void)
2857 {
2858     GHashTable *hash_table = NULL;
2859
2860     hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2861     g_hash_table_insert(hash_table, "-1", "1");
2862     g_hash_table_insert(hash_table, "0", "0");
2863     g_hash_table_insert(hash_table, "1", "-1");
2864     g_hash_table_insert(hash_table, "2", "-2");
2865
2866     return hash_table;
2867 }
2868
2869 /**
2870  * gi_marshalling_tests_ghashtable_utf8_full_return:
2871  *
2872  * Returns: (element-type utf8 utf8) (transfer full):
2873  */
2874 GHashTable *
2875 gi_marshalling_tests_ghashtable_utf8_full_return (void)
2876 {
2877     GHashTable *hash_table = NULL;
2878
2879     hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2880     g_hash_table_insert(hash_table, g_strdup("-1"), g_strdup("1"));
2881     g_hash_table_insert(hash_table, g_strdup("0"), g_strdup("0"));
2882     g_hash_table_insert(hash_table, g_strdup("1"), g_strdup("-1"));
2883     g_hash_table_insert(hash_table, g_strdup("2"), g_strdup("-2"));
2884
2885     return hash_table;
2886 }
2887
2888 /**
2889  * gi_marshalling_tests_ghashtable_int_none_in:
2890  * @hash_table: (element-type gint gint) (transfer none):
2891  */
2892 void
2893 gi_marshalling_tests_ghashtable_int_none_in (GHashTable *hash_table)
2894 {
2895     g_assert_cmpint(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(-1))), ==, 1);
2896     g_assert_cmpint(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(0))), ==, 0);
2897     g_assert_cmpint(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(1))), ==, -1);
2898     g_assert_cmpint(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(2))), ==, -2);
2899 }
2900
2901 /**
2902  * gi_marshalling_tests_ghashtable_utf8_none_in:
2903  * @hash_table: (element-type utf8 utf8) (transfer none):
2904  */
2905 void
2906 gi_marshalling_tests_ghashtable_utf8_none_in (GHashTable *hash_table)
2907 {
2908     g_assert_cmpstr(g_hash_table_lookup(hash_table, "-1"), ==, "1");
2909     g_assert_cmpstr(g_hash_table_lookup(hash_table, "0"), ==, "0");
2910     g_assert_cmpstr(g_hash_table_lookup(hash_table, "1"), ==, "-1");
2911     g_assert_cmpstr(g_hash_table_lookup(hash_table, "2"), ==, "-2");
2912 }
2913
2914 /**
2915  * gi_marshalling_tests_ghashtable_utf8_none_out:
2916  * @hash_table: (out) (element-type utf8 utf8) (transfer none):
2917  */
2918 void
2919 gi_marshalling_tests_ghashtable_utf8_none_out (GHashTable **hash_table)
2920 {
2921     static GHashTable *new_hash_table = NULL;
2922
2923     if (new_hash_table == NULL) {
2924         new_hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2925         g_hash_table_insert(new_hash_table, "-1", "1");
2926         g_hash_table_insert(new_hash_table, "0", "0");
2927         g_hash_table_insert(new_hash_table, "1", "-1");
2928         g_hash_table_insert(new_hash_table, "2", "-2");
2929     }
2930
2931     *hash_table = new_hash_table;
2932 }
2933
2934 /**
2935  * gi_marshalling_tests_ghashtable_utf8_container_out:
2936  * @hash_table: (out) (element-type utf8 utf8) (transfer container):
2937  */
2938 void
2939 gi_marshalling_tests_ghashtable_utf8_container_out (GHashTable **hash_table)
2940 {
2941     *hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2942     g_hash_table_insert(*hash_table, "-1", "1");
2943     g_hash_table_insert(*hash_table, "0", "0");
2944     g_hash_table_insert(*hash_table, "1", "-1");
2945     g_hash_table_insert(*hash_table, "2", "-2");
2946 }
2947
2948 /**
2949  * gi_marshalling_tests_ghashtable_utf8_full_out:
2950  * @hash_table: (out) (element-type utf8 utf8) (transfer full):
2951  */
2952 void
2953 gi_marshalling_tests_ghashtable_utf8_full_out (GHashTable **hash_table)
2954 {
2955     *hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2956     g_hash_table_insert(*hash_table, g_strdup("-1"), g_strdup("1"));
2957     g_hash_table_insert(*hash_table, g_strdup("0"), g_strdup("0"));
2958     g_hash_table_insert(*hash_table, g_strdup("1"), g_strdup("-1"));
2959     g_hash_table_insert(*hash_table, g_strdup("2"), g_strdup("-2"));
2960 }
2961
2962 /**
2963  * gi_marshalling_tests_ghashtable_utf8_none_inout:
2964  * @hash_table: (inout) (element-type utf8 utf8) (transfer none):
2965  */
2966 void
2967 gi_marshalling_tests_ghashtable_utf8_none_inout (GHashTable **hash_table)
2968 {
2969     static GHashTable *new_hash_table = NULL;
2970
2971     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "-1"), ==, "1");
2972     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "0"), ==, "0");
2973     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "1"), ==, "-1");
2974     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "2"), ==, "-2");
2975
2976     if (new_hash_table == NULL) {
2977         new_hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2978         g_hash_table_insert(new_hash_table, "-1", "1");
2979         g_hash_table_insert(new_hash_table, "0", "0");
2980         g_hash_table_insert(new_hash_table, "1", "1");
2981     }
2982
2983     *hash_table = new_hash_table;
2984 }
2985
2986 /**
2987  * gi_marshalling_tests_ghashtable_utf8_container_inout:
2988  * @hash_table: (inout) (element-type utf8 utf8) (transfer container):
2989  */
2990 void
2991 gi_marshalling_tests_ghashtable_utf8_container_inout (GHashTable **hash_table)
2992 {
2993     GHashTable *result = g_hash_table_new(g_str_hash, g_str_equal);
2994
2995     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "-1"), ==, "1");
2996     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "0"), ==, "0");
2997     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "1"), ==, "-1");
2998     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "2"), ==, "-2");
2999
3000     g_hash_table_insert(result, "-1", "1");
3001     g_hash_table_insert(result, "0", "0");
3002     g_hash_table_insert(result, "1", "1");
3003
3004     *hash_table = result;
3005 }
3006
3007 /**
3008  * gi_marshalling_tests_ghashtable_utf8_full_inout:
3009  * @hash_table: (inout) (element-type utf8 utf8) (transfer full):
3010  */
3011 void
3012 gi_marshalling_tests_ghashtable_utf8_full_inout (GHashTable **hash_table)
3013 {
3014     GHashTable *result = g_hash_table_new_full(g_str_hash, g_str_equal,
3015                                                g_free, g_free);
3016
3017     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "-1"), ==, "1");
3018     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "0"), ==, "0");
3019     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "1"), ==, "-1");
3020     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "2"), ==, "-2");
3021
3022     g_hash_table_insert(result, g_strdup("-1"), g_strdup("1"));
3023     g_hash_table_insert(result, g_strdup("0"), g_strdup("0"));
3024     g_hash_table_insert(result, g_strdup("1"), g_strdup("1"));
3025
3026     *hash_table = result;
3027 }
3028
3029
3030 /**
3031  * gi_marshalling_tests_gvalue_return:
3032  *
3033  * Returns: (transfer none):
3034  */
3035 GValue *
3036 gi_marshalling_tests_gvalue_return (void)
3037 {
3038     static GValue *value = NULL;
3039
3040     if (value == NULL) {
3041         value = g_new0(GValue, 1);
3042         g_value_init(value, G_TYPE_INT);
3043         g_value_set_int(value, 42);
3044     }
3045
3046     return value;
3047 }
3048
3049 /**
3050  * gi_marshalling_tests_gvalue_in:
3051  * @value: (transfer none):
3052  */
3053 void
3054 gi_marshalling_tests_gvalue_in (GValue *value)
3055 {
3056     g_assert_cmpint(g_value_get_int(value), ==, 42);
3057 }
3058
3059 /**
3060  * gi_marshalling_tests_gvalue_int64_in:
3061  * @value: (transfer none):
3062  */
3063 void
3064 gi_marshalling_tests_gvalue_int64_in (GValue *value)
3065 {
3066     g_assert_cmpint(g_value_get_int64(value), ==, G_MAXINT64);
3067 }
3068
3069 /**
3070  * gi_marshalling_tests_gvalue_in_with_type:
3071  * @value: (transfer none):
3072  * @type:
3073  */
3074 void
3075 gi_marshalling_tests_gvalue_in_with_type (GValue *value, GType type)
3076 {
3077   g_assert(g_type_is_a(G_VALUE_TYPE(value), type));
3078 }
3079
3080 /**
3081  * gi_marshalling_tests_gvalue_in_enum:
3082  * @value: (transfer none):
3083  */
3084 void
3085 gi_marshalling_tests_gvalue_in_enum (GValue *value)
3086 {
3087     g_assert(g_value_get_enum(value) == GI_MARSHALLING_TESTS_ENUM_VALUE3);
3088 }
3089
3090 /**
3091  * gi_marshalling_tests_gvalue_out:
3092  * @value: (out) (transfer none):
3093  */
3094 void
3095 gi_marshalling_tests_gvalue_out (GValue **value)
3096 {
3097     static GValue *new_value = NULL;
3098
3099     if (new_value == NULL) {
3100         new_value = g_new0(GValue, 1);
3101         g_value_init(new_value, G_TYPE_INT);
3102         g_value_set_int(new_value, 42);
3103     }
3104
3105     *value = new_value;
3106 }
3107
3108 /**
3109  * gi_marshalling_tests_gvalue_int64_out:
3110  * @value: (out) (transfer none):
3111  */
3112 void
3113 gi_marshalling_tests_gvalue_int64_out (GValue **value)
3114 {
3115     static GValue *new_value = NULL;
3116
3117     if (new_value == NULL) {
3118         new_value = g_new0(GValue, 1);
3119         g_value_init(new_value, G_TYPE_INT64);
3120         g_value_set_int64(new_value, G_MAXINT64);
3121     }
3122
3123     *value = new_value;
3124 }
3125
3126 /**
3127  * gi_marshalling_tests_gvalue_out_caller_allocates:
3128  * @value: (out) (transfer none):
3129  */
3130 void
3131 gi_marshalling_tests_gvalue_out_caller_allocates (GValue *value)
3132 {
3133     g_value_init(value, G_TYPE_INT);
3134     g_value_set_int(value, 42);
3135 }
3136
3137 /**
3138  * gi_marshalling_tests_gvalue_inout:
3139  * @value: (inout) (transfer none):
3140  */
3141 void
3142 gi_marshalling_tests_gvalue_inout (GValue **value)
3143 {
3144     g_assert_cmpint(g_value_get_int(*value), ==, 42);
3145     g_value_unset(*value);
3146     g_value_init(*value, G_TYPE_STRING);
3147     g_value_set_string(*value, "42");
3148 }
3149
3150 /**
3151  * gi_marshalling_tests_gvalue_flat_array:
3152  * @n_values: number of values
3153  * @values: (array length=n_values): an array containing values
3154  */
3155 void
3156 gi_marshalling_tests_gvalue_flat_array (guint         n_values,
3157                                         const GValue *values)
3158 {
3159     g_assert (n_values == 3);
3160
3161     g_assert_cmpint (g_value_get_int (&values[0]), ==, 42);
3162     g_assert_cmpstr (g_value_get_string (&values[1]), ==, "42");
3163     g_assert_cmpint (g_value_get_boolean (&values[2]), ==, TRUE);
3164 }
3165
3166 /**
3167  * gi_marshalling_tests_return_gvalue_flat_array:
3168  *
3169  * Returns: (array fixed-size=3) (transfer full): a flat GValue array
3170  */
3171 GValue *
3172 gi_marshalling_tests_return_gvalue_flat_array (void)
3173 {
3174     GValue *array = g_new0 (GValue, 3);
3175
3176     g_value_init (&array[0], G_TYPE_INT);
3177     g_value_set_int (&array[0], 42);
3178
3179     g_value_init (&array[1], G_TYPE_STRING);
3180     g_value_set_static_string (&array[1], "42");
3181
3182     g_value_init (&array[2], G_TYPE_BOOLEAN);
3183     g_value_set_boolean (&array[2], TRUE);
3184
3185     return array;
3186 }
3187
3188 /**
3189  * gi_marshalling_tests_gvalue_flat_array_round_trip:
3190  * @one: The first GValue
3191  * @two: The second GValue
3192  * @three: The third GValue
3193  *
3194  * Returns: (array fixed-size=3) (transfer full): a flat array of [@one, @two, @three]
3195  */
3196 GValue *
3197 gi_marshalling_tests_gvalue_flat_array_round_trip (const GValue one,
3198                                                    const GValue two,
3199                                                    const GValue three)
3200 {
3201     GValue *array = g_new (GValue, 3);
3202     array[0] = one;
3203     array[1] = two;
3204     array[2] = three;
3205
3206     return array;
3207 }
3208
3209 /**
3210  * gi_marshalling_tests_gclosure_in:
3211  * @closure: (transfer none):
3212  */
3213 void
3214 gi_marshalling_tests_gclosure_in (GClosure *closure)
3215 {
3216     GValue return_value = {0, };
3217
3218     g_value_init (&return_value, G_TYPE_INT);
3219
3220     g_closure_invoke (closure,
3221             &return_value,
3222             0, NULL,
3223             NULL);
3224
3225     g_assert_cmpint(g_value_get_int (&return_value), ==, 42);
3226
3227     g_value_unset(&return_value);
3228 }
3229
3230 static gint
3231 _closure_return_42 (void)
3232 {
3233   return 42;
3234 }
3235
3236 static void
3237 _marshal_INT__VOID (GClosure *closure,
3238                     GValue *return_value,
3239                     guint n_param_values,
3240                     const GValue *param_values,
3241                     gpointer invocation_hint,
3242                     gpointer marshal_data)
3243 {
3244   typedef gint (*GMarshalFunc_INT__VOID) (void);
3245   register GMarshalFunc_INT__VOID callback;
3246   register GCClosure *cc = (GCClosure*) closure;
3247
3248   callback = (GMarshalFunc_INT__VOID) cc->callback;
3249   g_value_set_int(return_value, callback());
3250 }
3251
3252 /**
3253  * gi_marshalling_tests_gclosure_return:
3254  * 
3255  * Return: a #GClosure
3256  */
3257 GClosure *
3258 gi_marshalling_tests_gclosure_return (void)
3259 {
3260     GClosure *closure = g_cclosure_new ((GCallback)_closure_return_42,
3261                                         NULL, NULL);
3262     g_closure_set_marshal (closure, _marshal_INT__VOID);
3263
3264     return closure;
3265 }
3266
3267
3268 /**
3269  * gi_marshalling_tests_callback_return_value_only:
3270  * @callback: (scope call):
3271  */
3272 glong
3273 gi_marshalling_tests_callback_return_value_only (GIMarshallingTestsCallbackReturnValueOnly callback)
3274 {
3275     return callback ();
3276 }
3277
3278 /**
3279  * gi_marshalling_tests_callback_one_out_parameter:
3280  * @callback: (scope call):
3281  * @a: (out):
3282  */
3283 void
3284 gi_marshalling_tests_callback_one_out_parameter (GIMarshallingTestsCallbackOneOutParameter  callback,
3285                                                  gfloat                                    *a)
3286 {
3287     callback (a);
3288 }
3289
3290 /**
3291  * gi_marshalling_tests_callback_multiple_out_parameters:
3292  * @callback: (scope call):
3293  * @a: (out):
3294  * @b: (out):
3295  */
3296 void
3297 gi_marshalling_tests_callback_multiple_out_parameters (GIMarshallingTestsCallbackMultipleOutParameters  callback,
3298                                                        gfloat                                          *a,
3299                                                        gfloat                                          *b)
3300 {
3301     callback (a, b);
3302 }
3303
3304 /**
3305  * gi_marshalling_tests_callback_return_value_and_one_out_parameter:
3306  * @callback: (scope call):
3307  * @a: (out):
3308  */
3309 glong
3310 gi_marshalling_tests_callback_return_value_and_one_out_parameter (GIMarshallingTestsCallbackReturnValueAndOneOutParameter  callback,
3311                                                                   glong                                                   *a)
3312 {
3313     return callback (a);
3314 }
3315
3316 /**
3317  * gi_marshalling_tests_callback_return_value_and_multiple_out_parameters:
3318  * @callback: (scope call):
3319  * @a: (out):
3320  * @b: (out):
3321  */
3322 glong
3323 gi_marshalling_tests_callback_return_value_and_multiple_out_parameters (GIMarshallingTestsCallbackReturnValueAndMultipleOutParameters  callback,
3324                                                                         glong                                                         *a,
3325                                                                         glong                                                         *b)
3326 {
3327     return callback (a, b);
3328 }
3329
3330
3331
3332 /**
3333  * gi_marshalling_tests_pointer_in_return:
3334  *
3335  * Returns: (transfer none): The same pointer
3336  */
3337 gpointer
3338 gi_marshalling_tests_pointer_in_return (gpointer pointer)
3339 {
3340     return pointer;
3341 }
3342
3343 GType
3344 gi_marshalling_tests_genum_get_type (void)
3345 {
3346     static GType type = 0;
3347     if (G_UNLIKELY(type == 0)) {
3348         static const GEnumValue values[] = {
3349             { GI_MARSHALLING_TESTS_GENUM_VALUE1, "GI_MARSHALLING_TESTS_GENUM_VALUE1", "value1" },
3350             { GI_MARSHALLING_TESTS_GENUM_VALUE2, "GI_MARSHALLING_TESTS_GENUM_VALUE2", "value2" },
3351             { GI_MARSHALLING_TESTS_GENUM_VALUE3, "GI_MARSHALLING_TESTS_GENUM_VALUE3", "value3" },
3352             { 0, NULL, NULL }
3353         };
3354         type = g_enum_register_static (g_intern_static_string ("GIMarshallingTestsGEnum"), values);
3355     }
3356
3357     return type;
3358 }
3359
3360 GIMarshallingTestsGEnum
3361 gi_marshalling_tests_genum_returnv (void)
3362 {
3363     return GI_MARSHALLING_TESTS_GENUM_VALUE3;
3364 }
3365
3366 void
3367 gi_marshalling_tests_genum_in (GIMarshallingTestsGEnum v)
3368 {
3369     g_assert_cmpint(v, ==, GI_MARSHALLING_TESTS_GENUM_VALUE3);
3370 }
3371
3372 /**
3373  * gi_marshalling_tests_genum_out:
3374  * @v: (out):
3375  */
3376 void
3377 gi_marshalling_tests_genum_out (GIMarshallingTestsGEnum *v)
3378 {
3379     *v = GI_MARSHALLING_TESTS_GENUM_VALUE3;
3380 }
3381
3382 /**
3383  * gi_marshalling_tests_genum_inout:
3384  * @v: (inout):
3385  */
3386 void
3387 gi_marshalling_tests_genum_inout (GIMarshallingTestsGEnum *v)
3388 {
3389     g_assert_cmpint(*v, ==, GI_MARSHALLING_TESTS_GENUM_VALUE3);
3390     *v = GI_MARSHALLING_TESTS_GENUM_VALUE1;
3391 }
3392
3393
3394 GIMarshallingTestsEnum
3395 gi_marshalling_tests_enum_returnv (void)
3396 {
3397     return GI_MARSHALLING_TESTS_ENUM_VALUE3;
3398 }
3399
3400 void
3401 gi_marshalling_tests_enum_in (GIMarshallingTestsEnum v)
3402 {
3403     g_assert_cmpint(v, ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
3404 }
3405
3406 /**
3407  * gi_marshalling_tests_enum_out:
3408  * @v: (out):
3409  */
3410 void
3411 gi_marshalling_tests_enum_out (GIMarshallingTestsEnum *v)
3412 {
3413     *v = GI_MARSHALLING_TESTS_ENUM_VALUE3;
3414 }
3415
3416 /**
3417  * gi_marshalling_tests_enum_inout:
3418  * @v: (inout):
3419  */
3420 void
3421 gi_marshalling_tests_enum_inout (GIMarshallingTestsEnum *v)
3422 {
3423     g_assert_cmpint(*v, ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
3424     *v = GI_MARSHALLING_TESTS_ENUM_VALUE1;
3425 }
3426
3427
3428 GType
3429 gi_marshalling_tests_flags_get_type (void)
3430 {
3431     static GType type = 0;
3432     if (G_UNLIKELY(type == 0)) {
3433         static const GFlagsValue values[] = {
3434             { GI_MARSHALLING_TESTS_FLAGS_VALUE1, "GI_MARSHALLING_TESTS_FLAGS_VALUE1", "value1" },
3435             { GI_MARSHALLING_TESTS_FLAGS_VALUE2, "GI_MARSHALLING_TESTS_FLAGS_VALUE2", "value2" },
3436             { GI_MARSHALLING_TESTS_FLAGS_VALUE3, "GI_MARSHALLING_TESTS_FLAGS_VALUE3", "value3" },
3437             { GI_MARSHALLING_TESTS_FLAGS_MASK,   "GI_MARSHALLING_TESTS_FLAGS_MASK",   "mask"   },
3438             { GI_MARSHALLING_TESTS_FLAGS_MASK2,  "GI_MARSHALLING_TESTS_FLAGS_MASK2",  "mask2"  },
3439             { 0, NULL, NULL }
3440         };
3441         type = g_flags_register_static (g_intern_static_string ("GIMarshallingTestsFlags"), values);
3442     }
3443
3444     return type;
3445 }
3446
3447 GIMarshallingTestsFlags
3448 gi_marshalling_tests_flags_returnv (void)
3449 {
3450     return GI_MARSHALLING_TESTS_FLAGS_VALUE2;
3451 }
3452
3453 void
3454 gi_marshalling_tests_flags_in (GIMarshallingTestsFlags v)
3455 {
3456     g_assert(v == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
3457 }
3458
3459 void
3460 gi_marshalling_tests_flags_in_zero (GIMarshallingTestsFlags v)
3461 {
3462     g_assert(v == 0);
3463 }
3464
3465 /**
3466  * gi_marshalling_tests_flags_out:
3467  * @v: (out):
3468  */
3469 void
3470 gi_marshalling_tests_flags_out (GIMarshallingTestsFlags *v)
3471 {
3472     *v = GI_MARSHALLING_TESTS_FLAGS_VALUE2;
3473 }
3474
3475 /**
3476  * gi_marshalling_tests_flags_inout:
3477  * @v: (inout):
3478  */
3479 void
3480 gi_marshalling_tests_flags_inout (GIMarshallingTestsFlags *v)
3481 {
3482     g_assert(*v == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
3483     *v = GI_MARSHALLING_TESTS_FLAGS_VALUE1;
3484 }
3485
3486
3487 GIMarshallingTestsNoTypeFlags
3488 gi_marshalling_tests_no_type_flags_returnv (void)
3489 {
3490     return GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
3491 }
3492
3493 void
3494 gi_marshalling_tests_no_type_flags_in (GIMarshallingTestsNoTypeFlags v)
3495 {
3496     g_assert(v == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
3497 }
3498
3499 void
3500 gi_marshalling_tests_no_type_flags_in_zero (GIMarshallingTestsNoTypeFlags v)
3501 {
3502     g_assert(v == 0);
3503 }
3504
3505 /**
3506  * gi_marshalling_tests_no_type_flags_out:
3507  * @v: (out):
3508  */
3509 void
3510 gi_marshalling_tests_no_type_flags_out (GIMarshallingTestsNoTypeFlags *v)
3511 {
3512     *v = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
3513 }
3514
3515 /**
3516  * gi_marshalling_tests_no_type_flags_inout:
3517  * @v: (inout):
3518  */
3519 void
3520 gi_marshalling_tests_no_type_flags_inout (GIMarshallingTestsNoTypeFlags *v)
3521 {
3522     g_assert(*v == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
3523     *v = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE1;
3524 }
3525
3526
3527 /**
3528  * gi_marshalling_tests_simple_struct_returnv:
3529  *
3530  * Returns: (transfer none):
3531  */
3532 GIMarshallingTestsSimpleStruct *
3533 gi_marshalling_tests_simple_struct_returnv (void)
3534 {
3535     static GIMarshallingTestsSimpleStruct *struct_ = NULL;
3536
3537     if (struct_ == NULL) {
3538         struct_ = g_new(GIMarshallingTestsSimpleStruct, 1);
3539
3540         struct_->long_ = 6;
3541         struct_->int8 = 7;
3542     }
3543
3544     return struct_;
3545 }
3546
3547 /**
3548  * gi_marshalling_tests_simple_struct_inv:
3549  * @struct_: (transfer none):
3550  */
3551 void
3552 gi_marshalling_tests_simple_struct_inv (GIMarshallingTestsSimpleStruct *struct_)
3553 {
3554     g_assert_cmpint(struct_->long_, ==, 6);
3555     g_assert_cmpint(struct_->int8, ==, 7);
3556 }
3557
3558 void
3559 gi_marshalling_tests_simple_struct_method (GIMarshallingTestsSimpleStruct *struct_)
3560 {
3561     g_assert_cmpint(struct_->long_, ==, 6);
3562     g_assert_cmpint(struct_->int8, ==, 7);
3563 }
3564
3565
3566 GType
3567 gi_marshalling_tests_pointer_struct_get_type (void)
3568 {
3569     static GType type = 0;
3570
3571     if (type == 0) {
3572         type = g_pointer_type_register_static ("GIMarshallingTestsPointerStruct");
3573     }
3574
3575     return type;
3576 }
3577
3578 /**
3579  * gi_marshalling_tests_pointer_struct_returnv:
3580  *
3581  * Returns: (transfer none):
3582  */
3583 GIMarshallingTestsPointerStruct *
3584 gi_marshalling_tests_pointer_struct_returnv (void)
3585 {
3586     static GIMarshallingTestsPointerStruct *struct_ = NULL;
3587
3588     if (struct_ == NULL) {
3589         struct_ = g_new(GIMarshallingTestsPointerStruct, 1);
3590
3591         struct_->long_ = 42;
3592     }
3593
3594     return struct_;
3595 }
3596
3597 /**
3598  * gi_marshalling_tests_pointer_struct_inv:
3599  * @struct_: (transfer none):
3600  */
3601 void
3602 gi_marshalling_tests_pointer_struct_inv (GIMarshallingTestsPointerStruct *struct_)
3603 {
3604     g_assert_cmpint(struct_->long_, ==, 42);
3605 }
3606
3607 static GIMarshallingTestsBoxedStruct *
3608 gi_marshalling_tests_boxed_struct_copy (GIMarshallingTestsBoxedStruct *struct_)
3609 {
3610     GIMarshallingTestsBoxedStruct *new_struct;
3611
3612     if (struct_ == NULL)
3613         return NULL;
3614
3615     new_struct = g_slice_new (GIMarshallingTestsBoxedStruct);
3616
3617     *new_struct = *struct_;
3618
3619     return new_struct;
3620 }
3621
3622 static void
3623 gi_marshalling_tests_boxed_struct_free (GIMarshallingTestsBoxedStruct *struct_)
3624 {
3625     if (struct_ != NULL)
3626         g_slice_free (GIMarshallingTestsBoxedStruct, struct_);
3627 }
3628
3629 GType
3630 gi_marshalling_tests_boxed_struct_get_type (void)
3631 {
3632     static GType type = 0;
3633
3634     if (type == 0) {
3635         type = g_boxed_type_register_static ("GIMarshallingTestsBoxedStruct",
3636                 (GBoxedCopyFunc) gi_marshalling_tests_boxed_struct_copy,
3637                 (GBoxedFreeFunc) gi_marshalling_tests_boxed_struct_free);
3638     }
3639
3640     return type;
3641 }
3642
3643 GIMarshallingTestsBoxedStruct *
3644 gi_marshalling_tests_boxed_struct_new (void)
3645 {
3646     return g_slice_new0 (GIMarshallingTestsBoxedStruct);
3647 }
3648
3649 /**
3650  * gi_marshalling_tests_boxed_struct_returnv:
3651  *
3652  * Returns: (transfer none):
3653  */
3654 GIMarshallingTestsBoxedStruct *
3655 gi_marshalling_tests_boxed_struct_returnv (void)
3656 {
3657     static GIMarshallingTestsBoxedStruct *struct_ = NULL;
3658
3659     if (struct_ == NULL) {
3660         struct_ = g_new(GIMarshallingTestsBoxedStruct, 1);
3661
3662         struct_->long_ = 42;
3663         struct_->g_strv = g_new0(gchar*, 4);
3664         struct_->g_strv[0] = g_strdup("0");
3665         struct_->g_strv[1] = g_strdup("1");
3666         struct_->g_strv[2] = g_strdup("2");
3667         struct_->g_strv[3] = NULL;
3668     }
3669
3670     return struct_;
3671 }
3672
3673 /**
3674  * gi_marshalling_tests_boxed_struct_inv:
3675  * @struct_: (transfer none):
3676  */
3677 void
3678 gi_marshalling_tests_boxed_struct_inv (GIMarshallingTestsBoxedStruct *struct_)
3679 {
3680     g_assert_cmpint(struct_->long_, ==, 42);
3681 }
3682
3683 /**
3684  * gi_marshalling_tests_boxed_struct_out:
3685  * @struct_: (out) (transfer none):
3686  */
3687 void
3688 gi_marshalling_tests_boxed_struct_out (GIMarshallingTestsBoxedStruct **struct_)
3689 {
3690     static GIMarshallingTestsBoxedStruct *new_struct = NULL;
3691
3692     if (new_struct == NULL) {
3693         new_struct = g_new(GIMarshallingTestsBoxedStruct, 1);
3694
3695         new_struct->long_ = 42;
3696     }
3697
3698     *struct_ = new_struct;
3699 }
3700
3701 /**
3702  * gi_marshalling_tests_boxed_struct_inout:
3703  * @struct_: (inout) (transfer full):
3704  */
3705 void
3706 gi_marshalling_tests_boxed_struct_inout (GIMarshallingTestsBoxedStruct **struct_)
3707 {
3708     g_assert_cmpint((*struct_)->long_, ==, 42);
3709
3710     (*struct_) = g_slice_new (GIMarshallingTestsBoxedStruct);
3711     (*struct_)->long_ = 0;
3712 }
3713
3714 static GIMarshallingTestsUnion *
3715 gi_marshalling_tests_union_copy (GIMarshallingTestsUnion *union_)
3716 {
3717     GIMarshallingTestsUnion *new_union;
3718
3719     new_union = g_slice_new (GIMarshallingTestsUnion);
3720
3721     *new_union = *union_;
3722
3723     return new_union;
3724 }
3725
3726 static void
3727 gi_marshalling_tests_union_free (GIMarshallingTestsUnion *union_)
3728 {
3729     g_slice_free (GIMarshallingTestsUnion, union_);
3730 }
3731
3732 GType
3733 gi_marshalling_tests_union_get_type (void)
3734 {
3735     static GType type = 0;
3736
3737     if (type == 0) {
3738         type = g_boxed_type_register_static ("GIMarshallingTestsUnion",
3739                 (GBoxedCopyFunc) gi_marshalling_tests_union_copy,
3740                 (GBoxedFreeFunc) gi_marshalling_tests_union_free);
3741     }
3742
3743     return type;
3744 }
3745
3746 /**
3747  * gi_marshalling_tests_union_returnv:
3748  *
3749  * Returns: (transfer none):
3750  */
3751 GIMarshallingTestsUnion *
3752 gi_marshalling_tests_union_returnv (void)
3753 {
3754     static GIMarshallingTestsUnion *union_ = NULL;
3755
3756     if (union_ == NULL) {
3757         union_ = g_new(GIMarshallingTestsUnion, 1);
3758
3759         union_->long_ = 42;
3760     }
3761
3762     return union_;
3763 }
3764
3765 /**
3766  * gi_marshalling_tests_union_inv:
3767  * @union_: (transfer none):
3768  */
3769 void
3770 gi_marshalling_tests_union_inv (GIMarshallingTestsUnion *union_)
3771 {
3772     g_assert_cmpint(union_->long_, ==, 42);
3773 }
3774
3775 void
3776 gi_marshalling_tests_union_method (GIMarshallingTestsUnion *union_)
3777 {
3778     g_assert_cmpint(union_->long_, ==, 42);
3779 }
3780
3781
3782
3783 enum
3784 {
3785         PROP_0,
3786         PROP_INT_
3787 };
3788
3789 static void gi_marshalling_tests_object_real_method_with_default_implementation (
3790         GIMarshallingTestsObject *self, gint8 in);
3791
3792 G_DEFINE_TYPE (GIMarshallingTestsObject, gi_marshalling_tests_object, G_TYPE_OBJECT);
3793
3794 static void
3795 gi_marshalling_tests_object_init (GIMarshallingTestsObject *object)
3796 {
3797 }
3798
3799 static void
3800 gi_marshalling_tests_object_finalize (GObject *object)
3801 {
3802         G_OBJECT_CLASS (gi_marshalling_tests_object_parent_class)->finalize (object);
3803 }
3804
3805 static void
3806 gi_marshalling_tests_object_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
3807 {
3808         g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3809
3810         switch (prop_id) {
3811         case PROP_INT_:
3812             GI_MARSHALLING_TESTS_OBJECT (object)->int_ = g_value_get_int (value);
3813             break;
3814         default:
3815             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3816             break;
3817         }
3818 }
3819
3820 static void
3821 gi_marshalling_tests_object_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
3822 {
3823         g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3824
3825         switch (prop_id) {
3826         case PROP_INT_:
3827             g_value_set_int (value, GI_MARSHALLING_TESTS_OBJECT (object)->int_);
3828             break;
3829         default:
3830             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3831             break;
3832         }
3833 }
3834
3835 static void
3836 gi_marshalling_tests_object_class_init (GIMarshallingTestsObjectClass *klass)
3837 {
3838         GObjectClass* object_class = G_OBJECT_CLASS (klass);
3839 #if 0
3840         GObjectClass* parent_class = G_OBJECT_CLASS (klass);
3841 #endif
3842
3843         object_class->finalize = gi_marshalling_tests_object_finalize;
3844         object_class->set_property = gi_marshalling_tests_object_set_property;
3845         object_class->get_property = gi_marshalling_tests_object_get_property;
3846
3847         g_object_class_install_property (object_class, PROP_INT_,
3848          g_param_spec_int ("int", "Integer", "An integer", G_MININT, G_MAXINT, 0,
3849               G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
3850
3851     klass->method_with_default_implementation = gi_marshalling_tests_object_real_method_with_default_implementation;
3852 }
3853
3854
3855 void
3856 gi_marshalling_tests_object_static_method (void)
3857 {
3858 }
3859
3860 void
3861 gi_marshalling_tests_object_method (GIMarshallingTestsObject *object)
3862 {
3863         g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3864     g_assert_cmpint (object->int_, ==, 42);
3865 }
3866
3867 void
3868 gi_marshalling_tests_object_overridden_method (GIMarshallingTestsObject *object)
3869 {
3870         g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3871     g_assert_cmpint (object->int_, ==, 0);
3872 }
3873
3874 GIMarshallingTestsObject *
3875 gi_marshalling_tests_object_new (gint int_)
3876 {
3877     return g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, "int", int_, NULL);
3878 }
3879
3880 /**
3881  * gi_marshalling_tests_object_method_array_in:
3882  * @ints: (array length=length):
3883  */
3884 void
3885 gi_marshalling_tests_object_method_array_in (GIMarshallingTestsObject *object, const gint *ints, gint length)
3886 {
3887     g_assert_cmpint(length, ==, 4);
3888     g_assert_cmpint(ints[0], ==, -1);
3889     g_assert_cmpint(ints[1], ==, 0);
3890     g_assert_cmpint(ints[2], ==, 1);
3891     g_assert_cmpint(ints[3], ==, 2);
3892 }
3893
3894 /**
3895  * gi_marshalling_tests_object_method_array_out:
3896  * @ints: (out) (array length=length) (transfer none):
3897  */
3898 void
3899 gi_marshalling_tests_object_method_array_out (GIMarshallingTestsObject *object, gint **ints, gint *length)
3900 {
3901     static gint values[] = {-1, 0, 1, 2};
3902
3903     *length = 4;
3904     *ints = values;
3905 }
3906
3907 /**
3908  * gi_marshalling_tests_object_method_array_inout:
3909  * @ints: (inout) (array length=length) (transfer none):
3910  * @length: (inout):
3911  */
3912 void
3913 gi_marshalling_tests_object_method_array_inout (GIMarshallingTestsObject *object, gint **ints, gint *length)
3914 {
3915     static gint values[] = {-2, -1, 0, 1, 2};
3916
3917     g_assert_cmpint(*length, ==, 4);
3918     g_assert_cmpint((*ints)[0], ==, -1);
3919     g_assert_cmpint((*ints)[1], ==, 0);
3920     g_assert_cmpint((*ints)[2], ==, 1);
3921     g_assert_cmpint((*ints)[3], ==, 2);
3922
3923     *length = 5;
3924     *ints = values;
3925 }
3926
3927 /**
3928  * gi_marshalling_tests_object_method_array_return:
3929  *
3930  * Returns: (array length=length):
3931  */
3932 const gint *
3933 gi_marshalling_tests_object_method_array_return (GIMarshallingTestsObject *object, gint *length)
3934 {
3935     static gint ints[] = {-1, 0, 1, 2};
3936
3937     *length = 4;
3938     return ints;
3939 }
3940
3941 /**
3942  * gi_marshalling_tests_object_method_int8_in:
3943  * @in: (in):
3944  */
3945 void
3946 gi_marshalling_tests_object_method_int8_in (GIMarshallingTestsObject *self, gint8 in)
3947 {
3948   GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_in (self, in);
3949 }
3950
3951 /**
3952  * gi_marshalling_tests_object_method_int8_out:
3953  * @out: (out):
3954  */
3955 void
3956 gi_marshalling_tests_object_method_int8_out (GIMarshallingTestsObject *self, gint8 *out)
3957 {
3958   GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_out (self, out);
3959 }
3960
3961 /**
3962  * gi_marshalling_tests_object_method_int8_arg_and_out_caller:
3963  * @out: (out caller-allocates):
3964  */
3965 void
3966 gi_marshalling_tests_object_method_int8_arg_and_out_caller (GIMarshallingTestsObject *self, gint8 arg, gint8 *out)
3967 {
3968   GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_arg_and_out_caller (self, arg, out);
3969 }
3970
3971 /**
3972  * gi_marshalling_tests_object_method_int8_arg_and_out_callee:
3973  * @out: (out):
3974  */
3975 void
3976 gi_marshalling_tests_object_method_int8_arg_and_out_callee (GIMarshallingTestsObject *self, gint8 arg, gint8 **out)
3977 {
3978   GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_arg_and_out_callee (self, arg, out);
3979 }
3980
3981 /**
3982  * gi_marshalling_tests_object_method_str_arg_out_ret:
3983  * @out: (out caller-allocates):
3984  *
3985  * Returns: (transfer none)
3986  */
3987 const gchar*
3988 gi_marshalling_tests_object_method_str_arg_out_ret (GIMarshallingTestsObject *self, const gchar* arg, guint *out)
3989 {
3990   return GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_str_arg_out_ret (self, arg, out);
3991 }
3992
3993 /**
3994  * gi_marshalling_tests_object_method_with_default_implementation:
3995  * @in: (in):
3996  */
3997 void
3998 gi_marshalling_tests_object_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
3999 {
4000     GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_with_default_implementation (self, in);
4001 }
4002
4003 static void
4004 gi_marshalling_tests_object_real_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
4005 {
4006     GValue val = {0, };
4007     g_value_init (&val, G_TYPE_INT);
4008     g_value_set_int (&val, in);
4009     g_object_set_property (G_OBJECT (self), "int", &val);
4010 }
4011
4012 /**
4013  * gi_marshalling_tests_object_vfunc_with_callback:
4014  * @callback: (scope call) (closure callback_data):
4015  * @callback_data: (allow-none):
4016  *
4017  * Virtual: vfunc_with_callback
4018  */
4019 void
4020 gi_marshalling_tests_object_vfunc_with_callback (GIMarshallingTestsObject *object,
4021                                                  GIMarshallingTestsCallbackIntInt callback,
4022                                                  void *callback_data)
4023 {
4024
4025 }
4026
4027 static int
4028 _callback (int val, void *user_data)
4029 {
4030   g_assert (user_data == (gpointer)0xdeadbeef);
4031   return val;
4032 }
4033
4034 void
4035 gi_marshalling_tests_object_call_vfunc_with_callback (GIMarshallingTestsObject *object)
4036 {
4037     GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (object)->vfunc_with_callback (object,
4038                                                                          _callback,
4039                                                                          (void *) 0xdeadbeef);
4040 }
4041
4042 /**
4043  * gi_marshalling_tests_object_none_return:
4044  *
4045  * Returns: (transfer none):
4046  */
4047 GIMarshallingTestsObject *
4048 gi_marshalling_tests_object_none_return (void)
4049 {
4050     static GIMarshallingTestsObject *object = NULL;
4051
4052     if (object == NULL) {
4053         object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4054     }
4055
4056     return object;
4057 }
4058
4059 /**
4060  * gi_marshalling_tests_object_full_return:
4061  *
4062  * Returns: (transfer full):
4063  */
4064 GIMarshallingTestsObject *
4065 gi_marshalling_tests_object_full_return (void)
4066 {
4067     return g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4068 }
4069
4070 /**
4071  * gi_marshalling_tests_object_none_in:
4072  * @object: (transfer none):
4073  */
4074 void
4075 gi_marshalling_tests_object_none_in (GIMarshallingTestsObject *object)
4076 {
4077     g_assert_cmpint(object->int_, ==, 42);
4078 }
4079
4080 /**
4081  * gi_marshalling_tests_object_none_out:
4082  * @object: (out) (transfer none):
4083  */
4084 void
4085 gi_marshalling_tests_object_none_out (GIMarshallingTestsObject **object)
4086 {
4087     static GIMarshallingTestsObject *new_object = NULL;
4088
4089     if (new_object == NULL) {
4090         new_object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4091     }
4092
4093     *object = new_object;
4094 }
4095
4096 /**
4097  * gi_marshalling_tests_object_full_out:
4098  * @object: (out) (transfer full):
4099  */
4100 void
4101 gi_marshalling_tests_object_full_out (GIMarshallingTestsObject **object)
4102 {
4103     *object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4104 }
4105
4106 /**
4107  * gi_marshalling_tests_object_none_inout:
4108  * @object: (inout) (transfer none):
4109  */
4110 void
4111 gi_marshalling_tests_object_none_inout (GIMarshallingTestsObject **object)
4112 {
4113     static GIMarshallingTestsObject *new_object = NULL;
4114
4115     g_assert_cmpint((*object)->int_, ==, 42);
4116
4117     if (new_object == NULL) {
4118         new_object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4119         new_object->int_ = 0;
4120     }
4121
4122     *object = new_object;
4123 }
4124
4125 /**
4126  * gi_marshalling_tests_object_full_inout:
4127  * @object: (inout) (transfer full):
4128  */
4129 void
4130 gi_marshalling_tests_object_full_inout (GIMarshallingTestsObject **object)
4131 {
4132     g_assert_cmpint((*object)->int_, ==, 42);
4133
4134     *object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4135 }
4136
4137 /**
4138  * gi_marshalling_tests_object_test_int8_in:
4139  * @in: (in):
4140  */
4141 void
4142 gi_marshalling_tests_object_int8_in (GIMarshallingTestsObject *object, gint8 in)
4143 {
4144   gi_marshalling_tests_object_method_int8_in (object, in);
4145 }
4146
4147 /**
4148  * gi_marshalling_tests_object_test_int8_out:
4149  * @out: (out):
4150  */
4151 void
4152 gi_marshalling_tests_object_int8_out (GIMarshallingTestsObject *object, gint8 *out)
4153 {
4154   gi_marshalling_tests_object_method_int8_out (object, out);
4155 }
4156
4157 /**
4158  * gi_marshalling_tests_object_vfunc_return_value_only:
4159  */
4160 glong
4161 gi_marshalling_tests_object_vfunc_return_value_only (GIMarshallingTestsObject *self)
4162 {
4163     /* make sure that local variables don't get smashed */
4164     glong return_value;
4165     gulong local = 0x12345678;
4166     return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_only (self);
4167     g_assert_cmpint(local, ==, 0x12345678);
4168     return return_value;
4169 }
4170
4171 /**
4172  * gi_marshalling_tests_object_vfunc_one_out_parameter:
4173  * @a: (out):
4174  */
4175 void
4176 gi_marshalling_tests_object_vfunc_one_out_parameter (GIMarshallingTestsObject *self, gfloat *a)
4177 {
4178     /* make sure that local variables don't get smashed */
4179     gulong local = 0x12345678;
4180     GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_one_out_parameter (self, a);
4181     g_assert_cmpint(local, ==, 0x12345678);
4182 }
4183
4184 /**
4185  * gi_marshalling_tests_object_vfunc_multiple_out_parameters:
4186  * @a: (out):
4187  * @b: (out):
4188  */
4189 void
4190 gi_marshalling_tests_object_vfunc_multiple_out_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b)
4191 {
4192     /* make sure that local variables don't get smashed */
4193     gulong local = 0x12345678;
4194     GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_multiple_out_parameters (self, a, b);
4195     g_assert_cmpint(local, ==, 0x12345678);
4196 }
4197
4198 /**
4199  * gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter:
4200  * @a: (out):
4201  */
4202 void
4203 gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter (GIMarshallingTestsObject *self, GValue *a)
4204 {
4205     /* make sure that local variables don't get smashed */
4206     gulong local = 0x12345678;
4207     GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_caller_allocated_out_parameter (self, a);
4208     g_assert_cmpint(local, ==, 0x12345678);
4209 }
4210
4211 /**
4212  * gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter:
4213  * @a: (out):
4214  */
4215 glong
4216 gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter (GIMarshallingTestsObject *self, glong *a)
4217 {
4218     /* make sure that local variables don't get smashed */
4219     gulong return_value;
4220     gulong local = 0x12345678;
4221     return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_one_out_parameter (self, a);
4222     g_assert_cmpint(local, ==, 0x12345678);
4223     return return_value;
4224 }
4225
4226 /**
4227  * gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters:
4228  * @a: (out):
4229  * @b: (out):
4230  */
4231 glong
4232 gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters (GIMarshallingTestsObject *self, glong *a, glong *b)
4233 {
4234     gulong return_value;
4235     gulong local = 0x12345678;
4236     return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_multiple_out_parameters (self, a, b);
4237     g_assert_cmpint(local, ==, 0x12345678);
4238     return return_value;
4239 }
4240
4241 gboolean
4242 gi_marshalling_tests_object_vfunc_meth_with_error (GIMarshallingTestsObject *self,
4243                                                    gint                      x,
4244                                                    GError                  **error)
4245 {
4246   gulong local = 0x12345678;
4247   gboolean ret = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_meth_with_err (self, x, error);
4248   g_assert_cmpint(local, ==, 0x12345678);
4249   return ret;
4250 }
4251
4252 G_DEFINE_TYPE (GIMarshallingTestsSubObject, gi_marshalling_tests_sub_object, GI_MARSHALLING_TESTS_TYPE_OBJECT);
4253
4254 static void
4255 gi_marshalling_tests_sub_object_init (GIMarshallingTestsSubObject *object)
4256 {
4257 }
4258
4259 static void
4260 gi_marshalling_tests_sub_object_finalize (GObject *object)
4261 {
4262         G_OBJECT_CLASS(gi_marshalling_tests_sub_object_parent_class)->finalize(object);
4263 }
4264
4265 static void
4266 method_deep_hierarchy (GIMarshallingTestsObject *self, gint8 in)
4267 {
4268     GValue val = {0, };
4269     g_value_init (&val, G_TYPE_INT);
4270     g_value_set_int (&val, in);
4271     g_object_set_property (G_OBJECT (self), "int", &val);
4272 }
4273
4274 static void
4275 gi_marshalling_tests_sub_object_class_init (GIMarshallingTestsSubObjectClass *klass)
4276 {
4277         G_OBJECT_CLASS(klass)->finalize = gi_marshalling_tests_sub_object_finalize;
4278     GI_MARSHALLING_TESTS_OBJECT_CLASS(klass)->method_deep_hierarchy = method_deep_hierarchy;
4279 }
4280
4281 void
4282 gi_marshalling_tests_sub_object_sub_method (GIMarshallingTestsSubObject *object)
4283 {
4284     g_assert_cmpint(GI_MARSHALLING_TESTS_OBJECT(object)->int_, ==, 0);
4285 }
4286
4287 void
4288 gi_marshalling_tests_sub_object_overwritten_method (GIMarshallingTestsSubObject *object)
4289 {
4290     g_assert_cmpint(GI_MARSHALLING_TESTS_OBJECT(object)->int_, ==, 0);
4291 }
4292
4293 G_DEFINE_TYPE (GIMarshallingTestsSubSubObject, gi_marshalling_tests_sub_sub_object, GI_MARSHALLING_TESTS_TYPE_SUB_OBJECT);
4294
4295 static void
4296 gi_marshalling_tests_sub_sub_object_init (GIMarshallingTestsSubSubObject *object)
4297 {
4298 }
4299
4300 static void
4301 gi_marshalling_tests_sub_sub_object_class_init (GIMarshallingTestsSubSubObjectClass *klass)
4302 {
4303 }
4304
4305 /* Interfaces */
4306
4307 static void
4308 gi_marshalling_tests_interface_class_init(void *g_iface)
4309 {
4310 }
4311
4312 GType
4313 gi_marshalling_tests_interface_get_type(void)
4314 {
4315     static GType type = 0;
4316     if (type == 0) {
4317         type = g_type_register_static_simple (G_TYPE_INTERFACE,
4318                                               "GIMarshallingTestsInterface",
4319                                               sizeof (GIMarshallingTestsInterfaceIface),
4320                                               (GClassInitFunc) gi_marshalling_tests_interface_class_init,
4321                                               0, NULL, 0);
4322     }
4323
4324     return type;
4325 }
4326
4327 /**
4328  * gi_marshalling_tests_interface_test_int8_in:
4329  * @in: (in):
4330  */
4331 void
4332 gi_marshalling_tests_interface_test_int8_in (GIMarshallingTestsInterface *self, gint8 in)
4333 {
4334   GI_MARSHALLING_TESTS_INTERFACE_GET_IFACE (self)->test_int8_in (self, in);
4335 }
4336
4337 /**
4338  * gi_marshalling_tests_test_interface_test_int8_in:
4339  * @in: (in):
4340  */
4341 void
4342 gi_marshalling_tests_test_interface_test_int8_in (GIMarshallingTestsInterface *test_iface, gint8 in)
4343 {
4344   gi_marshalling_tests_interface_test_int8_in (test_iface, in);
4345 }
4346
4347
4348 static void
4349 gi_marshalling_tests_interface2_class_init(void *g_iface)
4350 {
4351 }
4352
4353 GType
4354 gi_marshalling_tests_interface2_get_type(void)
4355 {
4356     static GType type = 0;
4357     if (type == 0) {
4358         type = g_type_register_static_simple (G_TYPE_INTERFACE,
4359                                               "GIMarshallingTestsInterface2",
4360                                               sizeof (GIMarshallingTestsInterface2Iface),
4361                                               (GClassInitFunc) gi_marshalling_tests_interface2_class_init,
4362                                               0, NULL, 0);
4363     }
4364
4365     return type;
4366 }
4367
4368 static void
4369 gi_marshalling_tests_interface3_class_init(void *g_iface)
4370 {
4371 }
4372
4373 GType
4374 gi_marshalling_tests_interface3_get_type(void)
4375 {
4376     static GType type = 0;
4377     if (type == 0) {
4378         type = g_type_register_static_simple (G_TYPE_INTERFACE,
4379                                               "GIMarshallingTestsInterface3",
4380                                               sizeof (GIMarshallingTestsInterface3Iface),
4381                                               (GClassInitFunc) gi_marshalling_tests_interface3_class_init,
4382                                               0, NULL, 0);
4383     }
4384
4385     return type;
4386 }
4387
4388 /**
4389  * gi_marshalling_tests_interface3_test_variant_array_in:
4390  * @in: (array length=n_in):
4391  * @n_in:
4392  */
4393 void
4394 gi_marshalling_tests_interface3_test_variant_array_in (GIMarshallingTestsInterface3 *self,
4395                                                        GVariant **in,
4396                                                        gsize n_in)
4397 {
4398   GI_MARSHALLING_TESTS_INTERFACE3_GET_IFACE (self)->test_variant_array_in (self, in, n_in);
4399 }
4400
4401 /**
4402  * gi_marshalling_tests_int_out_out:
4403  * @int0: (out):
4404  * @int1: (out):
4405  */
4406 void
4407 gi_marshalling_tests_int_out_out (gint *int0, gint *int1)
4408 {
4409     *int0 = 6;
4410     *int1 = 7;
4411 }
4412
4413 /**
4414  * gi_marshalling_tests_int_three_in_three_out:
4415  * @a: (in):
4416  * @b: (in):
4417  * @c: (in):
4418  * @out0: (out):
4419  * @out1: (out):
4420  * @out2: (out):
4421  */
4422 void
4423 gi_marshalling_tests_int_three_in_three_out(gint a, gint b, gint c,
4424                                             gint *out0, gint *out1, gint *out2)
4425 {
4426     *out0 = a;
4427     *out1 = b;
4428     *out2 = c;
4429 }
4430
4431 /**
4432  * gi_marshalling_tests_int_return_out:
4433  * @int_: (out):
4434  */
4435 gint
4436 gi_marshalling_tests_int_return_out (gint *int_)
4437 {
4438     *int_ = 7;
4439     return 6;
4440 }
4441
4442 /* GError */
4443
4444 void
4445 gi_marshalling_tests_gerror(GError **error)
4446 {
4447     GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4448     g_set_error_literal(error,
4449                         quark,
4450                         GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4451                         GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4452 }
4453
4454 /**
4455  * gi_marshalling_tests_gerror_array_in:
4456  * @in_ints: (array zero-terminated=1):
4457  */
4458 void
4459 gi_marshalling_tests_gerror_array_in(gint *in_ints, GError **error)
4460 {
4461     GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4462     g_set_error_literal(error,
4463                         quark,
4464                         GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4465                         GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4466 }
4467
4468 /**
4469  * gi_marshalling_tests_gerror_out:
4470  * @error: (out) (allow-none) (transfer full): location for the GError.
4471  * @debug: (out) (allow-none) (transfer full): location for the debug message
4472  *
4473  * Inspired by gst_message_parse_error.
4474  */
4475 void
4476 gi_marshalling_tests_gerror_out(GError **error, gchar **debug)
4477 {
4478     GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4479     g_set_error_literal(error,
4480                         quark,
4481                         GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4482                         GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4483
4484     if (debug != NULL) {
4485         *debug = g_strdup (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE);
4486     }
4487 }
4488
4489 /**
4490  * gi_marshalling_tests_gerror_out_transfer_none:
4491  * @err: (out) (allow-none) (transfer none): location for the GError.
4492  * @debug: (out) (allow-none) (transfer none): location for the debug message
4493  *
4494  * A variant of gi_marshalling_tests_gerror_out() which returns data the caller
4495  * must not free.
4496  */
4497 void
4498 gi_marshalling_tests_gerror_out_transfer_none(GError **err, const gchar **debug)
4499 {
4500     static GError error = { 0,
4501                         GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4502                         GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE };
4503     error.domain = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4504     *err = &error;
4505     *debug = GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE;
4506 }
4507
4508 /**
4509  * gi_marshalling_tests_gerror_return:
4510  *
4511  * Yet another variant of gi_marshalling_tests_gerror_out().
4512  *
4513  * Returns: (transfer full): a GError
4514  */
4515 GError *
4516 gi_marshalling_tests_gerror_return(void)
4517 {
4518     GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4519
4520     return g_error_new(quark,
4521                        GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4522                        GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4523 }
4524
4525 static GIMarshallingTestsOverridesStruct *
4526 gi_marshalling_tests_overrides_struct_copy (GIMarshallingTestsOverridesStruct *struct_)
4527 {
4528     GIMarshallingTestsOverridesStruct *new_struct;
4529
4530     new_struct = g_slice_new (GIMarshallingTestsOverridesStruct);
4531
4532     *new_struct = *struct_;
4533
4534     return new_struct;
4535 }
4536
4537 static void
4538 gi_marshalling_tests_overrides_struct_free (GIMarshallingTestsOverridesStruct *struct_)
4539 {
4540     g_slice_free (GIMarshallingTestsOverridesStruct, struct_);
4541 }
4542
4543 GType
4544 gi_marshalling_tests_overrides_struct_get_type (void)
4545 {
4546     static GType type = 0;
4547
4548     if (type == 0) {
4549         type = g_boxed_type_register_static ("GIMarshallingTestsOverridesStruct",
4550                 (GBoxedCopyFunc) gi_marshalling_tests_overrides_struct_copy,
4551                 (GBoxedFreeFunc) gi_marshalling_tests_overrides_struct_free);
4552     }
4553
4554     return type;
4555 }
4556
4557 GIMarshallingTestsOverridesStruct *
4558 gi_marshalling_tests_overrides_struct_new (void)
4559 {
4560     return g_slice_new (GIMarshallingTestsOverridesStruct);
4561 }
4562
4563 glong
4564 gi_marshalling_tests_overrides_struct_method (GIMarshallingTestsOverridesStruct *struct_)
4565 {
4566     return 42;
4567 }
4568
4569
4570 /**
4571  * gi_marshalling_tests_overrides_struct_returnv:
4572  *
4573  * Returns: (transfer full):
4574  */
4575 GIMarshallingTestsOverridesStruct *
4576 gi_marshalling_tests_overrides_struct_returnv (void)
4577 {
4578     return gi_marshalling_tests_overrides_struct_new();
4579 }
4580
4581
4582 G_DEFINE_TYPE (GIMarshallingTestsOverridesObject, gi_marshalling_tests_overrides_object, G_TYPE_OBJECT);
4583
4584 static void
4585 gi_marshalling_tests_overrides_object_init (GIMarshallingTestsOverridesObject *object)
4586 {
4587 }
4588
4589 static void
4590 gi_marshalling_tests_overrides_object_finalize (GObject *object)
4591 {
4592         G_OBJECT_CLASS (gi_marshalling_tests_overrides_object_parent_class)->finalize (object);
4593 }
4594
4595 static void
4596 gi_marshalling_tests_overrides_object_class_init (GIMarshallingTestsOverridesObjectClass *klass)
4597 {
4598         GObjectClass* object_class = G_OBJECT_CLASS (klass);
4599 #if 0
4600         GObjectClass* parent_class = G_OBJECT_CLASS (klass);
4601 #endif
4602
4603         object_class->finalize = gi_marshalling_tests_overrides_object_finalize;
4604 }
4605
4606 GIMarshallingTestsOverridesObject *
4607 gi_marshalling_tests_overrides_object_new (void)
4608 {
4609     return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
4610 }
4611
4612 glong
4613 gi_marshalling_tests_overrides_object_method (GIMarshallingTestsOverridesObject *object)
4614 {
4615     return 42;
4616 }
4617
4618 /**
4619  * gi_marshalling_tests_overrides_object_returnv:
4620  *
4621  * Returns: (transfer full):
4622  */
4623 GIMarshallingTestsOverridesObject *
4624 gi_marshalling_tests_overrides_object_returnv (void)
4625 {
4626     return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
4627 }
4628
4629 /**
4630  * gi_marshalling_tests_filename_list_return:
4631  *
4632  * Returns: (transfer none) (element-type filename): List of filenames
4633  */
4634 GSList *
4635 gi_marshalling_tests_filename_list_return (void)
4636 {
4637     return NULL;
4638 }
4639
4640 /**
4641  * gi_marshalling_tests_param_spec_return:
4642  *
4643  * Returns: (transfer full): a #GParamSpec
4644  */
4645 GParamSpec *
4646 gi_marshalling_tests_param_spec_return (void)
4647 {
4648   return g_param_spec_string ("test-param", "test", "This is a test", "42", G_PARAM_READABLE);
4649 }
4650
4651 /**
4652  * gi_marshalling_tests_param_spec_out:
4653  * @param: (out):
4654  */
4655 void
4656 gi_marshalling_tests_param_spec_out(GParamSpec **param)
4657 {
4658   *param = g_param_spec_string("test-param", "test", "This is a test", "42", G_PARAM_READABLE);
4659 }
4660
4661
4662 enum  {
4663     DUMMY_PROPERTY,
4664     SOME_BOOLEAN_PROPERTY,
4665     SOME_CHAR_PROPERTY,
4666     SOME_UCHAR_PROPERTY,
4667     SOME_INT_PROPERTY,
4668     SOME_UINT_PROPERTY,
4669     SOME_LONG_PROPERTY,
4670     SOME_ULONG_PROPERTY,
4671     SOME_INT64_PROPERTY,
4672     SOME_UINT64_PROPERTY,
4673     SOME_FLOAT_PROPERTY,
4674     SOME_DOUBLE_PROPERTY,
4675     SOME_STRV_PROPERTY,
4676     SOME_BOXED_STRUCT_PROPERTY,
4677     SOME_VARIANT_PROPERTY,
4678 };
4679
4680 G_DEFINE_TYPE (GIMarshallingTestsPropertiesObject, gi_marshalling_tests_properties_object, G_TYPE_OBJECT);
4681
4682 static void
4683 gi_marshalling_tests_properties_object_init (GIMarshallingTestsPropertiesObject * self)
4684 {
4685 }
4686
4687 static void
4688 gi_marshalling_tests_properties_object_finalize (GObject* obj)
4689 {
4690     G_OBJECT_CLASS (gi_marshalling_tests_properties_object_parent_class)->finalize (obj);
4691 }
4692
4693 static void
4694 gi_marshalling_tests_properties_object_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec)
4695 {
4696     GIMarshallingTestsPropertiesObject * self;
4697     self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
4698     switch (property_id) {
4699         case SOME_BOOLEAN_PROPERTY:
4700             g_value_set_boolean (value, self->some_boolean);
4701             break;
4702         case SOME_CHAR_PROPERTY:
4703             g_value_set_schar (value, self->some_char);
4704             break;
4705         case SOME_UCHAR_PROPERTY:
4706             g_value_set_uchar (value, self->some_uchar);
4707             break;
4708         case SOME_INT_PROPERTY:
4709             g_value_set_int (value, self->some_int);
4710             break;
4711         case SOME_UINT_PROPERTY:
4712             g_value_set_uint (value, self->some_uint);
4713             break;
4714         case SOME_LONG_PROPERTY:
4715             g_value_set_long (value, self->some_long);
4716             break;
4717         case SOME_ULONG_PROPERTY:
4718             g_value_set_ulong (value, self->some_ulong);
4719             break;
4720         case SOME_INT64_PROPERTY:
4721             g_value_set_int64 (value, self->some_int64);
4722             break;
4723         case SOME_UINT64_PROPERTY:
4724             g_value_set_uint64 (value, self->some_uint64);
4725             break;
4726         case SOME_FLOAT_PROPERTY:
4727             g_value_set_float (value, self->some_float);
4728             break;
4729         case SOME_DOUBLE_PROPERTY:
4730             g_value_set_double (value, self->some_double);
4731             break;
4732         case SOME_STRV_PROPERTY:
4733             g_value_set_boxed (value, self->some_strv);
4734             break;
4735         case SOME_BOXED_STRUCT_PROPERTY:
4736             g_value_set_boxed (value, self->some_boxed_struct);
4737             break;
4738         case SOME_VARIANT_PROPERTY:
4739             g_value_set_variant (value, self->some_variant);
4740             break;
4741         default:
4742             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
4743             break;
4744     }
4745 }
4746
4747 static void
4748 gi_marshalling_tests_properties_object_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec)
4749 {
4750     GIMarshallingTestsPropertiesObject * self;
4751     self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
4752     switch (property_id) {
4753         case SOME_BOOLEAN_PROPERTY:
4754             self->some_boolean = g_value_get_boolean (value);
4755             break;
4756         case SOME_CHAR_PROPERTY:
4757             self->some_char = g_value_get_schar (value);
4758             break;
4759         case SOME_UCHAR_PROPERTY:
4760             self->some_uchar = g_value_get_uchar (value);
4761             break;
4762         case SOME_INT_PROPERTY:
4763             self->some_int = g_value_get_int (value);
4764             break;
4765         case SOME_UINT_PROPERTY:
4766             self->some_uint = g_value_get_uint (value);
4767             break;
4768         case SOME_LONG_PROPERTY:
4769             self->some_long = g_value_get_long (value);
4770             break;
4771         case SOME_ULONG_PROPERTY:
4772             self->some_ulong = g_value_get_ulong (value);
4773             break;
4774         case SOME_INT64_PROPERTY:
4775             self->some_int64 = g_value_get_int64 (value);
4776             break;
4777         case SOME_UINT64_PROPERTY:
4778             self->some_uint64 = g_value_get_uint64 (value);
4779             break;
4780         case SOME_FLOAT_PROPERTY:
4781             self->some_float = g_value_get_float (value);
4782             break;
4783         case SOME_DOUBLE_PROPERTY:
4784             self->some_double = g_value_get_double (value);
4785             break;
4786         case SOME_STRV_PROPERTY:
4787             g_strfreev (self->some_strv);
4788             self->some_strv = g_strdupv (g_value_get_boxed (value));
4789             break;
4790         case SOME_BOXED_STRUCT_PROPERTY:
4791             gi_marshalling_tests_boxed_struct_free (self->some_boxed_struct);
4792             self->some_boxed_struct = gi_marshalling_tests_boxed_struct_copy (g_value_get_boxed (value));
4793             break;
4794         case SOME_VARIANT_PROPERTY:
4795             if (self->some_variant != NULL)
4796                 g_variant_unref (self->some_variant);
4797             self->some_variant = g_value_get_variant (value);
4798             if (self->some_variant != NULL)
4799                 g_variant_ref (self->some_variant);
4800             break;
4801         default:
4802             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
4803             break;
4804     }
4805 }
4806
4807 static void
4808 gi_marshalling_tests_properties_object_class_init (GIMarshallingTestsPropertiesObjectClass * klass)
4809 {
4810     GObjectClass* object_class = G_OBJECT_CLASS (klass);
4811
4812     object_class->finalize = gi_marshalling_tests_properties_object_finalize;
4813     object_class->get_property = gi_marshalling_tests_properties_object_get_property;
4814     object_class->set_property = gi_marshalling_tests_properties_object_set_property;
4815
4816     g_object_class_install_property (object_class, SOME_BOOLEAN_PROPERTY,
4817         g_param_spec_boolean ("some-boolean", "some-boolean", "some-boolean", FALSE,
4818             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4819
4820     g_object_class_install_property (object_class, SOME_CHAR_PROPERTY,
4821         g_param_spec_char ("some-char", "some-char", "some-char", G_MININT8, G_MAXINT8, 0,
4822             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4823
4824     g_object_class_install_property (object_class, SOME_UCHAR_PROPERTY,
4825         g_param_spec_uchar ("some-uchar", "some-uchar", "some-uchar", 0, G_MAXUINT8, 0,
4826             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4827
4828     g_object_class_install_property (object_class, SOME_INT_PROPERTY,
4829         g_param_spec_int ("some-int", "some-int", "some-int", G_MININT, G_MAXINT, 0,
4830             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4831
4832     g_object_class_install_property (object_class, SOME_UINT_PROPERTY,
4833         g_param_spec_uint ("some-uint", "some-uint", "some-uint", 0, G_MAXUINT, 0,
4834             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4835
4836     g_object_class_install_property (object_class, SOME_LONG_PROPERTY,
4837         g_param_spec_long ("some-long", "some-long", "some-long", G_MINLONG, G_MAXLONG, 0,
4838             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4839
4840     g_object_class_install_property (object_class, SOME_ULONG_PROPERTY,
4841         g_param_spec_ulong ("some-ulong", "some-ulong", "some-ulong", 0, G_MAXULONG, 0,
4842             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4843
4844     g_object_class_install_property (object_class, SOME_INT64_PROPERTY,
4845         g_param_spec_int64 ("some-int64", "some-int64", "some-int64", G_MININT64, G_MAXINT64, 0,
4846             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4847
4848     g_object_class_install_property (object_class, SOME_UINT64_PROPERTY,
4849         g_param_spec_uint64 ("some-uint64", "some-uint64", "some-uint64", 0, G_MAXUINT64, 0,
4850             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4851
4852     g_object_class_install_property (object_class, SOME_FLOAT_PROPERTY,
4853         g_param_spec_float ("some-float", "some-float", "some-float", -1 * G_MAXFLOAT, G_MAXFLOAT, 0,
4854             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4855
4856     g_object_class_install_property (object_class, SOME_DOUBLE_PROPERTY,
4857         g_param_spec_double ("some-double", "some-double", "some-double", -1 * G_MAXDOUBLE, G_MAXDOUBLE, 0,
4858             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4859
4860     g_object_class_install_property (object_class, SOME_STRV_PROPERTY,
4861         g_param_spec_boxed ("some-strv", "some-strv", "some-strv", G_TYPE_STRV,
4862             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4863
4864     g_object_class_install_property (object_class, SOME_BOXED_STRUCT_PROPERTY,
4865         g_param_spec_boxed ("some-boxed-struct", "some-boxed-struct", "some-boxed-struct", 
4866             gi_marshalling_tests_boxed_struct_get_type(),
4867             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4868
4869     g_object_class_install_property (object_class, SOME_VARIANT_PROPERTY,
4870         g_param_spec_variant ("some-variant", "some-variant", "some-variant", 
4871             G_VARIANT_TYPE_ANY, NULL,
4872             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4873 }
4874
4875 GIMarshallingTestsPropertiesObject*
4876 gi_marshalling_tests_properties_object_new (void)
4877 {
4878     return g_object_new (GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT, NULL);
4879 }