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