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