GIMarshallingTests: Add GVariant property
[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_none_out:
1069  * @utf8: (out) (transfer none):
1070  */
1071 void
1072 gi_marshalling_tests_utf8_none_out (gchar **utf8)
1073 {
1074     *utf8 = GI_MARSHALLING_TESTS_CONSTANT_UTF8;
1075 }
1076
1077 /**
1078  * gi_marshalling_tests_utf8_full_out:
1079  * @utf8: (out) (transfer full):
1080  */
1081 void
1082 gi_marshalling_tests_utf8_full_out (gchar **utf8)
1083 {
1084     *utf8 = g_strdup(GI_MARSHALLING_TESTS_CONSTANT_UTF8);
1085 }
1086
1087 /**
1088  * gi_marshalling_tests_utf8_dangling_out:
1089  * @utf8: (out) (transfer full):
1090  */
1091 void
1092 gi_marshalling_tests_utf8_dangling_out (gchar **utf8)
1093 {
1094     /* Intentionally don't touch the pointer to see how
1095        the bindings handle this case.  Bindings should be
1096        robust against broken C functions and can initialize
1097        even OUT vlues to NULL.
1098     */
1099 }
1100
1101 /**
1102  * gi_marshalling_tests_utf8_none_inout:
1103  * @utf8: (inout) (transfer none):
1104  */
1105 void
1106 gi_marshalling_tests_utf8_none_inout (gchar **utf8)
1107 {
1108     g_assert_cmpstr(GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, *utf8);
1109     *utf8 = "";
1110 }
1111
1112 /**
1113  * gi_marshalling_tests_utf8_full_inout:
1114  * @utf8: (inout) (transfer full):
1115  */
1116 void
1117 gi_marshalling_tests_utf8_full_inout (gchar **utf8)
1118 {
1119     g_assert_cmpstr(GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, *utf8);
1120     g_free(*utf8);
1121     *utf8 = g_strdup("");
1122 }
1123
1124
1125 /**
1126  * gi_marshalling_tests_init_function:
1127  * @n_args: (inout) (allow-none): number of args
1128  * @argv: (inout) (array length=n_args) (allow-none): args
1129  *
1130  * This is like gtk_init().
1131  */
1132 gboolean
1133 gi_marshalling_tests_init_function (gint *n_args, char ***argv)
1134 {
1135     if (n_args == NULL)
1136         return TRUE;
1137
1138     if (*n_args == 0)
1139         return TRUE;
1140     (*n_args)--;
1141     g_assert (argv != NULL);
1142     (*argv)[*n_args] = NULL;
1143     return TRUE;
1144 }
1145
1146 /**
1147  * gi_marshalling_tests_array_fixed_int_return:
1148  *
1149  * Returns: (array fixed-size=4):
1150  */
1151 const gint *
1152 gi_marshalling_tests_array_fixed_int_return (void)
1153 {
1154     static gint ints[] = {-1, 0, 1, 2};
1155     return ints;
1156 }
1157
1158 /**
1159  * gi_marshalling_tests_array_fixed_short_return:
1160  *
1161  * Returns: (array fixed-size=4):
1162  */
1163 const gshort *
1164 gi_marshalling_tests_array_fixed_short_return (void)
1165 {
1166     static gshort shorts[] = {-1, 0, 1, 2};
1167     return shorts;
1168 }
1169
1170 /**
1171  * gi_marshalling_tests_array_fixed_int_in:
1172  * @ints: (array fixed-size=4):
1173  */
1174 void
1175 gi_marshalling_tests_array_fixed_int_in (const gint *ints)
1176 {
1177     g_assert_cmpint(ints[0], ==, -1);
1178     g_assert_cmpint(ints[1], ==, 0);
1179     g_assert_cmpint(ints[2], ==, 1);
1180     g_assert_cmpint(ints[3], ==, 2);
1181 }
1182
1183 /**
1184  * gi_marshalling_tests_array_fixed_short_in:
1185  * @shorts: (array fixed-size=4):
1186  */
1187 void
1188 gi_marshalling_tests_array_fixed_short_in (const gshort *shorts)
1189 {
1190     g_assert_cmpint(shorts[0], ==, -1);
1191     g_assert_cmpint(shorts[1], ==, 0);
1192     g_assert_cmpint(shorts[2], ==, 1);
1193     g_assert_cmpint(shorts[3], ==, 2);
1194 }
1195
1196 /**
1197  * gi_marshalling_tests_array_fixed_out:
1198  * @ints: (out) (array fixed-size=4) (transfer none):
1199  */
1200 void
1201 gi_marshalling_tests_array_fixed_out (gint **ints)
1202 {
1203     static gint values[] = {-1, 0, 1, 2};
1204     *ints = values;
1205 }
1206
1207 /**
1208  * gi_marshalling_tests_array_fixed_out_struct:
1209  * @structs: (out) (array fixed-size=2) (transfer none):
1210  */
1211 void
1212 gi_marshalling_tests_array_fixed_out_struct (GIMarshallingTestsSimpleStruct **structs)
1213 {
1214     static GIMarshallingTestsSimpleStruct *values;
1215
1216     if (values == NULL) {
1217         values = g_new(GIMarshallingTestsSimpleStruct, 2);
1218
1219         values[0].long_ = 7;
1220         values[0].int8 = 6;
1221
1222         values[1].long_ = 6;
1223         values[1].int8 = 7;
1224     }
1225
1226     *structs = values;
1227 }
1228
1229 /**
1230  * gi_marshalling_tests_array_fixed_inout:
1231  * @ints: (inout) (array fixed-size=4) (transfer none):
1232  */
1233 void
1234 gi_marshalling_tests_array_fixed_inout (gint **ints)
1235 {
1236     static gint values[] = {2, 1, 0, -1};
1237
1238     g_assert_cmpint((*ints)[0], ==, -1);
1239     g_assert_cmpint((*ints)[1], ==, 0);
1240     g_assert_cmpint((*ints)[2], ==, 1);
1241     g_assert_cmpint((*ints)[3], ==, 2);
1242
1243     *ints = values;
1244 }
1245
1246
1247 /**
1248  * gi_marshalling_tests_array_return:
1249  *
1250  * Returns: (array length=length):
1251  */
1252 const gint *
1253 gi_marshalling_tests_array_return (gint *length)
1254 {
1255     static gint ints[] = {-1, 0, 1, 2};
1256
1257     *length = 4;
1258     return ints;
1259 }
1260
1261 /**
1262  * gi_marshalling_tests_array_return_etc:
1263  * @first:
1264  * @length: (out):
1265  * @last:
1266  * @sum: (out):
1267  *
1268  * Returns: (array length=length):
1269  */
1270 const gint *
1271 gi_marshalling_tests_array_return_etc (gint first, gint *length, gint last, gint *sum)
1272 {
1273     static gint ints[] = {-1, 0, 1, 2};
1274
1275     ints[0] = first;
1276     ints[3] = last;
1277     *sum = first + last;
1278     *length = 4;
1279     return ints;
1280 }
1281
1282 /**
1283  * gi_marshalling_tests_array_in:
1284  * @ints: (array length=length):
1285  * @length:
1286  */
1287 void
1288 gi_marshalling_tests_array_in (const gint *ints, gint length)
1289 {
1290     g_assert_cmpint(length, ==, 4);
1291     g_assert_cmpint(ints[0], ==, -1);
1292     g_assert_cmpint(ints[1], ==, 0);
1293     g_assert_cmpint(ints[2], ==, 1);
1294     g_assert_cmpint(ints[3], ==, 2);
1295 }
1296
1297 /**
1298  * gi_marshalling_tests_array_in_len_before:
1299  * @length:
1300  * @ints: (array length=length):
1301  */
1302 void
1303 gi_marshalling_tests_array_in_len_before (gint length, const gint *ints)
1304 {
1305     gi_marshalling_tests_array_in (ints, length);
1306 }
1307
1308 /**
1309  * gi_marshalling_tests_array_in_len_zero_terminated:
1310  * @ints: (array length=length zero-terminated=1):
1311  * @length:
1312  */
1313 void
1314 gi_marshalling_tests_array_in_len_zero_terminated (const gint *ints, gint length)
1315 {
1316     g_assert_cmpint(length, ==, 4);
1317
1318     g_assert_cmpint(ints[0], ==, -1);
1319     g_assert_cmpint(ints[1], ==, 0);
1320     g_assert_cmpint(ints[2], ==, 1);
1321     g_assert_cmpint(ints[3], ==, 2);
1322
1323     /* One past the end, null terminator */
1324     g_assert_cmpint(ints[4], ==, 0);
1325 }
1326
1327 /**
1328  * gi_marshalling_tests_array_string_in:
1329  * @strings: (array length=length):
1330  */
1331 void
1332 gi_marshalling_tests_array_string_in (const gchar **strings, gint length)
1333 {
1334     g_assert_cmpint(length, ==, 2);
1335     g_assert_cmpstr(strings[0], ==, "foo");
1336     g_assert_cmpstr(strings[1], ==, "bar");
1337 }
1338
1339 /**
1340  * gi_marshalling_tests_array_uint8_in:
1341  * @chars: (array length=length):
1342  */
1343 void
1344 gi_marshalling_tests_array_uint8_in (const guint8 *chars, gint length)
1345 {
1346     g_assert_cmpint(length, ==, 4);
1347     g_assert(chars[0] == 'a');
1348     g_assert(chars[1] == 'b');
1349     g_assert(chars[2] == 'c');
1350     g_assert(chars[3] == 'd');
1351 }
1352
1353 /**
1354  * gi_marshalling_tests_array_struct_in:
1355  * @structs: (array length=length):
1356  */
1357 void
1358 gi_marshalling_tests_array_struct_in (GIMarshallingTestsBoxedStruct **structs, gint length)
1359 {
1360     g_assert_cmpint(length, ==, 3);
1361     g_assert_cmpint(structs[0]->long_, ==, 1);
1362     g_assert_cmpint(structs[1]->long_, ==, 2);
1363     g_assert_cmpint(structs[2]->long_, ==, 3);
1364 }
1365
1366 /**
1367  * gi_marshalling_tests_array_simple_struct_in:
1368  * @structs: (array length=length):
1369  */
1370 void
1371 gi_marshalling_tests_array_simple_struct_in (GIMarshallingTestsSimpleStruct *structs, gint length)
1372 {
1373     g_assert_cmpint(length, ==, 3);
1374     g_assert_cmpint(structs[0].long_, ==, 1);
1375     g_assert_cmpint(structs[1].long_, ==, 2);
1376     g_assert_cmpint(structs[2].long_, ==, 3);
1377 }
1378
1379 /**
1380  * gi_marshalling_tests_multi_array_key_value_in:
1381  * @keys: (array length=length):
1382  * @values: (array length=length):
1383  */
1384 void
1385 gi_marshalling_tests_multi_array_key_value_in (gint length, const gchar **keys, const GValue *values)
1386 {
1387     g_assert_cmpint(length, ==, 3);
1388     g_assert_cmpstr("one", ==, keys[0]);
1389     g_assert_cmpint(g_value_get_int(&values[0]), ==, 1);
1390     g_assert_cmpstr("two", ==, keys[1]);
1391     g_assert_cmpint(g_value_get_int(&values[1]), ==, 2);
1392     g_assert_cmpstr("three", ==, keys[2]);
1393     g_assert_cmpint(g_value_get_int(&values[2]), ==, 3);
1394
1395 }
1396
1397 /**
1398  * gi_marshalling_tests_array_struct_take_in:
1399  * @structs: (array length=length) (transfer full):
1400  */
1401 void
1402 gi_marshalling_tests_array_struct_take_in (GIMarshallingTestsBoxedStruct **structs, gint length)
1403 {
1404     gi_marshalling_tests_array_struct_in (structs, length);
1405
1406     /* only really useful if run in valgrind actually */
1407     gi_marshalling_tests_boxed_struct_free (structs[0]);
1408     gi_marshalling_tests_boxed_struct_free (structs[1]);
1409     gi_marshalling_tests_boxed_struct_free (structs[2]);
1410     g_free (structs);
1411 }
1412
1413 /**
1414  * gi_marshalling_tests_array_enum_in:
1415  * @_enum: (array length=length) (transfer none):
1416  * @length:
1417  */
1418 void
1419 gi_marshalling_tests_array_enum_in (GIMarshallingTestsEnum *v, gint length)
1420 {
1421     g_assert_cmpint(length, ==, 3);
1422     g_assert_cmpint(v[0], ==, GI_MARSHALLING_TESTS_ENUM_VALUE1);
1423     g_assert_cmpint(v[1], ==, GI_MARSHALLING_TESTS_ENUM_VALUE2);
1424     g_assert_cmpint(v[2], ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
1425 }
1426
1427 /**
1428  * gi_marshalling_tests_array_in_guint64_len:
1429  * @ints: (array length=length) (transfer none):
1430  * @length:
1431  */
1432 void
1433 gi_marshalling_tests_array_in_guint64_len (const gint *ints, guint64 length)
1434 {
1435     g_assert_cmpint(length, ==, 4);
1436
1437     gi_marshalling_tests_array_in (ints, length);
1438 }
1439
1440 /**
1441  * gi_marshalling_tests_array_in_guint8_len:
1442  * @ints: (array length=length) (transfer none):
1443  * @length:
1444  */
1445 void
1446 gi_marshalling_tests_array_in_guint8_len (const gint *ints, guint8 length)
1447 {
1448     g_assert_cmpint(length, ==, 4);
1449
1450     gi_marshalling_tests_array_in (ints, length);
1451 }
1452
1453 /**
1454  * gi_marshalling_tests_array_out:
1455  * @ints: (out) (array length=length) (transfer none):
1456  */
1457 void
1458 gi_marshalling_tests_array_out (gint **ints, gint *length)
1459 {
1460     static gint values[] = {-1, 0, 1, 2};
1461
1462     *length = 4;
1463     *ints = values;
1464 }
1465
1466 /**
1467  * gi_marshalling_tests_array_out_etc:
1468  * @first:
1469  * @ints: (out) (array length=length) (transfer none):
1470  * @length: (out):
1471  * @last:
1472  * @sum: (out):
1473  */
1474 void
1475 gi_marshalling_tests_array_out_etc (gint first, gint **ints, gint *length, gint last, gint *sum)
1476 {
1477     static gint values[] = {-1, 0, 1, 2};
1478
1479     values[0] = first;
1480     values[3] = last;
1481     *sum = first + last;
1482     *length = 4;
1483     *ints = values;
1484 }
1485
1486 /**
1487  * gi_marshalling_tests_array_inout:
1488  * @ints: (inout) (array length=length) (transfer none):
1489  * @length: (inout):
1490  */
1491 void
1492 gi_marshalling_tests_array_inout (gint **ints, gint *length)
1493 {
1494     static gint values[] = {-2, -1, 0, 1, 2};
1495
1496     g_assert_cmpint(*length, ==, 4);
1497     g_assert_cmpint((*ints)[0], ==, -1);
1498     g_assert_cmpint((*ints)[1], ==, 0);
1499     g_assert_cmpint((*ints)[2], ==, 1);
1500     g_assert_cmpint((*ints)[3], ==, 2);
1501
1502     *length = 5;
1503     *ints = values;
1504 }
1505
1506 /**
1507  * gi_marshalling_tests_array_inout_etc:
1508  * @first:
1509  * @ints: (inout) (array length=length) (transfer none):
1510  * @length: (inout):
1511  * @last:
1512  * @sum: (out):
1513  */
1514 void
1515 gi_marshalling_tests_array_inout_etc (gint first, gint **ints, gint *length, gint last, gint *sum)
1516 {
1517     static gint values[] = {-2, -1, 0, 1, 2};
1518
1519     g_assert_cmpint(*length, ==, 4);
1520     g_assert_cmpint((*ints)[0], ==, -1);
1521     g_assert_cmpint((*ints)[1], ==, 0);
1522     g_assert_cmpint((*ints)[2], ==, 1);
1523     g_assert_cmpint((*ints)[3], ==, 2);
1524
1525     values[0] = first;
1526     values[4] = last;
1527     *sum = first + last;
1528     *length = 5;
1529     *ints = values;
1530 }
1531
1532 /**
1533  * gi_marshalling_tests_array_in_nonzero_nonlen:
1534  * @first:
1535  * @chars: (array):
1536  */
1537 void
1538 gi_marshalling_tests_array_in_nonzero_nonlen (gint first, const guint8 *chars)
1539 {
1540     g_assert(chars[0] == 'a');
1541     g_assert(chars[1] == 'b');
1542     g_assert(chars[2] == 'c');
1543     g_assert(chars[3] == 'd');
1544 }
1545
1546 /**
1547  * gi_marshalling_tests_array_zero_terminated_return:
1548  *
1549  * Returns: (array zero-terminated=1) (transfer none):
1550  */
1551 gchar **
1552 gi_marshalling_tests_array_zero_terminated_return (void)
1553 {
1554     static gchar *values[] = {"0", "1", "2", NULL};
1555     return values;
1556 }
1557
1558 /**
1559  * gi_marshalling_tests_array_zero_terminated_return_null:
1560  *
1561  * Returns: (array zero-terminated=1) (transfer none):
1562  */
1563 gchar **
1564 gi_marshalling_tests_array_zero_terminated_return_null (void)
1565 {
1566     return NULL;
1567 }
1568
1569 /**
1570  * gi_marshalling_tests_array_zero_terminated_return_struct:
1571  *
1572  * Returns: (array zero-terminated=1) (transfer full):
1573  */
1574 GIMarshallingTestsBoxedStruct **
1575 gi_marshalling_tests_array_zero_terminated_return_struct (void)
1576 {
1577     GIMarshallingTestsBoxedStruct **ret = (GIMarshallingTestsBoxedStruct**) g_new (gpointer, 4);
1578
1579     ret[0] = gi_marshalling_tests_boxed_struct_new ();
1580     ret[0]->long_ = 42;
1581
1582     ret[1] = gi_marshalling_tests_boxed_struct_new ();
1583     ret[1]->long_ = 43;
1584
1585     ret[2] = gi_marshalling_tests_boxed_struct_new ();
1586     ret[2]->long_ = 44;
1587
1588     ret[3] = NULL;
1589
1590     return ret;
1591 }
1592
1593 /**
1594  * gi_marshalling_tests_array_zero_terminated_in:
1595  * @utf8s: (array zero-terminated=1) (transfer none):
1596  */
1597 void
1598 gi_marshalling_tests_array_zero_terminated_in (gchar **utf8s)
1599 {
1600     g_assert(g_strv_length(utf8s));
1601     g_assert_cmpstr(utf8s[0], ==, "0");
1602     g_assert_cmpstr(utf8s[1], ==, "1");
1603     g_assert_cmpstr(utf8s[2], ==, "2");
1604 }
1605
1606 /**
1607  * gi_marshalling_tests_array_zero_terminated_out:
1608  * @utf8s: (out) (array zero-terminated=1) (transfer none):
1609  */
1610 void
1611 gi_marshalling_tests_array_zero_terminated_out (gchar ***utf8s)
1612 {
1613     static gchar *values[] = {"0", "1", "2", NULL};
1614     *utf8s = values;
1615 }
1616
1617 /**
1618  * gi_marshalling_tests_array_zero_terminated_inout:
1619  * @utf8s: (inout) (array zero-terminated=1) (transfer none):
1620  */
1621 void
1622 gi_marshalling_tests_array_zero_terminated_inout (gchar ***utf8s)
1623 {
1624     static gchar *values[] = {"-1", "0", "1", "2", NULL};
1625
1626     g_assert(g_strv_length(*utf8s));
1627     g_assert_cmpstr((*utf8s)[0], ==, "0");
1628     g_assert_cmpstr((*utf8s)[1], ==, "1");
1629     g_assert_cmpstr((*utf8s)[2], ==, "2");
1630
1631     *utf8s = values;
1632 }
1633
1634 /**
1635  * gi_marshalling_tests_array_gvariant_none_in:
1636  * @variants: (array zero-terminated=1) (transfer none):
1637  *
1638  * Returns: (array zero-terminated=1) (transfer none):
1639  */
1640 GVariant **
1641 gi_marshalling_tests_array_gvariant_none_in (GVariant **variants)
1642 {
1643     /* Use a static container to detect if someone tries to free it */
1644     static GVariant *private_container[3] = { NULL, NULL, NULL };
1645     
1646     if (private_container[0] == NULL) {
1647       private_container[0] = g_variant_new_int32 (27);
1648       private_container[1] = g_variant_new_string ("Hello");
1649     }
1650
1651     g_assert (variants != NULL);
1652     g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1653     g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1654     g_assert (variants[2] == NULL);
1655
1656     return private_container;
1657 }
1658
1659 /**
1660  * gi_marshalling_tests_array_gvariant_container_in:
1661  * @variants: (array zero-terminated=1) (transfer container):
1662  *
1663  * Returns: (array zero-terminated=1) (transfer container):
1664  */
1665 GVariant **
1666 gi_marshalling_tests_array_gvariant_container_in (GVariant **variants)
1667 {
1668     GVariant **container;
1669
1670     g_assert (variants != NULL);
1671     g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1672     g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1673     g_assert (variants[2] == NULL);
1674     
1675     container = g_new0 (GVariant*, 3);
1676     container[0] = variants[0];
1677     container[1] = variants[1];
1678     g_free (variants);
1679     
1680     return container;
1681 }
1682
1683 /**
1684  * gi_marshalling_tests_array_gvariant_full_in:
1685  * @variants: (array zero-terminated=1) (transfer full):
1686  *
1687  * Returns: (array zero-terminated=1) (transfer full):
1688  */
1689 GVariant **
1690 gi_marshalling_tests_array_gvariant_full_in (GVariant **variants)
1691 {
1692     GVariant **container;
1693
1694     g_assert (variants != NULL);
1695     g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1696     g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1697     g_assert (variants[2] == NULL);
1698     
1699     /* To catch different behaviors we reconstruct one variant from scratch,
1700      * while leaving the other untouched. Both approaches are legal with full
1701      * transfer in and out */
1702     container = g_new0 (GVariant*, 3);
1703     container[0] = g_variant_new_int32 (g_variant_get_int32 (variants[0]));
1704     g_variant_unref (variants[0]);
1705     container[1] = variants[1];
1706     g_free (variants);
1707
1708     return container;
1709 }
1710
1711 /**
1712  * gi_marshalling_tests_garray_int_none_return:
1713  *
1714  * Returns: (element-type gint) (transfer none):
1715  */
1716 GArray *
1717 gi_marshalling_tests_garray_int_none_return (void)
1718 {
1719     static GArray *v = NULL;
1720     gint i;
1721
1722     if (v == NULL) {
1723         v = g_array_new (TRUE, TRUE, sizeof (gint));
1724         for (i = -1; i < 3; i++)
1725             g_array_append_val (v, i);
1726     }
1727
1728     return v;
1729 }
1730
1731 /**
1732  * gi_marshalling_tests_garray_uint64_none_return:
1733  *
1734  * Returns: (element-type guint64) (transfer none):
1735  */
1736 GArray *
1737 gi_marshalling_tests_garray_uint64_none_return (void)
1738 {
1739     static GArray *array = NULL;
1740     guint64 i;
1741
1742     if (array == NULL) {
1743         array = g_array_new (TRUE, TRUE, sizeof (guint64));
1744         i = 0;
1745         g_array_append_val (array, i);
1746         i = G_MAXUINT64;
1747         g_array_append_val (array, i);
1748     }
1749
1750     return array;
1751 }
1752
1753 /**
1754  * gi_marshalling_tests_garray_utf8_none_return:
1755  *
1756  * Returns: (element-type utf8) (transfer none):
1757  */
1758 GArray *
1759 gi_marshalling_tests_garray_utf8_none_return (void)
1760 {
1761     static GArray *array = NULL;
1762     static gchar *values[] = {"0", "1", "2", NULL};
1763     gint i;
1764
1765     if (array == NULL) {
1766         array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1767         for (i = 0; values[i]; i++)
1768             g_array_append_val (array, values[i]);
1769     }
1770
1771     return array;
1772 }
1773
1774 /**
1775  * gi_marshalling_tests_garray_utf8_container_return:
1776  *
1777  * Returns: (element-type utf8) (transfer container):
1778  */
1779 GArray *
1780 gi_marshalling_tests_garray_utf8_container_return (void)
1781 {
1782     GArray *array = NULL;
1783     static gchar *values[] = {"0", "1", "2", NULL};
1784     gint i;
1785
1786     array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1787     for (i = 0; values[i]; i++)
1788         g_array_append_val (array, values[i]);
1789
1790     return array;
1791 }
1792
1793 /**
1794  * gi_marshalling_tests_garray_utf8_full_return:
1795  *
1796  * Returns: (element-type utf8) (transfer full):
1797  */
1798 GArray *
1799 gi_marshalling_tests_garray_utf8_full_return (void)
1800 {
1801     GArray *array = NULL;
1802     static gchar *values[] = {"0", "1", "2", NULL};
1803     gint i;
1804
1805     array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1806     for (i = 0; values[i]; i++) {
1807         gchar *str = g_strdup (values[i]);
1808         g_array_append_val (array, str);
1809     }
1810
1811     return array;
1812 }
1813
1814 /**
1815  * gi_marshalling_tests_garray_int_none_in:
1816  * @array_: (element-type gint) (transfer none):
1817  */
1818 void
1819 gi_marshalling_tests_garray_int_none_in (GArray *array_)
1820 {
1821     g_assert_cmpint(array_->len, ==, 4);
1822     g_assert_cmpint(g_array_index (array_, gint, 0), ==, -1);
1823     g_assert_cmpint(g_array_index (array_, gint, 1), ==, 0);
1824     g_assert_cmpint(g_array_index (array_, gint, 2), ==, 1);
1825     g_assert_cmpint(g_array_index (array_, gint, 3), ==, 2);
1826 }
1827
1828 /**
1829  * gi_marshalling_tests_garray_uint64_none_in:
1830  * @array_: (element-type guint64) (transfer none):
1831  */
1832 void
1833 gi_marshalling_tests_garray_uint64_none_in (GArray *array_)
1834 {
1835     g_assert_cmpint(array_->len, ==, 2);
1836     g_assert_cmpint(g_array_index (array_, guint64, 0), ==, 0);
1837     g_assert_cmpint(g_array_index (array_, guint64, 1), ==, G_MAXUINT64);
1838 }
1839
1840 /**
1841  * gi_marshalling_tests_garray_utf8_none_in:
1842  * @array_: (element-type utf8) (transfer none):
1843  */
1844 void
1845 gi_marshalling_tests_garray_utf8_none_in (GArray *array_)
1846 {
1847     g_assert_cmpint(array_->len, ==, 3);
1848     g_assert_cmpstr(g_array_index (array_, gchar*, 0), ==, "0");
1849     g_assert_cmpstr(g_array_index (array_, gchar*, 1), ==, "1");
1850     g_assert_cmpstr(g_array_index (array_, gchar*, 2), ==, "2");
1851 }
1852
1853 /**
1854  * gi_marshalling_tests_garray_utf8_none_out:
1855  * @array_: (out) (element-type utf8) (transfer none):
1856  */
1857 void
1858 gi_marshalling_tests_garray_utf8_none_out (GArray **array_)
1859 {
1860     static GArray *internal = NULL;
1861     static gchar *values[] = {"0", "1", "2", NULL};
1862     gint i;
1863
1864     if (internal == NULL) {
1865         internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
1866         for (i = 0; values[i]; i++)
1867             g_array_append_val (internal, values[i]);
1868     }
1869
1870     *array_ = internal;
1871 }
1872
1873 /**
1874  * gi_marshalling_tests_garray_utf8_container_out:
1875  * @array_: (out) (element-type utf8) (transfer container):
1876  */
1877 void
1878 gi_marshalling_tests_garray_utf8_container_out (GArray **array_)
1879 {
1880     static gchar *values[] = {"0", "1", "2", NULL};
1881     gint i;
1882
1883     *array_ = NULL;
1884
1885     *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
1886     for (i = 0; values[i]; i++)
1887         g_array_append_val (*array_, values[i]);
1888 }
1889
1890 /**
1891  * gi_marshalling_tests_garray_utf8_full_out:
1892  * @array_: (out) (element-type utf8) (transfer full):
1893  */
1894 void
1895 gi_marshalling_tests_garray_utf8_full_out (GArray **array_)
1896 {
1897     static gchar *values[] = {"0", "1", "2", NULL};
1898     gint i;
1899
1900     *array_ = NULL;
1901
1902     *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
1903     for (i = 0; values[i]; i++) {
1904         gchar *str = g_strdup (values[i]);
1905         g_array_append_val (*array_, str);
1906     }
1907 }
1908
1909 /**
1910  * gi_marshalling_tests_garray_utf8_none_inout:
1911  * @array_: (inout) (element-type utf8) (transfer none):
1912  */
1913 void
1914 gi_marshalling_tests_garray_utf8_none_inout (GArray **array_)
1915 {
1916     static GArray *internal = NULL;
1917     static gchar *values[] = {"-2", "-1", "0", "1", NULL};
1918     gint i;
1919
1920     g_assert_cmpint((*array_)->len, ==, 3);
1921     g_assert_cmpstr(g_array_index (*array_, gchar*, 0), ==, "0");
1922     g_assert_cmpstr(g_array_index (*array_, gchar*, 1), ==, "1");
1923     g_assert_cmpstr(g_array_index (*array_, gchar*, 2), ==, "2");
1924
1925     if (internal == NULL) {
1926         internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
1927         for (i = 0; values[i]; i++)
1928             g_array_append_val (internal, values[i]);
1929     }
1930
1931     *array_ = internal;
1932 }
1933
1934 /**
1935  * gi_marshalling_tests_garray_utf8_container_inout:
1936  * @array_: (inout) (element-type utf8) (transfer container):
1937  */
1938 void
1939 gi_marshalling_tests_garray_utf8_container_inout (GArray **array_)
1940 {
1941     static gchar *val1 = "-2";
1942     static gchar *val2 = "-1";
1943     static gchar *val3 = "0";
1944     static gchar *val4 = "1";
1945     GArray *result;
1946
1947     g_assert_cmpint((*array_)->len, ==, 3);
1948     g_assert_cmpstr(g_array_index (*array_, gchar*, 0), ==, "0");
1949     g_assert_cmpstr(g_array_index (*array_, gchar*, 1), ==, "1");
1950     g_assert_cmpstr(g_array_index (*array_, gchar*, 2), ==, "2");
1951
1952     result = g_array_new (TRUE, TRUE, sizeof (gchar *));
1953     g_array_append_val (result, val1);
1954     g_array_append_val (result, val2);
1955     g_array_append_val (result, val3);
1956     g_array_append_val (result, val4);
1957
1958     *array_ = result;
1959 }
1960
1961 /**
1962  * gi_marshalling_tests_garray_utf8_full_inout:
1963  * @array_: (inout) (element-type utf8) (transfer full):
1964  */
1965 void
1966 gi_marshalling_tests_garray_utf8_full_inout (GArray **array_)
1967 {
1968     static gchar *val1 = "-1";
1969     static gchar *val2 = "-2";
1970     gchar *val;
1971     GArray *result;
1972
1973     g_assert_cmpint((*array_)->len, ==, 3);
1974     g_assert_cmpstr(g_array_index (*array_, gchar*, 0), ==, "0");
1975     g_assert_cmpstr(g_array_index (*array_, gchar*, 1), ==, "1");
1976     g_assert_cmpstr(g_array_index (*array_, gchar*, 2), ==, "2");
1977
1978     result = g_array_new (TRUE, TRUE, sizeof (gchar *));
1979     val = g_strdup (val2);
1980     g_array_append_val(result, val);
1981     val = g_strdup (val1);
1982     g_array_append_val(result, val);
1983     val = g_strdup ("0");
1984     g_array_append_val(result, val);
1985     val = g_strdup ("1");
1986     g_array_append_val(result, val);
1987
1988     *array_ = result;
1989 }
1990
1991 /**
1992  * gi_marshalling_tests_gptrarray_utf8_none_return:
1993  *
1994  * Returns: (element-type utf8) (transfer none):
1995  */
1996 GPtrArray *
1997 gi_marshalling_tests_gptrarray_utf8_none_return (void)
1998 {
1999     static GPtrArray *parray = NULL;
2000     static gchar *values[] = {"0", "1", "2"};
2001     gint i;
2002
2003     if (parray == NULL) {
2004         parray = g_ptr_array_new ();
2005         for (i = 0; i < 3; i++)
2006             g_ptr_array_add (parray, (gpointer) values[i]);
2007     }
2008
2009     return parray;
2010 }
2011
2012 /**
2013  * gi_marshalling_tests_gptrarray_utf8_container_return:
2014  *
2015  * Returns: (element-type utf8) (transfer container):
2016  */
2017 GPtrArray *
2018 gi_marshalling_tests_gptrarray_utf8_container_return (void)
2019 {
2020     GPtrArray *parray = NULL;
2021     static gchar *values[] = {"0", "1", "2", NULL};
2022     gint i;
2023
2024     parray = g_ptr_array_new ();
2025     for (i = 0; values[i]; i++)
2026         g_ptr_array_add (parray, (gpointer)values[i]);
2027
2028     return parray;
2029 }
2030
2031 /**
2032  * gi_marshalling_tests_gptrarray_utf8_full_return:
2033  *
2034  * Returns: (element-type utf8) (transfer full):
2035  */
2036 GPtrArray *
2037 gi_marshalling_tests_gptrarray_utf8_full_return (void)
2038 {
2039     GPtrArray *parray = NULL;
2040     static gchar *values[] = {"0", "1", "2", NULL};
2041     gint i;
2042
2043     parray = g_ptr_array_new ();
2044     for (i = 0; values[i]; i++) {
2045         gchar *str = g_strdup (values[i]);
2046         g_ptr_array_add (parray, (gpointer)str);
2047     }
2048
2049     return parray;
2050 }
2051
2052 /**
2053  * gi_marshalling_tests_gptrarray_utf8_none_in:
2054  * @parray_: (element-type utf8) (transfer none):
2055  */
2056 void
2057 gi_marshalling_tests_gptrarray_utf8_none_in (GPtrArray *parray_)
2058 {
2059     g_assert_cmpint(parray_->len, ==, 3);
2060     g_assert_cmpstr(g_ptr_array_index (parray_, 0), ==, "0");
2061     g_assert_cmpstr(g_ptr_array_index (parray_, 1), ==, "1");
2062     g_assert_cmpstr(g_ptr_array_index (parray_, 2), ==, "2");
2063 }
2064
2065 /**
2066  * gi_marshalling_tests_gptrarray_utf8_none_out:
2067  * @parray_: (out) (element-type utf8) (transfer none):
2068  */
2069 void
2070 gi_marshalling_tests_gptrarray_utf8_none_out (GPtrArray **parray_)
2071 {
2072     static GPtrArray *internal = NULL;
2073     static gchar *values[] = {"0", "1", "2", NULL};
2074     gint i;
2075
2076     if (internal == NULL) {
2077         internal = g_ptr_array_new ();
2078         for (i = 0; values[i]; i++)
2079             g_ptr_array_add (internal, (gpointer)values[i]);
2080     }
2081
2082     *parray_ = internal;
2083 }
2084
2085 /**
2086  * gi_marshalling_tests_gptrarray_utf8_container_out:
2087  * @parray_: (out) (element-type utf8) (transfer container):
2088  */
2089 void
2090 gi_marshalling_tests_gptrarray_utf8_container_out (GPtrArray **parray_)
2091 {
2092     static gchar *values[] = {"0", "1", "2", NULL};
2093     gint i;
2094
2095     *parray_ = NULL;
2096
2097     *parray_ = g_ptr_array_new ();
2098     for (i = 0; values[i]; i++)
2099         g_ptr_array_add (*parray_, (gpointer)values[i]);
2100 }
2101
2102 /**
2103  * gi_marshalling_tests_gptrarray_utf8_full_out:
2104  * @parray_: (out) (element-type utf8) (transfer full):
2105  */
2106 void
2107 gi_marshalling_tests_gptrarray_utf8_full_out (GPtrArray **parray_)
2108 {
2109     static gchar *values[] = {"0", "1", "2", NULL};
2110     gint i;
2111
2112     *parray_ = NULL;
2113
2114     *parray_ = g_ptr_array_new ();
2115     for (i = 0; values[i]; i++) {
2116         gchar *str = g_strdup (values[i]);
2117         g_ptr_array_add (*parray_, (gpointer)str);
2118     }
2119 }
2120
2121 /**
2122  * gi_marshalling_tests_gptrarray_utf8_none_inout:
2123  * @parray_: (inout) (element-type utf8) (transfer none):
2124  */
2125 void
2126 gi_marshalling_tests_gptrarray_utf8_none_inout (GPtrArray **parray_)
2127 {
2128     static GPtrArray *internal = NULL;
2129     static gchar *values[] = {"-2", "-1", "0", "1", NULL};
2130     gint i;
2131
2132     g_assert_cmpint((*parray_)->len, ==, 3);
2133     g_assert_cmpstr(g_ptr_array_index (*parray_, 0), ==, "0");
2134     g_assert_cmpstr(g_ptr_array_index (*parray_, 1), ==, "1");
2135     g_assert_cmpstr(g_ptr_array_index (*parray_, 2), ==, "2");
2136
2137     if (internal == NULL) {
2138         internal = g_ptr_array_new ();
2139         for (i = 0; values[i]; i++)
2140             g_ptr_array_add (internal, (gpointer) values[i]);
2141     }
2142
2143     *parray_ = internal;
2144 }
2145
2146 /**
2147  * gi_marshalling_tests_gptrarray_utf8_container_inout:
2148  * @parray_: (inout) (element-type utf8) (transfer container):
2149  */
2150 void
2151 gi_marshalling_tests_gptrarray_utf8_container_inout (GPtrArray **parray_)
2152 {
2153     static gchar *val1 = "-2";
2154     static gchar *val2 = "-1";
2155     static gchar *val3 = "0";
2156     static gchar *val4 = "1";
2157     GPtrArray *result;
2158
2159     g_assert_cmpint((*parray_)->len, ==, 3);
2160     g_assert_cmpstr(g_ptr_array_index (*parray_, 0), ==, "0");
2161     g_assert_cmpstr(g_ptr_array_index (*parray_, 1), ==, "1");
2162     g_assert_cmpstr(g_ptr_array_index (*parray_, 2), ==, "2");
2163
2164     result = g_ptr_array_new ();
2165     g_ptr_array_add (result, (gpointer) val1);
2166     g_ptr_array_add (result, (gpointer) val2);
2167     g_ptr_array_add (result, (gpointer) val3);
2168     g_ptr_array_add (result, (gpointer) val4);
2169
2170     *parray_ = result;
2171 }
2172
2173 /**
2174  * gi_marshalling_tests_gptrarray_utf8_full_inout:
2175  * @parray_: (inout) (element-type utf8) (transfer full):
2176  */
2177 void
2178 gi_marshalling_tests_gptrarray_utf8_full_inout (GPtrArray **parray_)
2179 {
2180     static gchar *val1 = "-1";
2181     static gchar *val2 = "-2";
2182     gchar *val;
2183     GPtrArray *result;
2184
2185     g_assert_cmpint((*parray_)->len, ==, 3);
2186     g_assert_cmpstr(g_ptr_array_index (*parray_, 0), ==, "0");
2187     g_assert_cmpstr(g_ptr_array_index (*parray_, 1), ==, "1");
2188     g_assert_cmpstr(g_ptr_array_index (*parray_, 2), ==, "2");
2189
2190     result = g_ptr_array_new ();
2191     val = g_strdup (val2);
2192     g_ptr_array_add(result, (gpointer) val);
2193     val = g_strdup (val1);
2194     g_ptr_array_add(result, (gpointer) val);
2195     val = g_strdup ("0");
2196     g_ptr_array_add(result, (gpointer) val);
2197     val = g_strdup ("1");
2198     g_ptr_array_add(result, (gpointer) val);
2199
2200     *parray_ = result;
2201 }
2202
2203 /**
2204  * gi_marshalling_tests_bytearray_full_return:
2205  *
2206  * Returns: (transfer full):
2207  */
2208 GByteArray *
2209 gi_marshalling_tests_bytearray_full_return (void)
2210 {
2211     GByteArray *array = NULL;
2212     guint8 data[] = {'\0', '1', '\xFF', '3'};
2213
2214     array = g_byte_array_new ();
2215     g_byte_array_append (array, (const guint8*)data, G_N_ELEMENTS(data));
2216
2217     return array;
2218
2219 }
2220
2221 /**
2222  * gi_marshalling_tests_bytearray_none_in:
2223  * @v: (element-type gint8) (transfer none):
2224  */
2225 void
2226 gi_marshalling_tests_bytearray_none_in (GByteArray *v)
2227 {
2228     g_assert_cmpuint (v->len, ==, 4);
2229     g_assert_cmpuint (g_array_index (v, unsigned char, 0), ==, 0);
2230     g_assert_cmpuint (g_array_index (v, unsigned char, 1), ==, 49);
2231     g_assert_cmpuint (g_array_index (v, unsigned char, 2), ==, 0xFF);
2232     g_assert_cmpuint (g_array_index (v, unsigned char, 3), ==, 51);
2233 }
2234
2235 /**
2236  * gi_marshalling_tests_gbytes_full_return:
2237  *
2238  * Returns: (transfer full):
2239  */
2240 GBytes *
2241 gi_marshalling_tests_gbytes_full_return (void)
2242 {
2243   static guint8 data[] = {0, 49, 0xFF, 51};
2244
2245   return g_bytes_new_static (data, G_N_ELEMENTS(data));
2246 }
2247
2248 /**
2249  * gi_marshalling_tests_gbytes_none_in:
2250  */
2251 void
2252 gi_marshalling_tests_gbytes_none_in (GBytes *v)
2253 {
2254   const guint8 *data;
2255   gsize len;
2256   data = g_bytes_get_data (v, &len);
2257
2258   g_assert_cmpuint (len, ==, 4);
2259   g_assert_cmpuint (data[0], ==, 0);
2260   g_assert_cmpuint (data[1], ==, 49);
2261   g_assert_cmpuint (data[2], ==, 0xFF);
2262   g_assert_cmpuint (data[3], ==, 51);
2263 }
2264
2265 /**
2266  * gi_marshalling_tests_gstrv_return:
2267  *
2268  * Returns: (transfer full): an array of strings
2269  */
2270 GStrv
2271 gi_marshalling_tests_gstrv_return (void)
2272 {
2273     GStrv values = g_new0 (gchar*, 4);
2274     values[0] = g_strdup ("0");
2275     values[1] = g_strdup ("1");
2276     values[2] = g_strdup ("2");
2277     values[3] = NULL;
2278     return values;
2279 }
2280
2281 /**
2282  * gi_marshalling_tests_gstrv_in:
2283  * @g_strv:
2284  */
2285 void
2286 gi_marshalling_tests_gstrv_in (GStrv g_strv)
2287 {
2288     g_assert_cmpint(g_strv_length(g_strv), ==, 3);
2289     g_assert_cmpstr(g_strv[0], ==, "0");
2290     g_assert_cmpstr(g_strv[1], ==, "1");
2291     g_assert_cmpstr(g_strv[2], ==, "2");
2292 }
2293
2294 /**
2295  * gi_marshalling_tests_gstrv_out:
2296  * @g_strv: (out) (transfer none):
2297  */
2298 void
2299 gi_marshalling_tests_gstrv_out (GStrv *g_strv)
2300 {
2301     static gchar *values[] = {"0", "1", "2", NULL};
2302     *g_strv = values;
2303 }
2304
2305 /**
2306  * gi_marshalling_tests_gstrv_inout:
2307  * @g_strv: (inout) (transfer none):
2308  */
2309 void
2310 gi_marshalling_tests_gstrv_inout (GStrv *g_strv)
2311 {
2312     static gchar *values[] = {"-1", "0", "1", "2", NULL};
2313
2314     g_assert(g_strv_length(*g_strv) == 3);
2315     g_assert(strcmp((*g_strv)[0], "0") == 0);
2316     g_assert(strcmp((*g_strv)[1], "1") == 0);
2317     g_assert(strcmp((*g_strv)[2], "2") == 0);
2318
2319     *g_strv = values;
2320 }
2321
2322 /**
2323  * gi_marshalling_tests_glist_int_none_return:
2324  *
2325  * Returns: (element-type gint) (transfer none):
2326  */
2327 GList *
2328 gi_marshalling_tests_glist_int_none_return (void)
2329 {
2330     static GList *list = NULL;
2331
2332     if (list == NULL) {
2333         list = g_list_append(list, GINT_TO_POINTER(-1));
2334         list = g_list_append(list, GINT_TO_POINTER(0));
2335         list = g_list_append(list, GINT_TO_POINTER(1));
2336         list = g_list_append(list, GINT_TO_POINTER(2));
2337     }
2338
2339     return list;
2340 }
2341
2342 /**
2343  * gi_marshalling_tests_glist_uint32_none_return:
2344  *
2345  * Returns: (element-type guint32) (transfer none):
2346  */
2347 GList *
2348 gi_marshalling_tests_glist_uint32_none_return (void)
2349 {
2350     static GList *list = NULL;
2351
2352     if (list == NULL) {
2353         list = g_list_append(list, GUINT_TO_POINTER(0));
2354         list = g_list_append(list, GUINT_TO_POINTER(G_MAXUINT32));
2355     }
2356
2357     return list;
2358 }
2359
2360 /**
2361  * gi_marshalling_tests_glist_utf8_none_return:
2362  *
2363  * Returns: (element-type utf8) (transfer none):
2364  */
2365 GList *
2366 gi_marshalling_tests_glist_utf8_none_return (void)
2367 {
2368     static GList *list = NULL;
2369
2370     if (list == NULL) {
2371         list = g_list_append(list, "0");
2372         list = g_list_append(list, "1");
2373         list = g_list_append(list, "2");
2374     }
2375
2376     return list;
2377 }
2378
2379 /**
2380  * gi_marshalling_tests_glist_utf8_container_return:
2381  *
2382  * Returns: (element-type utf8) (transfer container):
2383  */
2384 GList *
2385 gi_marshalling_tests_glist_utf8_container_return (void)
2386 {
2387     GList *list = NULL;
2388
2389     list = g_list_append(list, "0");
2390     list = g_list_append(list, "1");
2391     list = g_list_append(list, "2");
2392
2393     return list;
2394 }
2395
2396 /**
2397  * gi_marshalling_tests_glist_utf8_full_return:
2398  *
2399  * Returns: (element-type utf8) (transfer full):
2400  */
2401 GList *
2402 gi_marshalling_tests_glist_utf8_full_return (void)
2403 {
2404     GList *list = NULL;
2405
2406     list = g_list_append(list, g_strdup("0"));
2407     list = g_list_append(list, g_strdup("1"));
2408     list = g_list_append(list, g_strdup("2"));
2409
2410     return list;
2411 }
2412
2413 /**
2414  * gi_marshalling_tests_glist_int_none_in:
2415  * @list: (element-type gint) (transfer none):
2416  */
2417 void
2418 gi_marshalling_tests_glist_int_none_in (GList *list)
2419 {
2420     g_assert_cmpint(g_list_length(list), ==, 4);
2421     g_assert_cmpint(GPOINTER_TO_INT(g_list_nth_data(list, 0)), ==, -1);
2422     g_assert_cmpint(GPOINTER_TO_INT(g_list_nth_data(list, 1)), ==, 0);
2423     g_assert_cmpint(GPOINTER_TO_INT(g_list_nth_data(list, 2)), ==, 1);
2424     g_assert_cmpint(GPOINTER_TO_INT(g_list_nth_data(list, 3)), ==, 2);
2425 }
2426
2427 /**
2428  * gi_marshalling_tests_glist_uint32_none_in:
2429  * @list: (element-type guint32) (transfer none):
2430  */
2431 void
2432 gi_marshalling_tests_glist_uint32_none_in (GList *list)
2433 {
2434     g_assert_cmpint(g_list_length(list), ==, 2);
2435     g_assert_cmpint(GPOINTER_TO_UINT(g_list_nth_data(list, 0)), ==, 0);
2436     g_assert_cmpint(GPOINTER_TO_UINT(g_list_nth_data(list, 1)), ==, G_MAXUINT32);
2437 }
2438
2439 /**
2440  * gi_marshalling_tests_glist_utf8_none_in:
2441  * @list: (element-type utf8) (transfer none):
2442  */
2443 void
2444 gi_marshalling_tests_glist_utf8_none_in (GList *list)
2445 {
2446     g_assert_cmpint(g_list_length(list), ==, 3);
2447     g_assert_cmpint(strcmp(g_list_nth_data(list, 0), "0"), ==, 0);
2448     g_assert_cmpint(strcmp(g_list_nth_data(list, 1), "1"), ==, 0);
2449     g_assert_cmpint(strcmp(g_list_nth_data(list, 2), "2"), ==, 0);
2450 }
2451
2452 /**
2453  * gi_marshalling_tests_glist_utf8_none_out:
2454  * @list: (out) (element-type utf8) (transfer none):
2455  */
2456 void
2457 gi_marshalling_tests_glist_utf8_none_out (GList **list)
2458 {
2459     static GList *values = NULL;
2460
2461     if (values == NULL) {
2462         values = g_list_append(values, "0");
2463         values = g_list_append(values, "1");
2464         values = g_list_append(values, "2");
2465     }
2466
2467     *list = values;
2468 }
2469
2470 /**
2471  * gi_marshalling_tests_glist_utf8_container_out:
2472  * @list: (out) (element-type utf8) (transfer container):
2473  */
2474 void
2475 gi_marshalling_tests_glist_utf8_container_out (GList **list)
2476 {
2477     *list = NULL;
2478
2479     *list = g_list_append(*list, "0");
2480     *list = g_list_append(*list, "1");
2481     *list = g_list_append(*list, "2");
2482 }
2483
2484 /**
2485  * gi_marshalling_tests_glist_utf8_full_out:
2486  * @list: (out) (element-type utf8) (transfer full):
2487  */
2488 void
2489 gi_marshalling_tests_glist_utf8_full_out (GList **list)
2490 {
2491     *list = NULL;
2492
2493     *list = g_list_append(*list, g_strdup("0"));
2494     *list = g_list_append(*list, g_strdup("1"));
2495     *list = g_list_append(*list, g_strdup("2"));
2496 }
2497
2498 /**
2499  * gi_marshalling_tests_glist_utf8_none_inout:
2500  * @list: (inout) (element-type utf8) (transfer none):
2501  */
2502 void
2503 gi_marshalling_tests_glist_utf8_none_inout (GList **list)
2504 {
2505     static GList *values = NULL;
2506
2507     g_assert_cmpint(g_list_length(*list), ==, 3);
2508     g_assert_cmpstr(g_list_nth_data(*list, 0), ==, "0");
2509     g_assert_cmpstr(g_list_nth_data(*list, 1), ==, "1");
2510     g_assert_cmpstr(g_list_nth_data(*list, 2), ==, "2");
2511
2512     if (values == NULL) {
2513         values = g_list_append(values, "-2");
2514         values = g_list_append(values, "-1");
2515         values = g_list_append(values, "0");
2516         values = g_list_append(values, "1");
2517     }
2518
2519     *list = values;
2520 }
2521
2522 /**
2523  * gi_marshalling_tests_glist_utf8_container_inout:
2524  * @list: (inout) (element-type utf8) (transfer container):
2525  */
2526 void
2527 gi_marshalling_tests_glist_utf8_container_inout (GList **list)
2528 {
2529     GList *result = NULL;
2530
2531     g_assert_cmpint(g_list_length(*list), ==, 3);
2532     g_assert_cmpstr(g_list_nth_data(*list, 0), ==, "0");
2533     g_assert_cmpstr(g_list_nth_data(*list, 1), ==, "1");
2534     g_assert_cmpstr(g_list_nth_data(*list, 2), ==, "2");
2535
2536     result = g_list_prepend(result, "1");
2537     result = g_list_prepend(result, "0");
2538     result = g_list_prepend(result, "-1");
2539     result = g_list_prepend(result, "-2");
2540
2541     *list = result;
2542 }
2543
2544 /**
2545  * gi_marshalling_tests_glist_utf8_full_inout:
2546  * @list: (inout) (element-type utf8) (transfer full):
2547  */
2548 void
2549 gi_marshalling_tests_glist_utf8_full_inout (GList **list)
2550 {
2551     GList *result = NULL;
2552
2553     g_assert_cmpint(g_list_length(*list), ==, 3);
2554     g_assert_cmpstr(g_list_nth_data(*list, 0), ==, "0");
2555     g_assert_cmpstr(g_list_nth_data(*list, 1), ==, "1");
2556     g_assert_cmpstr(g_list_nth_data(*list, 2), ==, "2");
2557
2558     result = g_list_prepend(result, g_strdup("1"));
2559     result = g_list_prepend(result, g_strdup("0"));
2560     result = g_list_prepend(result, g_strdup("-1"));
2561     result = g_list_prepend(result, g_strdup("-2"));
2562
2563     *list = result;
2564 }
2565
2566
2567 /**
2568  * gi_marshalling_tests_gslist_int_none_return:
2569  *
2570  * Returns: (element-type gint) (transfer none):
2571  */
2572 GSList *
2573 gi_marshalling_tests_gslist_int_none_return (void)
2574 {
2575     static GSList *list = NULL;
2576
2577     if (list == NULL) {
2578         list = g_slist_prepend(list, GINT_TO_POINTER(-1));
2579         list = g_slist_prepend(list, GINT_TO_POINTER(0));
2580         list = g_slist_prepend(list, GINT_TO_POINTER(1));
2581         list = g_slist_prepend(list, GINT_TO_POINTER(2));
2582         list = g_slist_reverse(list);
2583     }
2584
2585     return list;
2586 }
2587
2588 /**
2589  * gi_marshalling_tests_gslist_utf8_none_return:
2590  *
2591  * Returns: (element-type utf8) (transfer none):
2592  */
2593 GSList *
2594 gi_marshalling_tests_gslist_utf8_none_return (void)
2595 {
2596     static GSList *list = NULL;
2597
2598     if (list == NULL) {
2599         list = g_slist_prepend(list, "0");
2600         list = g_slist_prepend(list, "1");
2601         list = g_slist_prepend(list, "2");
2602         list = g_slist_reverse(list);
2603     }
2604
2605     return list;
2606 }
2607
2608 /**
2609  * gi_marshalling_tests_gslist_utf8_container_return:
2610  *
2611  * Returns: (element-type utf8) (transfer container):
2612  */
2613 GSList *
2614 gi_marshalling_tests_gslist_utf8_container_return (void)
2615 {
2616     GSList *list = NULL;
2617
2618     list = g_slist_prepend(list, "0");
2619     list = g_slist_prepend(list, "1");
2620     list = g_slist_prepend(list, "2");
2621     list = g_slist_reverse(list);
2622
2623     return list;
2624 }
2625
2626 /**
2627  * gi_marshalling_tests_gslist_utf8_full_return:
2628  *
2629  * Returns: (element-type utf8) (transfer full):
2630  */
2631 GSList *
2632 gi_marshalling_tests_gslist_utf8_full_return (void)
2633 {
2634     GSList *list = NULL;
2635
2636     list = g_slist_prepend(list, g_strdup("0"));
2637     list = g_slist_prepend(list, g_strdup("1"));
2638     list = g_slist_prepend(list, g_strdup("2"));
2639     list = g_slist_reverse(list);
2640
2641     return list;
2642 }
2643
2644 /**
2645  * gi_marshalling_tests_gslist_int_none_in:
2646  * @list: (element-type gint) (transfer none):
2647  */
2648 void
2649 gi_marshalling_tests_gslist_int_none_in (GSList *list)
2650 {
2651     g_assert_cmpint(g_slist_length(list), ==, 4);
2652     g_assert_cmpint(GPOINTER_TO_INT(g_slist_nth_data(list, 0)), ==, -1);
2653     g_assert_cmpint(GPOINTER_TO_INT(g_slist_nth_data(list, 1)), ==, 0);
2654     g_assert_cmpint(GPOINTER_TO_INT(g_slist_nth_data(list, 2)), ==, 1);
2655     g_assert_cmpint(GPOINTER_TO_INT(g_slist_nth_data(list, 3)), ==, 2);
2656 }
2657
2658 /**
2659  * gi_marshalling_tests_gslist_utf8_none_in:
2660  * @list: (element-type utf8) (transfer none):
2661  */
2662 void
2663 gi_marshalling_tests_gslist_utf8_none_in (GSList *list)
2664 {
2665     g_assert_cmpint(g_slist_length(list), ==, 3);
2666     g_assert_cmpstr(g_slist_nth_data(list, 0), ==, "0");
2667     g_assert_cmpstr(g_slist_nth_data(list, 1), ==, "1");
2668     g_assert_cmpstr(g_slist_nth_data(list, 2), ==, "2");
2669 }
2670
2671 /**
2672  * gi_marshalling_tests_gslist_utf8_none_out:
2673  * @list: (out) (element-type utf8) (transfer none):
2674  */
2675 void
2676 gi_marshalling_tests_gslist_utf8_none_out (GSList **list)
2677 {
2678     static GSList *values = NULL;
2679
2680     if (values == NULL) {
2681         values = g_slist_prepend(values, "0");
2682         values = g_slist_prepend(values, "1");
2683         values = g_slist_prepend(values, "2");
2684         values = g_slist_reverse(values);
2685     }
2686
2687     *list = values;
2688 }
2689
2690 /**
2691  * gi_marshalling_tests_gslist_utf8_container_out:
2692  * @list: (out) (element-type utf8) (transfer container):
2693  */
2694 void
2695 gi_marshalling_tests_gslist_utf8_container_out (GSList **list)
2696 {
2697     *list = NULL;
2698
2699     *list = g_slist_prepend(*list, "0");
2700     *list = g_slist_prepend(*list, "1");
2701     *list = g_slist_prepend(*list, "2");
2702     *list = g_slist_reverse(*list);
2703 }
2704
2705 /**
2706  * gi_marshalling_tests_gslist_utf8_full_out:
2707  * @list: (out) (element-type utf8) (transfer full):
2708  */
2709 void
2710 gi_marshalling_tests_gslist_utf8_full_out (GSList **list)
2711 {
2712     *list = NULL;
2713
2714     *list = g_slist_prepend(*list, g_strdup("0"));
2715     *list = g_slist_prepend(*list, g_strdup("1"));
2716     *list = g_slist_prepend(*list, g_strdup("2"));
2717     *list = g_slist_reverse(*list);
2718 }
2719
2720 /**
2721  * gi_marshalling_tests_gslist_utf8_none_inout:
2722  * @list: (inout) (element-type utf8) (transfer none):
2723  */
2724 void
2725 gi_marshalling_tests_gslist_utf8_none_inout (GSList **list)
2726 {
2727     static GSList *values = NULL;
2728
2729     g_assert_cmpint(g_slist_length(*list), ==, 3);
2730     g_assert_cmpstr(g_slist_nth_data(*list, 0), ==, "0");
2731     g_assert_cmpstr(g_slist_nth_data(*list, 1), ==, "1");
2732     g_assert_cmpstr(g_slist_nth_data(*list, 2), ==, "2");
2733
2734     if (values == NULL) {
2735         values = g_slist_prepend(values, "-2");
2736         values = g_slist_prepend(values, "-1");
2737         values = g_slist_prepend(values, "0");
2738         values = g_slist_prepend(values, "1");
2739         values = g_slist_reverse(values);
2740     }
2741
2742     *list = values;
2743 }
2744
2745 /**
2746  * gi_marshalling_tests_gslist_utf8_container_inout:
2747  * @list: (inout) (element-type utf8) (transfer container):
2748  */
2749 void
2750 gi_marshalling_tests_gslist_utf8_container_inout (GSList **list)
2751 {
2752     GSList *result = NULL;
2753
2754     g_assert_cmpint(g_slist_length(*list), ==, 3);
2755     g_assert_cmpstr(g_slist_nth_data(*list, 0), ==, "0");
2756     g_assert_cmpstr(g_slist_nth_data(*list, 1), ==, "1");
2757     g_assert_cmpstr(g_slist_nth_data(*list, 2), ==, "2");
2758
2759     result = g_slist_prepend(result, "1");
2760     result = g_slist_prepend(result, "0");
2761     result = g_slist_prepend(result, "-1");
2762     result = g_slist_prepend(result, "-2");
2763
2764     *list = result;
2765 }
2766
2767 /**
2768  * gi_marshalling_tests_gslist_utf8_full_inout:
2769  * @list: (inout) (element-type utf8) (transfer full):
2770  */
2771 void
2772 gi_marshalling_tests_gslist_utf8_full_inout (GSList **list)
2773 {
2774     GSList *result = NULL;
2775
2776     g_assert_cmpint(g_slist_length(*list), ==, 3);
2777     g_assert_cmpstr(g_slist_nth_data(*list, 0), ==, "0");
2778     g_assert_cmpstr(g_slist_nth_data(*list, 1), ==, "1");
2779     g_assert_cmpstr(g_slist_nth_data(*list, 2), ==, "2");
2780
2781     result = g_slist_prepend(result, g_strdup("1"));
2782     result = g_slist_prepend(result, g_strdup("0"));
2783     result = g_slist_prepend(result, g_strdup("-1"));
2784     result = g_slist_prepend(result, g_strdup("-2"));
2785
2786     *list = result;
2787 }
2788
2789
2790 /**
2791  * gi_marshalling_tests_ghashtable_int_none_return:
2792  *
2793  * Returns: (element-type gint gint) (transfer none):
2794  */
2795 GHashTable *
2796 gi_marshalling_tests_ghashtable_int_none_return (void)
2797 {
2798     static GHashTable *hash_table = NULL;
2799
2800     if (hash_table == NULL) {
2801         hash_table = g_hash_table_new(NULL, NULL);
2802         g_hash_table_insert(hash_table, GINT_TO_POINTER(-1), GINT_TO_POINTER(1));
2803         g_hash_table_insert(hash_table, GINT_TO_POINTER(0), GINT_TO_POINTER(0));
2804         g_hash_table_insert(hash_table, GINT_TO_POINTER(1), GINT_TO_POINTER(-1));
2805         g_hash_table_insert(hash_table, GINT_TO_POINTER(2), GINT_TO_POINTER(-2));
2806     }
2807
2808     return hash_table;
2809 }
2810
2811 /**
2812  * gi_marshalling_tests_ghashtable_utf8_none_return:
2813  *
2814  * Returns: (element-type utf8 utf8) (transfer none):
2815  */
2816 GHashTable *
2817 gi_marshalling_tests_ghashtable_utf8_none_return (void)
2818 {
2819     static GHashTable *hash_table = NULL;
2820
2821     if (hash_table == NULL) {
2822         hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2823         g_hash_table_insert(hash_table, "-1", "1");
2824         g_hash_table_insert(hash_table, "0", "0");
2825         g_hash_table_insert(hash_table, "1", "-1");
2826         g_hash_table_insert(hash_table, "2", "-2");
2827     }
2828
2829     return hash_table;
2830 }
2831
2832 /**
2833  * gi_marshalling_tests_ghashtable_utf8_container_return:
2834  *
2835  * Returns: (element-type utf8 utf8) (transfer container):
2836  */
2837 GHashTable *
2838 gi_marshalling_tests_ghashtable_utf8_container_return (void)
2839 {
2840     GHashTable *hash_table = NULL;
2841
2842     hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2843     g_hash_table_insert(hash_table, "-1", "1");
2844     g_hash_table_insert(hash_table, "0", "0");
2845     g_hash_table_insert(hash_table, "1", "-1");
2846     g_hash_table_insert(hash_table, "2", "-2");
2847
2848     return hash_table;
2849 }
2850
2851 /**
2852  * gi_marshalling_tests_ghashtable_utf8_full_return:
2853  *
2854  * Returns: (element-type utf8 utf8) (transfer full):
2855  */
2856 GHashTable *
2857 gi_marshalling_tests_ghashtable_utf8_full_return (void)
2858 {
2859     GHashTable *hash_table = NULL;
2860
2861     hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2862     g_hash_table_insert(hash_table, g_strdup("-1"), g_strdup("1"));
2863     g_hash_table_insert(hash_table, g_strdup("0"), g_strdup("0"));
2864     g_hash_table_insert(hash_table, g_strdup("1"), g_strdup("-1"));
2865     g_hash_table_insert(hash_table, g_strdup("2"), g_strdup("-2"));
2866
2867     return hash_table;
2868 }
2869
2870 /**
2871  * gi_marshalling_tests_ghashtable_int_none_in:
2872  * @hash_table: (element-type gint gint) (transfer none):
2873  */
2874 void
2875 gi_marshalling_tests_ghashtable_int_none_in (GHashTable *hash_table)
2876 {
2877     g_assert_cmpint(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(-1))), ==, 1);
2878     g_assert_cmpint(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(0))), ==, 0);
2879     g_assert_cmpint(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(1))), ==, -1);
2880     g_assert_cmpint(GPOINTER_TO_INT(g_hash_table_lookup(hash_table, GINT_TO_POINTER(2))), ==, -2);
2881 }
2882
2883 /**
2884  * gi_marshalling_tests_ghashtable_utf8_none_in:
2885  * @hash_table: (element-type utf8 utf8) (transfer none):
2886  */
2887 void
2888 gi_marshalling_tests_ghashtable_utf8_none_in (GHashTable *hash_table)
2889 {
2890     g_assert_cmpstr(g_hash_table_lookup(hash_table, "-1"), ==, "1");
2891     g_assert_cmpstr(g_hash_table_lookup(hash_table, "0"), ==, "0");
2892     g_assert_cmpstr(g_hash_table_lookup(hash_table, "1"), ==, "-1");
2893     g_assert_cmpstr(g_hash_table_lookup(hash_table, "2"), ==, "-2");
2894 }
2895
2896 /**
2897  * gi_marshalling_tests_ghashtable_utf8_none_out:
2898  * @hash_table: (out) (element-type utf8 utf8) (transfer none):
2899  */
2900 void
2901 gi_marshalling_tests_ghashtable_utf8_none_out (GHashTable **hash_table)
2902 {
2903     static GHashTable *new_hash_table = NULL;
2904
2905     if (new_hash_table == NULL) {
2906         new_hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2907         g_hash_table_insert(new_hash_table, "-1", "1");
2908         g_hash_table_insert(new_hash_table, "0", "0");
2909         g_hash_table_insert(new_hash_table, "1", "-1");
2910         g_hash_table_insert(new_hash_table, "2", "-2");
2911     }
2912
2913     *hash_table = new_hash_table;
2914 }
2915
2916 /**
2917  * gi_marshalling_tests_ghashtable_utf8_container_out:
2918  * @hash_table: (out) (element-type utf8 utf8) (transfer container):
2919  */
2920 void
2921 gi_marshalling_tests_ghashtable_utf8_container_out (GHashTable **hash_table)
2922 {
2923     *hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2924     g_hash_table_insert(*hash_table, "-1", "1");
2925     g_hash_table_insert(*hash_table, "0", "0");
2926     g_hash_table_insert(*hash_table, "1", "-1");
2927     g_hash_table_insert(*hash_table, "2", "-2");
2928 }
2929
2930 /**
2931  * gi_marshalling_tests_ghashtable_utf8_full_out:
2932  * @hash_table: (out) (element-type utf8 utf8) (transfer full):
2933  */
2934 void
2935 gi_marshalling_tests_ghashtable_utf8_full_out (GHashTable **hash_table)
2936 {
2937     *hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2938     g_hash_table_insert(*hash_table, g_strdup("-1"), g_strdup("1"));
2939     g_hash_table_insert(*hash_table, g_strdup("0"), g_strdup("0"));
2940     g_hash_table_insert(*hash_table, g_strdup("1"), g_strdup("-1"));
2941     g_hash_table_insert(*hash_table, g_strdup("2"), g_strdup("-2"));
2942 }
2943
2944 /**
2945  * gi_marshalling_tests_ghashtable_utf8_none_inout:
2946  * @hash_table: (inout) (element-type utf8 utf8) (transfer none):
2947  */
2948 void
2949 gi_marshalling_tests_ghashtable_utf8_none_inout (GHashTable **hash_table)
2950 {
2951     static GHashTable *new_hash_table = NULL;
2952
2953     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "-1"), ==, "1");
2954     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "0"), ==, "0");
2955     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "1"), ==, "-1");
2956     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "2"), ==, "-2");
2957
2958     if (new_hash_table == NULL) {
2959         new_hash_table = g_hash_table_new(g_str_hash, g_str_equal);
2960         g_hash_table_insert(new_hash_table, "-1", "1");
2961         g_hash_table_insert(new_hash_table, "0", "0");
2962         g_hash_table_insert(new_hash_table, "1", "1");
2963     }
2964
2965     *hash_table = new_hash_table;
2966 }
2967
2968 /**
2969  * gi_marshalling_tests_ghashtable_utf8_container_inout:
2970  * @hash_table: (inout) (element-type utf8 utf8) (transfer container):
2971  */
2972 void
2973 gi_marshalling_tests_ghashtable_utf8_container_inout (GHashTable **hash_table)
2974 {
2975     GHashTable *result = g_hash_table_new(g_str_hash, g_str_equal);
2976
2977     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "-1"), ==, "1");
2978     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "0"), ==, "0");
2979     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "1"), ==, "-1");
2980     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "2"), ==, "-2");
2981
2982     g_hash_table_insert(result, "-1", "1");
2983     g_hash_table_insert(result, "0", "0");
2984     g_hash_table_insert(result, "1", "1");
2985
2986     *hash_table = result;
2987 }
2988
2989 /**
2990  * gi_marshalling_tests_ghashtable_utf8_full_inout:
2991  * @hash_table: (inout) (element-type utf8 utf8) (transfer full):
2992  */
2993 void
2994 gi_marshalling_tests_ghashtable_utf8_full_inout (GHashTable **hash_table)
2995 {
2996     GHashTable *result = g_hash_table_new_full(g_str_hash, g_str_equal,
2997                                                g_free, g_free);
2998
2999     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "-1"), ==, "1");
3000     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "0"), ==, "0");
3001     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "1"), ==, "-1");
3002     g_assert_cmpstr(g_hash_table_lookup(*hash_table, "2"), ==, "-2");
3003
3004     g_hash_table_insert(result, g_strdup("-1"), g_strdup("1"));
3005     g_hash_table_insert(result, g_strdup("0"), g_strdup("0"));
3006     g_hash_table_insert(result, g_strdup("1"), g_strdup("1"));
3007
3008     *hash_table = result;
3009 }
3010
3011
3012 /**
3013  * gi_marshalling_tests_gvalue_return:
3014  *
3015  * Returns: (transfer none):
3016  */
3017 GValue *
3018 gi_marshalling_tests_gvalue_return (void)
3019 {
3020     static GValue *value = NULL;
3021
3022     if (value == NULL) {
3023         value = g_new0(GValue, 1);
3024         g_value_init(value, G_TYPE_INT);
3025         g_value_set_int(value, 42);
3026     }
3027
3028     return value;
3029 }
3030
3031 /**
3032  * gi_marshalling_tests_gvalue_in:
3033  * @value: (transfer none):
3034  */
3035 void
3036 gi_marshalling_tests_gvalue_in (GValue *value)
3037 {
3038     g_assert_cmpint(g_value_get_int(value), ==, 42);
3039 }
3040
3041 /**
3042  * gi_marshalling_tests_gvalue_int64_in:
3043  * @value: (transfer none):
3044  */
3045 void
3046 gi_marshalling_tests_gvalue_int64_in (GValue *value)
3047 {
3048     g_assert_cmpint(g_value_get_int64(value), ==, G_MAXINT64);
3049 }
3050
3051 /**
3052  * gi_marshalling_tests_gvalue_in_with_type:
3053  * @value: (transfer none):
3054  * @type:
3055  */
3056 void
3057 gi_marshalling_tests_gvalue_in_with_type (GValue *value, GType type)
3058 {
3059   g_assert(g_type_is_a(G_VALUE_TYPE(value), type));
3060 }
3061
3062 /**
3063  * gi_marshalling_tests_gvalue_in_enum:
3064  * @value: (transfer none):
3065  */
3066 void
3067 gi_marshalling_tests_gvalue_in_enum (GValue *value)
3068 {
3069     g_assert(g_value_get_enum(value) == GI_MARSHALLING_TESTS_ENUM_VALUE3);
3070 }
3071
3072 /**
3073  * gi_marshalling_tests_gvalue_out:
3074  * @value: (out) (transfer none):
3075  */
3076 void
3077 gi_marshalling_tests_gvalue_out (GValue **value)
3078 {
3079     static GValue *new_value = NULL;
3080
3081     if (new_value == NULL) {
3082         new_value = g_new0(GValue, 1);
3083         g_value_init(new_value, G_TYPE_INT);
3084         g_value_set_int(new_value, 42);
3085     }
3086
3087     *value = new_value;
3088 }
3089
3090 /**
3091  * gi_marshalling_tests_gvalue_int64_out:
3092  * @value: (out) (transfer none):
3093  */
3094 void
3095 gi_marshalling_tests_gvalue_int64_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_INT64);
3102         g_value_set_int64(new_value, G_MAXINT64);
3103     }
3104
3105     *value = new_value;
3106 }
3107
3108 /**
3109  * gi_marshalling_tests_gvalue_out_caller_allocates:
3110  * @value: (out) (transfer none):
3111  */
3112 void
3113 gi_marshalling_tests_gvalue_out_caller_allocates (GValue *value)
3114 {
3115     g_value_init(value, G_TYPE_INT);
3116     g_value_set_int(value, 42);
3117 }
3118
3119 /**
3120  * gi_marshalling_tests_gvalue_inout:
3121  * @value: (inout) (transfer none):
3122  */
3123 void
3124 gi_marshalling_tests_gvalue_inout (GValue **value)
3125 {
3126     g_assert_cmpint(g_value_get_int(*value), ==, 42);
3127     g_value_unset(*value);
3128     g_value_init(*value, G_TYPE_STRING);
3129     g_value_set_string(*value, "42");
3130 }
3131
3132 /**
3133  * gi_marshalling_tests_gvalue_flat_array:
3134  * @n_values: number of values
3135  * @values: (array length=n_values): an array containing values
3136  */
3137 void
3138 gi_marshalling_tests_gvalue_flat_array (guint         n_values,
3139                                         const GValue *values)
3140 {
3141     g_assert (n_values == 3);
3142
3143     g_assert_cmpint (g_value_get_int (&values[0]), ==, 42);
3144     g_assert_cmpstr (g_value_get_string (&values[1]), ==, "42");
3145     g_assert_cmpint (g_value_get_boolean (&values[2]), ==, TRUE);
3146 }
3147
3148 /**
3149  * gi_marshalling_tests_return_gvalue_flat_array:
3150  *
3151  * Returns: (array fixed-size=3) (transfer full): a flat GValue array
3152  */
3153 GValue *
3154 gi_marshalling_tests_return_gvalue_flat_array (void)
3155 {
3156     GValue *array = g_new0 (GValue, 3);
3157
3158     g_value_init (&array[0], G_TYPE_INT);
3159     g_value_set_int (&array[0], 42);
3160
3161     g_value_init (&array[1], G_TYPE_STRING);
3162     g_value_set_static_string (&array[1], "42");
3163
3164     g_value_init (&array[2], G_TYPE_BOOLEAN);
3165     g_value_set_boolean (&array[2], TRUE);
3166
3167     return array;
3168 }
3169
3170 /**
3171  * gi_marshalling_tests_gvalue_flat_array_round_trip:
3172  * @one: The first GValue
3173  * @two: The second GValue
3174  * @three: The third GValue
3175  *
3176  * Returns: (array fixed-size=3) (transfer full): a flat array of [@one, @two, @three]
3177  */
3178 GValue *
3179 gi_marshalling_tests_gvalue_flat_array_round_trip (const GValue one,
3180                                                    const GValue two,
3181                                                    const GValue three)
3182 {
3183     GValue *array = g_new (GValue, 3);
3184     array[0] = one;
3185     array[1] = two;
3186     array[2] = three;
3187
3188     return array;
3189 }
3190
3191 /**
3192  * gi_marshalling_tests_gclosure_in:
3193  * @closure: (transfer none):
3194  */
3195 void
3196 gi_marshalling_tests_gclosure_in (GClosure *closure)
3197 {
3198     GValue return_value = {0, };
3199
3200     g_value_init (&return_value, G_TYPE_INT);
3201
3202     g_closure_invoke (closure,
3203             &return_value,
3204             0, NULL,
3205             NULL);
3206
3207     g_assert_cmpint(g_value_get_int (&return_value), ==, 42);
3208
3209     g_value_unset(&return_value);
3210 }
3211
3212 static gint
3213 _closure_return_42 (void)
3214 {
3215   return 42;
3216 }
3217
3218 static void
3219 _marshal_INT__VOID (GClosure *closure,
3220                     GValue *return_value,
3221                     guint n_param_values,
3222                     const GValue *param_values,
3223                     gpointer invocation_hint,
3224                     gpointer marshal_data)
3225 {
3226   typedef gint (*GMarshalFunc_INT__VOID) (void);
3227   register GMarshalFunc_INT__VOID callback;
3228   register GCClosure *cc = (GCClosure*) closure;
3229
3230   callback = (GMarshalFunc_INT__VOID) cc->callback;
3231   g_value_set_int(return_value, callback());
3232 }
3233
3234 /**
3235  * gi_marshalling_tests_gclosure_return:
3236  * 
3237  * Return: a #GClosure
3238  */
3239 GClosure *
3240 gi_marshalling_tests_gclosure_return (void)
3241 {
3242     GClosure *closure = g_cclosure_new ((GCallback)_closure_return_42,
3243                                         NULL, NULL);
3244     g_closure_set_marshal (closure, _marshal_INT__VOID);
3245
3246     return closure;
3247 }
3248
3249
3250 /**
3251  * gi_marshalling_tests_callback_return_value_only:
3252  * @callback: (scope call):
3253  */
3254 glong
3255 gi_marshalling_tests_callback_return_value_only (GIMarshallingTestsCallbackReturnValueOnly callback)
3256 {
3257     return callback ();
3258 }
3259
3260 /**
3261  * gi_marshalling_tests_callback_one_out_parameter:
3262  * @callback: (scope call):
3263  * @a: (out):
3264  */
3265 void
3266 gi_marshalling_tests_callback_one_out_parameter (GIMarshallingTestsCallbackOneOutParameter  callback,
3267                                                  gfloat                                    *a)
3268 {
3269     callback (a);
3270 }
3271
3272 /**
3273  * gi_marshalling_tests_callback_multiple_out_parameters:
3274  * @callback: (scope call):
3275  * @a: (out):
3276  * @b: (out):
3277  */
3278 void
3279 gi_marshalling_tests_callback_multiple_out_parameters (GIMarshallingTestsCallbackMultipleOutParameters  callback,
3280                                                        gfloat                                          *a,
3281                                                        gfloat                                          *b)
3282 {
3283     callback (a, b);
3284 }
3285
3286 /**
3287  * gi_marshalling_tests_callback_return_value_and_one_out_parameter:
3288  * @callback: (scope call):
3289  * @a: (out):
3290  */
3291 glong
3292 gi_marshalling_tests_callback_return_value_and_one_out_parameter (GIMarshallingTestsCallbackReturnValueAndOneOutParameter  callback,
3293                                                                   glong                                                   *a)
3294 {
3295     return callback (a);
3296 }
3297
3298 /**
3299  * gi_marshalling_tests_callback_return_value_and_multiple_out_parameters:
3300  * @callback: (scope call):
3301  * @a: (out):
3302  * @b: (out):
3303  */
3304 glong
3305 gi_marshalling_tests_callback_return_value_and_multiple_out_parameters (GIMarshallingTestsCallbackReturnValueAndMultipleOutParameters  callback,
3306                                                                         glong                                                         *a,
3307                                                                         glong                                                         *b)
3308 {
3309     return callback (a, b);
3310 }
3311
3312
3313
3314 /**
3315  * gi_marshalling_tests_pointer_in_return:
3316  *
3317  * Returns: (transfer none): The same pointer
3318  */
3319 gpointer
3320 gi_marshalling_tests_pointer_in_return (gpointer pointer)
3321 {
3322     return pointer;
3323 }
3324
3325 GType
3326 gi_marshalling_tests_genum_get_type (void)
3327 {
3328     static GType type = 0;
3329     if (G_UNLIKELY(type == 0)) {
3330         static const GEnumValue values[] = {
3331             { GI_MARSHALLING_TESTS_GENUM_VALUE1, "GI_MARSHALLING_TESTS_GENUM_VALUE1", "value1" },
3332             { GI_MARSHALLING_TESTS_GENUM_VALUE2, "GI_MARSHALLING_TESTS_GENUM_VALUE2", "value2" },
3333             { GI_MARSHALLING_TESTS_GENUM_VALUE3, "GI_MARSHALLING_TESTS_GENUM_VALUE3", "value3" },
3334             { 0, NULL, NULL }
3335         };
3336         type = g_enum_register_static (g_intern_static_string ("GIMarshallingTestsGEnum"), values);
3337     }
3338
3339     return type;
3340 }
3341
3342 GIMarshallingTestsGEnum
3343 gi_marshalling_tests_genum_returnv (void)
3344 {
3345     return GI_MARSHALLING_TESTS_GENUM_VALUE3;
3346 }
3347
3348 void
3349 gi_marshalling_tests_genum_in (GIMarshallingTestsGEnum v)
3350 {
3351     g_assert_cmpint(v, ==, GI_MARSHALLING_TESTS_GENUM_VALUE3);
3352 }
3353
3354 /**
3355  * gi_marshalling_tests_genum_out:
3356  * @v: (out):
3357  */
3358 void
3359 gi_marshalling_tests_genum_out (GIMarshallingTestsGEnum *v)
3360 {
3361     *v = GI_MARSHALLING_TESTS_GENUM_VALUE3;
3362 }
3363
3364 /**
3365  * gi_marshalling_tests_genum_inout:
3366  * @v: (inout):
3367  */
3368 void
3369 gi_marshalling_tests_genum_inout (GIMarshallingTestsGEnum *v)
3370 {
3371     g_assert_cmpint(*v, ==, GI_MARSHALLING_TESTS_GENUM_VALUE3);
3372     *v = GI_MARSHALLING_TESTS_GENUM_VALUE1;
3373 }
3374
3375
3376 GIMarshallingTestsEnum
3377 gi_marshalling_tests_enum_returnv (void)
3378 {
3379     return GI_MARSHALLING_TESTS_ENUM_VALUE3;
3380 }
3381
3382 void
3383 gi_marshalling_tests_enum_in (GIMarshallingTestsEnum v)
3384 {
3385     g_assert_cmpint(v, ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
3386 }
3387
3388 /**
3389  * gi_marshalling_tests_enum_out:
3390  * @v: (out):
3391  */
3392 void
3393 gi_marshalling_tests_enum_out (GIMarshallingTestsEnum *v)
3394 {
3395     *v = GI_MARSHALLING_TESTS_ENUM_VALUE3;
3396 }
3397
3398 /**
3399  * gi_marshalling_tests_enum_inout:
3400  * @v: (inout):
3401  */
3402 void
3403 gi_marshalling_tests_enum_inout (GIMarshallingTestsEnum *v)
3404 {
3405     g_assert_cmpint(*v, ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
3406     *v = GI_MARSHALLING_TESTS_ENUM_VALUE1;
3407 }
3408
3409
3410 GType
3411 gi_marshalling_tests_flags_get_type (void)
3412 {
3413     static GType type = 0;
3414     if (G_UNLIKELY(type == 0)) {
3415         static const GFlagsValue values[] = {
3416             { GI_MARSHALLING_TESTS_FLAGS_VALUE1, "GI_MARSHALLING_TESTS_FLAGS_VALUE1", "value1" },
3417             { GI_MARSHALLING_TESTS_FLAGS_VALUE2, "GI_MARSHALLING_TESTS_FLAGS_VALUE2", "value2" },
3418             { GI_MARSHALLING_TESTS_FLAGS_VALUE3, "GI_MARSHALLING_TESTS_FLAGS_VALUE3", "value3" },
3419             { GI_MARSHALLING_TESTS_FLAGS_MASK,   "GI_MARSHALLING_TESTS_FLAGS_MASK",   "mask"   },
3420             { GI_MARSHALLING_TESTS_FLAGS_MASK2,  "GI_MARSHALLING_TESTS_FLAGS_MASK2",  "mask2"  },
3421             { 0, NULL, NULL }
3422         };
3423         type = g_flags_register_static (g_intern_static_string ("GIMarshallingTestsFlags"), values);
3424     }
3425
3426     return type;
3427 }
3428
3429 GIMarshallingTestsFlags
3430 gi_marshalling_tests_flags_returnv (void)
3431 {
3432     return GI_MARSHALLING_TESTS_FLAGS_VALUE2;
3433 }
3434
3435 void
3436 gi_marshalling_tests_flags_in (GIMarshallingTestsFlags v)
3437 {
3438     g_assert(v == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
3439 }
3440
3441 void
3442 gi_marshalling_tests_flags_in_zero (GIMarshallingTestsFlags v)
3443 {
3444     g_assert(v == 0);
3445 }
3446
3447 /**
3448  * gi_marshalling_tests_flags_out:
3449  * @v: (out):
3450  */
3451 void
3452 gi_marshalling_tests_flags_out (GIMarshallingTestsFlags *v)
3453 {
3454     *v = GI_MARSHALLING_TESTS_FLAGS_VALUE2;
3455 }
3456
3457 /**
3458  * gi_marshalling_tests_flags_inout:
3459  * @v: (inout):
3460  */
3461 void
3462 gi_marshalling_tests_flags_inout (GIMarshallingTestsFlags *v)
3463 {
3464     g_assert(*v == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
3465     *v = GI_MARSHALLING_TESTS_FLAGS_VALUE1;
3466 }
3467
3468
3469 GIMarshallingTestsNoTypeFlags
3470 gi_marshalling_tests_no_type_flags_returnv (void)
3471 {
3472     return GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
3473 }
3474
3475 void
3476 gi_marshalling_tests_no_type_flags_in (GIMarshallingTestsNoTypeFlags v)
3477 {
3478     g_assert(v == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
3479 }
3480
3481 void
3482 gi_marshalling_tests_no_type_flags_in_zero (GIMarshallingTestsNoTypeFlags v)
3483 {
3484     g_assert(v == 0);
3485 }
3486
3487 /**
3488  * gi_marshalling_tests_no_type_flags_out:
3489  * @v: (out):
3490  */
3491 void
3492 gi_marshalling_tests_no_type_flags_out (GIMarshallingTestsNoTypeFlags *v)
3493 {
3494     *v = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
3495 }
3496
3497 /**
3498  * gi_marshalling_tests_no_type_flags_inout:
3499  * @v: (inout):
3500  */
3501 void
3502 gi_marshalling_tests_no_type_flags_inout (GIMarshallingTestsNoTypeFlags *v)
3503 {
3504     g_assert(*v == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
3505     *v = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE1;
3506 }
3507
3508
3509 /**
3510  * gi_marshalling_tests_simple_struct_returnv:
3511  *
3512  * Returns: (transfer none):
3513  */
3514 GIMarshallingTestsSimpleStruct *
3515 gi_marshalling_tests_simple_struct_returnv (void)
3516 {
3517     static GIMarshallingTestsSimpleStruct *struct_ = NULL;
3518
3519     if (struct_ == NULL) {
3520         struct_ = g_new(GIMarshallingTestsSimpleStruct, 1);
3521
3522         struct_->long_ = 6;
3523         struct_->int8 = 7;
3524     }
3525
3526     return struct_;
3527 }
3528
3529 /**
3530  * gi_marshalling_tests_simple_struct_inv:
3531  * @struct_: (transfer none):
3532  */
3533 void
3534 gi_marshalling_tests_simple_struct_inv (GIMarshallingTestsSimpleStruct *struct_)
3535 {
3536     g_assert_cmpint(struct_->long_, ==, 6);
3537     g_assert_cmpint(struct_->int8, ==, 7);
3538 }
3539
3540 void
3541 gi_marshalling_tests_simple_struct_method (GIMarshallingTestsSimpleStruct *struct_)
3542 {
3543     g_assert_cmpint(struct_->long_, ==, 6);
3544     g_assert_cmpint(struct_->int8, ==, 7);
3545 }
3546
3547
3548 GType
3549 gi_marshalling_tests_pointer_struct_get_type (void)
3550 {
3551     static GType type = 0;
3552
3553     if (type == 0) {
3554         type = g_pointer_type_register_static ("GIMarshallingTestsPointerStruct");
3555     }
3556
3557     return type;
3558 }
3559
3560 /**
3561  * gi_marshalling_tests_pointer_struct_returnv:
3562  *
3563  * Returns: (transfer none):
3564  */
3565 GIMarshallingTestsPointerStruct *
3566 gi_marshalling_tests_pointer_struct_returnv (void)
3567 {
3568     static GIMarshallingTestsPointerStruct *struct_ = NULL;
3569
3570     if (struct_ == NULL) {
3571         struct_ = g_new(GIMarshallingTestsPointerStruct, 1);
3572
3573         struct_->long_ = 42;
3574     }
3575
3576     return struct_;
3577 }
3578
3579 /**
3580  * gi_marshalling_tests_pointer_struct_inv:
3581  * @struct_: (transfer none):
3582  */
3583 void
3584 gi_marshalling_tests_pointer_struct_inv (GIMarshallingTestsPointerStruct *struct_)
3585 {
3586     g_assert_cmpint(struct_->long_, ==, 42);
3587 }
3588
3589 static GIMarshallingTestsBoxedStruct *
3590 gi_marshalling_tests_boxed_struct_copy (GIMarshallingTestsBoxedStruct *struct_)
3591 {
3592     GIMarshallingTestsBoxedStruct *new_struct;
3593
3594     if (struct_ == NULL)
3595         return NULL;
3596
3597     new_struct = g_slice_new (GIMarshallingTestsBoxedStruct);
3598
3599     *new_struct = *struct_;
3600
3601     return new_struct;
3602 }
3603
3604 static void
3605 gi_marshalling_tests_boxed_struct_free (GIMarshallingTestsBoxedStruct *struct_)
3606 {
3607     if (struct_ != NULL)
3608         g_slice_free (GIMarshallingTestsBoxedStruct, struct_);
3609 }
3610
3611 GType
3612 gi_marshalling_tests_boxed_struct_get_type (void)
3613 {
3614     static GType type = 0;
3615
3616     if (type == 0) {
3617         type = g_boxed_type_register_static ("GIMarshallingTestsBoxedStruct",
3618                 (GBoxedCopyFunc) gi_marshalling_tests_boxed_struct_copy,
3619                 (GBoxedFreeFunc) gi_marshalling_tests_boxed_struct_free);
3620     }
3621
3622     return type;
3623 }
3624
3625 GIMarshallingTestsBoxedStruct *
3626 gi_marshalling_tests_boxed_struct_new (void)
3627 {
3628     return g_slice_new0 (GIMarshallingTestsBoxedStruct);
3629 }
3630
3631 /**
3632  * gi_marshalling_tests_boxed_struct_returnv:
3633  *
3634  * Returns: (transfer none):
3635  */
3636 GIMarshallingTestsBoxedStruct *
3637 gi_marshalling_tests_boxed_struct_returnv (void)
3638 {
3639     static GIMarshallingTestsBoxedStruct *struct_ = NULL;
3640
3641     if (struct_ == NULL) {
3642         struct_ = g_new(GIMarshallingTestsBoxedStruct, 1);
3643
3644         struct_->long_ = 42;
3645         struct_->g_strv = g_new0(gchar*, 4);
3646         struct_->g_strv[0] = g_strdup("0");
3647         struct_->g_strv[1] = g_strdup("1");
3648         struct_->g_strv[2] = g_strdup("2");
3649         struct_->g_strv[3] = NULL;
3650     }
3651
3652     return struct_;
3653 }
3654
3655 /**
3656  * gi_marshalling_tests_boxed_struct_inv:
3657  * @struct_: (transfer none):
3658  */
3659 void
3660 gi_marshalling_tests_boxed_struct_inv (GIMarshallingTestsBoxedStruct *struct_)
3661 {
3662     g_assert_cmpint(struct_->long_, ==, 42);
3663 }
3664
3665 /**
3666  * gi_marshalling_tests_boxed_struct_out:
3667  * @struct_: (out) (transfer none):
3668  */
3669 void
3670 gi_marshalling_tests_boxed_struct_out (GIMarshallingTestsBoxedStruct **struct_)
3671 {
3672     static GIMarshallingTestsBoxedStruct *new_struct = NULL;
3673
3674     if (new_struct == NULL) {
3675         new_struct = g_new(GIMarshallingTestsBoxedStruct, 1);
3676
3677         new_struct->long_ = 42;
3678     }
3679
3680     *struct_ = new_struct;
3681 }
3682
3683 /**
3684  * gi_marshalling_tests_boxed_struct_inout:
3685  * @struct_: (inout) (transfer full):
3686  */
3687 void
3688 gi_marshalling_tests_boxed_struct_inout (GIMarshallingTestsBoxedStruct **struct_)
3689 {
3690     g_assert_cmpint((*struct_)->long_, ==, 42);
3691
3692     (*struct_) = g_slice_new (GIMarshallingTestsBoxedStruct);
3693     (*struct_)->long_ = 0;
3694 }
3695
3696 static GIMarshallingTestsUnion *
3697 gi_marshalling_tests_union_copy (GIMarshallingTestsUnion *union_)
3698 {
3699     GIMarshallingTestsUnion *new_union;
3700
3701     new_union = g_slice_new (GIMarshallingTestsUnion);
3702
3703     *new_union = *union_;
3704
3705     return new_union;
3706 }
3707
3708 static void
3709 gi_marshalling_tests_union_free (GIMarshallingTestsUnion *union_)
3710 {
3711     g_slice_free (GIMarshallingTestsUnion, union_);
3712 }
3713
3714 GType
3715 gi_marshalling_tests_union_get_type (void)
3716 {
3717     static GType type = 0;
3718
3719     if (type == 0) {
3720         type = g_boxed_type_register_static ("GIMarshallingTestsUnion",
3721                 (GBoxedCopyFunc) gi_marshalling_tests_union_copy,
3722                 (GBoxedFreeFunc) gi_marshalling_tests_union_free);
3723     }
3724
3725     return type;
3726 }
3727
3728 /**
3729  * gi_marshalling_tests_union_returnv:
3730  *
3731  * Returns: (transfer none):
3732  */
3733 GIMarshallingTestsUnion *
3734 gi_marshalling_tests_union_returnv (void)
3735 {
3736     static GIMarshallingTestsUnion *union_ = NULL;
3737
3738     if (union_ == NULL) {
3739         union_ = g_new(GIMarshallingTestsUnion, 1);
3740
3741         union_->long_ = 42;
3742     }
3743
3744     return union_;
3745 }
3746
3747 /**
3748  * gi_marshalling_tests_union_inv:
3749  * @union_: (transfer none):
3750  */
3751 void
3752 gi_marshalling_tests_union_inv (GIMarshallingTestsUnion *union_)
3753 {
3754     g_assert_cmpint(union_->long_, ==, 42);
3755 }
3756
3757 void
3758 gi_marshalling_tests_union_method (GIMarshallingTestsUnion *union_)
3759 {
3760     g_assert_cmpint(union_->long_, ==, 42);
3761 }
3762
3763
3764
3765 enum
3766 {
3767         PROP_0,
3768         PROP_INT_
3769 };
3770
3771 static void gi_marshalling_tests_object_real_method_with_default_implementation (
3772         GIMarshallingTestsObject *self, gint8 in);
3773
3774 G_DEFINE_TYPE (GIMarshallingTestsObject, gi_marshalling_tests_object, G_TYPE_OBJECT);
3775
3776 static void
3777 gi_marshalling_tests_object_init (GIMarshallingTestsObject *object)
3778 {
3779 }
3780
3781 static void
3782 gi_marshalling_tests_object_finalize (GObject *object)
3783 {
3784         G_OBJECT_CLASS (gi_marshalling_tests_object_parent_class)->finalize (object);
3785 }
3786
3787 static void
3788 gi_marshalling_tests_object_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
3789 {
3790         g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3791
3792         switch (prop_id) {
3793         case PROP_INT_:
3794             GI_MARSHALLING_TESTS_OBJECT (object)->int_ = g_value_get_int (value);
3795             break;
3796         default:
3797             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3798             break;
3799         }
3800 }
3801
3802 static void
3803 gi_marshalling_tests_object_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
3804 {
3805         g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3806
3807         switch (prop_id) {
3808         case PROP_INT_:
3809             g_value_set_int (value, GI_MARSHALLING_TESTS_OBJECT (object)->int_);
3810             break;
3811         default:
3812             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3813             break;
3814         }
3815 }
3816
3817 static void
3818 gi_marshalling_tests_object_class_init (GIMarshallingTestsObjectClass *klass)
3819 {
3820         GObjectClass* object_class = G_OBJECT_CLASS (klass);
3821 #if 0
3822         GObjectClass* parent_class = G_OBJECT_CLASS (klass);
3823 #endif
3824
3825         object_class->finalize = gi_marshalling_tests_object_finalize;
3826         object_class->set_property = gi_marshalling_tests_object_set_property;
3827         object_class->get_property = gi_marshalling_tests_object_get_property;
3828
3829         g_object_class_install_property (object_class, PROP_INT_,
3830          g_param_spec_int ("int", "Integer", "An integer", G_MININT, G_MAXINT, 0,
3831               G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
3832
3833     klass->method_with_default_implementation = gi_marshalling_tests_object_real_method_with_default_implementation;
3834 }
3835
3836
3837 void
3838 gi_marshalling_tests_object_static_method (void)
3839 {
3840 }
3841
3842 void
3843 gi_marshalling_tests_object_method (GIMarshallingTestsObject *object)
3844 {
3845         g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3846     g_assert_cmpint (object->int_, ==, 42);
3847 }
3848
3849 void
3850 gi_marshalling_tests_object_overridden_method (GIMarshallingTestsObject *object)
3851 {
3852         g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
3853     g_assert_cmpint (object->int_, ==, 0);
3854 }
3855
3856 GIMarshallingTestsObject *
3857 gi_marshalling_tests_object_new (gint int_)
3858 {
3859     return g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, "int", int_, NULL);
3860 }
3861
3862 /**
3863  * gi_marshalling_tests_object_method_array_in:
3864  * @ints: (array length=length):
3865  */
3866 void
3867 gi_marshalling_tests_object_method_array_in (GIMarshallingTestsObject *object, const gint *ints, gint length)
3868 {
3869     g_assert_cmpint(length, ==, 4);
3870     g_assert_cmpint(ints[0], ==, -1);
3871     g_assert_cmpint(ints[1], ==, 0);
3872     g_assert_cmpint(ints[2], ==, 1);
3873     g_assert_cmpint(ints[3], ==, 2);
3874 }
3875
3876 /**
3877  * gi_marshalling_tests_object_method_array_out:
3878  * @ints: (out) (array length=length) (transfer none):
3879  */
3880 void
3881 gi_marshalling_tests_object_method_array_out (GIMarshallingTestsObject *object, gint **ints, gint *length)
3882 {
3883     static gint values[] = {-1, 0, 1, 2};
3884
3885     *length = 4;
3886     *ints = values;
3887 }
3888
3889 /**
3890  * gi_marshalling_tests_object_method_array_inout:
3891  * @ints: (inout) (array length=length) (transfer none):
3892  * @length: (inout):
3893  */
3894 void
3895 gi_marshalling_tests_object_method_array_inout (GIMarshallingTestsObject *object, gint **ints, gint *length)
3896 {
3897     static gint values[] = {-2, -1, 0, 1, 2};
3898
3899     g_assert_cmpint(*length, ==, 4);
3900     g_assert_cmpint((*ints)[0], ==, -1);
3901     g_assert_cmpint((*ints)[1], ==, 0);
3902     g_assert_cmpint((*ints)[2], ==, 1);
3903     g_assert_cmpint((*ints)[3], ==, 2);
3904
3905     *length = 5;
3906     *ints = values;
3907 }
3908
3909 /**
3910  * gi_marshalling_tests_object_method_array_return:
3911  *
3912  * Returns: (array length=length):
3913  */
3914 const gint *
3915 gi_marshalling_tests_object_method_array_return (GIMarshallingTestsObject *object, gint *length)
3916 {
3917     static gint ints[] = {-1, 0, 1, 2};
3918
3919     *length = 4;
3920     return ints;
3921 }
3922
3923 /**
3924  * gi_marshalling_tests_object_method_int8_in:
3925  * @in: (in):
3926  */
3927 void
3928 gi_marshalling_tests_object_method_int8_in (GIMarshallingTestsObject *self, gint8 in)
3929 {
3930   GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_in (self, in);
3931 }
3932
3933 /**
3934  * gi_marshalling_tests_object_method_int8_out:
3935  * @out: (out):
3936  */
3937 void
3938 gi_marshalling_tests_object_method_int8_out (GIMarshallingTestsObject *self, gint8 *out)
3939 {
3940   GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_out (self, out);
3941 }
3942
3943 /**
3944  * gi_marshalling_tests_object_method_with_default_implementation:
3945  * @in: (in):
3946  */
3947 void
3948 gi_marshalling_tests_object_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
3949 {
3950     GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_with_default_implementation (self, in);
3951 }
3952
3953 static void
3954 gi_marshalling_tests_object_real_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
3955 {
3956     GValue val = {0, };
3957     g_value_init (&val, G_TYPE_INT);
3958     g_value_set_int (&val, in);
3959     g_object_set_property (G_OBJECT (self), "int", &val);
3960 }
3961
3962 /**
3963  * gi_marshalling_tests_object_vfunc_with_callback:
3964  * @callback: (scope call) (closure callback_data):
3965  * @callback_data: (allow-none):
3966  *
3967  * Virtual: vfunc_with_callback
3968  */
3969 void
3970 gi_marshalling_tests_object_vfunc_with_callback (GIMarshallingTestsObject *object,
3971                                                  GIMarshallingTestsCallbackIntInt callback,
3972                                                  void *callback_data)
3973 {
3974
3975 }
3976
3977 static int
3978 _callback (int val, void *user_data)
3979 {
3980   g_assert (user_data == (gpointer)0xdeadbeef);
3981   return val;
3982 }
3983
3984 void
3985 gi_marshalling_tests_object_call_vfunc_with_callback (GIMarshallingTestsObject *object)
3986 {
3987     GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (object)->vfunc_with_callback (object,
3988                                                                          _callback,
3989                                                                          (void *) 0xdeadbeef);
3990 }
3991
3992 /**
3993  * gi_marshalling_tests_object_none_return:
3994  *
3995  * Returns: (transfer none):
3996  */
3997 GIMarshallingTestsObject *
3998 gi_marshalling_tests_object_none_return (void)
3999 {
4000     static GIMarshallingTestsObject *object = NULL;
4001
4002     if (object == NULL) {
4003         object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4004     }
4005
4006     return object;
4007 }
4008
4009 /**
4010  * gi_marshalling_tests_object_full_return:
4011  *
4012  * Returns: (transfer full):
4013  */
4014 GIMarshallingTestsObject *
4015 gi_marshalling_tests_object_full_return (void)
4016 {
4017     return g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4018 }
4019
4020 /**
4021  * gi_marshalling_tests_object_none_in:
4022  * @object: (transfer none):
4023  */
4024 void
4025 gi_marshalling_tests_object_none_in (GIMarshallingTestsObject *object)
4026 {
4027     g_assert_cmpint(object->int_, ==, 42);
4028 }
4029
4030 /**
4031  * gi_marshalling_tests_object_none_out:
4032  * @object: (out) (transfer none):
4033  */
4034 void
4035 gi_marshalling_tests_object_none_out (GIMarshallingTestsObject **object)
4036 {
4037     static GIMarshallingTestsObject *new_object = NULL;
4038
4039     if (new_object == NULL) {
4040         new_object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4041     }
4042
4043     *object = new_object;
4044 }
4045
4046 /**
4047  * gi_marshalling_tests_object_full_out:
4048  * @object: (out) (transfer full):
4049  */
4050 void
4051 gi_marshalling_tests_object_full_out (GIMarshallingTestsObject **object)
4052 {
4053     *object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4054 }
4055
4056 /**
4057  * gi_marshalling_tests_object_none_inout:
4058  * @object: (inout) (transfer none):
4059  */
4060 void
4061 gi_marshalling_tests_object_none_inout (GIMarshallingTestsObject **object)
4062 {
4063     static GIMarshallingTestsObject *new_object = NULL;
4064
4065     g_assert_cmpint((*object)->int_, ==, 42);
4066
4067     if (new_object == NULL) {
4068         new_object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4069         new_object->int_ = 0;
4070     }
4071
4072     *object = new_object;
4073 }
4074
4075 /**
4076  * gi_marshalling_tests_object_full_inout:
4077  * @object: (inout) (transfer full):
4078  */
4079 void
4080 gi_marshalling_tests_object_full_inout (GIMarshallingTestsObject **object)
4081 {
4082     g_assert_cmpint((*object)->int_, ==, 42);
4083
4084     *object = g_object_new(GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4085 }
4086
4087 /**
4088  * gi_marshalling_tests_object_test_int8_in:
4089  * @in: (in):
4090  */
4091 void
4092 gi_marshalling_tests_object_int8_in (GIMarshallingTestsObject *object, gint8 in)
4093 {
4094   gi_marshalling_tests_object_method_int8_in (object, in);
4095 }
4096
4097 /**
4098  * gi_marshalling_tests_object_test_int8_out:
4099  * @out: (out):
4100  */
4101 void
4102 gi_marshalling_tests_object_int8_out (GIMarshallingTestsObject *object, gint8 *out)
4103 {
4104   gi_marshalling_tests_object_method_int8_out (object, out);
4105 }
4106
4107 /**
4108  * gi_marshalling_tests_object_vfunc_return_value_only:
4109  */
4110 glong
4111 gi_marshalling_tests_object_vfunc_return_value_only (GIMarshallingTestsObject *self)
4112 {
4113     /* make sure that local variables don't get smashed */
4114     glong return_value;
4115     gulong local = 0x12345678;
4116     return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_only (self);
4117     g_assert_cmpint(local, ==, 0x12345678);
4118     return return_value;
4119 }
4120
4121 /**
4122  * gi_marshalling_tests_object_vfunc_one_out_parameter:
4123  * @a: (out):
4124  */
4125 void
4126 gi_marshalling_tests_object_vfunc_one_out_parameter (GIMarshallingTestsObject *self, gfloat *a)
4127 {
4128     /* make sure that local variables don't get smashed */
4129     gulong local = 0x12345678;
4130     GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_one_out_parameter (self, a);
4131     g_assert_cmpint(local, ==, 0x12345678);
4132 }
4133
4134 /**
4135  * gi_marshalling_tests_object_vfunc_multiple_out_parameters:
4136  * @a: (out):
4137  * @b: (out):
4138  */
4139 void
4140 gi_marshalling_tests_object_vfunc_multiple_out_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b)
4141 {
4142     /* make sure that local variables don't get smashed */
4143     gulong local = 0x12345678;
4144     GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_multiple_out_parameters (self, a, b);
4145     g_assert_cmpint(local, ==, 0x12345678);
4146 }
4147
4148 /**
4149  * gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter:
4150  * @a: (out):
4151  */
4152 void
4153 gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter (GIMarshallingTestsObject *self, GValue *a)
4154 {
4155     /* make sure that local variables don't get smashed */
4156     gulong local = 0x12345678;
4157     GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_caller_allocated_out_parameter (self, a);
4158     g_assert_cmpint(local, ==, 0x12345678);
4159 }
4160
4161 /**
4162  * gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter:
4163  * @a: (out):
4164  */
4165 glong
4166 gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter (GIMarshallingTestsObject *self, glong *a)
4167 {
4168     /* make sure that local variables don't get smashed */
4169     gulong return_value;
4170     gulong local = 0x12345678;
4171     return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_one_out_parameter (self, a);
4172     g_assert_cmpint(local, ==, 0x12345678);
4173     return return_value;
4174 }
4175
4176 /**
4177  * gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters:
4178  * @a: (out):
4179  * @b: (out):
4180  */
4181 glong
4182 gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters (GIMarshallingTestsObject *self, glong *a, glong *b)
4183 {
4184     gulong return_value;
4185     gulong local = 0x12345678;
4186     return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_multiple_out_parameters (self, a, b);
4187     g_assert_cmpint(local, ==, 0x12345678);
4188     return return_value;
4189 }
4190
4191 gboolean
4192 gi_marshalling_tests_object_vfunc_meth_with_error (GIMarshallingTestsObject *self,
4193                                                    gint                      x,
4194                                                    GError                  **error)
4195 {
4196   gulong local = 0x12345678;
4197   gboolean ret = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_meth_with_err (self, x, error);
4198   g_assert_cmpint(local, ==, 0x12345678);
4199   return ret;
4200 }
4201
4202 G_DEFINE_TYPE (GIMarshallingTestsSubObject, gi_marshalling_tests_sub_object, GI_MARSHALLING_TESTS_TYPE_OBJECT);
4203
4204 static void
4205 gi_marshalling_tests_sub_object_init (GIMarshallingTestsSubObject *object)
4206 {
4207 }
4208
4209 static void
4210 gi_marshalling_tests_sub_object_finalize (GObject *object)
4211 {
4212         G_OBJECT_CLASS(gi_marshalling_tests_sub_object_parent_class)->finalize(object);
4213 }
4214
4215 static void
4216 method_deep_hierarchy (GIMarshallingTestsObject *self, gint8 in)
4217 {
4218     GValue val = {0, };
4219     g_value_init (&val, G_TYPE_INT);
4220     g_value_set_int (&val, in);
4221     g_object_set_property (G_OBJECT (self), "int", &val);
4222 }
4223
4224 static void
4225 gi_marshalling_tests_sub_object_class_init (GIMarshallingTestsSubObjectClass *klass)
4226 {
4227         G_OBJECT_CLASS(klass)->finalize = gi_marshalling_tests_sub_object_finalize;
4228     GI_MARSHALLING_TESTS_OBJECT_CLASS(klass)->method_deep_hierarchy = method_deep_hierarchy;
4229 }
4230
4231 void
4232 gi_marshalling_tests_sub_object_sub_method (GIMarshallingTestsSubObject *object)
4233 {
4234     g_assert_cmpint(GI_MARSHALLING_TESTS_OBJECT(object)->int_, ==, 0);
4235 }
4236
4237 void
4238 gi_marshalling_tests_sub_object_overwritten_method (GIMarshallingTestsSubObject *object)
4239 {
4240     g_assert_cmpint(GI_MARSHALLING_TESTS_OBJECT(object)->int_, ==, 0);
4241 }
4242
4243 G_DEFINE_TYPE (GIMarshallingTestsSubSubObject, gi_marshalling_tests_sub_sub_object, GI_MARSHALLING_TESTS_TYPE_SUB_OBJECT);
4244
4245 static void
4246 gi_marshalling_tests_sub_sub_object_init (GIMarshallingTestsSubSubObject *object)
4247 {
4248 }
4249
4250 static void
4251 gi_marshalling_tests_sub_sub_object_class_init (GIMarshallingTestsSubSubObjectClass *klass)
4252 {
4253 }
4254
4255 /* Interfaces */
4256
4257 static void
4258 gi_marshalling_tests_interface_class_init(void *g_iface)
4259 {
4260 }
4261
4262 GType
4263 gi_marshalling_tests_interface_get_type(void)
4264 {
4265     static GType type = 0;
4266     if (type == 0) {
4267         type = g_type_register_static_simple (G_TYPE_INTERFACE,
4268                                               "GIMarshallingTestsInterface",
4269                                               sizeof (GIMarshallingTestsInterfaceIface),
4270                                               (GClassInitFunc) gi_marshalling_tests_interface_class_init,
4271                                               0, NULL, 0);
4272     }
4273
4274     return type;
4275 }
4276
4277 /**
4278  * gi_marshalling_tests_interface_test_int8_in:
4279  * @in: (in):
4280  */
4281 void
4282 gi_marshalling_tests_interface_test_int8_in (GIMarshallingTestsInterface *self, gint8 in)
4283 {
4284   GI_MARSHALLING_TESTS_INTERFACE_GET_IFACE (self)->test_int8_in (self, in);
4285 }
4286
4287 /**
4288  * gi_marshalling_tests_test_interface_test_int8_in:
4289  * @in: (in):
4290  */
4291 void
4292 gi_marshalling_tests_test_interface_test_int8_in (GIMarshallingTestsInterface *test_iface, gint8 in)
4293 {
4294   gi_marshalling_tests_interface_test_int8_in (test_iface, in);
4295 }
4296
4297
4298 static void
4299 gi_marshalling_tests_interface2_class_init(void *g_iface)
4300 {
4301 }
4302
4303 GType
4304 gi_marshalling_tests_interface2_get_type(void)
4305 {
4306     static GType type = 0;
4307     if (type == 0) {
4308         type = g_type_register_static_simple (G_TYPE_INTERFACE,
4309                                               "GIMarshallingTestsInterface2",
4310                                               sizeof (GIMarshallingTestsInterface2Iface),
4311                                               (GClassInitFunc) gi_marshalling_tests_interface2_class_init,
4312                                               0, NULL, 0);
4313     }
4314
4315     return type;
4316 }
4317
4318 static void
4319 gi_marshalling_tests_interface3_class_init(void *g_iface)
4320 {
4321 }
4322
4323 GType
4324 gi_marshalling_tests_interface3_get_type(void)
4325 {
4326     static GType type = 0;
4327     if (type == 0) {
4328         type = g_type_register_static_simple (G_TYPE_INTERFACE,
4329                                               "GIMarshallingTestsInterface3",
4330                                               sizeof (GIMarshallingTestsInterface3Iface),
4331                                               (GClassInitFunc) gi_marshalling_tests_interface3_class_init,
4332                                               0, NULL, 0);
4333     }
4334
4335     return type;
4336 }
4337
4338 /**
4339  * gi_marshalling_tests_interface3_test_variant_array_in:
4340  * @in: (array length=n_in):
4341  * @n_in:
4342  */
4343 void
4344 gi_marshalling_tests_interface3_test_variant_array_in (GIMarshallingTestsInterface3 *self,
4345                                                        GVariant **in,
4346                                                        gsize n_in)
4347 {
4348   GI_MARSHALLING_TESTS_INTERFACE3_GET_IFACE (self)->test_variant_array_in (self, in, n_in);
4349 }
4350
4351 /**
4352  * gi_marshalling_tests_int_out_out:
4353  * @int0: (out):
4354  * @int1: (out):
4355  */
4356 void
4357 gi_marshalling_tests_int_out_out (gint *int0, gint *int1)
4358 {
4359     *int0 = 6;
4360     *int1 = 7;
4361 }
4362
4363 /**
4364  * gi_marshalling_tests_int_three_in_three_out:
4365  * @a: (in):
4366  * @b: (in):
4367  * @c: (in):
4368  * @out0: (out):
4369  * @out1: (out):
4370  * @out2: (out):
4371  */
4372 void
4373 gi_marshalling_tests_int_three_in_three_out(gint a, gint b, gint c,
4374                                             gint *out0, gint *out1, gint *out2)
4375 {
4376     *out0 = a;
4377     *out1 = b;
4378     *out2 = c;
4379 }
4380
4381 /**
4382  * gi_marshalling_tests_int_return_out:
4383  * @int_: (out):
4384  */
4385 gint
4386 gi_marshalling_tests_int_return_out (gint *int_)
4387 {
4388     *int_ = 7;
4389     return 6;
4390 }
4391
4392 /* GError */
4393
4394 void
4395 gi_marshalling_tests_gerror(GError **error)
4396 {
4397     GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4398     g_set_error_literal(error,
4399                         quark,
4400                         GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4401                         GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4402 }
4403
4404 /**
4405  * gi_marshalling_tests_gerror_array_in:
4406  * @in_ints: (array zero-terminated=1):
4407  */
4408 void
4409 gi_marshalling_tests_gerror_array_in(gint *in_ints, GError **error)
4410 {
4411     GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4412     g_set_error_literal(error,
4413                         quark,
4414                         GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4415                         GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4416 }
4417
4418 /**
4419  * gi_marshalling_tests_gerror_out:
4420  * @error: (out) (allow-none) (transfer full): location for the GError.
4421  * @debug: (out) (allow-none) (transfer full): location for the debug message
4422  *
4423  * Inspired by gst_message_parse_error.
4424  */
4425 void
4426 gi_marshalling_tests_gerror_out(GError **error, gchar **debug)
4427 {
4428     GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4429     g_set_error_literal(error,
4430                         quark,
4431                         GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4432                         GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4433
4434     if (debug != NULL) {
4435         *debug = g_strdup (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE);
4436     }
4437 }
4438
4439 /**
4440  * gi_marshalling_tests_gerror_out_transfer_none:
4441  * @err: (out) (allow-none) (transfer none): location for the GError.
4442  * @debug: (out) (allow-none) (transfer none): location for the debug message
4443  *
4444  * A variant of gi_marshalling_tests_gerror_out() which returns data the caller
4445  * must not free.
4446  */
4447 void
4448 gi_marshalling_tests_gerror_out_transfer_none(GError **err, const gchar **debug)
4449 {
4450     static GError error = { 0,
4451                         GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4452                         GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE };
4453     error.domain = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4454     *err = &error;
4455     *debug = GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE;
4456 }
4457
4458 /**
4459  * gi_marshalling_tests_gerror_return:
4460  *
4461  * Yet another variant of gi_marshalling_tests_gerror_out().
4462  *
4463  * Returns: (transfer full): a GError
4464  */
4465 GError *
4466 gi_marshalling_tests_gerror_return(void)
4467 {
4468     GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
4469
4470     return g_error_new(quark,
4471                        GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4472                        GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4473 }
4474
4475 static GIMarshallingTestsOverridesStruct *
4476 gi_marshalling_tests_overrides_struct_copy (GIMarshallingTestsOverridesStruct *struct_)
4477 {
4478     GIMarshallingTestsOverridesStruct *new_struct;
4479
4480     new_struct = g_slice_new (GIMarshallingTestsOverridesStruct);
4481
4482     *new_struct = *struct_;
4483
4484     return new_struct;
4485 }
4486
4487 static void
4488 gi_marshalling_tests_overrides_struct_free (GIMarshallingTestsOverridesStruct *struct_)
4489 {
4490     g_slice_free (GIMarshallingTestsOverridesStruct, struct_);
4491 }
4492
4493 GType
4494 gi_marshalling_tests_overrides_struct_get_type (void)
4495 {
4496     static GType type = 0;
4497
4498     if (type == 0) {
4499         type = g_boxed_type_register_static ("GIMarshallingTestsOverridesStruct",
4500                 (GBoxedCopyFunc) gi_marshalling_tests_overrides_struct_copy,
4501                 (GBoxedFreeFunc) gi_marshalling_tests_overrides_struct_free);
4502     }
4503
4504     return type;
4505 }
4506
4507 GIMarshallingTestsOverridesStruct *
4508 gi_marshalling_tests_overrides_struct_new (void)
4509 {
4510     return g_slice_new (GIMarshallingTestsOverridesStruct);
4511 }
4512
4513 glong
4514 gi_marshalling_tests_overrides_struct_method (GIMarshallingTestsOverridesStruct *struct_)
4515 {
4516     return 42;
4517 }
4518
4519
4520 /**
4521  * gi_marshalling_tests_overrides_struct_returnv:
4522  *
4523  * Returns: (transfer full):
4524  */
4525 GIMarshallingTestsOverridesStruct *
4526 gi_marshalling_tests_overrides_struct_returnv (void)
4527 {
4528     return gi_marshalling_tests_overrides_struct_new();
4529 }
4530
4531
4532 G_DEFINE_TYPE (GIMarshallingTestsOverridesObject, gi_marshalling_tests_overrides_object, G_TYPE_OBJECT);
4533
4534 static void
4535 gi_marshalling_tests_overrides_object_init (GIMarshallingTestsOverridesObject *object)
4536 {
4537 }
4538
4539 static void
4540 gi_marshalling_tests_overrides_object_finalize (GObject *object)
4541 {
4542         G_OBJECT_CLASS (gi_marshalling_tests_overrides_object_parent_class)->finalize (object);
4543 }
4544
4545 static void
4546 gi_marshalling_tests_overrides_object_class_init (GIMarshallingTestsOverridesObjectClass *klass)
4547 {
4548         GObjectClass* object_class = G_OBJECT_CLASS (klass);
4549 #if 0
4550         GObjectClass* parent_class = G_OBJECT_CLASS (klass);
4551 #endif
4552
4553         object_class->finalize = gi_marshalling_tests_overrides_object_finalize;
4554 }
4555
4556 GIMarshallingTestsOverridesObject *
4557 gi_marshalling_tests_overrides_object_new (void)
4558 {
4559     return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
4560 }
4561
4562 glong
4563 gi_marshalling_tests_overrides_object_method (GIMarshallingTestsOverridesObject *object)
4564 {
4565     return 42;
4566 }
4567
4568 /**
4569  * gi_marshalling_tests_overrides_object_returnv:
4570  *
4571  * Returns: (transfer full):
4572  */
4573 GIMarshallingTestsOverridesObject *
4574 gi_marshalling_tests_overrides_object_returnv (void)
4575 {
4576     return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
4577 }
4578
4579 /**
4580  * gi_marshalling_tests_filename_list_return:
4581  *
4582  * Returns: (transfer none) (element-type filename): List of filenames
4583  */
4584 GSList *
4585 gi_marshalling_tests_filename_list_return (void)
4586 {
4587     return NULL;
4588 }
4589
4590 /**
4591  * gi_marshalling_tests_param_spec_return:
4592  *
4593  * Returns: (transfer full): a #GParamSpec
4594  */
4595 GParamSpec *
4596 gi_marshalling_tests_param_spec_return (void)
4597 {
4598   return g_param_spec_string ("test-param", "test", "This is a test", "42", G_PARAM_READABLE);
4599 }
4600
4601 /**
4602  * gi_marshalling_tests_param_spec_out:
4603  * @param: (out):
4604  */
4605 void
4606 gi_marshalling_tests_param_spec_out(GParamSpec **param)
4607 {
4608   *param = g_param_spec_string("test-param", "test", "This is a test", "42", G_PARAM_READABLE);
4609 }
4610
4611
4612 enum  {
4613     DUMMY_PROPERTY,
4614     SOME_BOOLEAN_PROPERTY,
4615     SOME_CHAR_PROPERTY,
4616     SOME_UCHAR_PROPERTY,
4617     SOME_INT_PROPERTY,
4618     SOME_UINT_PROPERTY,
4619     SOME_LONG_PROPERTY,
4620     SOME_ULONG_PROPERTY,
4621     SOME_INT64_PROPERTY,
4622     SOME_UINT64_PROPERTY,
4623     SOME_FLOAT_PROPERTY,
4624     SOME_DOUBLE_PROPERTY,
4625     SOME_STRV_PROPERTY,
4626     SOME_BOXED_STRUCT_PROPERTY,
4627     SOME_VARIANT_PROPERTY,
4628 };
4629
4630 G_DEFINE_TYPE (GIMarshallingTestsPropertiesObject, gi_marshalling_tests_properties_object, G_TYPE_OBJECT);
4631
4632 static void
4633 gi_marshalling_tests_properties_object_init (GIMarshallingTestsPropertiesObject * self)
4634 {
4635 }
4636
4637 static void
4638 gi_marshalling_tests_properties_object_finalize (GObject* obj)
4639 {
4640     G_OBJECT_CLASS (gi_marshalling_tests_properties_object_parent_class)->finalize (obj);
4641 }
4642
4643 static void
4644 gi_marshalling_tests_properties_object_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec)
4645 {
4646     GIMarshallingTestsPropertiesObject * self;
4647     self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
4648     switch (property_id) {
4649         case SOME_BOOLEAN_PROPERTY:
4650             g_value_set_boolean (value, self->some_boolean);
4651             break;
4652         case SOME_CHAR_PROPERTY:
4653             g_value_set_schar (value, self->some_char);
4654             break;
4655         case SOME_UCHAR_PROPERTY:
4656             g_value_set_uchar (value, self->some_uchar);
4657             break;
4658         case SOME_INT_PROPERTY:
4659             g_value_set_int (value, self->some_int);
4660             break;
4661         case SOME_UINT_PROPERTY:
4662             g_value_set_uint (value, self->some_uint);
4663             break;
4664         case SOME_LONG_PROPERTY:
4665             g_value_set_long (value, self->some_long);
4666             break;
4667         case SOME_ULONG_PROPERTY:
4668             g_value_set_ulong (value, self->some_ulong);
4669             break;
4670         case SOME_INT64_PROPERTY:
4671             g_value_set_int64 (value, self->some_int64);
4672             break;
4673         case SOME_UINT64_PROPERTY:
4674             g_value_set_uint64 (value, self->some_uint64);
4675             break;
4676         case SOME_FLOAT_PROPERTY:
4677             g_value_set_float (value, self->some_float);
4678             break;
4679         case SOME_DOUBLE_PROPERTY:
4680             g_value_set_double (value, self->some_double);
4681             break;
4682         case SOME_STRV_PROPERTY:
4683             g_value_set_boxed (value, self->some_strv);
4684             break;
4685         case SOME_BOXED_STRUCT_PROPERTY:
4686             g_value_set_boxed (value, self->some_boxed_struct);
4687             break;
4688         case SOME_VARIANT_PROPERTY:
4689             g_value_set_variant (value, self->some_variant);
4690             break;
4691         default:
4692             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
4693             break;
4694     }
4695 }
4696
4697 static void
4698 gi_marshalling_tests_properties_object_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec)
4699 {
4700     GIMarshallingTestsPropertiesObject * self;
4701     self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
4702     switch (property_id) {
4703         case SOME_BOOLEAN_PROPERTY:
4704             self->some_boolean = g_value_get_boolean (value);
4705             break;
4706         case SOME_CHAR_PROPERTY:
4707             self->some_char = g_value_get_schar (value);
4708             break;
4709         case SOME_UCHAR_PROPERTY:
4710             self->some_uchar = g_value_get_uchar (value);
4711             break;
4712         case SOME_INT_PROPERTY:
4713             self->some_int = g_value_get_int (value);
4714             break;
4715         case SOME_UINT_PROPERTY:
4716             self->some_uint = g_value_get_uint (value);
4717             break;
4718         case SOME_LONG_PROPERTY:
4719             self->some_long = g_value_get_long (value);
4720             break;
4721         case SOME_ULONG_PROPERTY:
4722             self->some_ulong = g_value_get_ulong (value);
4723             break;
4724         case SOME_INT64_PROPERTY:
4725             self->some_int64 = g_value_get_int64 (value);
4726             break;
4727         case SOME_UINT64_PROPERTY:
4728             self->some_uint64 = g_value_get_uint64 (value);
4729             break;
4730         case SOME_FLOAT_PROPERTY:
4731             self->some_float = g_value_get_float (value);
4732             break;
4733         case SOME_DOUBLE_PROPERTY:
4734             self->some_double = g_value_get_double (value);
4735             break;
4736         case SOME_STRV_PROPERTY:
4737             g_strfreev (self->some_strv);
4738             self->some_strv = g_strdupv (g_value_get_boxed (value));
4739             break;
4740         case SOME_BOXED_STRUCT_PROPERTY:
4741             gi_marshalling_tests_boxed_struct_free (self->some_boxed_struct);
4742             self->some_boxed_struct = gi_marshalling_tests_boxed_struct_copy (g_value_get_boxed (value));
4743             break;
4744         case SOME_VARIANT_PROPERTY:
4745             if (self->some_variant != NULL)
4746                 g_variant_unref (self->some_variant);
4747             self->some_variant = g_value_get_variant (value);
4748             if (self->some_variant != NULL)
4749                 g_variant_ref (self->some_variant);
4750             break;
4751         default:
4752             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
4753             break;
4754     }
4755 }
4756
4757 static void
4758 gi_marshalling_tests_properties_object_class_init (GIMarshallingTestsPropertiesObjectClass * klass)
4759 {
4760     GObjectClass* object_class = G_OBJECT_CLASS (klass);
4761
4762     object_class->finalize = gi_marshalling_tests_properties_object_finalize;
4763     object_class->get_property = gi_marshalling_tests_properties_object_get_property;
4764     object_class->set_property = gi_marshalling_tests_properties_object_set_property;
4765
4766     g_object_class_install_property (object_class, SOME_BOOLEAN_PROPERTY,
4767         g_param_spec_boolean ("some-boolean", "some-boolean", "some-boolean", FALSE,
4768             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4769
4770     g_object_class_install_property (object_class, SOME_CHAR_PROPERTY,
4771         g_param_spec_char ("some-char", "some-char", "some-char", G_MININT8, G_MAXINT8, 0,
4772             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4773
4774     g_object_class_install_property (object_class, SOME_UCHAR_PROPERTY,
4775         g_param_spec_uchar ("some-uchar", "some-uchar", "some-uchar", 0, G_MAXUINT8, 0,
4776             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4777
4778     g_object_class_install_property (object_class, SOME_INT_PROPERTY,
4779         g_param_spec_int ("some-int", "some-int", "some-int", G_MININT, G_MAXINT, 0,
4780             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4781
4782     g_object_class_install_property (object_class, SOME_UINT_PROPERTY,
4783         g_param_spec_uint ("some-uint", "some-uint", "some-uint", 0, G_MAXUINT, 0,
4784             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4785
4786     g_object_class_install_property (object_class, SOME_LONG_PROPERTY,
4787         g_param_spec_long ("some-long", "some-long", "some-long", G_MINLONG, G_MAXLONG, 0,
4788             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4789
4790     g_object_class_install_property (object_class, SOME_ULONG_PROPERTY,
4791         g_param_spec_ulong ("some-ulong", "some-ulong", "some-ulong", 0, G_MAXULONG, 0,
4792             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4793
4794     g_object_class_install_property (object_class, SOME_INT64_PROPERTY,
4795         g_param_spec_int64 ("some-int64", "some-int64", "some-int64", G_MININT64, G_MAXINT64, 0,
4796             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4797
4798     g_object_class_install_property (object_class, SOME_UINT64_PROPERTY,
4799         g_param_spec_uint64 ("some-uint64", "some-uint64", "some-uint64", 0, G_MAXUINT64, 0,
4800             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4801
4802     g_object_class_install_property (object_class, SOME_FLOAT_PROPERTY,
4803         g_param_spec_float ("some-float", "some-float", "some-float", -1 * G_MAXFLOAT, G_MAXFLOAT, 0,
4804             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4805
4806     g_object_class_install_property (object_class, SOME_DOUBLE_PROPERTY,
4807         g_param_spec_double ("some-double", "some-double", "some-double", -1 * G_MAXDOUBLE, G_MAXDOUBLE, 0,
4808             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4809
4810     g_object_class_install_property (object_class, SOME_STRV_PROPERTY,
4811         g_param_spec_boxed ("some-strv", "some-strv", "some-strv", G_TYPE_STRV,
4812             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4813
4814     g_object_class_install_property (object_class, SOME_BOXED_STRUCT_PROPERTY,
4815         g_param_spec_boxed ("some-boxed-struct", "some-boxed-struct", "some-boxed-struct", 
4816             gi_marshalling_tests_boxed_struct_get_type(),
4817             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4818
4819     g_object_class_install_property (object_class, SOME_VARIANT_PROPERTY,
4820         g_param_spec_variant ("some-variant", "some-variant", "some-variant", 
4821             G_VARIANT_TYPE_ANY, NULL,
4822             G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4823 }
4824
4825 GIMarshallingTestsPropertiesObject*
4826 gi_marshalling_tests_properties_object_new (void)
4827 {
4828     return g_object_new (GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT, NULL);
4829 }