Debian Codegraph @

subprojects/gobject-introspection-tests/gimarshallingtests.c

raw
1 /*
2 SPDX-License-Identifier: GPL-2.0-or-later AND LGPL-2.0-or-later AND MIT
3 SPDX-FileCopyrightText: 2010-2012 Collabora, Ltd.
4 SPDX-FileCopyrightText: 2010 Johan Dahlin
5 SPDX-FileCopyrightText: 2010 Sugar Labs
6 SPDX-FileCopyrightText: 2010 Zach Goldberg
7 SPDX-FileCopyrightText: 2011 Alex Eftimie
8 SPDX-FileCopyrightText: 2011-2012 Canonical Ltd.
9 SPDX-FileCopyrightText: 2011-2012 Colin Walters <[email protected]>
10 SPDX-FileCopyrightText: 2011 Dan Winship
11 SPDX-FileCopyrightText: 2011-2012 Giovanni Campagna
12 SPDX-FileCopyrightText: 2011 Ignacio Casal Quinteiro
13 SPDX-FileCopyrightText: 2011-2012 Jasper St. Pierre
14 SPDX-FileCopyrightText: 2011 Laszlo Pandy
15 SPDX-FileCopyrightText: 2011 Red Hat, Inc.
16 SPDX-FileCopyrightText: 2012 Bastian Winkler
17 SPDX-FileCopyrightText: 2012 Epitech
18 SPDX-FileCopyrightText: 2012 Gonzalo Odiard
19 SPDX-FileCopyrightText: 2012-2013 Martin Pitt
20 SPDX-FileCopyrightText: 2012-2013 Paolo Borelli
21 SPDX-FileCopyrightText: 2012 Sebastian Pölsterl
22 SPDX-FileCopyrightText: 2013 Simon Feltman
23 SPDX-FileCopyrightText: 2014 Lionel Landwerlin
24 SPDX-FileCopyrightText: 2014 RIFT.io, Inc.
25 SPDX-FileCopyrightText: 2014 SuSE
26 SPDX-FileCopyrightText: 2016 Endless Mobile, Inc.
27 SPDX-FileCopyrightText: 2016-2018, 2023, 2025 Philip Chimento
28 SPDX-FileCopyrightText: 2017 Christoph Reiter
29 SPDX-FileCopyrightText: 2018 Tomasz Miąsko
30 SPDX-FileCopyrightText: 2019 Stéphane Seng
31 SPDX-FileCopyrightText: 2020-2023 Marco Trevisan
32 SPDX-FileCopyrightText: 2020, 2024 Simon McVittie
33 SPDX-FileCopyrightText: 2021 Carlos Garnacho
34 */
35
36 #include <stdint.h>
37 #include <string.h>
38
39 #include "gimarshallingtests.h"
40
41 /* Unaligned buffer, for testing that language bindings can deal with pointers
42 * allocated at arbitrary 1-byte alignments. */
43 static guint8 *unaligned_buffer = NULL;
44 static const size_t UNALIGNED_BUFFER_SIZE = 33;
45
46 /**
47 * gi_marshalling_tests_cleanup_unaligned_buffer:
48 *
49 * It's OK not to call this and just leak the buffer, but if you are running
50 * your tests with AddressSanitizer or valgrind, you should call this after
51 * completing each unaligned buffer test.
52 *
53 * We can't send an unaligned buffer as (transfer full) because g_free() won't
54 * work on it on Windows.
55 */
56 void
57 gi_marshalling_tests_cleanup_unaligned_buffer (void)
58 {
59 g_aligned_free_sized (unaligned_buffer, 8, UNALIGNED_BUFFER_SIZE);
60 unaligned_buffer = NULL;
61 }
62
63 static const guint8 *
64 init_unaligned_buffer (void)
65 {
66 if (unaligned_buffer)
67 gi_marshalling_tests_cleanup_unaligned_buffer ();
68
69 unaligned_buffer = g_aligned_alloc0 (1, UNALIGNED_BUFFER_SIZE, 8);
70 for (size_t ix = 0; ix < UNALIGNED_BUFFER_SIZE; ix++)
71 unaligned_buffer[ix] = (uintptr_t) (unaligned_buffer + ix) & 0x07;
72 return unaligned_buffer + 1;
73 }
74
75 static void gi_marshalling_tests_boxed_struct_free (GIMarshallingTestsBoxedStruct *v);
76
77 /* Booleans */
78
79 gboolean
80 gi_marshalling_tests_boolean_return_true (void)
81 {
82 return TRUE;
83 }
84
85 gboolean
86 gi_marshalling_tests_boolean_return_false (void)
87 {
88 return FALSE;
89 }
90
91 void
92 gi_marshalling_tests_boolean_in_true (gboolean v)
93 {
94 g_assert (v == TRUE);
95 }
96
97 void
98 gi_marshalling_tests_boolean_in_false (gboolean v)
99 {
100 g_assert (v == FALSE);
101 }
102
103 /**
104 * gi_marshalling_tests_boolean_out_true:
105 * @v: (out):
106 */
107 void
108 gi_marshalling_tests_boolean_out_true (gboolean *v)
109 {
110 *v = TRUE;
111 }
112
113 /**
114 * gi_marshalling_tests_boolean_out_false:
115 * @v: (out):
116 */
117 void
118 gi_marshalling_tests_boolean_out_false (gboolean *v)
119 {
120 *v = FALSE;
121 }
122
123 /**
124 * gi_marshalling_tests_boolean_out_uninitialized:
125 * @v: (out):
126 */
127 gboolean
128 gi_marshalling_tests_boolean_out_uninitialized (gboolean *v G_GNUC_UNUSED)
129 {
130 return FALSE;
131 }
132
133 /**
134 * gi_marshalling_tests_boolean_inout_true_false:
135 * @v: (inout):
136 */
137 void
138 gi_marshalling_tests_boolean_inout_true_false (gboolean *v)
139 {
140 g_assert (*v == TRUE);
141 *v = FALSE;
142 }
143
144 /**
145 * gi_marshalling_tests_boolean_inout_false_true:
146 * @v: (inout):
147 */
148 void
149 gi_marshalling_tests_boolean_inout_false_true (gboolean *v)
150 {
151 g_assert (*v == FALSE);
152 *v = TRUE;
153 }
154
155 /* Integers */
156
157 gint8
158 gi_marshalling_tests_int8_return_max (void)
159 {
160 return G_MAXINT8;
161 }
162
163 gint8
164 gi_marshalling_tests_int8_return_min (void)
165 {
166 return G_MININT8;
167 }
168
169 void
170 gi_marshalling_tests_int8_in_max (gint8 v)
171 {
172 g_assert_cmpint (v, ==, G_MAXINT8);
173 }
174
175 void
176 gi_marshalling_tests_int8_in_min (gint8 v)
177 {
178 g_assert_cmpint (v, ==, G_MININT8);
179 }
180
181 /**
182 * gi_marshalling_tests_int8_out_max:
183 * @v: (out):
184 */
185 void
186 gi_marshalling_tests_int8_out_max (gint8 *v)
187 {
188 *v = G_MAXINT8;
189 }
190
191 /**
192 * gi_marshalling_tests_int8_out_min:
193 * @v: (out):
194 */
195 void
196 gi_marshalling_tests_int8_out_min (gint8 *v)
197 {
198 *v = G_MININT8;
199 }
200
201 /**
202 * gi_marshalling_tests_int8_out_uninitialized:
203 * @v: (out):
204 */
205 gboolean
206 gi_marshalling_tests_int8_out_uninitialized (gint8 *v G_GNUC_UNUSED)
207 {
208 return FALSE;
209 }
210
211 /**
212 * gi_marshalling_tests_int8_inout_max_min:
213 * @v: (inout):
214 */
215 void
216 gi_marshalling_tests_int8_inout_max_min (gint8 *v)
217 {
218 g_assert_cmpint (*v, ==, G_MAXINT8);
219 *v = G_MININT8;
220 }
221
222 /**
223 * gi_marshalling_tests_int8_inout_min_max:
224 * @v: (inout):
225 */
226 void
227 gi_marshalling_tests_int8_inout_min_max (gint8 *v)
228 {
229 g_assert_cmpint (*v, ==, G_MININT8);
230 *v = G_MAXINT8;
231 }
232
233 guint8
234 gi_marshalling_tests_uint8_return (void)
235 {
236 return G_MAXUINT8;
237 }
238
239 void
240 gi_marshalling_tests_uint8_in (guint8 v)
241 {
242 g_assert_cmpuint (v, ==, G_MAXUINT8);
243 }
244
245 /**
246 * gi_marshalling_tests_uint8_out:
247 * @v: (out):
248 */
249 void
250 gi_marshalling_tests_uint8_out (guint8 *v)
251 {
252 *v = G_MAXUINT8;
253 }
254
255 /**
256 * gi_marshalling_tests_uint8_out_uninitialized:
257 * @v: (out):
258 */
259 gboolean
260 gi_marshalling_tests_uint8_out_uninitialized (guint8 *v G_GNUC_UNUSED)
261 {
262 return FALSE;
263 }
264
265 /**
266 * gi_marshalling_tests_uint8_inout:
267 * @v: (inout):
268 */
269 void
270 gi_marshalling_tests_uint8_inout (guint8 *v)
271 {
272 g_assert_cmpuint (*v, ==, G_MAXUINT8);
273 *v = 0;
274 }
275
276 gint16
277 gi_marshalling_tests_int16_return_max (void)
278 {
279 return G_MAXINT16;
280 }
281
282 gint16
283 gi_marshalling_tests_int16_return_min (void)
284 {
285 return G_MININT16;
286 }
287
288 void
289 gi_marshalling_tests_int16_in_max (gint16 v)
290 {
291 g_assert_cmpint (v, ==, G_MAXINT16);
292 }
293
294 void
295 gi_marshalling_tests_int16_in_min (gint16 v)
296 {
297 g_assert_cmpint (v, ==, G_MININT16);
298 }
299
300 /**
301 * gi_marshalling_tests_int16_out_max:
302 * @v: (out):
303 */
304 void
305 gi_marshalling_tests_int16_out_max (gint16 *v)
306 {
307 *v = G_MAXINT16;
308 }
309
310 /**
311 * gi_marshalling_tests_int16_out_min:
312 * @v: (out):
313 */
314 void
315 gi_marshalling_tests_int16_out_min (gint16 *v)
316 {
317 *v = G_MININT16;
318 }
319
320 /**
321 * gi_marshalling_tests_int16_out_uninitialized:
322 * @v: (out):
323 */
324 gboolean
325 gi_marshalling_tests_int16_out_uninitialized (gint16 *v G_GNUC_UNUSED)
326 {
327 return FALSE;
328 }
329
330 /**
331 * gi_marshalling_tests_int16_inout_max_min:
332 * @v: (inout):
333 */
334 void
335 gi_marshalling_tests_int16_inout_max_min (gint16 *v)
336 {
337 g_assert_cmpint (*v, ==, G_MAXINT16);
338 *v = G_MININT16;
339 }
340
341 /**
342 * gi_marshalling_tests_int16_inout_min_max:
343 * @v: (inout):
344 */
345 void
346 gi_marshalling_tests_int16_inout_min_max (gint16 *v)
347 {
348 g_assert_cmpint (*v, ==, G_MININT16);
349 *v = G_MAXINT16;
350 }
351
352 guint16
353 gi_marshalling_tests_uint16_return (void)
354 {
355 return G_MAXUINT16;
356 }
357
358 void
359 gi_marshalling_tests_uint16_in (guint16 v)
360 {
361 g_assert_cmpuint (v, ==, G_MAXUINT16);
362 }
363
364 /**
365 * gi_marshalling_tests_uint16_out:
366 * @v: (out):
367 */
368 void
369 gi_marshalling_tests_uint16_out (guint16 *v)
370 {
371 *v = G_MAXUINT16;
372 }
373
374 /**
375 * gi_marshalling_tests_uint16_out_uninitialized:
376 * @v: (out):
377 */
378 gboolean
379 gi_marshalling_tests_uint16_out_uninitialized (guint16 *v G_GNUC_UNUSED)
380 {
381 return FALSE;
382 }
383
384 /**
385 * gi_marshalling_tests_uint16_inout:
386 * @v: (inout):
387 */
388 void
389 gi_marshalling_tests_uint16_inout (guint16 *v)
390 {
391 g_assert_cmpuint (*v, ==, G_MAXUINT16);
392 *v = 0;
393 }
394
395 gint32
396 gi_marshalling_tests_int32_return_max (void)
397 {
398 return G_MAXINT32;
399 }
400
401 gint32
402 gi_marshalling_tests_int32_return_min (void)
403 {
404 return G_MININT32;
405 }
406
407 void
408 gi_marshalling_tests_int32_in_max (gint32 v)
409 {
410 g_assert_cmpint (v, ==, G_MAXINT32);
411 }
412
413 void
414 gi_marshalling_tests_int32_in_min (gint32 v)
415 {
416 g_assert_cmpint (v, ==, G_MININT32);
417 }
418
419 /**
420 * gi_marshalling_tests_int32_out_max:
421 * @v: (out):
422 */
423 void
424 gi_marshalling_tests_int32_out_max (gint32 *v)
425 {
426 *v = G_MAXINT32;
427 }
428
429 /**
430 * gi_marshalling_tests_int32_out_min:
431 * @v: (out):
432 */
433 void
434 gi_marshalling_tests_int32_out_min (gint32 *v)
435 {
436 *v = G_MININT32;
437 }
438
439 /**
440 * gi_marshalling_tests_int32_out_uninitialized:
441 * @v: (out):
442 */
443 gboolean
444 gi_marshalling_tests_int32_out_uninitialized (gint32 *v G_GNUC_UNUSED)
445 {
446 return FALSE;
447 }
448
449 /**
450 * gi_marshalling_tests_int32_inout_max_min:
451 * @v: (inout):
452 */
453 void
454 gi_marshalling_tests_int32_inout_max_min (gint32 *v)
455 {
456 g_assert_cmpint (*v, ==, G_MAXINT32);
457 *v = G_MININT32;
458 }
459
460 /**
461 * gi_marshalling_tests_int32_inout_min_max:
462 * @v: (inout):
463 */
464 void
465 gi_marshalling_tests_int32_inout_min_max (gint32 *v)
466 {
467 g_assert_cmpint (*v, ==, G_MININT32);
468 *v = G_MAXINT32;
469 }
470
471 guint32
472 gi_marshalling_tests_uint32_return (void)
473 {
474 return G_MAXUINT32;
475 }
476
477 void
478 gi_marshalling_tests_uint32_in (guint32 v)
479 {
480 g_assert_cmpuint (v, ==, G_MAXUINT32);
481 }
482
483 /**
484 * gi_marshalling_tests_uint32_out:
485 * @v: (out):
486 */
487 void
488 gi_marshalling_tests_uint32_out (guint32 *v)
489 {
490 *v = G_MAXUINT32;
491 }
492
493 /**
494 * gi_marshalling_tests_uint32_out_uninitialized:
495 * @v: (out):
496 */
497 gboolean
498 gi_marshalling_tests_uint32_out_uninitialized (guint32 *v G_GNUC_UNUSED)
499 {
500 return FALSE;
501 }
502
503 /**
504 * gi_marshalling_tests_uint32_inout:
505 * @v: (inout):
506 */
507 void
508 gi_marshalling_tests_uint32_inout (guint32 *v)
509 {
510 g_assert_cmpuint (*v, ==, G_MAXUINT32);
511 *v = 0;
512 }
513
514 gint64
515 gi_marshalling_tests_int64_return_max (void)
516 {
517 return G_MAXINT64;
518 }
519
520 gint64
521 gi_marshalling_tests_int64_return_min (void)
522 {
523 return G_MININT64;
524 }
525
526 void
527 gi_marshalling_tests_int64_in_max (gint64 v)
528 {
529 g_assert_cmpint (v, ==, G_MAXINT64);
530 }
531
532 void
533 gi_marshalling_tests_int64_in_min (gint64 v)
534 {
535 g_assert_cmpint (v, ==, G_MININT64);
536 }
537
538 /**
539 * gi_marshalling_tests_int64_out_max:
540 * @v: (out):
541 */
542 void
543 gi_marshalling_tests_int64_out_max (gint64 *v)
544 {
545 *v = G_MAXINT64;
546 }
547
548 /**
549 * gi_marshalling_tests_int64_out_min:
550 * @v: (out):
551 */
552 void
553 gi_marshalling_tests_int64_out_min (gint64 *v)
554 {
555 *v = G_MININT64;
556 }
557
558 /**
559 * gi_marshalling_tests_int64_out_uninitialized:
560 * @v: (out):
561 */
562 gboolean
563 gi_marshalling_tests_int64_out_uninitialized (gint64 *v G_GNUC_UNUSED)
564 {
565 return FALSE;
566 }
567
568 /**
569 * gi_marshalling_tests_int64_inout_max_min:
570 * @v: (inout):
571 */
572 void
573 gi_marshalling_tests_int64_inout_max_min (gint64 *v)
574 {
575 g_assert_cmpint (*v, ==, G_MAXINT64);
576 *v = G_MININT64;
577 }
578
579 /**
580 * gi_marshalling_tests_int64_inout_min_max:
581 * @v: (inout):
582 */
583 void
584 gi_marshalling_tests_int64_inout_min_max (gint64 *v)
585 {
586 g_assert_cmpint (*v, ==, G_MININT64);
587 *v = G_MAXINT64;
588 }
589
590 guint64
591 gi_marshalling_tests_uint64_return (void)
592 {
593 return G_MAXUINT64;
594 }
595
596 void
597 gi_marshalling_tests_uint64_in (guint64 v)
598 {
599 g_assert_cmpuint (v, ==, G_MAXUINT64);
600 }
601
602 /**
603 * gi_marshalling_tests_uint64_out:
604 * @v: (out):
605 */
606 void
607 gi_marshalling_tests_uint64_out (guint64 *v)
608 {
609 *v = G_MAXUINT64;
610 }
611
612 /**
613 * gi_marshalling_tests_uint64_out_uninitialized:
614 * @v: (out):
615 */
616 gboolean
617 gi_marshalling_tests_uint64_out_uninitialized (guint64 *v G_GNUC_UNUSED)
618 {
619 return FALSE;
620 }
621
622 /**
623 * gi_marshalling_tests_uint64_inout:
624 * @v: (inout):
625 */
626 void
627 gi_marshalling_tests_uint64_inout (guint64 *v)
628 {
629 g_assert_cmpuint (*v, ==, G_MAXUINT64);
630 *v = 0;
631 }
632
633 gshort
634 gi_marshalling_tests_short_return_max (void)
635 {
636 return G_MAXSHORT;
637 }
638
639 gshort
640 gi_marshalling_tests_short_return_min (void)
641 {
642 return G_MINSHORT;
643 }
644
645 void
646 gi_marshalling_tests_short_in_max (gshort short_)
647 {
648 g_assert_cmpint (short_, ==, G_MAXSHORT);
649 }
650
651 void
652 gi_marshalling_tests_short_in_min (gshort short_)
653 {
654 g_assert_cmpint (short_, ==, G_MINSHORT);
655 }
656
657 /**
658 * gi_marshalling_tests_short_out_max:
659 * @short_: (out):
660 */
661 void
662 gi_marshalling_tests_short_out_max (gshort *short_)
663 {
664 *short_ = G_MAXSHORT;
665 }
666
667 /**
668 * gi_marshalling_tests_short_out_min:
669 * @short_: (out):
670 */
671 void
672 gi_marshalling_tests_short_out_min (gshort *short_)
673 {
674 *short_ = G_MINSHORT;
675 }
676
677 /**
678 * gi_marshalling_tests_short_out_uninitialized:
679 * @v: (out):
680 */
681 gboolean
682 gi_marshalling_tests_short_out_uninitialized (gshort *v G_GNUC_UNUSED)
683 {
684 return FALSE;
685 }
686
687 /**
688 * gi_marshalling_tests_short_inout_max_min:
689 * @short_: (inout):
690 */
691 void
692 gi_marshalling_tests_short_inout_max_min (gshort *short_)
693 {
694 g_assert_cmpint (*short_, ==, G_MAXSHORT);
695 *short_ = G_MINSHORT;
696 }
697
698 /**
699 * gi_marshalling_tests_short_inout_min_max:
700 * @short_: (inout):
701 */
702 void
703 gi_marshalling_tests_short_inout_min_max (gshort *short_)
704 {
705 g_assert_cmpint (*short_, ==, G_MINSHORT);
706 *short_ = G_MAXSHORT;
707 }
708
709 gushort
710 gi_marshalling_tests_ushort_return (void)
711 {
712 return G_MAXUSHORT;
713 }
714
715 void
716 gi_marshalling_tests_ushort_in (gushort ushort_)
717 {
718 g_assert_cmpuint (ushort_, ==, G_MAXUSHORT);
719 }
720
721 /**
722 * gi_marshalling_tests_ushort_out:
723 * @ushort_: (out):
724 */
725 void
726 gi_marshalling_tests_ushort_out (gushort *ushort_)
727 {
728 *ushort_ = G_MAXUSHORT;
729 }
730
731 /**
732 * gi_marshalling_tests_ushort_out_uninitialized:
733 * @v: (out):
734 */
735 gboolean
736 gi_marshalling_tests_ushort_out_uninitialized (gushort *v G_GNUC_UNUSED)
737 {
738 return FALSE;
739 }
740
741 /**
742 * gi_marshalling_tests_ushort_inout:
743 * @ushort_: (inout):
744 */
745 void
746 gi_marshalling_tests_ushort_inout (gushort *ushort_)
747 {
748 g_assert_cmpuint (*ushort_, ==, G_MAXUSHORT);
749 *ushort_ = 0;
750 }
751
752 gint
753 gi_marshalling_tests_int_return_max (void)
754 {
755 return G_MAXINT;
756 }
757
758 gint
759 gi_marshalling_tests_int_return_min (void)
760 {
761 return G_MININT;
762 }
763
764 void
765 gi_marshalling_tests_int_in_max (gint int_)
766 {
767 g_assert_cmpint (int_, ==, G_MAXINT);
768 }
769
770 void
771 gi_marshalling_tests_int_in_min (gint int_)
772 {
773 g_assert_cmpint (int_, ==, G_MININT);
774 }
775
776 /**
777 * gi_marshalling_tests_int_out_max:
778 * @int_: (out):
779 */
780 void
781 gi_marshalling_tests_int_out_max (gint *int_)
782 {
783 *int_ = G_MAXINT;
784 }
785
786 /**
787 * gi_marshalling_tests_int_out_min:
788 * @int_: (out):
789 */
790 void
791 gi_marshalling_tests_int_out_min (gint *int_)
792 {
793 *int_ = G_MININT;
794 }
795
796 /**
797 * gi_marshalling_tests_int_out_uninitialized:
798 * @v: (out):
799 */
800 gboolean
801 gi_marshalling_tests_int_out_uninitialized (gint *v G_GNUC_UNUSED)
802 {
803 return FALSE;
804 }
805
806 /**
807 * gi_marshalling_tests_int_inout_max_min:
808 * @int_: (inout):
809 */
810 void
811 gi_marshalling_tests_int_inout_max_min (gint *int_)
812 {
813 g_assert_cmpint (*int_, ==, G_MAXINT);
814 *int_ = G_MININT;
815 }
816
817 /**
818 * gi_marshalling_tests_int_inout_min_max:
819 * @int_: (inout):
820 */
821 void
822 gi_marshalling_tests_int_inout_min_max (gint *int_)
823 {
824 g_assert_cmpint (*int_, ==, G_MININT);
825 *int_ = G_MAXINT;
826 }
827
828 guint
829 gi_marshalling_tests_uint_return (void)
830 {
831 return G_MAXUINT;
832 }
833
834 void
835 gi_marshalling_tests_uint_in (guint uint_)
836 {
837 g_assert_cmpuint (uint_, ==, G_MAXUINT);
838 }
839
840 /**
841 * gi_marshalling_tests_uint_out:
842 * @uint_: (out):
843 */
844 void
845 gi_marshalling_tests_uint_out (guint *uint_)
846 {
847 *uint_ = G_MAXUINT;
848 }
849
850 /**
851 * gi_marshalling_tests_uint_out_uninitialized:
852 * @v: (out):
853 */
854 gboolean
855 gi_marshalling_tests_uint_out_uninitialized (guint *v G_GNUC_UNUSED)
856 {
857 return FALSE;
858 }
859
860 /**
861 * gi_marshalling_tests_uint_inout:
862 * @uint_: (inout):
863 */
864 void
865 gi_marshalling_tests_uint_inout (guint *uint_)
866 {
867 g_assert_cmpuint (*uint_, ==, G_MAXUINT);
868 *uint_ = 0;
869 }
870
871 glong
872 gi_marshalling_tests_long_return_max (void)
873 {
874 return G_MAXLONG;
875 }
876
877 glong
878 gi_marshalling_tests_long_return_min (void)
879 {
880 return G_MINLONG;
881 }
882
883 void
884 gi_marshalling_tests_long_in_max (glong long_)
885 {
886 g_assert_cmpint (long_, ==, G_MAXLONG);
887 }
888
889 void
890 gi_marshalling_tests_long_in_min (glong long_)
891 {
892 g_assert_cmpint (long_, ==, G_MINLONG);
893 }
894
895 /**
896 * gi_marshalling_tests_long_out_max:
897 * @long_: (out):
898 */
899 void
900 gi_marshalling_tests_long_out_max (glong *long_)
901 {
902 *long_ = G_MAXLONG;
903 }
904
905 /**
906 * gi_marshalling_tests_long_out_min:
907 * @long_: (out):
908 */
909 void
910 gi_marshalling_tests_long_out_min (glong *long_)
911 {
912 *long_ = G_MINLONG;
913 }
914
915 /**
916 * gi_marshalling_tests_long_out_uninitialized:
917 * @v: (out):
918 */
919 gboolean
920 gi_marshalling_tests_long_out_uninitialized (glong *v G_GNUC_UNUSED)
921 {
922 return FALSE;
923 }
924
925 /**
926 * gi_marshalling_tests_long_inout_max_min:
927 * @long_: (inout):
928 */
929 void
930 gi_marshalling_tests_long_inout_max_min (glong *long_)
931 {
932 g_assert_cmpint (*long_, ==, G_MAXLONG);
933 *long_ = G_MINLONG;
934 }
935
936 /**
937 * gi_marshalling_tests_long_inout_min_max:
938 * @long_: (inout):
939 */
940 void
941 gi_marshalling_tests_long_inout_min_max (glong *long_)
942 {
943 g_assert_cmpint (*long_, ==, G_MINLONG);
944 *long_ = G_MAXLONG;
945 }
946
947 gulong
948 gi_marshalling_tests_ulong_return (void)
949 {
950 return G_MAXULONG;
951 }
952
953 void
954 gi_marshalling_tests_ulong_in (gulong ulong_)
955 {
956 g_assert_cmpuint (ulong_, ==, G_MAXULONG);
957 }
958
959 /**
960 * gi_marshalling_tests_ulong_out:
961 * @ulong_: (out):
962 */
963 void
964 gi_marshalling_tests_ulong_out (gulong *ulong_)
965 {
966 *ulong_ = G_MAXULONG;
967 }
968
969 /**
970 * gi_marshalling_tests_ulong_out_uninitialized:
971 * @v: (out):
972 */
973 gboolean
974 gi_marshalling_tests_ulong_out_uninitialized (gulong *v G_GNUC_UNUSED)
975 {
976 return FALSE;
977 }
978
979 /**
980 * gi_marshalling_tests_ulong_inout:
981 * @ulong_: (inout):
982 */
983 void
984 gi_marshalling_tests_ulong_inout (gulong *ulong_)
985 {
986 g_assert_cmpuint (*ulong_, ==, G_MAXULONG);
987 *ulong_ = 0;
988 }
989
990 gssize
991 gi_marshalling_tests_ssize_return_max (void)
992 {
993 return G_MAXSSIZE;
994 }
995
996 gssize
997 gi_marshalling_tests_ssize_return_min (void)
998 {
999 return G_MINSSIZE;
1000 }
1001
1002 void
1003 gi_marshalling_tests_ssize_in_max (gssize ssize)
1004 {
1005 g_assert_cmpint (ssize, ==, G_MAXSSIZE);
1006 }
1007
1008 void
1009 gi_marshalling_tests_ssize_in_min (gssize ssize)
1010 {
1011 g_assert_cmpint (ssize, ==, G_MINSSIZE);
1012 }
1013
1014 /**
1015 * gi_marshalling_tests_ssize_out_max:
1016 * @ssize: (out):
1017 */
1018 void
1019 gi_marshalling_tests_ssize_out_max (gssize *ssize)
1020 {
1021 *ssize = G_MAXSSIZE;
1022 }
1023
1024 /**
1025 * gi_marshalling_tests_ssize_out_min:
1026 * @ssize: (out):
1027 */
1028 void
1029 gi_marshalling_tests_ssize_out_min (gssize *ssize)
1030 {
1031 *ssize = G_MINSSIZE;
1032 }
1033
1034 /**
1035 * gi_marshalling_tests_ssize_out_uninitialized:
1036 * @v: (out):
1037 */
1038 gboolean
1039 gi_marshalling_tests_ssize_out_uninitialized (gssize *v G_GNUC_UNUSED)
1040 {
1041 return FALSE;
1042 }
1043
1044 /**
1045 * gi_marshalling_tests_ssize_inout_max_min:
1046 * @ssize: (inout):
1047 */
1048 void
1049 gi_marshalling_tests_ssize_inout_max_min (gssize *ssize)
1050 {
1051 g_assert_cmpint (*ssize, ==, G_MAXSSIZE);
1052 *ssize = G_MINSSIZE;
1053 }
1054
1055 /**
1056 * gi_marshalling_tests_ssize_inout_min_max:
1057 * @ssize: (inout):
1058 */
1059 void
1060 gi_marshalling_tests_ssize_inout_min_max (gssize *ssize)
1061 {
1062 g_assert_cmpint (*ssize, ==, G_MINSSIZE);
1063 *ssize = G_MAXSSIZE;
1064 }
1065
1066 gsize
1067 gi_marshalling_tests_size_return (void)
1068 {
1069 return G_MAXSIZE;
1070 }
1071
1072 void
1073 gi_marshalling_tests_size_in (gsize size)
1074 {
1075 g_assert_cmpuint (size, ==, G_MAXSIZE);
1076 }
1077
1078 /**
1079 * gi_marshalling_tests_size_out:
1080 * @size: (out):
1081 */
1082 void
1083 gi_marshalling_tests_size_out (gsize *size)
1084 {
1085 *size = G_MAXSIZE;
1086 }
1087
1088 /**
1089 * gi_marshalling_tests_size_out_uninitialized:
1090 * @v: (out):
1091 */
1092 gboolean
1093 gi_marshalling_tests_size_out_uninitialized (gsize *v G_GNUC_UNUSED)
1094 {
1095 return FALSE;
1096 }
1097
1098 /**
1099 * gi_marshalling_tests_size_inout:
1100 * @size: (inout):
1101 */
1102 void
1103 gi_marshalling_tests_size_inout (gsize *size)
1104 {
1105 g_assert_cmpuint (*size, ==, G_MAXSIZE);
1106 *size = 0;
1107 }
1108
1109 gfloat
1110 gi_marshalling_tests_float_return (void)
1111 {
1112 return G_MAXFLOAT;
1113 }
1114
1115 void
1116 gi_marshalling_tests_float_in (gfloat v)
1117 {
1118 g_assert_cmpfloat (v, ==, G_MAXFLOAT);
1119 }
1120
1121 /**
1122 * gi_marshalling_tests_float_out:
1123 * @v: (out):
1124 */
1125 void
1126 gi_marshalling_tests_float_out (gfloat *v)
1127 {
1128 *v = G_MAXFLOAT;
1129 }
1130
1131 #define NONCANONICAL_NAN_BIT_PATTERN_32 0xfffb1236;
1132 #define NONCANONICAL_NAN_BIT_PATTERN_64 0xfffb1236fedcba98;
1133
1134 static gfloat
1135 noncanonical_nan_float (void)
1136 {
1137 gfloat retval;
1138
1139 if (sizeof (gfloat) == sizeof (guint32))
1140 {
1141 guint32 bit_pattern = NONCANONICAL_NAN_BIT_PATTERN_32;
1142 memcpy (&retval, &bit_pattern, sizeof (gfloat));
1143 }
1144 else
1145 {
1146 g_assert (sizeof (gfloat) == sizeof (guint64) && "gfloat must be 32 or 64 bits");
1147 guint64 bit_pattern = NONCANONICAL_NAN_BIT_PATTERN_64;
1148 memcpy (&retval, &bit_pattern, sizeof (gfloat));
1149 }
1150
1151 return retval;
1152 }
1153
1154 /**
1155 * gi_marshalling_tests_float_noncanonical_nan_out:
1156 * @v: (out):
1157 */
1158 void
1159 gi_marshalling_tests_float_noncanonical_nan_out (gfloat *v)
1160 {
1161 *v = noncanonical_nan_float ();
1162 }
1163
1164 /**
1165 * gi_marshalling_tests_float_out_uninitialized:
1166 * @v: (out):
1167 */
1168 gboolean
1169 gi_marshalling_tests_float_out_uninitialized (gfloat *v G_GNUC_UNUSED)
1170 {
1171 return FALSE;
1172 }
1173
1174 /**
1175 * gi_marshalling_tests_float_inout:
1176 * @v: (inout):
1177 */
1178 void
1179 gi_marshalling_tests_float_inout (gfloat *v)
1180 {
1181 g_assert_cmpfloat (*v, ==, G_MAXFLOAT);
1182 *v = G_MINFLOAT;
1183 }
1184
1185 gdouble
1186 gi_marshalling_tests_double_return (void)
1187 {
1188 return G_MAXDOUBLE;
1189 }
1190
1191 void
1192 gi_marshalling_tests_double_in (gdouble v)
1193 {
1194 g_assert_cmpfloat (v, ==, G_MAXDOUBLE);
1195 }
1196
1197 /**
1198 * gi_marshalling_tests_double_out:
1199 * @v: (out):
1200 */
1201 void
1202 gi_marshalling_tests_double_out (gdouble *v)
1203 {
1204 *v = G_MAXDOUBLE;
1205 }
1206
1207 static gdouble
1208 noncanonical_nan_double (void)
1209 {
1210 gdouble retval;
1211
1212 g_assert (sizeof (gdouble) == sizeof (guint64) && "gdouble must be 64 bits");
1213
1214 guint64 bit_pattern = NONCANONICAL_NAN_BIT_PATTERN_64;
1215 memcpy (&retval, &bit_pattern, sizeof (gdouble));
1216
1217 return retval;
1218 }
1219
1220 /**
1221 * gi_marshalling_tests_double_noncanonical_nan_out:
1222 * @v: (out):
1223 */
1224 void
1225 gi_marshalling_tests_double_noncanonical_nan_out (gdouble *v)
1226 {
1227 *v = noncanonical_nan_double ();
1228 }
1229
1230 /**
1231 * gi_marshalling_tests_double_out_uninitialized:
1232 * @v: (out):
1233 */
1234 gboolean
1235 gi_marshalling_tests_double_out_uninitialized (gdouble *v G_GNUC_UNUSED)
1236 {
1237 return FALSE;
1238 }
1239
1240 /**
1241 * gi_marshalling_tests_double_inout:
1242 * @v: (inout):
1243 */
1244 void
1245 gi_marshalling_tests_double_inout (gdouble *v)
1246 {
1247 g_assert_cmpfloat (*v, ==, G_MAXDOUBLE);
1248 *v = G_MINDOUBLE;
1249 }
1250
1251 time_t
1252 gi_marshalling_tests_time_t_return (void)
1253 {
1254 return 1234567890;
1255 }
1256
1257 void
1258 gi_marshalling_tests_time_t_in (time_t v)
1259 {
1260 g_assert_cmpuint (v, ==, 1234567890);
1261 }
1262
1263 /**
1264 * gi_marshalling_tests_time_t_out:
1265 * @v: (out):
1266 */
1267 void
1268 gi_marshalling_tests_time_t_out (time_t *v)
1269 {
1270 *v = 1234567890;
1271 }
1272
1273 /**
1274 * gi_marshalling_tests_time_t_out_uninitialized:
1275 * @v: (out):
1276 */
1277 gboolean
1278 gi_marshalling_tests_time_t_out_uninitialized (time_t *v G_GNUC_UNUSED)
1279 {
1280 return FALSE;
1281 }
1282
1283 /**
1284 * gi_marshalling_tests_time_t_inout:
1285 * @v: (inout):
1286 */
1287 void
1288 gi_marshalling_tests_time_t_inout (time_t *v)
1289 {
1290 g_assert_cmpuint (*v, ==, 1234567890);
1291 *v = 0;
1292 }
1293
1294 off_t
1295 gi_marshalling_tests_off_t_return (void)
1296 {
1297 return 1234567890;
1298 }
1299
1300 void
1301 gi_marshalling_tests_off_t_in (off_t v)
1302 {
1303 g_assert_cmpuint (v, ==, 1234567890);
1304 }
1305
1306 /**
1307 * gi_marshalling_tests_off_t_out:
1308 * @v: (out):
1309 */
1310 void
1311 gi_marshalling_tests_off_t_out (off_t *v)
1312 {
1313 *v = 1234567890;
1314 }
1315
1316 /**
1317 * gi_marshalling_tests_off_t_out_uninitialized:
1318 * @v: (out):
1319 */
1320 gboolean
1321 gi_marshalling_tests_off_t_out_uninitialized (off_t *v G_GNUC_UNUSED)
1322 {
1323 return FALSE;
1324 }
1325
1326 /**
1327 * gi_marshalling_tests_off_t_inout:
1328 * @v: (inout):
1329 */
1330 void
1331 gi_marshalling_tests_off_t_inout (off_t *v)
1332 {
1333 g_assert_cmpuint (*v, ==, 1234567890);
1334 *v = 0;
1335 }
1336
1337 #ifdef G_OS_UNIX
1338
1339 dev_t
1340 gi_marshalling_tests_dev_t_return (void)
1341 {
1342 return 1234567890;
1343 }
1344
1345 void
1346 gi_marshalling_tests_dev_t_in (dev_t v)
1347 {
1348 g_assert_cmpuint (v, ==, 1234567890);
1349 }
1350
1351 /**
1352 * gi_marshalling_tests_dev_t_out:
1353 * @v: (out):
1354 */
1355 void
1356 gi_marshalling_tests_dev_t_out (dev_t *v)
1357 {
1358 *v = 1234567890;
1359 }
1360
1361 /**
1362 * gi_marshalling_tests_dev_t_out_uninitialized:
1363 * @v: (out):
1364 */
1365 gboolean
1366 gi_marshalling_tests_dev_t_out_uninitialized (dev_t *v G_GNUC_UNUSED)
1367 {
1368 return FALSE;
1369 }
1370
1371 /**
1372 * gi_marshalling_tests_dev_t_inout:
1373 * @v: (inout):
1374 */
1375 void
1376 gi_marshalling_tests_dev_t_inout (dev_t *v)
1377 {
1378 g_assert_cmpuint (*v, ==, 1234567890);
1379 *v = 0;
1380 }
1381
1382 gid_t
1383 gi_marshalling_tests_gid_t_return (void)
1384 {
1385 return 65534;
1386 }
1387
1388 void
1389 gi_marshalling_tests_gid_t_in (gid_t v)
1390 {
1391 g_assert_cmpuint (v, ==, 65534);
1392 }
1393
1394 /**
1395 * gi_marshalling_tests_gid_t_out:
1396 * @v: (out):
1397 */
1398 void
1399 gi_marshalling_tests_gid_t_out (gid_t *v)
1400 {
1401 *v = 65534;
1402 }
1403
1404 /**
1405 * gi_marshalling_tests_gid_t_out_uninitialized:
1406 * @v: (out):
1407 */
1408 gboolean
1409 gi_marshalling_tests_gid_t_out_uninitialized (gid_t *v G_GNUC_UNUSED)
1410 {
1411 return FALSE;
1412 }
1413
1414 /**
1415 * gi_marshalling_tests_gid_t_inout:
1416 * @v: (inout):
1417 */
1418 void
1419 gi_marshalling_tests_gid_t_inout (gid_t *v)
1420 {
1421 g_assert_cmpuint (*v, ==, 65534);
1422 *v = 0;
1423 }
1424
1425 pid_t
1426 gi_marshalling_tests_pid_t_return (void)
1427 {
1428 return 12345;
1429 }
1430
1431 void
1432 gi_marshalling_tests_pid_t_in (pid_t v)
1433 {
1434 g_assert_cmpuint (v, ==, 12345);
1435 }
1436
1437 /**
1438 * gi_marshalling_tests_pid_t_out:
1439 * @v: (out):
1440 */
1441 void
1442 gi_marshalling_tests_pid_t_out (pid_t *v)
1443 {
1444 *v = 12345;
1445 }
1446
1447 /**
1448 * gi_marshalling_tests_pid_t_out_uninitialized:
1449 * @v: (out):
1450 */
1451 gboolean
1452 gi_marshalling_tests_pid_t_out_uninitialized (pid_t *v G_GNUC_UNUSED)
1453 {
1454 return FALSE;
1455 }
1456
1457 /**
1458 * gi_marshalling_tests_pid_t_inout:
1459 * @v: (inout):
1460 */
1461 void
1462 gi_marshalling_tests_pid_t_inout (pid_t *v)
1463 {
1464 g_assert_cmpuint (*v, ==, 12345);
1465 *v = 0;
1466 }
1467
1468 socklen_t
1469 gi_marshalling_tests_socklen_t_return (void)
1470 {
1471 return 123;
1472 }
1473
1474 void
1475 gi_marshalling_tests_socklen_t_in (socklen_t v)
1476 {
1477 g_assert_cmpuint (v, ==, 123);
1478 }
1479
1480 /**
1481 * gi_marshalling_tests_socklen_t_out:
1482 * @v: (out):
1483 */
1484 void
1485 gi_marshalling_tests_socklen_t_out (socklen_t *v)
1486 {
1487 *v = 123;
1488 }
1489
1490 /**
1491 * gi_marshalling_tests_socklen_t_out_uninitialized:
1492 * @v: (out):
1493 */
1494 gboolean
1495 gi_marshalling_tests_socklen_t_out_uninitialized (socklen_t *v G_GNUC_UNUSED)
1496 {
1497 return FALSE;
1498 }
1499
1500 /**
1501 * gi_marshalling_tests_socklen_t_inout:
1502 * @v: (inout):
1503 */
1504 void
1505 gi_marshalling_tests_socklen_t_inout (socklen_t *v)
1506 {
1507 g_assert_cmpuint (*v, ==, 123);
1508 *v = 0;
1509 }
1510
1511 uid_t
1512 gi_marshalling_tests_uid_t_return (void)
1513 {
1514 return 65534;
1515 }
1516
1517 void
1518 gi_marshalling_tests_uid_t_in (uid_t v)
1519 {
1520 g_assert_cmpuint (v, ==, 65534);
1521 }
1522
1523 /**
1524 * gi_marshalling_tests_uid_t_out:
1525 * @v: (out):
1526 */
1527 void
1528 gi_marshalling_tests_uid_t_out (uid_t *v)
1529 {
1530 *v = 65534;
1531 }
1532
1533 /**
1534 * gi_marshalling_tests_uid_t_out_uninitialized:
1535 * @v: (out):
1536 */
1537 gboolean
1538 gi_marshalling_tests_uid_t_out_uninitialized (uid_t *v G_GNUC_UNUSED)
1539 {
1540 return FALSE;
1541 }
1542
1543 /**
1544 * gi_marshalling_tests_uid_t_inout:
1545 * @v: (inout):
1546 */
1547 void
1548 gi_marshalling_tests_uid_t_inout (uid_t *v)
1549 {
1550 g_assert_cmpuint (*v, ==, 65534);
1551 *v = 0;
1552 }
1553
1554 #endif /* G_OS_UNIX */
1555
1556 GType
1557 gi_marshalling_tests_gtype_return (void)
1558 {
1559 return G_TYPE_NONE;
1560 }
1561
1562 GType
1563 gi_marshalling_tests_gtype_string_return (void)
1564 {
1565 return G_TYPE_STRING;
1566 }
1567
1568 void
1569 gi_marshalling_tests_gtype_in (GType gtype)
1570 {
1571 g_assert (gtype == G_TYPE_NONE);
1572 }
1573
1574 void
1575 gi_marshalling_tests_gtype_string_in (GType gtype)
1576 {
1577 g_assert (gtype == G_TYPE_STRING);
1578 }
1579
1580 /**
1581 * gi_marshalling_tests_gtype_out:
1582 * @gtype: (out):
1583 */
1584 void
1585 gi_marshalling_tests_gtype_out (GType *gtype)
1586 {
1587 *gtype = G_TYPE_NONE;
1588 }
1589
1590 /**
1591 * gi_marshalling_tests_gtype_out_uninitialized:
1592 * @v: (out):
1593 */
1594 gboolean
1595 gi_marshalling_tests_gtype_out_uninitialized (GType *v G_GNUC_UNUSED)
1596 {
1597 return FALSE;
1598 }
1599
1600 /**
1601 * gi_marshalling_tests_gtype_string_out:
1602 * @gtype: (out):
1603 */
1604 void
1605 gi_marshalling_tests_gtype_string_out (GType *gtype)
1606 {
1607 *gtype = G_TYPE_STRING;
1608 }
1609
1610 /**
1611 * gi_marshalling_tests_gtype_inout:
1612 * @gtype: (inout):
1613 */
1614 void
1615 gi_marshalling_tests_gtype_inout (GType *gtype)
1616 {
1617 g_assert (*gtype == G_TYPE_NONE);
1618 *gtype = G_TYPE_INT;
1619 }
1620
1621 const gchar *
1622 gi_marshalling_tests_utf8_none_return (void)
1623 {
1624 return GI_MARSHALLING_TESTS_CONSTANT_UTF8;
1625 }
1626
1627 gchar *
1628 gi_marshalling_tests_utf8_full_return (void)
1629 {
1630 return g_strdup (GI_MARSHALLING_TESTS_CONSTANT_UTF8);
1631 }
1632
1633 void
1634 gi_marshalling_tests_utf8_none_in (const gchar *utf8)
1635 {
1636 g_assert_cmpstr (GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, utf8);
1637 }
1638
1639 /**
1640 * gi_marshalling_tests_utf8_full_in:
1641 * @utf8: (transfer full):
1642 */
1643 void
1644 gi_marshalling_tests_utf8_full_in (gchar *utf8)
1645 {
1646 g_assert_cmpstr (GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, utf8);
1647 g_free (utf8);
1648 }
1649
1650 /**
1651 * gi_marshalling_tests_utf8_as_uint8array_in:
1652 * @array: (array length=len) (element-type guint8): Byte data that happens to be UTF-8
1653 * @len: Length
1654 *
1655 * Takes data that happens to be UTF-8 as a byte array, to test
1656 * binding conversion from their string type (e.g. JavaScript's
1657 * UTF-16) to UTF-8.
1658 */
1659 void
1660 gi_marshalling_tests_utf8_as_uint8array_in (const guint8 *array, gsize len)
1661 {
1662 gsize orig_len = strlen (GI_MARSHALLING_TESTS_CONSTANT_UTF8);
1663 g_assert_cmpint (orig_len, ==, len);
1664 g_assert (memcmp (GI_MARSHALLING_TESTS_CONSTANT_UTF8, array, len) == 0);
1665 }
1666
1667 /**
1668 * gi_marshalling_tests_utf8_none_out:
1669 * @utf8: (out) (transfer none):
1670 */
1671 void
1672 gi_marshalling_tests_utf8_none_out (const gchar **utf8)
1673 {
1674 *utf8 = GI_MARSHALLING_TESTS_CONSTANT_UTF8;
1675 }
1676
1677 /**
1678 * gi_marshalling_tests_utf8_none_out_uninitialized:
1679 * @v: (out) (transfer none):
1680 */
1681 gboolean
1682 gi_marshalling_tests_utf8_none_out_uninitialized (const gchar **v G_GNUC_UNUSED)
1683 {
1684 return FALSE;
1685 }
1686
1687 /**
1688 * gi_marshalling_tests_utf8_full_out:
1689 * @utf8: (out) (transfer full):
1690 */
1691 void
1692 gi_marshalling_tests_utf8_full_out (gchar **utf8)
1693 {
1694 *utf8 = g_strdup (GI_MARSHALLING_TESTS_CONSTANT_UTF8);
1695 }
1696
1697 /**
1698 * gi_marshalling_tests_utf8_dangling_out:
1699 * @utf8: (out) (transfer full):
1700 */
1701 void
1702 gi_marshalling_tests_utf8_dangling_out (gchar **utf8 G_GNUC_UNUSED)
1703 {
1704 /* Intentionally don't touch the pointer to see how
1705 the bindings handle this case. Bindings should be
1706 robust against broken C functions and can initialize
1707 even OUT vlues to NULL.
1708 */
1709 }
1710
1711 /**
1712 * gi_marshalling_tests_utf8_none_inout:
1713 * @utf8: (inout) (transfer none):
1714 */
1715 void
1716 gi_marshalling_tests_utf8_none_inout (const gchar **utf8)
1717 {
1718 g_assert_cmpstr (GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, *utf8);
1719 *utf8 = "";
1720 }
1721
1722 /**
1723 * gi_marshalling_tests_utf8_full_inout:
1724 * @utf8: (inout) (transfer full):
1725 */
1726 void
1727 gi_marshalling_tests_utf8_full_inout (gchar **utf8)
1728 {
1729 g_assert_cmpstr (GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, *utf8);
1730 g_free (*utf8);
1731 *utf8 = g_strdup ("");
1732 }
1733
1734 /**
1735 * gi_marshalling_tests_init_function:
1736 * @n_args: (inout) (allow-none): number of args
1737 * @argv: (inout) (array length=n_args) (allow-none): args
1738 *
1739 * This is like gtk_init().
1740 */
1741 gboolean
1742 gi_marshalling_tests_init_function (gint *n_args, char ***argv)
1743 {
1744 if (n_args == NULL)
1745 return TRUE;
1746
1747 if (*n_args == 0)
1748 return TRUE;
1749 (*n_args)--;
1750 g_assert (argv != NULL);
1751 /* we have transfer ownership full, so we need to free the element ourself */
1752 g_free ((*argv)[*n_args]);
1753 (*argv)[*n_args] = NULL;
1754 return TRUE;
1755 }
1756
1757 /**
1758 * gi_marshalling_tests_array_fixed_int_return:
1759 *
1760 * Returns: (array fixed-size=4):
1761 */
1762 const gint *
1763 gi_marshalling_tests_array_fixed_int_return (void)
1764 {
1765 static gint ints[] = { -1, 0, 1, 2 };
1766 return ints;
1767 }
1768
1769 /**
1770 * gi_marshalling_tests_array_fixed_short_return:
1771 *
1772 * Returns: (array fixed-size=4):
1773 */
1774 const gshort *
1775 gi_marshalling_tests_array_fixed_short_return (void)
1776 {
1777 static gshort shorts[] = { -1, 0, 1, 2 };
1778 return shorts;
1779 }
1780
1781 /**
1782 * gi_marshalling_tests_array_fixed_return_unaligned:
1783 *
1784 * Note that the buffer will leak unless you call
1785 * gi_marshalling_tests_cleanup_unaligned_buffer().
1786 *
1787 * Returns: (array fixed-size=32) (transfer none):
1788 */
1789 const guint8 *
1790 gi_marshalling_tests_array_fixed_return_unaligned (void)
1791 {
1792 return init_unaligned_buffer ();
1793 }
1794
1795 /**
1796 * gi_marshalling_tests_array_fixed_int_in:
1797 * @ints: (array fixed-size=4):
1798 */
1799 void
1800 gi_marshalling_tests_array_fixed_int_in (const gint *ints)
1801 {
1802 g_assert_cmpint (ints[0], ==, -1);
1803 g_assert_cmpint (ints[1], ==, 0);
1804 g_assert_cmpint (ints[2], ==, 1);
1805 g_assert_cmpint (ints[3], ==, 2);
1806 }
1807
1808 /**
1809 * gi_marshalling_tests_array_fixed_caller_allocated_out:
1810 * @ints: (out caller-allocates) (array fixed-size=4):
1811 */
1812 void
1813 gi_marshalling_tests_array_fixed_caller_allocated_out (gint *ints)
1814 {
1815 ints[0] = -1;
1816 ints[1] = 0;
1817 ints[2] = 1;
1818 ints[3] = 2;
1819 }
1820
1821 /**
1822 * gi_marshalling_tests_array_fixed_short_in:
1823 * @shorts: (array fixed-size=4):
1824 */
1825 void
1826 gi_marshalling_tests_array_fixed_short_in (const gshort *shorts)
1827 {
1828 g_assert_cmpint (shorts[0], ==, -1);
1829 g_assert_cmpint (shorts[1], ==, 0);
1830 g_assert_cmpint (shorts[2], ==, 1);
1831 g_assert_cmpint (shorts[3], ==, 2);
1832 }
1833
1834 /**
1835 * gi_marshalling_tests_array_fixed_out:
1836 * @ints: (out) (array fixed-size=4) (transfer none):
1837 */
1838 void
1839 gi_marshalling_tests_array_fixed_out (gint **ints)
1840 {
1841 static gint values[] = { -1, 0, 1, 2 };
1842 *ints = values;
1843 }
1844
1845 /**
1846 * gi_marshalling_tests_array_fixed_out_uninitialized:
1847 * @v: (out) (array fixed-size=4) (transfer none):
1848 */
1849 gboolean
1850 gi_marshalling_tests_array_fixed_out_uninitialized (gint **v G_GNUC_UNUSED)
1851 {
1852 return FALSE;
1853 }
1854
1855 /**
1856 * gi_marshalling_tests_array_fixed_out_unaligned:
1857 * @v: (out) (array fixed-size=32) (transfer none):
1858 *
1859 * Note that the buffer will leak unless you call
1860 * gi_marshalling_tests_cleanup_unaligned_buffer().
1861 */
1862 void
1863 gi_marshalling_tests_array_fixed_out_unaligned (const guint8 **v)
1864 {
1865 *v = init_unaligned_buffer ();
1866 }
1867
1868 /**
1869 * gi_marshalling_tests_array_fixed_out_struct:
1870 * @structs: (out) (array fixed-size=2) (transfer none):
1871 */
1872 void
1873 gi_marshalling_tests_array_fixed_out_struct (GIMarshallingTestsSimpleStruct **structs)
1874 {
1875 static GIMarshallingTestsSimpleStruct *values;
1876
1877 if (values == NULL)
1878 {
1879 values = g_new (GIMarshallingTestsSimpleStruct, 2);
1880
1881 values[0].long_ = 7;
1882 values[0].int8 = 6;
1883
1884 values[1].long_ = 6;
1885 values[1].int8 = 7;
1886 }
1887
1888 *structs = values;
1889 }
1890
1891 /**
1892 * gi_marshalling_tests_array_fixed_out_struct_uninitialized:
1893 * @v: (out):
1894 */
1895 gboolean
1896 gi_marshalling_tests_array_fixed_out_struct_uninitialized (GIMarshallingTestsSimpleStruct **v G_GNUC_UNUSED)
1897 {
1898 return FALSE;
1899 }
1900
1901 /**
1902 * gi_marshalling_tests_array_fixed_caller_allocated_struct_out:
1903 * @structs: (out caller-allocates) (array fixed-size=4):
1904 */
1905 void
1906 gi_marshalling_tests_array_fixed_caller_allocated_struct_out (GIMarshallingTestsSimpleStruct *structs)
1907 {
1908 structs[0].long_ = -2;
1909 structs[0].int8 = -1;
1910 structs[1].long_ = 1;
1911 structs[1].int8 = 2;
1912 structs[2].long_ = 3;
1913 structs[2].int8 = 4;
1914 structs[3].long_ = 5;
1915 structs[3].int8 = 6;
1916 }
1917
1918 /**
1919 * gi_marshalling_tests_array_fixed_inout:
1920 * @ints: (inout) (array fixed-size=4) (transfer none):
1921 */
1922 void
1923 gi_marshalling_tests_array_fixed_inout (gint **ints)
1924 {
1925 static gint values[] = { 2, 1, 0, -1 };
1926
1927 g_assert_cmpint ((*ints)[0], ==, -1);
1928 g_assert_cmpint ((*ints)[1], ==, 0);
1929 g_assert_cmpint ((*ints)[2], ==, 1);
1930 g_assert_cmpint ((*ints)[3], ==, 2);
1931
1932 *ints = values;
1933 }
1934
1935 /**
1936 * gi_marshalling_tests_array_return:
1937 *
1938 * Returns: (array length=length):
1939 */
1940 const gint *
1941 gi_marshalling_tests_array_return (gint *length)
1942 {
1943 static gint ints[] = { -1, 0, 1, 2 };
1944
1945 *length = 4;
1946 return ints;
1947 }
1948
1949 /**
1950 * gi_marshalling_tests_array_return_etc:
1951 * @first:
1952 * @length: (out):
1953 * @last:
1954 * @sum: (out):
1955 *
1956 * Returns: (array length=length):
1957 */
1958 const gint *
1959 gi_marshalling_tests_array_return_etc (gint first, gint *length, gint last, gint *sum)
1960 {
1961 static gint ints[] = { -1, 0, 1, 2 };
1962
1963 ints[0] = first;
1964 ints[3] = last;
1965 *sum = first + last;
1966 *length = 4;
1967 return ints;
1968 }
1969
1970 /**
1971 * gi_marshalling_tests_array_return_unaligned:
1972 * @len: (out):
1973 *
1974 * Note that the buffer will leak unless you call
1975 * gi_marshalling_tests_cleanup_unaligned_buffer().
1976 *
1977 * Returns: (array length=len):
1978 */
1979 const guint8 *
1980 gi_marshalling_tests_array_return_unaligned (gsize *len)
1981 {
1982 *len = UNALIGNED_BUFFER_SIZE - 1;
1983 return init_unaligned_buffer ();
1984 }
1985
1986 /**
1987 * gi_marshalling_tests_array_in:
1988 * @ints: (array length=length):
1989 * @length:
1990 */
1991 void
1992 gi_marshalling_tests_array_in (const gint *ints, gint length)
1993 {
1994 g_assert_cmpint (length, ==, 4);
1995 g_assert_cmpint (ints[0], ==, -1);
1996 g_assert_cmpint (ints[1], ==, 0);
1997 g_assert_cmpint (ints[2], ==, 1);
1998 g_assert_cmpint (ints[3], ==, 2);
1999 }
2000
2001 /**
2002 * gi_marshalling_tests_array_in_len_before:
2003 * @length:
2004 * @ints: (array length=length):
2005 */
2006 void
2007 gi_marshalling_tests_array_in_len_before (gint length, const gint *ints)
2008 {
2009 gi_marshalling_tests_array_in (ints, length);
2010 }
2011
2012 /**
2013 * gi_marshalling_tests_array_in_len_zero_terminated:
2014 * @ints: (array length=length zero-terminated):
2015 * @length:
2016 */
2017 void
2018 gi_marshalling_tests_array_in_len_zero_terminated (const gint *ints, gint length)
2019 {
2020 g_assert_cmpint (length, ==, 4);
2021
2022 g_assert_cmpint (ints[0], ==, -1);
2023 g_assert_cmpint (ints[1], ==, 0);
2024 g_assert_cmpint (ints[2], ==, 1);
2025 g_assert_cmpint (ints[3], ==, 2);
2026
2027 /* One past the end, null terminator */
2028 g_assert_cmpint (ints[4], ==, 0);
2029 }
2030
2031 /**
2032 * gi_marshalling_tests_array_string_in:
2033 * @strings: (array length=length):
2034 */
2035 void
2036 gi_marshalling_tests_array_string_in (const gchar **strings, gint length)
2037 {
2038 g_assert_cmpint (length, ==, 2);
2039 g_assert_cmpstr (strings[0], ==, "foo");
2040 g_assert_cmpstr (strings[1], ==, "bar");
2041 }
2042
2043 /**
2044 * gi_marshalling_tests_array_uint8_in:
2045 * @chars: (array length=length):
2046 */
2047 void
2048 gi_marshalling_tests_array_uint8_in (const guint8 *chars, gint length)
2049 {
2050 g_assert_cmpint (length, ==, 4);
2051 g_assert (chars[0] == 'a');
2052 g_assert (chars[1] == 'b');
2053 g_assert (chars[2] == 'c');
2054 g_assert (chars[3] == 'd');
2055 }
2056
2057 /**
2058 * gi_marshalling_tests_array_int64_in:
2059 * @ints: (array length=length):
2060 * @length:
2061 */
2062 void
2063 gi_marshalling_tests_array_int64_in (const gint64 *ints, gint length)
2064 {
2065 g_assert_cmpint (length, ==, 4);
2066 g_assert_cmpint (ints[0], ==, -1);
2067 g_assert_cmpint (ints[1], ==, 0);
2068 g_assert_cmpint (ints[2], ==, 1);
2069 g_assert_cmpint (ints[3], ==, 2);
2070 }
2071
2072 /**
2073 * gi_marshalling_tests_array_uint64_in:
2074 * @ints: (array length=length):
2075 * @length:
2076 */
2077 void
2078 gi_marshalling_tests_array_uint64_in (const guint64 *ints, gint length)
2079 {
2080 g_assert_cmpint (length, ==, 4);
2081 g_assert_cmpint (ints[0], ==, -1);
2082 g_assert_cmpint (ints[1], ==, 0);
2083 g_assert_cmpint (ints[2], ==, 1);
2084 g_assert_cmpint (ints[3], ==, 2);
2085 }
2086
2087 /**
2088 * gi_marshalling_tests_array_unichar_in:
2089 * @chars: (array length=length):
2090 * @length:
2091 */
2092 void
2093 gi_marshalling_tests_array_unichar_in (const gunichar *chars, gint length)
2094 {
2095 int ix;
2096 static const gunichar expected[] = GI_MARSHALLING_TESTS_CONSTANT_UCS4;
2097 g_assert_cmpint (length, ==, 12);
2098 for (ix = 0; ix < length; ix++)
2099 g_assert_cmpuint (chars[ix], ==, expected[ix]);
2100 }
2101
2102 /**
2103 * gi_marshalling_tests_array_bool_in:
2104 * @bools: (array length=length):
2105 * @length:
2106 */
2107 void
2108 gi_marshalling_tests_array_bool_in (const gboolean *bools, gint length)
2109 {
2110 g_assert_cmpint (length, ==, 4);
2111 g_assert_cmpint (bools[0], ==, TRUE);
2112 g_assert_cmpint (bools[1], ==, FALSE);
2113 g_assert_cmpint (bools[2], ==, TRUE);
2114 g_assert_cmpint (bools[3], ==, TRUE);
2115 }
2116
2117 /**
2118 * gi_marshalling_tests_array_struct_in:
2119 * @structs: (array length=length):
2120 */
2121 void
2122 gi_marshalling_tests_array_struct_in (GIMarshallingTestsBoxedStruct **structs, gint length)
2123 {
2124 g_assert_cmpint (length, ==, 3);
2125 g_assert_cmpint (structs[0]->long_, ==, 1);
2126 g_assert_cmpint (structs[1]->long_, ==, 2);
2127 g_assert_cmpint (structs[2]->long_, ==, 3);
2128 }
2129
2130 /**
2131 * gi_marshalling_tests_array_struct_full_in:
2132 * @structs: (array length=length) (transfer full):
2133 */
2134 void
2135 gi_marshalling_tests_array_struct_full_in (GIMarshallingTestsBoxedStruct **structs, gint length)
2136 {
2137 g_assert_cmpint (length, ==, 3);
2138 g_assert_cmpint (structs[0]->long_, ==, 1);
2139 g_assert_cmpint (structs[1]->long_, ==, 2);
2140 g_assert_cmpint (structs[2]->long_, ==, 3);
2141
2142 for (int i = 0; i < length; i++)
2143 g_free (structs[i]);
2144
2145 g_free (structs);
2146 }
2147
2148 /**
2149 * gi_marshalling_tests_array_struct_value_in:
2150 * @structs: (array length=length):
2151 */
2152 void
2153 gi_marshalling_tests_array_struct_value_in (GIMarshallingTestsBoxedStruct *structs, gint length)
2154 {
2155 g_assert_cmpint (length, ==, 3);
2156 g_assert_cmpint (structs[0].long_, ==, 1);
2157 g_assert_cmpint (structs[1].long_, ==, 2);
2158 g_assert_cmpint (structs[2].long_, ==, 3);
2159 }
2160
2161 /**
2162 * gi_marshalling_tests_array_simple_struct_in:
2163 * @structs: (array length=length):
2164 */
2165 void
2166 gi_marshalling_tests_array_simple_struct_in (GIMarshallingTestsSimpleStruct *structs, gint length)
2167 {
2168 g_assert_cmpint (length, ==, 3);
2169 g_assert_cmpint (structs[0].long_, ==, 1);
2170 g_assert_cmpint (structs[1].long_, ==, 2);
2171 g_assert_cmpint (structs[2].long_, ==, 3);
2172 }
2173
2174 /**
2175 * gi_marshalling_tests_multi_array_key_value_in:
2176 * @keys: (array length=length):
2177 * @values: (array length=length):
2178 */
2179 void
2180 gi_marshalling_tests_multi_array_key_value_in (gint length, const gchar **keys, const GValue *values)
2181 {
2182 g_assert_cmpint (length, ==, 3);
2183 g_assert_cmpstr ("one", ==, keys[0]);
2184 g_assert_cmpint (g_value_get_int (&values[0]), ==, 1);
2185 g_assert_cmpstr ("two", ==, keys[1]);
2186 g_assert_cmpint (g_value_get_int (&values[1]), ==, 2);
2187 g_assert_cmpstr ("three", ==, keys[2]);
2188 g_assert_cmpint (g_value_get_int (&values[2]), ==, 3);
2189 }
2190
2191 /**
2192 * gi_marshalling_tests_array_struct_take_in:
2193 * @structs: (array length=length) (transfer full):
2194 */
2195 void
2196 gi_marshalling_tests_array_struct_take_in (GIMarshallingTestsBoxedStruct **structs, gint length)
2197 {
2198 gi_marshalling_tests_array_struct_in (structs, length);
2199
2200 /* only really useful if run in valgrind actually */
2201 gi_marshalling_tests_boxed_struct_free (structs[0]);
2202 gi_marshalling_tests_boxed_struct_free (structs[1]);
2203 gi_marshalling_tests_boxed_struct_free (structs[2]);
2204 g_free (structs);
2205 }
2206
2207 /**
2208 * gi_marshalling_tests_array_enum_in:
2209 * @_enum: (array length=length) (transfer none):
2210 * @length:
2211 */
2212 void
2213 gi_marshalling_tests_array_enum_in (GIMarshallingTestsEnum *v, gint length)
2214 {
2215 g_assert_cmpint (length, ==, 3);
2216 g_assert_cmpint (v[0], ==, GI_MARSHALLING_TESTS_ENUM_VALUE1);
2217 g_assert_cmpint (v[1], ==, GI_MARSHALLING_TESTS_ENUM_VALUE2);
2218 g_assert_cmpint (v[2], ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
2219 }
2220
2221 /**
2222 * gi_marshalling_tests_array_flags_in:
2223 * @flags: (array length=length) (transfer none):
2224 * @length:
2225 */
2226 void
2227 gi_marshalling_tests_array_flags_in (GIMarshallingTestsFlags *v, gint length)
2228 {
2229 g_assert_cmpint (length, ==, 3);
2230 g_assert_cmpint (v[0], ==, GI_MARSHALLING_TESTS_FLAGS_VALUE1);
2231 g_assert_cmpint (v[1], ==, GI_MARSHALLING_TESTS_FLAGS_VALUE2);
2232 g_assert_cmpint (v[2], ==, GI_MARSHALLING_TESTS_FLAGS_VALUE3);
2233 }
2234
2235 /**
2236 * gi_marshalling_tests_array_in_guint64_len:
2237 * @ints: (array length=length) (transfer none):
2238 * @length:
2239 */
2240 void
2241 gi_marshalling_tests_array_in_guint64_len (const gint *ints, guint64 length)
2242 {
2243 g_assert_cmpint (length, ==, 4);
2244
2245 gi_marshalling_tests_array_in (ints, length);
2246 }
2247
2248 /**
2249 * gi_marshalling_tests_array_in_guint8_len:
2250 * @ints: (array length=length) (transfer none):
2251 * @length:
2252 */
2253 void
2254 gi_marshalling_tests_array_in_guint8_len (const gint *ints, guint8 length)
2255 {
2256 g_assert_cmpint (length, ==, 4);
2257
2258 gi_marshalling_tests_array_in (ints, length);
2259 }
2260
2261 /**
2262 * gi_marshalling_tests_array_out:
2263 * @ints: (out) (array length=length) (transfer none):
2264 */
2265 void
2266 gi_marshalling_tests_array_out (gint **ints, gint *length)
2267 {
2268 static gint values[] = { -1, 0, 1, 2 };
2269
2270 *length = 4;
2271 *ints = values;
2272 }
2273
2274 /**
2275 * gi_marshalling_tests_array_out_uninitialized:
2276 * @v: (out) (array length=length) (transfer none):
2277 * @length:
2278 */
2279 gboolean
2280 gi_marshalling_tests_array_out_uninitialized (gint **v G_GNUC_UNUSED, gint *length G_GNUC_UNUSED)
2281 {
2282 return FALSE;
2283 }
2284
2285 /**
2286 * gi_marshalling_tests_array_out_unaligned:
2287 * @v: (out) (array length=len) (transfer none):
2288 * @len:
2289 *
2290 * Note that the buffer will leak unless you call
2291 * gi_marshalling_tests_cleanup_unaligned_buffer().
2292 */
2293 void
2294 gi_marshalling_tests_array_out_unaligned (const guint8 **v, gsize *len)
2295 {
2296 *v = init_unaligned_buffer ();
2297 *len = UNALIGNED_BUFFER_SIZE - 1;
2298 }
2299
2300 /**
2301 * gi_marshalling_tests_array_out_etc:
2302 * @first:
2303 * @ints: (out) (array length=length) (transfer none):
2304 * @length: (out):
2305 * @last:
2306 * @sum: (out):
2307 */
2308 void
2309 gi_marshalling_tests_array_out_etc (gint first, gint **ints, gint *length, gint last, gint *sum)
2310 {
2311 static gint values[] = { -1, 0, 1, 2 };
2312
2313 values[0] = first;
2314 values[3] = last;
2315 *sum = first + last;
2316 *length = 4;
2317 *ints = values;
2318 }
2319
2320 /**
2321 * gi_marshalling_tests_array_bool_out:
2322 * @bools: (out) (array length=length) (transfer none):
2323 */
2324 void
2325 gi_marshalling_tests_array_bool_out (const gboolean **bools, gint *length)
2326 {
2327 static const gboolean values[] = { TRUE, FALSE, TRUE, TRUE };
2328
2329 *length = 4;
2330 *bools = values;
2331 }
2332
2333 /**
2334 * gi_marshalling_tests_array_unichar_out:
2335 * @chars: (out) (array length=length) (transfer none):
2336 */
2337 void
2338 gi_marshalling_tests_array_unichar_out (const gunichar **chars, gint *length)
2339 {
2340 static const gunichar values[] = GI_MARSHALLING_TESTS_CONSTANT_UCS4;
2341 *length = 12;
2342 *chars = values;
2343 }
2344
2345 /**
2346 * gi_marshalling_tests_array_inout:
2347 * @ints: (inout) (array length=length) (transfer none):
2348 * @length: (inout):
2349 */
2350 void
2351 gi_marshalling_tests_array_inout (gint **ints, gint *length)
2352 {
2353 static gint values[] = { -2, -1, 0, 1, 2 };
2354
2355 g_assert_cmpint (*length, ==, 4);
2356 g_assert_cmpint ((*ints)[0], ==, -1);
2357 g_assert_cmpint ((*ints)[1], ==, 0);
2358 g_assert_cmpint ((*ints)[2], ==, 1);
2359 g_assert_cmpint ((*ints)[3], ==, 2);
2360
2361 *length = 5;
2362 *ints = values;
2363 }
2364
2365 /**
2366 * gi_marshalling_tests_array_inout_etc:
2367 * @first:
2368 * @ints: (inout) (array length=length) (transfer none):
2369 * @length: (inout):
2370 * @last:
2371 * @sum: (out):
2372 */
2373 void
2374 gi_marshalling_tests_array_inout_etc (gint first, gint **ints, gint *length, gint last, gint *sum)
2375 {
2376 static gint values[] = { -2, -1, 0, 1, 2 };
2377
2378 g_assert_cmpint (*length, ==, 4);
2379 g_assert_cmpint ((*ints)[0], ==, -1);
2380 g_assert_cmpint ((*ints)[1], ==, 0);
2381 g_assert_cmpint ((*ints)[2], ==, 1);
2382 g_assert_cmpint ((*ints)[3], ==, 2);
2383
2384 values[0] = first;
2385 values[4] = last;
2386 *sum = first + last;
2387 *length = 5;
2388 *ints = values;
2389 }
2390
2391 /**
2392 * gi_marshalling_tests_array_in_nonzero_nonlen:
2393 * @first:
2394 * @chars: (array):
2395 */
2396 void
2397 gi_marshalling_tests_array_in_nonzero_nonlen (gint first G_GNUC_UNUSED,
2398 const guint8 *chars)
2399 {
2400 g_assert (chars[0] == 'a');
2401 g_assert (chars[1] == 'b');
2402 g_assert (chars[2] == 'c');
2403 g_assert (chars[3] == 'd');
2404 }
2405
2406 /**
2407 * gi_marshalling_tests_array_zero_terminated_return:
2408 *
2409 * Returns: (array zero-terminated) (transfer none):
2410 */
2411 const gchar **
2412 gi_marshalling_tests_array_zero_terminated_return (void)
2413 {
2414 static const gchar *values[] = { "0", "1", "2", NULL };
2415 return values;
2416 }
2417
2418 /**
2419 * gi_marshalling_tests_array_zero_terminated_return_null:
2420 *
2421 * Returns: (array zero-terminated) (transfer none):
2422 */
2423 gchar **
2424 gi_marshalling_tests_array_zero_terminated_return_null (void)
2425 {
2426 return NULL;
2427 }
2428
2429 /**
2430 * gi_marshalling_tests_array_zero_terminated_return_struct:
2431 *
2432 * Returns: (array zero-terminated) (transfer full):
2433 */
2434 GIMarshallingTestsBoxedStruct **
2435 gi_marshalling_tests_array_zero_terminated_return_struct (void)
2436 {
2437 GIMarshallingTestsBoxedStruct **ret = (GIMarshallingTestsBoxedStruct **) g_new (gpointer, 4);
2438
2439 ret[0] = gi_marshalling_tests_boxed_struct_new ();
2440 ret[0]->long_ = 42;
2441
2442 ret[1] = gi_marshalling_tests_boxed_struct_new ();
2443 ret[1]->long_ = 43;
2444
2445 ret[2] = gi_marshalling_tests_boxed_struct_new ();
2446 ret[2]->long_ = 44;
2447
2448 ret[3] = NULL;
2449
2450 return ret;
2451 }
2452
2453 /**
2454 * gi_marshalling_tests_array_zero_terminated_return_sequential_struct:
2455 *
2456 * Returns: (array zero-terminated) (transfer full):
2457 */
2458 GIMarshallingTestsBoxedStruct *
2459 gi_marshalling_tests_array_zero_terminated_return_sequential_struct (void)
2460 {
2461 GIMarshallingTestsBoxedStruct *ret = (GIMarshallingTestsBoxedStruct *) g_new0 (GIMarshallingTestsBoxedStruct, 4);
2462
2463 ret[0].long_ = 42;
2464 ret[1].long_ = 43;
2465 ret[2].long_ = 44;
2466
2467 return ret;
2468 }
2469
2470 /**
2471 * gi_marshalling_tests_array_zero_terminated_return_unichar:
2472 *
2473 * Returns: (array zero-terminated) (transfer full):
2474 */
2475 gunichar *
2476 gi_marshalling_tests_array_zero_terminated_return_unichar (void)
2477 {
2478 static const gunichar value[] = GI_MARSHALLING_TESTS_CONSTANT_UCS4;
2479 gunichar *retval = g_new0 (gunichar, 13);
2480 memcpy (retval, value, 12 * sizeof (gunichar));
2481 return retval;
2482 }
2483
2484 /**
2485 * gi_marshalling_tests_array_zero_terminated_return_unaligned:
2486 *
2487 * Note that the buffer will leak unless you call
2488 * gi_marshalling_tests_cleanup_unaligned_buffer().
2489 *
2490 * Returns: (array zero-terminated) (transfer none):
2491 */
2492 const guint8 *
2493 gi_marshalling_tests_array_zero_terminated_return_unaligned (void)
2494 {
2495 return init_unaligned_buffer ();
2496 }
2497
2498 /**
2499 * gi_marshalling_tests_array_zero_terminated_in:
2500 * @utf8s: (array zero-terminated) (transfer none):
2501 */
2502 void
2503 gi_marshalling_tests_array_zero_terminated_in (gchar **utf8s)
2504 {
2505 g_assert (g_strv_length (utf8s));
2506 g_assert_cmpstr (utf8s[0], ==, "0");
2507 g_assert_cmpstr (utf8s[1], ==, "1");
2508 g_assert_cmpstr (utf8s[2], ==, "2");
2509 }
2510
2511 /**
2512 * gi_marshalling_tests_array_zero_terminated_out:
2513 * @utf8s: (out) (array zero-terminated) (transfer none):
2514 */
2515 void
2516 gi_marshalling_tests_array_zero_terminated_out (const gchar ***utf8s)
2517 {
2518 static const gchar *values[] = { "0", "1", "2", NULL };
2519 *utf8s = values;
2520 }
2521
2522 /**
2523 * gi_marshalling_tests_array_zero_terminated_out_uninitialized:
2524 * @v: (out) (array zero-terminated) (transfer none):
2525 */
2526 gboolean
2527 gi_marshalling_tests_array_zero_terminated_out_uninitialized (const gchar ***v G_GNUC_UNUSED)
2528 {
2529 return FALSE;
2530 }
2531
2532 /**
2533 * gi_marshalling_tests_array_zero_terminated_out_unaligned:
2534 * @v: (out) (array zero-terminated) (transfer none):
2535 *
2536 * Note that the buffer will leak unless you call
2537 * gi_marshalling_tests_cleanup_unaligned_buffer().
2538 */
2539 void
2540 gi_marshalling_tests_array_zero_terminated_out_unaligned (const guint8 **v)
2541 {
2542 *v = init_unaligned_buffer ();
2543 }
2544
2545 /**
2546 * gi_marshalling_tests_array_zero_terminated_inout:
2547 * @utf8s: (inout) (array zero-terminated) (transfer none):
2548 */
2549 void
2550 gi_marshalling_tests_array_zero_terminated_inout (const gchar ***utf8s)
2551 {
2552 static const gchar *values[] = { "-1", "0", "1", "2", NULL };
2553
2554 g_assert (g_strv_length ((gchar **) (*utf8s)));
2555 g_assert_cmpstr ((*utf8s)[0], ==, "0");
2556 g_assert_cmpstr ((*utf8s)[1], ==, "1");
2557 g_assert_cmpstr ((*utf8s)[2], ==, "2");
2558
2559 *utf8s = values;
2560 }
2561
2562 /**
2563 * gi_marshalling_tests_array_gvariant_none_in:
2564 * @variants: (array zero-terminated) (transfer none):
2565 *
2566 * Returns: (array zero-terminated) (transfer none):
2567 */
2568 GVariant **
2569 gi_marshalling_tests_array_gvariant_none_in (GVariant **variants)
2570 {
2571 /* Use a static container to detect if someone tries to free it */
2572 static GVariant *private_container[3] = { NULL, NULL, NULL };
2573
2574 if (private_container[0] == NULL)
2575 {
2576 private_container[0] = g_variant_new_int32 (27);
2577 private_container[1] = g_variant_new_string ("Hello");
2578 }
2579
2580 g_assert (variants != NULL);
2581 g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
2582 g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
2583 g_assert (variants[2] == NULL);
2584
2585 return private_container;
2586 }
2587
2588 /**
2589 * gi_marshalling_tests_array_gvariant_container_in:
2590 * @variants: (array zero-terminated) (transfer container):
2591 *
2592 * Returns: (array zero-terminated) (transfer container):
2593 */
2594 GVariant **
2595 gi_marshalling_tests_array_gvariant_container_in (GVariant **variants)
2596 {
2597 GVariant **container;
2598
2599 g_assert (variants != NULL);
2600 g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
2601 g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
2602 g_assert (variants[2] == NULL);
2603
2604 container = g_new0 (GVariant *, 3);
2605 /* This is a floating reference, so it's fine for transfer container */
2606 container[0] = g_variant_new_int32 (g_variant_get_int32 (variants[0]));
2607 container[1] = variants[1];
2608 g_free (variants);
2609
2610 return container;
2611 }
2612
2613 /**
2614 * gi_marshalling_tests_array_gvariant_full_in:
2615 * @variants: (array zero-terminated) (transfer full):
2616 *
2617 * Returns: (array zero-terminated) (transfer full):
2618 */
2619 GVariant **
2620 gi_marshalling_tests_array_gvariant_full_in (GVariant **variants)
2621 {
2622 GVariant **container;
2623
2624 g_assert (variants != NULL);
2625 g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
2626 g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
2627 g_assert (variants[2] == NULL);
2628
2629 /* To catch different behaviors we reconstruct one variant from scratch,
2630 * while taking the refernce of the other. Both approaches are legal with full
2631 * transfer in and out */
2632 container = g_new0 (GVariant *, 3);
2633 container[0] = g_variant_ref_sink (
2634 g_variant_new_int32 (g_variant_get_int32 (variants[0])));
2635 g_variant_unref (variants[0]);
2636
2637 /* In case the variant is floating, we want to transform it into a full
2638 * reference, so that's fully owned by the container like if the case
2639 * above, otherwise we just steal it since it has already a strong reference.
2640 */
2641 container[1] = g_variant_take_ref (variants[1]);
2642 g_free (variants);
2643
2644 return container;
2645 }
2646
2647 /* The following tests expect the following arrays:
2648 * in: 🅰, β, c, d (the first two characters are U+1F170 and U+03B2)
2649 * out/return: a, b, ¢, 🔠 (the last two characters are U+00A2 and U+1F520)
2650 * This is intended to test the full capabilities of C arrays of a basic type.
2651 * UTF-8 strings and filenames are the only basic types that need to be released
2652 * as individual elements, so we test UTF-8 strings. We test ASCII characters,
2653 * basic multilingual plane characters, and astral plane characters in both the
2654 * in and out arrays.
2655 */
2656 #define SQUARED_A "\xf0\x9f\x85\xb0"
2657 #define BETA "\xce\xb2"
2658 #define CENT "\xc2\xa2"
2659 #define ABCD "\xf0\x9f\x94\xa0"
2660
2661 /**
2662 * gi_marshalling_tests_length_array_utf8_none_return:
2663 *
2664 * Returns: (array length=out_length) (transfer none):
2665 */
2666 const gchar *const *
2667 gi_marshalling_tests_length_array_utf8_none_return (size_t *out_length)
2668 {
2669 static const gchar *array[] = { "a", "b", CENT, ABCD };
2670
2671 *out_length = 4;
2672 return array;
2673 }
2674
2675 /**
2676 * gi_marshalling_tests_length_array_utf8_container_return:
2677 *
2678 * Returns: (array length=out_length) (transfer container):
2679 */
2680 const gchar **
2681 gi_marshalling_tests_length_array_utf8_container_return (size_t *out_length)
2682 {
2683 const gchar **array = g_new0 (const gchar *, 4);
2684
2685 array[0] = "a";
2686 array[1] = "b";
2687 array[2] = CENT;
2688 array[3] = ABCD;
2689
2690 *out_length = 4;
2691 return array;
2692 }
2693
2694 /**
2695 * gi_marshalling_tests_length_array_utf8_full_return:
2696 *
2697 * Returns: (array length=out_length) (transfer full):
2698 */
2699 gchar **
2700 gi_marshalling_tests_length_array_utf8_full_return (size_t *out_length)
2701 {
2702 gchar **array = g_new0 (gchar *, 4);
2703 array[0] = g_strdup ("a");
2704 array[1] = g_strdup ("b");
2705 array[2] = g_strdup (CENT);
2706 array[3] = g_strdup (ABCD);
2707
2708 *out_length = 4;
2709 return array;
2710 }
2711
2712 /**
2713 * gi_marshalling_tests_length_array_utf8_none_in:
2714 * @array: (array length=length) (transfer none):
2715 */
2716 void
2717 gi_marshalling_tests_length_array_utf8_none_in (const gchar *const *array, size_t length)
2718 {
2719 g_assert_cmpint (length, ==, 4);
2720
2721 g_assert_cmpstr (array[0], ==, SQUARED_A);
2722 g_assert_cmpstr (array[1], ==, BETA);
2723 g_assert_cmpstr (array[2], ==, "c");
2724 g_assert_cmpstr (array[3], ==, "d");
2725 }
2726
2727 /**
2728 * gi_marshalling_tests_length_array_utf8_container_in:
2729 * @array: (array length=length) (transfer container):
2730 */
2731 void
2732 gi_marshalling_tests_length_array_utf8_container_in (const gchar **array, size_t length)
2733 {
2734 gi_marshalling_tests_length_array_utf8_none_in (array, length);
2735
2736 g_clear_pointer (&array, g_free);
2737 }
2738
2739 /**
2740 * gi_marshalling_tests_length_array_utf8_full_in:
2741 * @array: (array length=length) (transfer full):
2742 */
2743 void
2744 gi_marshalling_tests_length_array_utf8_full_in (gchar **array, size_t length)
2745 {
2746 gi_marshalling_tests_length_array_utf8_none_in ((const gchar *const *) array, length);
2747
2748 g_clear_pointer (&array[0], g_free);
2749 g_clear_pointer (&array[1], g_free);
2750 g_clear_pointer (&array[2], g_free);
2751 g_clear_pointer (&array[3], g_free);
2752
2753 g_clear_pointer (&array, g_free);
2754 }
2755
2756 /**
2757 * gi_marshalling_tests_length_array_utf8_none_out:
2758 * @array_out: (array length=out_length) (out) (transfer none):
2759 * @out_length: (out):
2760 */
2761 void
2762 gi_marshalling_tests_length_array_utf8_none_out (const gchar *const **array_out, size_t *out_length)
2763 {
2764 *array_out = gi_marshalling_tests_length_array_utf8_none_return (out_length);
2765 }
2766
2767 /**
2768 * gi_marshalling_tests_length_array_utf8_container_out:
2769 * @array_out: (array length=out_length) (out) (transfer container):
2770 */
2771 void
2772 gi_marshalling_tests_length_array_utf8_container_out (const gchar ***array_out, size_t *out_length)
2773 {
2774 *array_out = gi_marshalling_tests_length_array_utf8_container_return (out_length);
2775 }
2776
2777 /**
2778 * gi_marshalling_tests_length_array_utf8_full_out:
2779 * @array_out: (array length=out_length) (out) (transfer full):
2780 */
2781 void
2782 gi_marshalling_tests_length_array_utf8_full_out (gchar ***array_out, size_t *out_length)
2783 {
2784 *array_out = gi_marshalling_tests_length_array_utf8_full_return (out_length);
2785 }
2786
2787 /**
2788 * gi_marshalling_tests_length_array_utf8_none_inout:
2789 * @array_inout: (array length=inout_length) (inout) (transfer none):
2790 * @inout_length: (inout):
2791 */
2792 void
2793 gi_marshalling_tests_length_array_utf8_none_inout (const gchar *const **array_inout, size_t *inout_length)
2794 {
2795 static const gchar *array_out[] = { "a", "b", CENT, ABCD };
2796
2797 g_assert_nonnull (inout_length);
2798 gi_marshalling_tests_length_array_utf8_none_in (*array_inout, *inout_length);
2799
2800 *array_inout = array_out;
2801 *inout_length = 4;
2802 }
2803
2804 /**
2805 * gi_marshalling_tests_length_array_utf8_container_inout:
2806 * @array_inout: (array length=inout_length) (inout) (transfer container):
2807 * @inout_length: (inout):
2808 */
2809 void
2810 gi_marshalling_tests_length_array_utf8_container_inout (const gchar ***array_inout, size_t *inout_length)
2811 {
2812 const gchar **array_out = g_new0 (const gchar *, 4);
2813
2814 g_assert_nonnull (inout_length);
2815 g_assert_nonnull (array_inout);
2816 gi_marshalling_tests_length_array_utf8_container_in (*array_inout, *inout_length);
2817
2818 array_out[0] = "a";
2819 array_out[1] = "b";
2820 array_out[2] = CENT;
2821 array_out[3] = ABCD;
2822
2823 *array_inout = array_out;
2824 *inout_length = 4;
2825 }
2826
2827 /**
2828 * gi_marshalling_tests_length_array_utf8_full_inout:
2829 * @array_inout: (array length=inout_length) (inout) (transfer full):
2830 * @inout_length: (inout):
2831 */
2832 void
2833 gi_marshalling_tests_length_array_utf8_full_inout (gchar ***array_inout, size_t *inout_length)
2834 {
2835 gchar **array_out = g_new0 (gchar *, 4);
2836
2837 g_assert_nonnull (inout_length);
2838 g_assert_nonnull (array_inout);
2839 gi_marshalling_tests_length_array_utf8_full_in (
2840 g_steal_pointer (array_inout), *inout_length);
2841
2842 array_out[0] = g_strdup ("a");
2843 array_out[1] = g_strdup ("b");
2844 array_out[2] = g_strdup (CENT);
2845 array_out[3] = g_strdup (ABCD);
2846
2847 *array_inout = array_out;
2848 *inout_length = 4;
2849 }
2850
2851 /**
2852 * gi_marshalling_tests_length_array_utf8_optional_inout:
2853 * @inout_length: (inout) (optional): @array_inout's length
2854 * @array_inout: (inout) (array length=inout_length) (optional): array ["🅰", "β", "c", "d"]
2855 *
2856 * See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9524
2857 */
2858 void
2859 gi_marshalling_tests_length_array_utf8_optional_inout (int *inout_length, char **array_inout[])
2860 {
2861 if (inout_length == NULL)
2862 {
2863 g_assert_null (array_inout);
2864 }
2865 else if (*inout_length > 0)
2866 {
2867 size_t size = *inout_length;
2868
2869 g_assert_nonnull (array_inout);
2870 g_assert_nonnull (*array_inout);
2871
2872 gi_marshalling_tests_length_array_utf8_full_inout (array_inout, &size);
2873 *inout_length = size;
2874 }
2875 else
2876 {
2877 g_free (*array_inout);
2878
2879 gchar **array_out = g_new0 (gchar *, 2);
2880
2881 g_assert_nonnull (inout_length);
2882 g_assert_nonnull (array_inout);
2883
2884 array_out[0] = g_strdup ("a");
2885 array_out[1] = g_strdup ("b");
2886
2887 *array_inout = array_out;
2888 *inout_length = 2;
2889 }
2890 }
2891
2892 /**
2893 * gi_marshalling_tests_zero_terminated_array_utf8_none_return:
2894 *
2895 * Returns: (array zero-terminated) (transfer none):
2896 */
2897 const gchar *const *
2898 gi_marshalling_tests_zero_terminated_array_utf8_none_return (void)
2899 {
2900 static const gchar *array[] = { "a", "b", CENT, ABCD, NULL };
2901 return array;
2902 }
2903
2904 /**
2905 * gi_marshalling_tests_zero_terminated_array_utf8_container_return:
2906 *
2907 * Returns: (array zero-terminated) (transfer container):
2908 */
2909 const gchar **
2910 gi_marshalling_tests_zero_terminated_array_utf8_container_return (void)
2911 {
2912 const gchar **array = g_new0 (const gchar *, 5);
2913
2914 array[0] = "a";
2915 array[1] = "b";
2916 array[2] = CENT;
2917 array[3] = ABCD;
2918
2919 return array;
2920 }
2921
2922 /**
2923 * gi_marshalling_tests_zero_terminated_array_utf8_full_return:
2924 *
2925 * Returns: (array zero-terminated) (transfer full):
2926 */
2927 gchar **
2928 gi_marshalling_tests_zero_terminated_array_utf8_full_return (void)
2929 {
2930 gchar **array = g_new0 (gchar *, 5);
2931
2932 array[0] = g_strdup ("a");
2933 array[1] = g_strdup ("b");
2934 array[2] = g_strdup (CENT);
2935 array[3] = g_strdup (ABCD);
2936
2937 return array;
2938 }
2939
2940 /**
2941 * gi_marshalling_tests_zero_terminated_array_utf8_none_in:
2942 * @array: (array zero-terminated) (transfer none):
2943 * @extra: (nullable) (transfer none):
2944 * The extra parameter can be used to trigger marshalling errors,
2945 * so you can test the cleanup of array in case of invalid parameters.
2946 */
2947 void
2948 gi_marshalling_tests_zero_terminated_array_utf8_none_in (const gchar *const *array, gchar *extra)
2949 {
2950 g_assert_cmpstr (array[0], ==, SQUARED_A);
2951 g_assert_cmpstr (array[1], ==, BETA);
2952 g_assert_cmpstr (array[2], ==, "c");
2953 g_assert_cmpstr (array[3], ==, "d");
2954
2955 g_assert_null (array[4]);
2956 g_assert_null (extra);
2957 }
2958
2959 /**
2960 * gi_marshalling_tests_zero_terminated_array_utf8_container_in:
2961 * @array: (array zero-terminated) (transfer container):
2962 * @extra: (nullable) (transfer none):
2963 * The extra parameter can be used to trigger marshalling errors,
2964 * so you can test the cleanup of array in case of invalid parameters.
2965 */
2966 void
2967 gi_marshalling_tests_zero_terminated_array_utf8_container_in (const gchar **array, gchar *extra)
2968 {
2969 gi_marshalling_tests_zero_terminated_array_utf8_none_in (array, extra);
2970
2971 g_clear_pointer (&array, g_free);
2972 }
2973
2974 /**
2975 * gi_marshalling_tests_zero_terminated_array_utf8_full_in:
2976 * @array: (array zero-terminated) (transfer full):
2977 * @extra: (nullable) (transfer none):
2978 * The extra parameter can be used to trigger marshalling errors,
2979 * so you can test the cleanup of array in case of invalid parameters.
2980 */
2981 void
2982 gi_marshalling_tests_zero_terminated_array_utf8_full_in (gchar **array, gchar *extra)
2983 {
2984 gi_marshalling_tests_zero_terminated_array_utf8_none_in ((const gchar *const *) array, extra);
2985
2986 for (size_t i = 0; array && array[i] != NULL; i++)
2987 g_clear_pointer (&array[i], g_free);
2988
2989 g_clear_pointer (&array, g_free);
2990 }
2991
2992 /**
2993 * gi_marshalling_tests_zero_terminated_array_utf8_none_out:
2994 * @array_out: (array zero-terminated) (out) (transfer none):
2995 */
2996 void
2997 gi_marshalling_tests_zero_terminated_array_utf8_none_out (const gchar *const **array_out)
2998 {
2999 *array_out = gi_marshalling_tests_zero_terminated_array_utf8_none_return ();
3000 }
3001
3002 /**
3003 * gi_marshalling_tests_zero_terminated_array_utf8_container_out:
3004 * @array_out: (array zero-terminated) (out) (transfer container):
3005 */
3006 void
3007 gi_marshalling_tests_zero_terminated_array_utf8_container_out (const gchar ***array_out)
3008 {
3009 *array_out = gi_marshalling_tests_zero_terminated_array_utf8_container_return ();
3010 }
3011
3012 /**
3013 * gi_marshalling_tests_zero_terminated_array_utf8_full_out:
3014 * @array_out: (array zero-terminated) (out) (transfer full):
3015 */
3016 void
3017 gi_marshalling_tests_zero_terminated_array_utf8_full_out (gchar ***array_out)
3018 {
3019 *array_out = gi_marshalling_tests_zero_terminated_array_utf8_full_return ();
3020 }
3021
3022 /**
3023 * gi_marshalling_tests_zero_terminated_array_utf8_none_inout:
3024 * @array_inout: (array zero-terminated) (inout) (transfer none):
3025 */
3026 void
3027 gi_marshalling_tests_zero_terminated_array_utf8_none_inout (const gchar *const **array_inout)
3028 {
3029 static const gchar *array_out[] = { "a", "b", CENT, ABCD, NULL };
3030
3031 gi_marshalling_tests_zero_terminated_array_utf8_none_in (*array_inout, NULL);
3032
3033 *array_inout = array_out;
3034 }
3035
3036 /**
3037 * gi_marshalling_tests_zero_terminated_array_utf8_container_inout:
3038 * @array_inout: (array zero-terminated) (inout) (transfer container):
3039 */
3040 void
3041 gi_marshalling_tests_zero_terminated_array_utf8_container_inout (const gchar ***array_inout)
3042 {
3043 const gchar **array_out = g_new0 (const gchar *, 5);
3044
3045 gi_marshalling_tests_zero_terminated_array_utf8_container_in (*array_inout, NULL);
3046
3047 array_out[0] = "a";
3048 array_out[1] = "b";
3049 array_out[2] = CENT;
3050 array_out[3] = ABCD;
3051
3052 *array_inout = array_out;
3053 }
3054
3055 /**
3056 * gi_marshalling_tests_zero_terminated_array_utf8_full_inout:
3057 * @array_inout: (array zero-terminated) (inout) (transfer full):
3058 */
3059 void
3060 gi_marshalling_tests_zero_terminated_array_utf8_full_inout (gchar ***array_inout)
3061 {
3062 gchar **array_out = g_new0 (gchar *, 5);
3063
3064 gi_marshalling_tests_zero_terminated_array_utf8_full_in (
3065 g_steal_pointer (array_inout), NULL);
3066
3067 array_out[0] = g_strdup ("a");
3068 array_out[1] = g_strdup ("b");
3069 array_out[2] = g_strdup (CENT);
3070 array_out[3] = g_strdup (ABCD);
3071
3072 *array_inout = array_out;
3073 }
3074
3075 /**
3076 * gi_marshalling_tests_fixed_array_utf8_none_return:
3077 *
3078 * Returns: (array fixed-size=4) (transfer none):
3079 */
3080 const gchar *const *
3081 gi_marshalling_tests_fixed_array_utf8_none_return (void)
3082 {
3083 static const gchar *array[] = { "a", "b", CENT, ABCD };
3084 return array;
3085 }
3086
3087 /**
3088 * gi_marshalling_tests_fixed_array_utf8_container_return:
3089 *
3090 * Returns: (array fixed-size=4) (transfer container):
3091 */
3092 const gchar **
3093 gi_marshalling_tests_fixed_array_utf8_container_return (void)
3094 {
3095 const gchar **array = g_new0 (const gchar *, 4);
3096
3097 array[0] = "a";
3098 array[1] = "b";
3099 array[2] = CENT;
3100 array[3] = ABCD;
3101
3102 return array;
3103 }
3104
3105 /**
3106 * gi_marshalling_tests_fixed_array_utf8_full_return:
3107 *
3108 * Returns: (array fixed-size=4) (transfer full):
3109 */
3110 gchar **
3111 gi_marshalling_tests_fixed_array_utf8_full_return (void)
3112 {
3113 gchar **array = g_new0 (gchar *, 4);
3114
3115 array[0] = g_strdup ("a");
3116 array[1] = g_strdup ("b");
3117 array[2] = g_strdup (CENT);
3118 array[3] = g_strdup (ABCD);
3119
3120 return array;
3121 }
3122
3123 /**
3124 * gi_marshalling_tests_fixed_array_utf8_none_in:
3125 * @array: (array fixed-size=4) (transfer none):
3126 */
3127 void
3128 gi_marshalling_tests_fixed_array_utf8_none_in (const gchar *const *array)
3129 {
3130 g_assert_cmpstr (array[0], ==, SQUARED_A);
3131 g_assert_cmpstr (array[1], ==, BETA);
3132 g_assert_cmpstr (array[2], ==, "c");
3133 g_assert_cmpstr (array[3], ==, "d");
3134 }
3135
3136 /**
3137 * gi_marshalling_tests_fixed_array_utf8_container_in:
3138 * @array: (array fixed-size=4) (transfer container):
3139 */
3140 void
3141 gi_marshalling_tests_fixed_array_utf8_container_in (const gchar **array)
3142 {
3143 gi_marshalling_tests_fixed_array_utf8_none_in (array);
3144
3145 g_clear_pointer (&array, g_free);
3146 }
3147
3148 /**
3149 * gi_marshalling_tests_fixed_array_utf8_full_in:
3150 * @array: (array fixed-size=4) (transfer full):
3151 */
3152 void
3153 gi_marshalling_tests_fixed_array_utf8_full_in (gchar **array)
3154 {
3155 gi_marshalling_tests_fixed_array_utf8_none_in ((const gchar *const *) array);
3156
3157 g_clear_pointer (&array[0], g_free);
3158 g_clear_pointer (&array[1], g_free);
3159 g_clear_pointer (&array[2], g_free);
3160 g_clear_pointer (&array[3], g_free);
3161
3162 g_clear_pointer (&array, g_free);
3163 }
3164
3165 /**
3166 * gi_marshalling_tests_fixed_array_utf8_none_out:
3167 * @array_out: (array fixed-size=4) (out) (transfer none):
3168 */
3169 void
3170 gi_marshalling_tests_fixed_array_utf8_none_out (const gchar *const **array_out)
3171 {
3172 *array_out = gi_marshalling_tests_fixed_array_utf8_none_return ();
3173 }
3174
3175 /**
3176 * gi_marshalling_tests_fixed_array_utf8_container_out:
3177 * @array_out: (array fixed-size=4) (out) (transfer container):
3178 */
3179 void
3180 gi_marshalling_tests_fixed_array_utf8_container_out (const gchar ***array_out)
3181 {
3182 *array_out = gi_marshalling_tests_fixed_array_utf8_container_return ();
3183 }
3184
3185 /**
3186 * gi_marshalling_tests_fixed_array_utf8_full_out:
3187 * @array_out: (array fixed-size=4) (out) (transfer full):
3188 */
3189 void
3190 gi_marshalling_tests_fixed_array_utf8_full_out (gchar ***array_out)
3191 {
3192 *array_out = gi_marshalling_tests_fixed_array_utf8_full_return ();
3193 }
3194
3195 /**
3196 * gi_marshalling_tests_fixed_array_utf8_none_inout:
3197 * @array_inout: (array fixed-size=4) (inout) (transfer none):
3198 */
3199 void
3200 gi_marshalling_tests_fixed_array_utf8_none_inout (const gchar *const **array_inout)
3201 {
3202 static const gchar *array_out[] = { "a", "b", CENT, ABCD };
3203
3204 gi_marshalling_tests_fixed_array_utf8_none_in (*array_inout);
3205
3206 *array_inout = array_out;
3207 }
3208
3209 /**
3210 * gi_marshalling_tests_fixed_array_utf8_container_inout:
3211 * @array_inout: (array fixed-size=4) (inout) (transfer container):
3212 */
3213 void
3214 gi_marshalling_tests_fixed_array_utf8_container_inout (const gchar ***array_inout)
3215 {
3216 const gchar **array_out = g_new0 (const gchar *, 4);
3217
3218 gi_marshalling_tests_fixed_array_utf8_container_in (*array_inout);
3219
3220 array_out[0] = "a";
3221 array_out[1] = "b";
3222 array_out[2] = CENT;
3223 array_out[3] = ABCD;
3224
3225 *array_inout = array_out;
3226 }
3227
3228 /**
3229 * gi_marshalling_tests_fixed_array_utf8_full_inout:
3230 * @array_inout: (array fixed-size=4) (inout) (transfer full):
3231 */
3232 void
3233 gi_marshalling_tests_fixed_array_utf8_full_inout (gchar ***array_inout)
3234 {
3235 gchar **array_out = g_new0 (gchar *, 4);
3236
3237 gi_marshalling_tests_fixed_array_utf8_full_in (
3238 g_steal_pointer (array_inout));
3239
3240 array_out[0] = g_strdup ("a");
3241 array_out[1] = g_strdup ("b");
3242 array_out[2] = g_strdup (CENT);
3243 array_out[3] = g_strdup (ABCD);
3244
3245 *array_inout = array_out;
3246 }
3247
3248 /**
3249 * gi_marshalling_tests_garray_int_none_return:
3250 *
3251 * Returns: (element-type gint) (transfer none):
3252 */
3253 GArray *
3254 gi_marshalling_tests_garray_int_none_return (void)
3255 {
3256 static GArray *v = NULL;
3257 gint i;
3258
3259 if (v == NULL)
3260 {
3261 v = g_array_new (TRUE, TRUE, sizeof (gint));
3262 for (i = -1; i < 3; i++)
3263 g_array_append_val (v, i);
3264 }
3265
3266 return v;
3267 }
3268
3269 /**
3270 * gi_marshalling_tests_garray_uint64_none_return:
3271 *
3272 * Returns: (element-type guint64) (transfer none):
3273 */
3274 GArray *
3275 gi_marshalling_tests_garray_uint64_none_return (void)
3276 {
3277 static GArray *array = NULL;
3278 guint64 i;
3279
3280 if (array == NULL)
3281 {
3282 array = g_array_new (TRUE, TRUE, sizeof (guint64));
3283 i = 0;
3284 g_array_append_val (array, i);
3285 i = G_MAXUINT64;
3286 g_array_append_val (array, i);
3287 }
3288
3289 return array;
3290 }
3291
3292 /**
3293 * gi_marshalling_tests_garray_enum_none_return:
3294 *
3295 * Returns: (element-type GIMarshallingTestsGEnum) (transfer none):
3296 */
3297 GArray *
3298 gi_marshalling_tests_garray_enum_none_return (void)
3299 {
3300 static GArray *array = NULL;
3301 GIMarshallingTestsGEnum value;
3302
3303 if (array == NULL)
3304 {
3305 array = g_array_new (TRUE, TRUE, sizeof (GIMarshallingTestsGEnum));
3306 value = GI_MARSHALLING_TESTS_GENUM_VALUE1;
3307 g_array_append_val (array, value);
3308 value = GI_MARSHALLING_TESTS_GENUM_VALUE2;
3309 g_array_append_val (array, value);
3310 value = GI_MARSHALLING_TESTS_GENUM_VALUE3;
3311 g_array_append_val (array, value);
3312 }
3313
3314 return array;
3315 }
3316
3317 /**
3318 * gi_marshalling_tests_garray_utf8_none_return:
3319 *
3320 * Returns: (element-type utf8) (transfer none):
3321 */
3322 GArray *
3323 gi_marshalling_tests_garray_utf8_none_return (void)
3324 {
3325 static GArray *array = NULL;
3326 static const gchar *values[] = { "0", "1", "2", NULL };
3327 gint i;
3328
3329 if (array == NULL)
3330 {
3331 array = g_array_new (TRUE, TRUE, sizeof (gchar *));
3332 for (i = 0; values[i]; i++)
3333 g_array_append_val (array, values[i]);
3334 }
3335
3336 return array;
3337 }
3338
3339 /**
3340 * gi_marshalling_tests_garray_utf8_container_return:
3341 *
3342 * Returns: (element-type utf8) (transfer container):
3343 */
3344 GArray *
3345 gi_marshalling_tests_garray_utf8_container_return (void)
3346 {
3347 GArray *array = NULL;
3348 static const gchar *values[] = { "0", "1", "2", NULL };
3349 gint i;
3350
3351 array = g_array_new (TRUE, TRUE, sizeof (gchar *));
3352 for (i = 0; values[i]; i++)
3353 g_array_append_val (array, values[i]);
3354
3355 return array;
3356 }
3357
3358 /**
3359 * gi_marshalling_tests_garray_utf8_full_return:
3360 *
3361 * Returns: (element-type utf8) (transfer full):
3362 */
3363 GArray *
3364 gi_marshalling_tests_garray_utf8_full_return (void)
3365 {
3366 GArray *array = NULL;
3367 static const gchar *values[] = { "0", "1", "2", NULL };
3368 gint i;
3369
3370 array = g_array_new (TRUE, TRUE, sizeof (gchar *));
3371 for (i = 0; values[i]; i++)
3372 {
3373 gchar *str = g_strdup (values[i]);
3374 g_array_append_val (array, str);
3375 }
3376
3377 return array;
3378 }
3379
3380 /**
3381 * gi_marshalling_tests_garray_boxed_struct_full_return:
3382 *
3383 * Returns: (element-type GIMarshallingTestsBoxedStruct) (transfer full):
3384 */
3385 GArray *
3386 gi_marshalling_tests_garray_boxed_struct_full_return (void)
3387 {
3388 GArray *array = NULL;
3389 static const glong long_values[] = { 42, 43, 44 };
3390 gint i;
3391
3392 array = g_array_new (TRUE, TRUE, sizeof (GIMarshallingTestsBoxedStruct));
3393 g_array_set_size (array, 3);
3394 for (i = 0; i < 3; i++)
3395 {
3396 GIMarshallingTestsBoxedStruct *new_struct;
3397 new_struct = &g_array_index (array, GIMarshallingTestsBoxedStruct, i);
3398 memset (new_struct, 0, sizeof (GIMarshallingTestsSimpleStruct));
3399 new_struct->long_ = long_values[i];
3400 }
3401
3402 return array;
3403 }
3404
3405 /**
3406 * gi_marshalling_tests_garray_int_none_in:
3407 * @array_: (element-type gint) (transfer none):
3408 */
3409 void
3410 gi_marshalling_tests_garray_int_none_in (GArray *array_)
3411 {
3412 g_assert_cmpint (array_->len, ==, 4);
3413 g_assert_cmpint (g_array_index (array_, gint, 0), ==, -1);
3414 g_assert_cmpint (g_array_index (array_, gint, 1), ==, 0);
3415 g_assert_cmpint (g_array_index (array_, gint, 2), ==, 1);
3416 g_assert_cmpint (g_array_index (array_, gint, 3), ==, 2);
3417 }
3418
3419 /**
3420 * gi_marshalling_tests_garray_uint64_none_in:
3421 * @array_: (element-type guint64) (transfer none):
3422 */
3423 void
3424 gi_marshalling_tests_garray_uint64_none_in (GArray *array_)
3425 {
3426 g_assert_cmpint (array_->len, ==, 2);
3427 g_assert_cmpint (g_array_index (array_, guint64, 0), ==, 0);
3428 g_assert_cmpint (g_array_index (array_, guint64, 1), ==, G_MAXUINT64);
3429 }
3430
3431 /**
3432 * gi_marshalling_tests_garray_utf8_none_in:
3433 * @array_: (element-type utf8) (transfer none):
3434 */
3435 void
3436 gi_marshalling_tests_garray_utf8_none_in (GArray *array_)
3437 {
3438 g_assert_cmpint (array_->len, ==, 3);
3439 g_assert_cmpstr (g_array_index (array_, gchar *, 0), ==, "0");
3440 g_assert_cmpstr (g_array_index (array_, gchar *, 1), ==, "1");
3441 g_assert_cmpstr (g_array_index (array_, gchar *, 2), ==, "2");
3442 }
3443
3444 /**
3445 * gi_marshalling_tests_garray_utf8_container_in:
3446 * @array_: (element-type utf8) (transfer container):
3447 */
3448 void
3449 gi_marshalling_tests_garray_utf8_container_in (GArray *array_)
3450 {
3451 gi_marshalling_tests_garray_utf8_none_in (array_);
3452 g_array_unref (array_);
3453 }
3454
3455 /**
3456 * gi_marshalling_tests_garray_utf8_full_in:
3457 * @array_: (element-type utf8) (transfer full):
3458 */
3459 void
3460 gi_marshalling_tests_garray_utf8_full_in (GArray *array_)
3461 {
3462 gi_marshalling_tests_garray_utf8_none_in (array_);
3463 for (size_t ix = 0; ix < 3; ix++)
3464 g_clear_pointer (&g_array_index (array_, gchar *, ix), g_free);
3465 g_array_unref (array_);
3466 }
3467
3468 /**
3469 * gi_marshalling_tests_garray_utf8_none_out:
3470 * @array_: (out) (element-type utf8) (transfer none):
3471 */
3472 void
3473 gi_marshalling_tests_garray_utf8_none_out (GArray **array_)
3474 {
3475 static GArray *internal = NULL;
3476 static const gchar *values[] = { "0", "1", "2", NULL };
3477 gint i;
3478
3479 if (internal == NULL)
3480 {
3481 internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
3482 for (i = 0; values[i]; i++)
3483 g_array_append_val (internal, values[i]);
3484 }
3485
3486 *array_ = internal;
3487 }
3488
3489 /**
3490 * gi_marshalling_tests_garray_utf8_none_out_uninitialized:
3491 * @v: (out) (element-type utf8) (transfer none):
3492 */
3493 gboolean
3494 gi_marshalling_tests_garray_utf8_none_out_uninitialized (GArray **v G_GNUC_UNUSED)
3495 {
3496 return FALSE;
3497 }
3498
3499 /**
3500 * gi_marshalling_tests_garray_utf8_container_out:
3501 * @array_: (out) (element-type utf8) (transfer container):
3502 */
3503 void
3504 gi_marshalling_tests_garray_utf8_container_out (GArray **array_)
3505 {
3506 static const gchar *values[] = { "0", "1", "2", NULL };
3507 gint i;
3508
3509 *array_ = NULL;
3510
3511 *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
3512 for (i = 0; values[i]; i++)
3513 g_array_append_val (*array_, values[i]);
3514 }
3515
3516 /**
3517 * gi_marshalling_tests_garray_utf8_container_out_uninitialized:
3518 * @v: (out) (element-type utf8) (transfer container):
3519 */
3520 gboolean
3521 gi_marshalling_tests_garray_utf8_container_out_uninitialized (GArray **v G_GNUC_UNUSED)
3522 {
3523 return FALSE;
3524 }
3525
3526 /**
3527 * gi_marshalling_tests_garray_utf8_full_out:
3528 * @array_: (out) (element-type utf8) (transfer full):
3529 */
3530 void
3531 gi_marshalling_tests_garray_utf8_full_out (GArray **array_)
3532 {
3533 static const gchar *values[] = { "0", "1", "2", NULL };
3534 gint i;
3535
3536 *array_ = NULL;
3537
3538 *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
3539 for (i = 0; values[i]; i++)
3540 {
3541 gchar *str = g_strdup (values[i]);
3542 g_array_append_val (*array_, str);
3543 }
3544 }
3545
3546 /**
3547 * gi_marshalling_tests_garray_utf8_full_out_uninitialized:
3548 * @v: (out) (element-type utf8) (transfer full):
3549 */
3550 gboolean
3551 gi_marshalling_tests_garray_utf8_full_out_uninitialized (GArray **v G_GNUC_UNUSED)
3552 {
3553 return FALSE;
3554 }
3555
3556 /**
3557 * gi_marshalling_tests_garray_utf8_full_out_caller_allocated:
3558 * @array_: (out caller-allocates) (array) (element-type utf8) (transfer full):
3559 */
3560 void
3561 gi_marshalling_tests_garray_utf8_full_out_caller_allocated (GArray *array_)
3562 {
3563 static const gchar *values[] = { "0", "1", "2", NULL };
3564 gint i;
3565
3566 g_array_set_size (array_, 0);
3567 for (i = 0; values[i]; i++)
3568 {
3569 gchar *str = g_strdup (values[i]);
3570 g_array_append_val (array_, str);
3571 }
3572 }
3573
3574 /**
3575 * gi_marshalling_tests_garray_utf8_none_inout:
3576 * @array_: (inout) (element-type utf8) (transfer none):
3577 */
3578 void
3579 gi_marshalling_tests_garray_utf8_none_inout (GArray **array_)
3580 {
3581 static GArray *internal = NULL;
3582 static const gchar *values[] = { "-2", "-1", "0", "1", NULL };
3583 gint i;
3584
3585 g_assert_cmpint ((*array_)->len, ==, 3);
3586 g_assert_cmpstr (g_array_index (*array_, gchar *, 0), ==, "0");
3587 g_assert_cmpstr (g_array_index (*array_, gchar *, 1), ==, "1");
3588 g_assert_cmpstr (g_array_index (*array_, gchar *, 2), ==, "2");
3589
3590 if (internal == NULL)
3591 {
3592 internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
3593 for (i = 0; values[i]; i++)
3594 g_array_append_val (internal, values[i]);
3595 }
3596
3597 *array_ = internal;
3598 }
3599
3600 /**
3601 * gi_marshalling_tests_garray_utf8_container_inout:
3602 * @array_: (inout) (element-type utf8) (transfer container):
3603 */
3604 void
3605 gi_marshalling_tests_garray_utf8_container_inout (GArray **array_)
3606 {
3607 static const gchar *val1 = "-2";
3608 static const gchar *val2 = "-1";
3609 static const gchar *val3 = "0";
3610 static const gchar *val4 = "1";
3611 GArray *result;
3612
3613 g_assert_cmpint ((*array_)->len, ==, 3);
3614 g_assert_cmpstr (g_array_index (*array_, gchar *, 0), ==, "0");
3615 g_assert_cmpstr (g_array_index (*array_, gchar *, 1), ==, "1");
3616 g_assert_cmpstr (g_array_index (*array_, gchar *, 2), ==, "2");
3617
3618 result = g_array_new (TRUE, TRUE, sizeof (gchar *));
3619 g_array_append_val (result, val1);
3620 g_array_append_val (result, val2);
3621 g_array_append_val (result, val3);
3622 g_array_append_val (result, val4);
3623
3624 g_array_unref (*array_);
3625 *array_ = result;
3626 }
3627
3628 /**
3629 * gi_marshalling_tests_garray_utf8_full_inout:
3630 * @array_: (inout) (element-type utf8) (transfer full):
3631 */
3632 void
3633 gi_marshalling_tests_garray_utf8_full_inout (GArray **array_)
3634 {
3635 static const gchar *val1 = "-1";
3636 static const gchar *val2 = "-2";
3637 gchar *val;
3638 GArray *result;
3639
3640 g_assert_cmpint ((*array_)->len, ==, 3);
3641 g_assert_cmpstr (g_array_index (*array_, gchar *, 0), ==, "0");
3642 g_assert_cmpstr (g_array_index (*array_, gchar *, 1), ==, "1");
3643 g_assert_cmpstr (g_array_index (*array_, gchar *, 2), ==, "2");
3644
3645 result = g_array_new (TRUE, TRUE, sizeof (gchar *));
3646 val = g_strdup (val2);
3647 g_array_append_val (result, val);
3648 val = g_strdup (val1);
3649 g_array_append_val (result, val);
3650 val = g_strdup ("0");
3651 g_array_append_val (result, val);
3652 val = g_strdup ("1");
3653 g_array_append_val (result, val);
3654
3655 g_array_unref (*array_);
3656 *array_ = result;
3657 }
3658
3659 /**
3660 * gi_marshalling_tests_garray_bool_none_in:
3661 * @array_: (element-type gboolean) (transfer none):
3662 */
3663 void
3664 gi_marshalling_tests_garray_bool_none_in (GArray *array_)
3665 {
3666 g_assert_cmpint (array_->len, ==, 4);
3667 g_assert_cmpint (g_array_index (array_, gboolean, 0), ==, TRUE);
3668 g_assert_cmpint (g_array_index (array_, gboolean, 1), ==, FALSE);
3669 g_assert_cmpint (g_array_index (array_, gboolean, 2), ==, TRUE);
3670 g_assert_cmpint (g_array_index (array_, gboolean, 3), ==, TRUE);
3671 }
3672
3673 /**
3674 * gi_marshalling_tests_garray_unichar_none_in:
3675 * @array_: (element-type gunichar) (transfer none):
3676 */
3677 void
3678 gi_marshalling_tests_garray_unichar_none_in (GArray *array_)
3679 {
3680 unsigned ix;
3681 static const gunichar expected[] = GI_MARSHALLING_TESTS_CONSTANT_UCS4;
3682 g_assert_cmpint (array_->len, ==, 12);
3683 for (ix = 0; ix < array_->len; ix++)
3684 g_assert_cmpuint (g_array_index (array_, gunichar, ix), ==, expected[ix]);
3685 }
3686
3687 /**
3688 * gi_marshalling_tests_gptrarray_utf8_none_return:
3689 *
3690 * Returns: (element-type utf8) (transfer none):
3691 */
3692 GPtrArray *
3693 gi_marshalling_tests_gptrarray_utf8_none_return (void)
3694 {
3695 static GPtrArray *parray = NULL;
3696 static const gchar *values[] = { "0", "1", "2" };
3697 gint i;
3698
3699 if (parray == NULL)
3700 {
3701 parray = g_ptr_array_new ();
3702 for (i = 0; i < 3; i++)
3703 g_ptr_array_add (parray, (gpointer) values[i]);
3704 }
3705
3706 return parray;
3707 }
3708
3709 /**
3710 * gi_marshalling_tests_gptrarray_utf8_container_return:
3711 *
3712 * Returns: (element-type utf8) (transfer container):
3713 */
3714 GPtrArray *
3715 gi_marshalling_tests_gptrarray_utf8_container_return (void)
3716 {
3717 GPtrArray *parray = NULL;
3718 static const gchar *values[] = { "0", "1", "2", NULL };
3719 gint i;
3720
3721 parray = g_ptr_array_new ();
3722 for (i = 0; values[i]; i++)
3723 g_ptr_array_add (parray, (gpointer) values[i]);
3724
3725 return parray;
3726 }
3727
3728 /**
3729 * gi_marshalling_tests_gptrarray_utf8_full_return:
3730 *
3731 * Returns: (element-type utf8) (transfer full):
3732 */
3733 GPtrArray *
3734 gi_marshalling_tests_gptrarray_utf8_full_return (void)
3735 {
3736 GPtrArray *parray = NULL;
3737 static const gchar *values[] = { "0", "1", "2", NULL };
3738 gint i;
3739
3740 parray = g_ptr_array_new ();
3741 for (i = 0; values[i]; i++)
3742 {
3743 gchar *str = g_strdup (values[i]);
3744 g_ptr_array_add (parray, (gpointer) str);
3745 }
3746
3747 return parray;
3748 }
3749
3750 /**
3751 * gi_marshalling_tests_gptrarray_boxed_struct_full_return:
3752 *
3753 * Returns: (element-type GIMarshallingTestsBoxedStruct) (transfer full):
3754 */
3755 GPtrArray *
3756 gi_marshalling_tests_gptrarray_boxed_struct_full_return (void)
3757 {
3758 GPtrArray *parray = NULL;
3759 static const glong long_values[] = { 42, 43, 44 };
3760 gint i;
3761
3762 parray = g_ptr_array_new ();
3763 for (i = 0; i < 3; i++)
3764 {
3765 GIMarshallingTestsBoxedStruct *new_struct = gi_marshalling_tests_boxed_struct_new ();
3766 new_struct->long_ = long_values[i];
3767 g_ptr_array_add (parray, (gpointer) new_struct);
3768 }
3769
3770 return parray;
3771 }
3772
3773 /**
3774 * gi_marshalling_tests_gptrarray_utf8_none_in:
3775 * @parray_: (element-type utf8) (transfer none):
3776 */
3777 void
3778 gi_marshalling_tests_gptrarray_utf8_none_in (GPtrArray *parray_)
3779 {
3780 g_assert_cmpint (parray_->len, ==, 3);
3781 g_assert_cmpstr (g_ptr_array_index (parray_, 0), ==, "0");
3782 g_assert_cmpstr (g_ptr_array_index (parray_, 1), ==, "1");
3783 g_assert_cmpstr (g_ptr_array_index (parray_, 2), ==, "2");
3784 }
3785
3786 /**
3787 * gi_marshalling_tests_gptrarray_utf8_container_in:
3788 * @parray_: (element-type utf8) (transfer container):
3789 */
3790 void
3791 gi_marshalling_tests_gptrarray_utf8_container_in (GPtrArray *parray_)
3792 {
3793 gi_marshalling_tests_gptrarray_utf8_none_in (parray_);
3794 g_ptr_array_unref (parray_);
3795 }
3796
3797 /**
3798 * gi_marshalling_tests_gptrarray_utf8_full_in:
3799 * @parray_: (element-type utf8) (transfer full):
3800 */
3801 void
3802 gi_marshalling_tests_gptrarray_utf8_full_in (GPtrArray *parray_)
3803 {
3804 gi_marshalling_tests_gptrarray_utf8_none_in (parray_);
3805 for (size_t ix = 0; ix < 3; ix++)
3806 g_clear_pointer (&g_ptr_array_index (parray_, ix), g_free);
3807 g_ptr_array_unref (parray_);
3808 }
3809
3810 /**
3811 * gi_marshalling_tests_gptrarray_utf8_none_out:
3812 * @parray_: (out) (element-type utf8) (transfer none):
3813 */
3814 void
3815 gi_marshalling_tests_gptrarray_utf8_none_out (GPtrArray **parray_)
3816 {
3817 static GPtrArray *internal = NULL;
3818 static const gchar *values[] = { "0", "1", "2", NULL };
3819 gint i;
3820
3821 if (internal == NULL)
3822 {
3823 internal = g_ptr_array_new ();
3824 for (i = 0; values[i]; i++)
3825 g_ptr_array_add (internal, (gpointer) values[i]);
3826 }
3827
3828 *parray_ = internal;
3829 }
3830
3831 /**
3832 * gi_marshalling_tests_gptrarray_utf8_none_out_uninitialized:
3833 * @v: (out) (element-type utf8) (transfer none):
3834 */
3835 gboolean
3836 gi_marshalling_tests_gptrarray_utf8_none_out_uninitialized (GPtrArray **v G_GNUC_UNUSED)
3837 {
3838 return FALSE;
3839 }
3840
3841 /**
3842 * gi_marshalling_tests_gptrarray_utf8_container_out:
3843 * @parray_: (out) (element-type utf8) (transfer container):
3844 */
3845 void
3846 gi_marshalling_tests_gptrarray_utf8_container_out (GPtrArray **parray_)
3847 {
3848 static const gchar *values[] = { "0", "1", "2", NULL };
3849 gint i;
3850
3851 *parray_ = NULL;
3852
3853 *parray_ = g_ptr_array_new ();
3854 for (i = 0; values[i]; i++)
3855 g_ptr_array_add (*parray_, (gpointer) values[i]);
3856 }
3857
3858 /**
3859 * gi_marshalling_tests_gptrarray_utf8_container_out_uninitialized:
3860 * @v: (out) (element-type utf8) (transfer container):
3861 */
3862 gboolean
3863 gi_marshalling_tests_gptrarray_utf8_container_out_uninitialized (GPtrArray **v G_GNUC_UNUSED)
3864 {
3865 return FALSE;
3866 }
3867
3868 /**
3869 * gi_marshalling_tests_gptrarray_utf8_full_out:
3870 * @parray_: (out) (element-type utf8) (transfer full):
3871 */
3872 void
3873 gi_marshalling_tests_gptrarray_utf8_full_out (GPtrArray **parray_)
3874 {
3875 static const gchar *values[] = { "0", "1", "2", NULL };
3876 gint i;
3877
3878 *parray_ = NULL;
3879
3880 *parray_ = g_ptr_array_new ();
3881 for (i = 0; values[i]; i++)
3882 {
3883 gchar *str = g_strdup (values[i]);
3884 g_ptr_array_add (*parray_, (gpointer) str);
3885 }
3886 }
3887
3888 /**
3889 * gi_marshalling_tests_gptrarray_utf8_full_out_uninitialized:
3890 * @v: (out) (element-type utf8) (transfer full):
3891 */
3892 gboolean
3893 gi_marshalling_tests_gptrarray_utf8_full_out_uninitialized (GPtrArray **v G_GNUC_UNUSED)
3894 {
3895 return FALSE;
3896 }
3897
3898 /**
3899 * gi_marshalling_tests_gptrarray_utf8_none_inout:
3900 * @parray_: (inout) (element-type utf8) (transfer none):
3901 */
3902 void
3903 gi_marshalling_tests_gptrarray_utf8_none_inout (GPtrArray **parray_)
3904 {
3905 static GPtrArray *internal = NULL;
3906 static const gchar *values[] = { "-2", "-1", "0", "1", NULL };
3907 gint i;
3908
3909 g_assert_cmpint ((*parray_)->len, ==, 3);
3910 g_assert_cmpstr (g_ptr_array_index (*parray_, 0), ==, "0");
3911 g_assert_cmpstr (g_ptr_array_index (*parray_, 1), ==, "1");
3912 g_assert_cmpstr (g_ptr_array_index (*parray_, 2), ==, "2");
3913
3914 if (internal == NULL)
3915 {
3916 internal = g_ptr_array_new ();
3917 for (i = 0; values[i]; i++)
3918 g_ptr_array_add (internal, (gpointer) values[i]);
3919 }
3920
3921 *parray_ = internal;
3922 }
3923
3924 /**
3925 * gi_marshalling_tests_gptrarray_utf8_container_inout:
3926 * @parray_: (inout) (element-type utf8) (transfer container):
3927 */
3928 void
3929 gi_marshalling_tests_gptrarray_utf8_container_inout (GPtrArray **parray_)
3930 {
3931 static const gchar *val1 = "-2";
3932 static const gchar *val2 = "-1";
3933 static const gchar *val3 = "0";
3934 static const gchar *val4 = "1";
3935 GPtrArray *result;
3936
3937 g_assert_cmpint ((*parray_)->len, ==, 3);
3938 g_assert_cmpstr (g_ptr_array_index (*parray_, 0), ==, "0");
3939 g_assert_cmpstr (g_ptr_array_index (*parray_, 1), ==, "1");
3940 g_assert_cmpstr (g_ptr_array_index (*parray_, 2), ==, "2");
3941
3942 result = g_ptr_array_new ();
3943 g_ptr_array_add (result, (gpointer) val1);
3944 g_ptr_array_add (result, (gpointer) val2);
3945 g_ptr_array_add (result, (gpointer) val3);
3946 g_ptr_array_add (result, (gpointer) val4);
3947
3948 g_ptr_array_unref (*parray_);
3949 *parray_ = result;
3950 }
3951
3952 /**
3953 * gi_marshalling_tests_gptrarray_utf8_full_inout:
3954 * @parray_: (inout) (element-type utf8) (transfer full):
3955 */
3956 void
3957 gi_marshalling_tests_gptrarray_utf8_full_inout (GPtrArray **parray_)
3958 {
3959 static const gchar *val1 = "-1";
3960 static const gchar *val2 = "-2";
3961 gchar *val;
3962 GPtrArray *result;
3963
3964 g_assert_cmpint ((*parray_)->len, ==, 3);
3965 g_assert_cmpstr (g_ptr_array_index (*parray_, 0), ==, "0");
3966 g_assert_cmpstr (g_ptr_array_index (*parray_, 1), ==, "1");
3967 g_assert_cmpstr (g_ptr_array_index (*parray_, 2), ==, "2");
3968
3969 result = g_ptr_array_new ();
3970 val = g_strdup (val2);
3971 g_ptr_array_add (result, (gpointer) val);
3972 val = g_strdup (val1);
3973 g_ptr_array_add (result, (gpointer) val);
3974 val = g_strdup ("0");
3975 g_ptr_array_add (result, (gpointer) val);
3976 val = g_strdup ("1");
3977 g_ptr_array_add (result, (gpointer) val);
3978
3979 g_ptr_array_unref (*parray_);
3980 *parray_ = result;
3981 }
3982
3983 /**
3984 * gi_marshalling_tests_bytearray_full_return:
3985 *
3986 * Returns: (transfer full):
3987 */
3988 GByteArray *
3989 gi_marshalling_tests_bytearray_full_return (void)
3990 {
3991 GByteArray *array = NULL;
3992 guint8 data[] = { '\0', '1', '\xFF', '3' };
3993
3994 array = g_byte_array_new ();
3995 g_byte_array_append (array, (const guint8 *) data, G_N_ELEMENTS (data));
3996
3997 return array;
3998 }
3999
4000 /**
4001 * gi_marshalling_tests_bytearray_none_in:
4002 * @v: (element-type gint8) (transfer none):
4003 */
4004 void
4005 gi_marshalling_tests_bytearray_none_in (GByteArray *v)
4006 {
4007 g_assert_cmpuint (v->len, ==, 4);
4008 g_assert_cmpuint (g_array_index (v, unsigned char, 0), ==, 0);
4009 g_assert_cmpuint (g_array_index (v, unsigned char, 1), ==, 49);
4010 g_assert_cmpuint (g_array_index (v, unsigned char, 2), ==, 0xFF);
4011 g_assert_cmpuint (g_array_index (v, unsigned char, 3), ==, 51);
4012 }
4013
4014 /**
4015 * gi_marshalling_tests_bytearray_full_out:
4016 * @v: (out) (transfer full):
4017 */
4018 void
4019 gi_marshalling_tests_bytearray_full_out (GByteArray **v)
4020 {
4021 *v = gi_marshalling_tests_bytearray_full_return ();
4022 }
4023
4024 /**
4025 * gi_marshalling_tests_bytearray_full_inout:
4026 * @v: (inout) (transfer full):
4027 */
4028 void
4029 gi_marshalling_tests_bytearray_full_inout (GByteArray **v)
4030 {
4031 gi_marshalling_tests_bytearray_none_in (*v);
4032 g_byte_array_unref (*v);
4033
4034 guint8 data[] = { 'h', 'e', 'l', '\0', '\xFF' };
4035
4036 GByteArray *array = g_byte_array_new ();
4037 g_byte_array_append (array, (const guint8 *) data, G_N_ELEMENTS (data));
4038
4039 *v = array;
4040 }
4041
4042 /**
4043 * gi_marshalling_tests_gbytes_full_return:
4044 *
4045 * Returns: (transfer full):
4046 */
4047 GBytes *
4048 gi_marshalling_tests_gbytes_full_return (void)
4049 {
4050 static guint8 data[] = { 0, 49, 0xFF, 51 };
4051
4052 return g_bytes_new_static (data, G_N_ELEMENTS (data));
4053 }
4054
4055 /**
4056 * gi_marshalling_tests_gbytes_none_in:
4057 */
4058 void
4059 gi_marshalling_tests_gbytes_none_in (GBytes *v)
4060 {
4061 const guint8 *data;
4062 gsize len;
4063 data = g_bytes_get_data (v, &len);
4064
4065 g_assert_cmpuint (len, ==, 4);
4066 g_assert_cmpuint (data[0], ==, 0);
4067 g_assert_cmpuint (data[1], ==, 49);
4068 g_assert_cmpuint (data[2], ==, 0xFF);
4069 g_assert_cmpuint (data[3], ==, 51);
4070 }
4071
4072 /**
4073 * gi_marshalling_tests_gstrv_return:
4074 *
4075 * Returns: (transfer full): an array of strings
4076 */
4077 GStrv
4078 gi_marshalling_tests_gstrv_return (void)
4079 {
4080 GStrv values = g_new0 (gchar *, 4);
4081 values[0] = g_strdup ("0");
4082 values[1] = g_strdup ("1");
4083 values[2] = g_strdup ("2");
4084 values[3] = NULL;
4085 return values;
4086 }
4087
4088 /**
4089 * gi_marshalling_tests_gstrv_in:
4090 * @g_strv:
4091 */
4092 void
4093 gi_marshalling_tests_gstrv_in (GStrv g_strv)
4094 {
4095 g_assert_cmpint (g_strv_length (g_strv), ==, 3);
4096 g_assert_cmpstr (g_strv[0], ==, "0");
4097 g_assert_cmpstr (g_strv[1], ==, "1");
4098 g_assert_cmpstr (g_strv[2], ==, "2");
4099 }
4100
4101 /**
4102 * gi_marshalling_tests_gstrv_out:
4103 * @g_strv: (out) (transfer none):
4104 */
4105 void
4106 gi_marshalling_tests_gstrv_out (GStrv *g_strv)
4107 {
4108 static const gchar *values[] = { "0", "1", "2", NULL };
4109 *g_strv = (gchar **) values;
4110 }
4111
4112 /**
4113 * gi_marshalling_tests_gstrv_out_uninitialized:
4114 * @v: (out) (transfer none):
4115 */
4116 gboolean
4117 gi_marshalling_tests_gstrv_out_uninitialized (GStrv *v G_GNUC_UNUSED)
4118 {
4119 return FALSE;
4120 }
4121
4122 /**
4123 * gi_marshalling_tests_gstrv_inout:
4124 * @g_strv: (inout) (transfer none):
4125 */
4126 void
4127 gi_marshalling_tests_gstrv_inout (GStrv *g_strv)
4128 {
4129 static const gchar *values[] = { "-1", "0", "1", "2", NULL };
4130
4131 g_assert (g_strv_length (*g_strv) == 3);
4132 g_assert (strcmp ((*g_strv)[0], "0") == 0);
4133 g_assert (strcmp ((*g_strv)[1], "1") == 0);
4134 g_assert (strcmp ((*g_strv)[2], "2") == 0);
4135
4136 *g_strv = (gchar **) values;
4137 }
4138
4139 /**
4140 * gi_marshalling_tests_length_array_of_gstrv_transfer_full_return:
4141 *
4142 * Returns: (array length=out_length) (element-type GStrv) (transfer full):
4143 */
4144 GStrv *
4145 gi_marshalling_tests_length_array_of_gstrv_transfer_full_return (size_t *out_length)
4146 {
4147 GStrv *array = g_new0 (GStrv, 3);
4148 GStrv values;
4149
4150 values = g_new0 (gchar *, 4);
4151 values[0] = g_strdup ("0");
4152 values[1] = g_strdup ("1");
4153 values[2] = g_strdup ("2");
4154 values[3] = NULL;
4155 array[0] = g_steal_pointer (&values);
4156
4157 values = g_new0 (gchar *, 4);
4158 values[0] = g_strdup ("3");
4159 values[1] = g_strdup ("4");
4160 values[2] = g_strdup ("5");
4161 values[3] = NULL;
4162 array[1] = g_steal_pointer (&values);
4163
4164 values = g_new0 (gchar *, 4);
4165 values[0] = g_strdup ("6");
4166 values[1] = g_strdup ("7");
4167 values[2] = g_strdup ("8");
4168 values[3] = NULL;
4169 array[2] = g_steal_pointer (&values);
4170
4171 *out_length = 3;
4172
4173 return array;
4174 }
4175
4176 /**
4177 * gi_marshalling_tests_length_array_of_gstrv_transfer_container_return:
4178 *
4179 * Returns: (array length=out_length) (element-type GStrv) (transfer container):
4180 */
4181 GStrv *
4182 gi_marshalling_tests_length_array_of_gstrv_transfer_container_return (size_t *out_length)
4183 {
4184 GStrv *array = g_new0 (GStrv, 3);
4185 static const gchar *values0[] = { "0", "1", "2", NULL };
4186 static const gchar *values1[] = { "3", "4", "5", NULL };
4187 static const gchar *values2[] = { "6", "7", "8", NULL };
4188
4189 array[0] = (GStrv) values0;
4190 array[1] = (GStrv) values1;
4191 array[2] = (GStrv) values2;
4192
4193 *out_length = 3;
4194
4195 return array;
4196 }
4197
4198 /**
4199 * gi_marshalling_tests_length_array_of_gstrv_transfer_none_return:
4200 *
4201 * Returns: (array length=out_length) (element-type GStrv) (transfer none):
4202 */
4203 GStrv *
4204 gi_marshalling_tests_length_array_of_gstrv_transfer_none_return (size_t *out_length)
4205 {
4206 static const gchar *values0[] = { "0", "1", "2", NULL };
4207 static const gchar *values1[] = { "3", "4", "5", NULL };
4208 static const gchar *values2[] = { "6", "7", "8", NULL };
4209 static const gchar **array[] = { values0, values1, values2 };
4210
4211 *out_length = 3;
4212
4213 return (GStrv *) array;
4214 }
4215
4216 /**
4217 * gi_marshalling_tests_length_array_of_gstrv_transfer_none_in:
4218 * @array: (array length=length) (element-type GStrv) (transfer none):
4219 */
4220 void
4221 gi_marshalling_tests_length_array_of_gstrv_transfer_none_in (GStrv *array, size_t length)
4222 {
4223 GStrv g_strv;
4224
4225 g_assert_cmpint (length, ==, 3);
4226
4227 g_strv = array[0];
4228 g_assert_cmpint (g_strv_length (g_strv), ==, 3);
4229 g_assert_cmpstr (g_strv[0], ==, "0");
4230 g_assert_cmpstr (g_strv[1], ==, "1");
4231 g_assert_cmpstr (g_strv[2], ==, "2");
4232
4233 g_strv = array[1];
4234 g_assert_cmpint (g_strv_length (g_strv), ==, 3);
4235 g_assert_cmpstr (g_strv[0], ==, "3");
4236 g_assert_cmpstr (g_strv[1], ==, "4");
4237 g_assert_cmpstr (g_strv[2], ==, "5");
4238
4239 g_strv = array[2];
4240 g_assert_cmpint (g_strv_length (g_strv), ==, 3);
4241 g_assert_cmpstr (g_strv[0], ==, "6");
4242 g_assert_cmpstr (g_strv[1], ==, "7");
4243 g_assert_cmpstr (g_strv[2], ==, "8");
4244 }
4245
4246 /**
4247 * gi_marshalling_tests_length_array_of_gstrv_transfer_container_in:
4248 * @array: (array length=length) (element-type GStrv) (transfer container):
4249 */
4250 void
4251 gi_marshalling_tests_length_array_of_gstrv_transfer_container_in (GStrv *array, size_t length)
4252 {
4253 gi_marshalling_tests_length_array_of_gstrv_transfer_none_in (array, length);
4254
4255 g_clear_pointer (&array, g_free);
4256 }
4257
4258 /**
4259 * gi_marshalling_tests_length_array_of_gstrv_transfer_full_in:
4260 * @array: (array length=length) (element-type GStrv) (transfer full):
4261 */
4262 void
4263 gi_marshalling_tests_length_array_of_gstrv_transfer_full_in (GStrv *array, size_t length)
4264 {
4265 gi_marshalling_tests_length_array_of_gstrv_transfer_none_in (array, length);
4266
4267 g_clear_pointer (&array[0], g_strfreev);
4268 g_clear_pointer (&array[1], g_strfreev);
4269 g_clear_pointer (&array[2], g_strfreev);
4270
4271 g_clear_pointer (&array, g_free);
4272 }
4273
4274 /**
4275 * gi_marshalling_tests_length_array_of_gstrv_transfer_none_out:
4276 * @array_out: (array length=out_length) (out) (element-type GStrv) (transfer none):
4277 * @out_length: (out):
4278 */
4279 void
4280 gi_marshalling_tests_length_array_of_gstrv_transfer_none_out (GStrv **array_out, size_t *out_length)
4281 {
4282 *array_out = gi_marshalling_tests_length_array_of_gstrv_transfer_none_return (out_length);
4283 }
4284
4285 /**
4286 * gi_marshalling_tests_length_array_of_gstrv_transfer_container_out:
4287 * @array_out: (array length=out_length) (out) (element-type GStrv) (transfer container):
4288 */
4289 void
4290 gi_marshalling_tests_length_array_of_gstrv_transfer_container_out (GStrv **array_out, size_t *out_length)
4291 {
4292 *array_out = gi_marshalling_tests_length_array_of_gstrv_transfer_container_return (out_length);
4293 }
4294
4295 /**
4296 * gi_marshalling_tests_length_array_of_gstrv_transfer_full_out:
4297 * @array_out: (array length=out_length) (out) (element-type GStrv) (transfer full):
4298 */
4299 void
4300 gi_marshalling_tests_length_array_of_gstrv_transfer_full_out (GStrv **array_out, size_t *out_length)
4301 {
4302 *array_out = gi_marshalling_tests_length_array_of_gstrv_transfer_full_return (out_length);
4303 }
4304
4305 /**
4306 * gi_marshalling_tests_length_array_of_gstrv_transfer_full_inout:
4307 * @array_inout: (array length=inout_length) (inout) (element-type GStrv) (transfer full):
4308 * @inout_length: (inout):
4309 */
4310 void
4311 gi_marshalling_tests_length_array_of_gstrv_transfer_full_inout (GStrv **array_inout, size_t *inout_length)
4312 {
4313 GStrv *array = g_new0 (GStrv, 4);
4314 GStrv values;
4315
4316 g_assert_nonnull (inout_length);
4317 g_assert_nonnull (array_inout);
4318 gi_marshalling_tests_length_array_of_gstrv_transfer_full_in (
4319 g_steal_pointer (array_inout), *inout_length);
4320
4321 values = g_new0 (gchar *, 5);
4322 values[0] = g_strdup ("-1");
4323 values[1] = g_strdup ("0");
4324 values[2] = g_strdup ("1");
4325 values[3] = g_strdup ("2");
4326 values[4] = NULL;
4327 array[0] = g_steal_pointer (&values);
4328
4329 values = g_new0 (gchar *, 5);
4330 values[0] = g_strdup ("-1");
4331 values[1] = g_strdup ("3");
4332 values[2] = g_strdup ("4");
4333 values[3] = g_strdup ("5");
4334 values[4] = NULL;
4335 array[1] = g_steal_pointer (&values);
4336
4337 values = g_new0 (gchar *, 5);
4338 values[0] = g_strdup ("-1");
4339 values[1] = g_strdup ("6");
4340 values[2] = g_strdup ("7");
4341 values[3] = g_strdup ("8");
4342 values[4] = NULL;
4343 array[2] = g_steal_pointer (&values);
4344
4345 values = g_new0 (gchar *, 5);
4346 values[0] = g_strdup ("-1");
4347 values[1] = g_strdup ("9");
4348 values[2] = g_strdup ("10");
4349 values[3] = g_strdup ("11");
4350 values[4] = NULL;
4351 array[3] = g_steal_pointer (&values);
4352
4353 *array_inout = (GStrv *) array;
4354 *inout_length = 4;
4355 }
4356
4357 /**
4358 * gi_marshalling_tests_length_array_of_gstrv_transfer_none_inout:
4359 * @array_inout: (array length=inout_length) (inout) (element-type GStrv) (transfer none):
4360 * @inout_length: (inout):
4361 */
4362 void
4363 gi_marshalling_tests_length_array_of_gstrv_transfer_none_inout (GStrv **array_inout, size_t *inout_length)
4364 {
4365 static const gchar *values0[] = { "-1", "0", "1", "2", NULL };
4366 static const gchar *values1[] = { "-1", "3", "4", "5", NULL };
4367 static const gchar *values2[] = { "-1", "6", "7", "8", NULL };
4368 static const gchar *values3[] = { "-1", "9", "10", "11", NULL };
4369 static const gchar **array[] = { values0, values1, values2, values3 };
4370
4371 g_assert_nonnull (inout_length);
4372 gi_marshalling_tests_length_array_of_gstrv_transfer_none_in (*array_inout, *inout_length);
4373
4374 *array_inout = (GStrv *) array;
4375 *inout_length = 4;
4376 }
4377
4378 /**
4379 * gi_marshalling_tests_length_array_of_gstrv_transfer_container_inout:
4380 * @array_inout: (array length=inout_length) (inout) (element-type GStrv) (transfer container):
4381 * @inout_length: (inout):
4382 */
4383 void
4384 gi_marshalling_tests_length_array_of_gstrv_transfer_container_inout (GStrv **array_inout, size_t *inout_length)
4385 {
4386 GStrv *array = g_new0 (GStrv, 4);
4387 static const gchar *values0[] = { "-1", "0", "1", "2", NULL };
4388 static const gchar *values1[] = { "-1", "3", "4", "5", NULL };
4389 static const gchar *values2[] = { "-1", "6", "7", "8", NULL };
4390 static const gchar *values3[] = { "-1", "9", "10", "11", NULL };
4391
4392 g_assert_nonnull (inout_length);
4393 g_assert_nonnull (array_inout);
4394 gi_marshalling_tests_length_array_of_gstrv_transfer_container_in (*array_inout, *inout_length);
4395
4396 array[0] = (GStrv) values0;
4397 array[1] = (GStrv) values1;
4398 array[2] = (GStrv) values2;
4399 array[3] = (GStrv) values3;
4400
4401 *array_inout = (GStrv *) array;
4402 *inout_length = 4;
4403 }
4404
4405 /**
4406 * gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_full_return:
4407 *
4408 * Returns: (array zero-terminated) (element-type GStrv) (transfer full):
4409 */
4410 GStrv *
4411 gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_full_return (void)
4412 {
4413 GStrv *array = g_new0 (GStrv, 4);
4414 GStrv values;
4415
4416 values = g_new0 (gchar *, 4);
4417 values[0] = g_strdup ("0");
4418 values[1] = g_strdup ("1");
4419 values[2] = g_strdup ("2");
4420 values[3] = NULL;
4421 array[0] = g_steal_pointer (&values);
4422
4423 values = g_new0 (gchar *, 4);
4424 values[0] = g_strdup ("3");
4425 values[1] = g_strdup ("4");
4426 values[2] = g_strdup ("5");
4427 values[3] = NULL;
4428 array[1] = g_steal_pointer (&values);
4429
4430 values = g_new0 (gchar *, 4);
4431 values[0] = g_strdup ("6");
4432 values[1] = g_strdup ("7");
4433 values[2] = g_strdup ("8");
4434 values[3] = NULL;
4435 array[2] = g_steal_pointer (&values);
4436
4437 return array;
4438 }
4439
4440 /**
4441 * gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_container_return:
4442 *
4443 * Returns: (array zero-terminated) (element-type GStrv) (transfer container):
4444 */
4445 GStrv *
4446 gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_container_return (void)
4447 {
4448 GStrv *array = g_new0 (GStrv, 4);
4449 static const gchar *values0[] = { "0", "1", "2", NULL };
4450 static const gchar *values1[] = { "3", "4", "5", NULL };
4451 static const gchar *values2[] = { "6", "7", "8", NULL };
4452
4453 array[0] = (GStrv) values0;
4454 array[1] = (GStrv) values1;
4455 array[2] = (GStrv) values2;
4456 array[3] = NULL;
4457
4458 return array;
4459 }
4460
4461 /**
4462 * gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_none_return:
4463 *
4464 * Returns: (array zero-terminated) (element-type GStrv) (transfer none):
4465 */
4466 GStrv *
4467 gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_none_return (void)
4468 {
4469 static const gchar *values0[] = { "0", "1", "2", NULL };
4470 static const gchar *values1[] = { "3", "4", "5", NULL };
4471 static const gchar *values2[] = { "6", "7", "8", NULL };
4472 static const gchar **array[] = { values0, values1, values2, NULL };
4473
4474 return (GStrv *) array;
4475 }
4476
4477 /**
4478 * gi_marshalling_tests_fixed_array_of_gstrv_transfer_full_return:
4479 *
4480 * Returns: (array fixed-size=3) (element-type GStrv) (transfer full):
4481 */
4482 GStrv *
4483 gi_marshalling_tests_fixed_array_of_gstrv_transfer_full_return (void)
4484 {
4485 GStrv *array = g_new0 (GStrv, 3);
4486 GStrv values;
4487
4488 values = g_new0 (gchar *, 4);
4489 values[0] = g_strdup ("0");
4490 values[1] = g_strdup ("1");
4491 values[2] = g_strdup ("2");
4492 values[3] = NULL;
4493 array[0] = g_steal_pointer (&values);
4494
4495 values = g_new0 (gchar *, 4);
4496 values[0] = g_strdup ("3");
4497 values[1] = g_strdup ("4");
4498 values[2] = g_strdup ("5");
4499 values[3] = NULL;
4500 array[1] = g_steal_pointer (&values);
4501
4502 values = g_new0 (gchar *, 4);
4503 values[0] = g_strdup ("6");
4504 values[1] = g_strdup ("7");
4505 values[2] = g_strdup ("8");
4506 values[3] = NULL;
4507 array[2] = g_steal_pointer (&values);
4508
4509 return array;
4510 }
4511
4512 /**
4513 * gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_none_in:
4514 * @array: (array zero-terminated) (element-type GStrv) (transfer none):
4515 */
4516 void
4517 gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_none_in (GStrv *array)
4518 {
4519 GStrv g_strv;
4520
4521 g_strv = array[0];
4522 g_assert_cmpint (g_strv_length (g_strv), ==, 3);
4523 g_assert_cmpstr (g_strv[0], ==, "0");
4524 g_assert_cmpstr (g_strv[1], ==, "1");
4525 g_assert_cmpstr (g_strv[2], ==, "2");
4526
4527 g_strv = array[1];
4528 g_assert_cmpint (g_strv_length (g_strv), ==, 3);
4529 g_assert_cmpstr (g_strv[0], ==, "3");
4530 g_assert_cmpstr (g_strv[1], ==, "4");
4531 g_assert_cmpstr (g_strv[2], ==, "5");
4532
4533 g_strv = array[2];
4534 g_assert_cmpint (g_strv_length (g_strv), ==, 3);
4535 g_assert_cmpstr (g_strv[0], ==, "6");
4536 g_assert_cmpstr (g_strv[1], ==, "7");
4537 g_assert_cmpstr (g_strv[2], ==, "8");
4538
4539 g_assert_null (array[3]);
4540 }
4541
4542 /**
4543 * gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_container_in:
4544 * @array: (array zero-terminated) (element-type GStrv) (transfer container):
4545 */
4546 void
4547 gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_container_in (GStrv *array)
4548 {
4549 gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_none_in (array);
4550
4551 g_clear_pointer (&array, g_free);
4552 }
4553
4554 /**
4555 * gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_full_in:
4556 * @array: (array zero-terminated) (element-type GStrv) (transfer full):
4557 */
4558 void
4559 gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_full_in (GStrv *array)
4560 {
4561 gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_none_in (array);
4562
4563 for (int i = 0; array && array[i] != NULL; i++)
4564 g_clear_pointer (&array[i], g_strfreev);
4565
4566 g_clear_pointer (&array, g_free);
4567 }
4568
4569 /**
4570 * gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_none_out:
4571 * @array_out: (array zero-terminated) (out) (element-type GStrv) (transfer none):
4572 */
4573 void
4574 gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_none_out (GStrv **array_out)
4575 {
4576 *array_out = gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_none_return ();
4577 }
4578
4579 /**
4580 * gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_container_out:
4581 * @array_out: (array zero-terminated) (out) (element-type GStrv) (transfer container):
4582 */
4583 void
4584 gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_container_out (GStrv **array_out)
4585 {
4586 *array_out = gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_container_return ();
4587 }
4588
4589 /**
4590 * gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_full_out:
4591 * @array_out: (array zero-terminated) (out) (element-type GStrv) (transfer full):
4592 */
4593 void
4594 gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_full_out (GStrv **array_out)
4595 {
4596 *array_out = gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_full_return ();
4597 }
4598
4599 /**
4600 * gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_full_inout:
4601 * @array_inout: (array zero-terminated) (inout) (element-type GStrv) (transfer full):
4602 */
4603 void
4604 gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_full_inout (GStrv **array_inout)
4605 {
4606 GStrv *array = g_new0 (GStrv, 5);
4607 GStrv values;
4608
4609 gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_full_in (
4610 g_steal_pointer (array_inout));
4611
4612 values = g_new0 (gchar *, 5);
4613 values[0] = g_strdup ("-1");
4614 values[1] = g_strdup ("0");
4615 values[2] = g_strdup ("1");
4616 values[3] = g_strdup ("2");
4617 values[4] = NULL;
4618 array[0] = g_steal_pointer (&values);
4619
4620 values = g_new0 (gchar *, 5);
4621 values[0] = g_strdup ("-1");
4622 values[1] = g_strdup ("3");
4623 values[2] = g_strdup ("4");
4624 values[3] = g_strdup ("5");
4625 values[4] = NULL;
4626 array[1] = g_steal_pointer (&values);
4627
4628 values = g_new0 (gchar *, 5);
4629 values[0] = g_strdup ("-1");
4630 values[1] = g_strdup ("6");
4631 values[2] = g_strdup ("7");
4632 values[3] = g_strdup ("8");
4633 values[4] = NULL;
4634 array[2] = g_steal_pointer (&values);
4635
4636 values = g_new0 (gchar *, 5);
4637 values[0] = g_strdup ("-1");
4638 values[1] = g_strdup ("9");
4639 values[2] = g_strdup ("10");
4640 values[3] = g_strdup ("11");
4641 values[4] = NULL;
4642 array[3] = g_steal_pointer (&values);
4643
4644 *array_inout = (GStrv *) array;
4645 }
4646
4647 /**
4648 * gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_none_inout:
4649 * @array_inout: (array zero-terminated) (inout) (element-type GStrv) (transfer none):
4650 */
4651 void
4652 gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_none_inout (GStrv **array_inout)
4653 {
4654 static const gchar *values0[] = { "-1", "0", "1", "2", NULL };
4655 static const gchar *values1[] = { "-1", "3", "4", "5", NULL };
4656 static const gchar *values2[] = { "-1", "6", "7", "8", NULL };
4657 static const gchar *values3[] = { "-1", "9", "10", "11", NULL };
4658 static const gchar **array[] = { values0, values1, values2, values3, NULL };
4659
4660 gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_none_in (*array_inout);
4661
4662 *array_inout = (GStrv *) array;
4663 }
4664
4665 /**
4666 * gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_container_inout:
4667 * @array_inout: (array zero-terminated) (inout) (element-type GStrv) (transfer container):
4668 */
4669 void
4670 gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_container_inout (GStrv **array_inout)
4671 {
4672 GStrv *array = g_new0 (GStrv, 5);
4673
4674 static const gchar *values0[] = { "-1", "0", "1", "2", NULL };
4675 static const gchar *values1[] = { "-1", "3", "4", "5", NULL };
4676 static const gchar *values2[] = { "-1", "6", "7", "8", NULL };
4677 static const gchar *values3[] = { "-1", "9", "10", "11", NULL };
4678
4679 gi_marshalling_tests_zero_terminated_array_of_gstrv_transfer_container_in (*array_inout);
4680
4681 array[0] = (GStrv) values0;
4682 array[1] = (GStrv) values1;
4683 array[2] = (GStrv) values2;
4684 array[3] = (GStrv) values3;
4685 array[4] = NULL;
4686
4687 *array_inout = (GStrv *) array;
4688 }
4689
4690 /**
4691 * gi_marshalling_tests_fixed_array_of_gstrv_transfer_container_return:
4692 *
4693 * Returns: (array fixed-size=3) (element-type GStrv) (transfer container):
4694 */
4695 GStrv *
4696 gi_marshalling_tests_fixed_array_of_gstrv_transfer_container_return (void)
4697 {
4698 GStrv *array = g_new0 (GStrv, 3);
4699 static const gchar *values0[] = { "0", "1", "2", NULL };
4700 static const gchar *values1[] = { "3", "4", "5", NULL };
4701 static const gchar *values2[] = { "6", "7", "8", NULL };
4702
4703 array[0] = (GStrv) values0;
4704 array[1] = (GStrv) values1;
4705 array[2] = (GStrv) values2;
4706
4707 return array;
4708 }
4709
4710 /**
4711 * gi_marshalling_tests_fixed_array_of_gstrv_transfer_none_return:
4712 *
4713 * Returns: (array fixed-size=3) (element-type GStrv) (transfer none):
4714 */
4715 GStrv *
4716 gi_marshalling_tests_fixed_array_of_gstrv_transfer_none_return (void)
4717 {
4718 static const gchar *values0[] = { "0", "1", "2", NULL };
4719 static const gchar *values1[] = { "3", "4", "5", NULL };
4720 static const gchar *values2[] = { "6", "7", "8", NULL };
4721 static const gchar **array[] = { values0, values1, values2 };
4722
4723 return (GStrv *) array;
4724 }
4725
4726 /**
4727 * gi_marshalling_tests_fixed_array_of_gstrv_transfer_none_in:
4728 * @array: (array fixed-size=3) (element-type GStrv) (transfer none):
4729 */
4730 void
4731 gi_marshalling_tests_fixed_array_of_gstrv_transfer_none_in (GStrv *array)
4732 {
4733 GStrv g_strv;
4734
4735 g_strv = array[0];
4736 g_assert_cmpint (g_strv_length (g_strv), ==, 3);
4737 g_assert_cmpstr (g_strv[0], ==, "0");
4738 g_assert_cmpstr (g_strv[1], ==, "1");
4739 g_assert_cmpstr (g_strv[2], ==, "2");
4740
4741 g_strv = array[1];
4742 g_assert_cmpint (g_strv_length (g_strv), ==, 3);
4743 g_assert_cmpstr (g_strv[0], ==, "3");
4744 g_assert_cmpstr (g_strv[1], ==, "4");
4745 g_assert_cmpstr (g_strv[2], ==, "5");
4746
4747 g_strv = array[2];
4748 g_assert_cmpint (g_strv_length (g_strv), ==, 3);
4749 g_assert_cmpstr (g_strv[0], ==, "6");
4750 g_assert_cmpstr (g_strv[1], ==, "7");
4751 g_assert_cmpstr (g_strv[2], ==, "8");
4752 }
4753
4754 /**
4755 * gi_marshalling_tests_fixed_array_of_gstrv_transfer_container_in:
4756 * @array: (array fixed-size=3) (element-type GStrv) (transfer container):
4757 */
4758 void
4759 gi_marshalling_tests_fixed_array_of_gstrv_transfer_container_in (GStrv *array)
4760 {
4761 gi_marshalling_tests_fixed_array_of_gstrv_transfer_none_in (array);
4762
4763 g_clear_pointer (&array, g_free);
4764 }
4765
4766 /**
4767 * gi_marshalling_tests_fixed_array_of_gstrv_transfer_full_in:
4768 * @array: (array fixed-size=3) (element-type GStrv) (transfer full):
4769 */
4770 void
4771 gi_marshalling_tests_fixed_array_of_gstrv_transfer_full_in (GStrv *array)
4772 {
4773 gi_marshalling_tests_fixed_array_of_gstrv_transfer_none_in (array);
4774
4775 g_clear_pointer (&array[0], g_strfreev);
4776 g_clear_pointer (&array[1], g_strfreev);
4777 g_clear_pointer (&array[2], g_strfreev);
4778
4779 g_clear_pointer (&array, g_free);
4780 }
4781
4782 /**
4783 * gi_marshalling_tests_fixed_array_of_gstrv_transfer_none_out:
4784 * @array_out: (array fixed-size=3) (out) (element-type GStrv) (transfer none):
4785 */
4786 void
4787 gi_marshalling_tests_fixed_array_of_gstrv_transfer_none_out (GStrv **array_out)
4788 {
4789 *array_out = gi_marshalling_tests_fixed_array_of_gstrv_transfer_none_return ();
4790 }
4791
4792 /**
4793 * gi_marshalling_tests_fixed_array_of_gstrv_transfer_container_out:
4794 * @array_out: (array fixed-size=3) (out) (element-type GStrv) (transfer container):
4795 */
4796 void
4797 gi_marshalling_tests_fixed_array_of_gstrv_transfer_container_out (GStrv **array_out)
4798 {
4799 *array_out = gi_marshalling_tests_fixed_array_of_gstrv_transfer_container_return ();
4800 }
4801
4802 /**
4803 * gi_marshalling_tests_fixed_array_of_gstrv_transfer_full_out:
4804 * @array_out: (array fixed-size=3) (out) (element-type GStrv) (transfer full):
4805 */
4806 void
4807 gi_marshalling_tests_fixed_array_of_gstrv_transfer_full_out (GStrv **array_out)
4808 {
4809 *array_out = gi_marshalling_tests_fixed_array_of_gstrv_transfer_full_return ();
4810 }
4811
4812 /**
4813 * gi_marshalling_tests_fixed_array_of_gstrv_transfer_full_inout:
4814 * @array_inout: (array fixed-size=3) (inout) (element-type GStrv) (transfer full):
4815 */
4816 void
4817 gi_marshalling_tests_fixed_array_of_gstrv_transfer_full_inout (GStrv **array_inout)
4818 {
4819 GStrv *array = g_new0 (GStrv, 3);
4820 GStrv values;
4821
4822 gi_marshalling_tests_fixed_array_of_gstrv_transfer_full_in (
4823 g_steal_pointer (array_inout));
4824
4825 values = g_new0 (gchar *, 5);
4826 values[0] = g_strdup ("-1");
4827 values[1] = g_strdup ("0");
4828 values[2] = g_strdup ("1");
4829 values[3] = g_strdup ("2");
4830 values[4] = NULL;
4831 array[0] = g_steal_pointer (&values);
4832
4833 values = g_new0 (gchar *, 5);
4834 values[0] = g_strdup ("-1");
4835 values[1] = g_strdup ("3");
4836 values[2] = g_strdup ("4");
4837 values[3] = g_strdup ("5");
4838 values[4] = NULL;
4839 array[1] = g_steal_pointer (&values);
4840
4841 values = g_new0 (gchar *, 5);
4842 values[0] = g_strdup ("-1");
4843 values[1] = g_strdup ("6");
4844 values[2] = g_strdup ("7");
4845 values[3] = g_strdup ("8");
4846 values[4] = NULL;
4847 array[2] = g_steal_pointer (&values);
4848
4849 *array_inout = (GStrv *) array;
4850 }
4851
4852 /**
4853 * gi_marshalling_tests_fixed_array_of_gstrv_transfer_none_inout:
4854 * @array_inout: (array fixed-size=3) (inout) (element-type GStrv) (transfer none):
4855 */
4856 void
4857 gi_marshalling_tests_fixed_array_of_gstrv_transfer_none_inout (GStrv **array_inout)
4858 {
4859 static const gchar *values0[] = { "-1", "0", "1", "2", NULL };
4860 static const gchar *values1[] = { "-1", "3", "4", "5", NULL };
4861 static const gchar *values2[] = { "-1", "6", "7", "8", NULL };
4862 static const gchar **array[] = { values0, values1, values2 };
4863
4864 gi_marshalling_tests_fixed_array_of_gstrv_transfer_none_in (*array_inout);
4865
4866 *array_inout = (GStrv *) array;
4867 }
4868
4869 /**
4870 * gi_marshalling_tests_fixed_array_of_gstrv_transfer_container_inout:
4871 * @array_inout: (array fixed-size=3) (inout) (element-type GStrv) (transfer container):
4872 */
4873 void
4874 gi_marshalling_tests_fixed_array_of_gstrv_transfer_container_inout (GStrv **array_inout)
4875 {
4876 GStrv *array = g_new0 (GStrv, 3);
4877 static const gchar *values0[] = { "-1", "0", "1", "2", NULL };
4878 static const gchar *values1[] = { "-1", "3", "4", "5", NULL };
4879 static const gchar *values2[] = { "-1", "6", "7", "8", NULL };
4880
4881 gi_marshalling_tests_fixed_array_of_gstrv_transfer_container_in (*array_inout);
4882
4883 array[0] = (GStrv) values0;
4884 array[1] = (GStrv) values1;
4885 array[2] = (GStrv) values2;
4886
4887 *array_inout = (GStrv *) array;
4888 }
4889
4890 /**
4891 * gi_marshalling_tests_glist_int_none_return:
4892 *
4893 * Returns: (element-type gint) (transfer none):
4894 */
4895 GList *
4896 gi_marshalling_tests_glist_int_none_return (void)
4897 {
4898 static GList *list = NULL;
4899
4900 if (list == NULL)
4901 {
4902 list = g_list_append (list, GINT_TO_POINTER (-1));
4903 list = g_list_append (list, GINT_TO_POINTER (0));
4904 list = g_list_append (list, GINT_TO_POINTER (1));
4905 list = g_list_append (list, GINT_TO_POINTER (2));
4906 }
4907
4908 return list;
4909 }
4910
4911 /**
4912 * gi_marshalling_tests_glist_uint32_none_return:
4913 *
4914 * Returns: (element-type guint32) (transfer none):
4915 */
4916 GList *
4917 gi_marshalling_tests_glist_uint32_none_return (void)
4918 {
4919 static GList *list = NULL;
4920
4921 if (list == NULL)
4922 {
4923 list = g_list_append (list, GUINT_TO_POINTER (0));
4924 list = g_list_append (list, GUINT_TO_POINTER (G_MAXUINT32));
4925 }
4926
4927 return list;
4928 }
4929
4930 /**
4931 * gi_marshalling_tests_glist_utf8_none_return:
4932 *
4933 * Returns: (element-type utf8) (transfer none):
4934 */
4935 GList *
4936 gi_marshalling_tests_glist_utf8_none_return (void)
4937 {
4938 static GList *list = NULL;
4939
4940 if (list == NULL)
4941 {
4942 list = g_list_append (list, (gpointer) "0");
4943 list = g_list_append (list, (gpointer) "1");
4944 list = g_list_append (list, (gpointer) "2");
4945 }
4946
4947 return list;
4948 }
4949
4950 /**
4951 * gi_marshalling_tests_glist_utf8_container_return:
4952 *
4953 * Returns: (element-type utf8) (transfer container):
4954 */
4955 GList *
4956 gi_marshalling_tests_glist_utf8_container_return (void)
4957 {
4958 GList *list = NULL;
4959
4960 list = g_list_append (list, (gpointer) "0");
4961 list = g_list_append (list, (gpointer) "1");
4962 list = g_list_append (list, (gpointer) "2");
4963
4964 return list;
4965 }
4966
4967 /**
4968 * gi_marshalling_tests_glist_utf8_full_return:
4969 *
4970 * Returns: (element-type utf8) (transfer full):
4971 */
4972 GList *
4973 gi_marshalling_tests_glist_utf8_full_return (void)
4974 {
4975 GList *list = NULL;
4976
4977 list = g_list_append (list, g_strdup ("0"));
4978 list = g_list_append (list, g_strdup ("1"));
4979 list = g_list_append (list, g_strdup ("2"));
4980
4981 return list;
4982 }
4983
4984 /**
4985 * gi_marshalling_tests_glist_int_none_in:
4986 * @list: (element-type gint) (transfer none):
4987 */
4988 void
4989 gi_marshalling_tests_glist_int_none_in (GList *list)
4990 {
4991 g_assert_cmpint (g_list_length (list), ==, 4);
4992 g_assert_cmpint (GPOINTER_TO_INT (g_list_nth_data (list, 0)), ==, -1);
4993 g_assert_cmpint (GPOINTER_TO_INT (g_list_nth_data (list, 1)), ==, 0);
4994 g_assert_cmpint (GPOINTER_TO_INT (g_list_nth_data (list, 2)), ==, 1);
4995 g_assert_cmpint (GPOINTER_TO_INT (g_list_nth_data (list, 3)), ==, 2);
4996 }
4997
4998 /**
4999 * gi_marshalling_tests_glist_uint32_none_in:
5000 * @list: (element-type guint32) (transfer none):
5001 */
5002 void
5003 gi_marshalling_tests_glist_uint32_none_in (GList *list)
5004 {
5005 g_assert_cmpint (g_list_length (list), ==, 2);
5006 g_assert_cmpint (GPOINTER_TO_UINT (g_list_nth_data (list, 0)), ==, 0);
5007 g_assert_cmpint (GPOINTER_TO_UINT (g_list_nth_data (list, 1)), ==, G_MAXUINT32);
5008 }
5009
5010 /**
5011 * gi_marshalling_tests_glist_utf8_none_in:
5012 * @list: (element-type utf8) (transfer none):
5013 */
5014 void
5015 gi_marshalling_tests_glist_utf8_none_in (GList *list)
5016 {
5017 g_assert_cmpint (g_list_length (list), ==, 3);
5018 g_assert_cmpint (strcmp (g_list_nth_data (list, 0), "0"), ==, 0);
5019 g_assert_cmpint (strcmp (g_list_nth_data (list, 1), "1"), ==, 0);
5020 g_assert_cmpint (strcmp (g_list_nth_data (list, 2), "2"), ==, 0);
5021 }
5022
5023 /**
5024 * gi_marshalling_tests_glist_utf8_container_in:
5025 * @list: (element-type utf8) (transfer container):
5026 */
5027 void
5028 gi_marshalling_tests_glist_utf8_container_in (GList *list)
5029 {
5030 gi_marshalling_tests_glist_utf8_none_in (list);
5031 g_list_free (list);
5032 }
5033
5034 /**
5035 * gi_marshalling_tests_glist_utf8_full_in:
5036 * @list: (element-type utf8) (transfer full):
5037 */
5038 void
5039 gi_marshalling_tests_glist_utf8_full_in (GList *list)
5040 {
5041 gi_marshalling_tests_glist_utf8_none_in (list);
5042 g_list_free_full (list, g_free);
5043 }
5044
5045 /**
5046 * gi_marshalling_tests_glist_utf8_none_out:
5047 * @list: (out) (element-type utf8) (transfer none):
5048 */
5049 void
5050 gi_marshalling_tests_glist_utf8_none_out (GList **list)
5051 {
5052 static GList *values = NULL;
5053
5054 if (values == NULL)
5055 {
5056 values = g_list_append (values, (gpointer) "0");
5057 values = g_list_append (values, (gpointer) "1");
5058 values = g_list_append (values, (gpointer) "2");
5059 }
5060
5061 *list = values;
5062 }
5063
5064 /**
5065 * gi_marshalling_tests_glist_utf8_none_out_uninitialized:
5066 * @v: (out) (element-type utf8) (transfer none):
5067 */
5068 gboolean
5069 gi_marshalling_tests_glist_utf8_none_out_uninitialized (GList **v G_GNUC_UNUSED)
5070 {
5071 return FALSE;
5072 }
5073
5074 /**
5075 * gi_marshalling_tests_glist_utf8_container_out:
5076 * @list: (out) (element-type utf8) (transfer container):
5077 */
5078 void
5079 gi_marshalling_tests_glist_utf8_container_out (GList **list)
5080 {
5081 *list = NULL;
5082
5083 *list = g_list_append (*list, (gpointer) "0");
5084 *list = g_list_append (*list, (gpointer) "1");
5085 *list = g_list_append (*list, (gpointer) "2");
5086 }
5087
5088 /**
5089 * gi_marshalling_tests_glist_utf8_container_out_uninitialized:
5090 * @v: (out) (element-type utf8) (transfer container):
5091 */
5092 gboolean
5093 gi_marshalling_tests_glist_utf8_container_out_uninitialized (GList **v G_GNUC_UNUSED)
5094 {
5095 return FALSE;
5096 }
5097
5098 /**
5099 * gi_marshalling_tests_glist_utf8_full_out:
5100 * @list: (out) (element-type utf8) (transfer full):
5101 */
5102 void
5103 gi_marshalling_tests_glist_utf8_full_out (GList **list)
5104 {
5105 *list = NULL;
5106
5107 *list = g_list_append (*list, g_strdup ("0"));
5108 *list = g_list_append (*list, g_strdup ("1"));
5109 *list = g_list_append (*list, g_strdup ("2"));
5110 }
5111
5112 /**
5113 * gi_marshalling_tests_glist_utf8_full_out_uninitialized:
5114 * @v: (out) (element-type utf8) (transfer full):
5115 */
5116 gboolean
5117 gi_marshalling_tests_glist_utf8_full_out_uninitialized (GList **v G_GNUC_UNUSED)
5118 {
5119 return FALSE;
5120 }
5121
5122 /**
5123 * gi_marshalling_tests_glist_utf8_none_inout:
5124 * @list: (inout) (element-type utf8) (transfer none):
5125 */
5126 void
5127 gi_marshalling_tests_glist_utf8_none_inout (GList **list)
5128 {
5129 static GList *values = NULL;
5130
5131 g_assert_cmpint (g_list_length (*list), ==, 3);
5132 g_assert_cmpstr (g_list_nth_data (*list, 0), ==, "0");
5133 g_assert_cmpstr (g_list_nth_data (*list, 1), ==, "1");
5134 g_assert_cmpstr (g_list_nth_data (*list, 2), ==, "2");
5135
5136 if (values == NULL)
5137 {
5138 values = g_list_append (values, (gpointer) "-2");
5139 values = g_list_append (values, (gpointer) "-1");
5140 values = g_list_append (values, (gpointer) "0");
5141 values = g_list_append (values, (gpointer) "1");
5142 }
5143
5144 *list = values;
5145 }
5146
5147 /**
5148 * gi_marshalling_tests_glist_utf8_container_inout:
5149 * @list: (inout) (element-type utf8) (transfer container):
5150 */
5151 void
5152 gi_marshalling_tests_glist_utf8_container_inout (GList **list)
5153 {
5154 GList *result = NULL;
5155
5156 g_assert_cmpint (g_list_length (*list), ==, 3);
5157 g_assert_cmpstr (g_list_nth_data (*list, 0), ==, "0");
5158 g_assert_cmpstr (g_list_nth_data (*list, 1), ==, "1");
5159 g_assert_cmpstr (g_list_nth_data (*list, 2), ==, "2");
5160
5161 result = g_list_prepend (result, (gpointer) "1");
5162 result = g_list_prepend (result, (gpointer) "0");
5163 result = g_list_prepend (result, (gpointer) "-1");
5164 result = g_list_prepend (result, (gpointer) "-2");
5165
5166 g_list_free (*list);
5167 *list = result;
5168 }
5169
5170 /**
5171 * gi_marshalling_tests_glist_utf8_full_inout:
5172 * @list: (inout) (element-type utf8) (transfer full):
5173 */
5174 void
5175 gi_marshalling_tests_glist_utf8_full_inout (GList **list)
5176 {
5177 GList *result = NULL;
5178
5179 g_assert_cmpint (g_list_length (*list), ==, 3);
5180 g_assert_cmpstr (g_list_nth_data (*list, 0), ==, "0");
5181 g_assert_cmpstr (g_list_nth_data (*list, 1), ==, "1");
5182 g_assert_cmpstr (g_list_nth_data (*list, 2), ==, "2");
5183
5184 result = g_list_prepend (result, g_strdup ("1"));
5185 result = g_list_prepend (result, g_strdup ("0"));
5186 result = g_list_prepend (result, g_strdup ("-1"));
5187 result = g_list_prepend (result, g_strdup ("-2"));
5188
5189 g_list_free_full (*list, g_free);
5190 *list = result;
5191 }
5192
5193 /**
5194 * gi_marshalling_tests_gslist_int_none_return:
5195 *
5196 * Returns: (element-type gint) (transfer none):
5197 */
5198 GSList *
5199 gi_marshalling_tests_gslist_int_none_return (void)
5200 {
5201 static GSList *list = NULL;
5202
5203 if (list == NULL)
5204 {
5205 list = g_slist_prepend (list, GINT_TO_POINTER (-1));
5206 list = g_slist_prepend (list, GINT_TO_POINTER (0));
5207 list = g_slist_prepend (list, GINT_TO_POINTER (1));
5208 list = g_slist_prepend (list, GINT_TO_POINTER (2));
5209 list = g_slist_reverse (list);
5210 }
5211
5212 return list;
5213 }
5214
5215 /**
5216 * gi_marshalling_tests_gslist_utf8_none_return:
5217 *
5218 * Returns: (element-type utf8) (transfer none):
5219 */
5220 GSList *
5221 gi_marshalling_tests_gslist_utf8_none_return (void)
5222 {
5223 static GSList *list = NULL;
5224
5225 if (list == NULL)
5226 {
5227 list = g_slist_prepend (list, (gpointer) "0");
5228 list = g_slist_prepend (list, (gpointer) "1");
5229 list = g_slist_prepend (list, (gpointer) "2");
5230 list = g_slist_reverse (list);
5231 }
5232
5233 return list;
5234 }
5235
5236 /**
5237 * gi_marshalling_tests_gslist_utf8_container_return:
5238 *
5239 * Returns: (element-type utf8) (transfer container):
5240 */
5241 GSList *
5242 gi_marshalling_tests_gslist_utf8_container_return (void)
5243 {
5244 GSList *list = NULL;
5245
5246 list = g_slist_prepend (list, (gpointer) "0");
5247 list = g_slist_prepend (list, (gpointer) "1");
5248 list = g_slist_prepend (list, (gpointer) "2");
5249 list = g_slist_reverse (list);
5250
5251 return list;
5252 }
5253
5254 /**
5255 * gi_marshalling_tests_gslist_utf8_full_return:
5256 *
5257 * Returns: (element-type utf8) (transfer full):
5258 */
5259 GSList *
5260 gi_marshalling_tests_gslist_utf8_full_return (void)
5261 {
5262 GSList *list = NULL;
5263
5264 list = g_slist_prepend (list, g_strdup ("0"));
5265 list = g_slist_prepend (list, g_strdup ("1"));
5266 list = g_slist_prepend (list, g_strdup ("2"));
5267 list = g_slist_reverse (list);
5268
5269 return list;
5270 }
5271
5272 /**
5273 * gi_marshalling_tests_gslist_int_none_in:
5274 * @list: (element-type gint) (transfer none):
5275 */
5276 void
5277 gi_marshalling_tests_gslist_int_none_in (GSList *list)
5278 {
5279 g_assert_cmpint (g_slist_length (list), ==, 4);
5280 g_assert_cmpint (GPOINTER_TO_INT (g_slist_nth_data (list, 0)), ==, -1);
5281 g_assert_cmpint (GPOINTER_TO_INT (g_slist_nth_data (list, 1)), ==, 0);
5282 g_assert_cmpint (GPOINTER_TO_INT (g_slist_nth_data (list, 2)), ==, 1);
5283 g_assert_cmpint (GPOINTER_TO_INT (g_slist_nth_data (list, 3)), ==, 2);
5284 }
5285
5286 /**
5287 * gi_marshalling_tests_gslist_utf8_none_in:
5288 * @list: (element-type utf8) (transfer none):
5289 */
5290 void
5291 gi_marshalling_tests_gslist_utf8_none_in (GSList *list)
5292 {
5293 g_assert_cmpint (g_slist_length (list), ==, 3);
5294 g_assert_cmpstr (g_slist_nth_data (list, 0), ==, "0");
5295 g_assert_cmpstr (g_slist_nth_data (list, 1), ==, "1");
5296 g_assert_cmpstr (g_slist_nth_data (list, 2), ==, "2");
5297 }
5298
5299 /**
5300 * gi_marshalling_tests_gslist_utf8_container_in:
5301 * @list: (element-type utf8) (transfer container):
5302 */
5303 void
5304 gi_marshalling_tests_gslist_utf8_container_in (GSList *list)
5305 {
5306 gi_marshalling_tests_gslist_utf8_none_in (list);
5307 g_slist_free (list);
5308 }
5309
5310 /**
5311 * gi_marshalling_tests_gslist_utf8_full_in:
5312 * @list: (element-type utf8) (transfer full):
5313 */
5314 void
5315 gi_marshalling_tests_gslist_utf8_full_in (GSList *list)
5316 {
5317 gi_marshalling_tests_gslist_utf8_none_in (list);
5318 g_slist_free_full (list, g_free);
5319 }
5320
5321 /**
5322 * gi_marshalling_tests_gslist_utf8_none_out:
5323 * @list: (out) (element-type utf8) (transfer none):
5324 */
5325 void
5326 gi_marshalling_tests_gslist_utf8_none_out (GSList **list)
5327 {
5328 static GSList *values = NULL;
5329
5330 if (values == NULL)
5331 {
5332 values = g_slist_prepend (values, (gpointer) "0");
5333 values = g_slist_prepend (values, (gpointer) "1");
5334 values = g_slist_prepend (values, (gpointer) "2");
5335 values = g_slist_reverse (values);
5336 }
5337
5338 *list = values;
5339 }
5340
5341 /**
5342 * gi_marshalling_tests_gslist_utf8_none_out_uninitialized:
5343 * @v: (out) (element-type utf8) (transfer none):
5344 */
5345 gboolean
5346 gi_marshalling_tests_gslist_utf8_none_out_uninitialized (GSList **v G_GNUC_UNUSED)
5347 {
5348 return FALSE;
5349 }
5350
5351 /**
5352 * gi_marshalling_tests_gslist_utf8_container_out:
5353 * @list: (out) (element-type utf8) (transfer container):
5354 */
5355 void
5356 gi_marshalling_tests_gslist_utf8_container_out (GSList **list)
5357 {
5358 *list = NULL;
5359
5360 *list = g_slist_prepend (*list, (gpointer) "0");
5361 *list = g_slist_prepend (*list, (gpointer) "1");
5362 *list = g_slist_prepend (*list, (gpointer) "2");
5363 *list = g_slist_reverse (*list);
5364 }
5365
5366 /**
5367 * gi_marshalling_tests_gslist_utf8_container_out_uninitialized:
5368 * @v: (out) (element-type utf8) (transfer container):
5369 */
5370 gboolean
5371 gi_marshalling_tests_gslist_utf8_container_out_uninitialized (GSList **v G_GNUC_UNUSED)
5372 {
5373 return FALSE;
5374 }
5375
5376 /**
5377 * gi_marshalling_tests_gslist_utf8_full_out:
5378 * @list: (out) (element-type utf8) (transfer full):
5379 */
5380 void
5381 gi_marshalling_tests_gslist_utf8_full_out (GSList **list)
5382 {
5383 *list = NULL;
5384
5385 *list = g_slist_prepend (*list, g_strdup ("0"));
5386 *list = g_slist_prepend (*list, g_strdup ("1"));
5387 *list = g_slist_prepend (*list, g_strdup ("2"));
5388 *list = g_slist_reverse (*list);
5389 }
5390
5391 /**
5392 * gi_marshalling_tests_gslist_utf8_full_out_uninitialized:
5393 * @v: (out) (element-type utf8) (transfer full):
5394 */
5395 gboolean
5396 gi_marshalling_tests_gslist_utf8_full_out_uninitialized (GSList **v G_GNUC_UNUSED)
5397 {
5398 return FALSE;
5399 }
5400
5401 /**
5402 * gi_marshalling_tests_gslist_utf8_none_inout:
5403 * @list: (inout) (element-type utf8) (transfer none):
5404 */
5405 void
5406 gi_marshalling_tests_gslist_utf8_none_inout (GSList **list)
5407 {
5408 static GSList *values = NULL;
5409
5410 g_assert_cmpint (g_slist_length (*list), ==, 3);
5411 g_assert_cmpstr (g_slist_nth_data (*list, 0), ==, "0");
5412 g_assert_cmpstr (g_slist_nth_data (*list, 1), ==, "1");
5413 g_assert_cmpstr (g_slist_nth_data (*list, 2), ==, "2");
5414
5415 if (values == NULL)
5416 {
5417 values = g_slist_prepend (values, (gpointer) "-2");
5418 values = g_slist_prepend (values, (gpointer) "-1");
5419 values = g_slist_prepend (values, (gpointer) "0");
5420 values = g_slist_prepend (values, (gpointer) "1");
5421 values = g_slist_reverse (values);
5422 }
5423
5424 *list = values;
5425 }
5426
5427 /**
5428 * gi_marshalling_tests_gslist_utf8_container_inout:
5429 * @list: (inout) (element-type utf8) (transfer container):
5430 */
5431 void
5432 gi_marshalling_tests_gslist_utf8_container_inout (GSList **list)
5433 {
5434 GSList *result = NULL;
5435
5436 g_assert_cmpint (g_slist_length (*list), ==, 3);
5437 g_assert_cmpstr (g_slist_nth_data (*list, 0), ==, "0");
5438 g_assert_cmpstr (g_slist_nth_data (*list, 1), ==, "1");
5439 g_assert_cmpstr (g_slist_nth_data (*list, 2), ==, "2");
5440
5441 result = g_slist_prepend (result, (gpointer) "1");
5442 result = g_slist_prepend (result, (gpointer) "0");
5443 result = g_slist_prepend (result, (gpointer) "-1");
5444 result = g_slist_prepend (result, (gpointer) "-2");
5445
5446 g_slist_free (*list);
5447 *list = result;
5448 }
5449
5450 /**
5451 * gi_marshalling_tests_gslist_utf8_full_inout:
5452 * @list: (inout) (element-type utf8) (transfer full):
5453 */
5454 void
5455 gi_marshalling_tests_gslist_utf8_full_inout (GSList **list)
5456 {
5457 GSList *result = NULL;
5458
5459 g_assert_cmpint (g_slist_length (*list), ==, 3);
5460 g_assert_cmpstr (g_slist_nth_data (*list, 0), ==, "0");
5461 g_assert_cmpstr (g_slist_nth_data (*list, 1), ==, "1");
5462 g_assert_cmpstr (g_slist_nth_data (*list, 2), ==, "2");
5463
5464 result = g_slist_prepend (result, g_strdup ("1"));
5465 result = g_slist_prepend (result, g_strdup ("0"));
5466 result = g_slist_prepend (result, g_strdup ("-1"));
5467 result = g_slist_prepend (result, g_strdup ("-2"));
5468
5469 g_slist_free_full (*list, g_free);
5470 *list = result;
5471 }
5472
5473 /**
5474 * gi_marshalling_tests_ghashtable_int_none_return:
5475 *
5476 * Returns: (element-type gint gint) (transfer none):
5477 */
5478 GHashTable *
5479 gi_marshalling_tests_ghashtable_int_none_return (void)
5480 {
5481 static GHashTable *hash_table = NULL;
5482
5483 if (hash_table == NULL)
5484 {
5485 hash_table = g_hash_table_new (NULL, NULL);
5486 g_hash_table_insert (hash_table, GINT_TO_POINTER (-1), GINT_TO_POINTER (1));
5487 g_hash_table_insert (hash_table, GINT_TO_POINTER (0), GINT_TO_POINTER (0));
5488 g_hash_table_insert (hash_table, GINT_TO_POINTER (1), GINT_TO_POINTER (-1));
5489 g_hash_table_insert (hash_table, GINT_TO_POINTER (2), GINT_TO_POINTER (-2));
5490 }
5491
5492 return hash_table;
5493 }
5494
5495 /**
5496 * gi_marshalling_tests_ghashtable_utf8_none_return:
5497 *
5498 * Returns: (element-type utf8 utf8) (transfer none):
5499 */
5500 GHashTable *
5501 gi_marshalling_tests_ghashtable_utf8_none_return (void)
5502 {
5503 static GHashTable *hash_table = NULL;
5504
5505 if (hash_table == NULL)
5506 {
5507 hash_table = g_hash_table_new (g_str_hash, g_str_equal);
5508 g_hash_table_insert (hash_table, (gpointer) "-1", (gpointer) "1");
5509 g_hash_table_insert (hash_table, (gpointer) "0", (gpointer) "0");
5510 g_hash_table_insert (hash_table, (gpointer) "1", (gpointer) "-1");
5511 g_hash_table_insert (hash_table, (gpointer) "2", (gpointer) "-2");
5512 }
5513
5514 return hash_table;
5515 }
5516
5517 /**
5518 * gi_marshalling_tests_ghashtable_utf8_container_return:
5519 *
5520 * Returns: (element-type utf8 utf8) (transfer container):
5521 */
5522 GHashTable *
5523 gi_marshalling_tests_ghashtable_utf8_container_return (void)
5524 {
5525 GHashTable *hash_table = NULL;
5526
5527 hash_table = g_hash_table_new (g_str_hash, g_str_equal);
5528 g_hash_table_insert (hash_table, (gpointer) "-1", (gpointer) "1");
5529 g_hash_table_insert (hash_table, (gpointer) "0", (gpointer) "0");
5530 g_hash_table_insert (hash_table, (gpointer) "1", (gpointer) "-1");
5531 g_hash_table_insert (hash_table, (gpointer) "2", (gpointer) "-2");
5532
5533 return hash_table;
5534 }
5535
5536 /**
5537 * gi_marshalling_tests_ghashtable_utf8_full_return:
5538 *
5539 * Returns: (element-type utf8 utf8) (transfer full):
5540 */
5541 GHashTable *
5542 gi_marshalling_tests_ghashtable_utf8_full_return (void)
5543 {
5544 GHashTable *hash_table = NULL;
5545
5546 hash_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
5547 g_hash_table_insert (hash_table, g_strdup ("-1"), g_strdup ("1"));
5548 g_hash_table_insert (hash_table, g_strdup ("0"), g_strdup ("0"));
5549 g_hash_table_insert (hash_table, g_strdup ("1"), g_strdup ("-1"));
5550 g_hash_table_insert (hash_table, g_strdup ("2"), g_strdup ("-2"));
5551
5552 return hash_table;
5553 }
5554
5555 /**
5556 * gi_marshalling_tests_ghashtable_int_none_in:
5557 * @hash_table: (element-type gint gint) (transfer none):
5558 */
5559 void
5560 gi_marshalling_tests_ghashtable_int_none_in (GHashTable *hash_table)
5561 {
5562 g_assert_cmpint (GPOINTER_TO_INT (g_hash_table_lookup (hash_table, GINT_TO_POINTER (-1))), ==, 1);
5563 g_assert_cmpint (GPOINTER_TO_INT (g_hash_table_lookup (hash_table, GINT_TO_POINTER (0))), ==, 0);
5564 g_assert_cmpint (GPOINTER_TO_INT (g_hash_table_lookup (hash_table, GINT_TO_POINTER (1))), ==, -1);
5565 g_assert_cmpint (GPOINTER_TO_INT (g_hash_table_lookup (hash_table, GINT_TO_POINTER (2))), ==, -2);
5566 }
5567
5568 /**
5569 * gi_marshalling_tests_ghashtable_utf8_none_in:
5570 * @hash_table: (element-type utf8 utf8) (transfer none):
5571 */
5572 void
5573 gi_marshalling_tests_ghashtable_utf8_none_in (GHashTable *hash_table)
5574 {
5575 g_assert_cmpstr (g_hash_table_lookup (hash_table, "-1"), ==, "1");
5576 g_assert_cmpstr (g_hash_table_lookup (hash_table, "0"), ==, "0");
5577 g_assert_cmpstr (g_hash_table_lookup (hash_table, "1"), ==, "-1");
5578 g_assert_cmpstr (g_hash_table_lookup (hash_table, "2"), ==, "-2");
5579 }
5580
5581 /**
5582 * gi_marshalling_tests_ghashtable_utf8_container_in:
5583 * @hash_table: (element-type utf8 utf8) (transfer container):
5584 */
5585 void
5586 gi_marshalling_tests_ghashtable_utf8_container_in (GHashTable *hash_table)
5587 {
5588 gi_marshalling_tests_ghashtable_utf8_none_in (hash_table);
5589 g_hash_table_steal_all (hash_table);
5590 g_hash_table_unref (hash_table);
5591 }
5592
5593 static gboolean
5594 hash_table_free_helper (gpointer key, gpointer value, gpointer data G_GNUC_UNUSED)
5595 {
5596 g_free (key);
5597 g_free (value);
5598 return TRUE;
5599 }
5600
5601 /**
5602 * gi_marshalling_tests_ghashtable_utf8_full_in:
5603 * @hash_table: (element-type utf8 utf8) (transfer full):
5604 */
5605 void
5606 gi_marshalling_tests_ghashtable_utf8_full_in (GHashTable *hash_table)
5607 {
5608 gi_marshalling_tests_ghashtable_utf8_none_in (hash_table);
5609
5610 /* Free the keys and values manually. Do not rely on the binding passing in a
5611 * GHashTable with the destroy functions set. */
5612 g_hash_table_foreach_steal (hash_table, hash_table_free_helper, NULL);
5613
5614 g_hash_table_unref (hash_table);
5615 }
5616
5617 /**
5618 * gi_marshalling_tests_ghashtable_double_in:
5619 * @hash_table: (element-type utf8 double) (transfer none):
5620 *
5621 * Meant to test a value type that doesn't fit inside a pointer.
5622 */
5623 void
5624 gi_marshalling_tests_ghashtable_double_in (GHashTable *hash_table)
5625 {
5626 double *value;
5627
5628 value = g_hash_table_lookup (hash_table, "-1");
5629 g_assert_cmpfloat_with_epsilon (*value, -0.1, 0.01);
5630 value = g_hash_table_lookup (hash_table, "0");
5631 g_assert_cmpfloat (*value, ==, 0.0);
5632 value = g_hash_table_lookup (hash_table, "1");
5633 g_assert_cmpfloat_with_epsilon (*value, 0.1, 0.01);
5634 value = g_hash_table_lookup (hash_table, "2");
5635 g_assert_cmpfloat_with_epsilon (*value, 0.2, 0.01);
5636 }
5637
5638 /**
5639 * gi_marshalling_tests_ghashtable_float_in:
5640 * @hash_table: (element-type utf8 float) (transfer none):
5641 *
5642 * Meant to test a value type that doesn't fit inside a pointer.
5643 */
5644 void
5645 gi_marshalling_tests_ghashtable_float_in (GHashTable *hash_table)
5646 {
5647 float *value;
5648
5649 value = g_hash_table_lookup (hash_table, "-1");
5650 g_assert_cmpfloat_with_epsilon (*value, -0.1f, 0.01f);
5651 value = g_hash_table_lookup (hash_table, "0");
5652 g_assert_cmpfloat (*value, ==, 0.0f);
5653 value = g_hash_table_lookup (hash_table, "1");
5654 g_assert_cmpfloat_with_epsilon (*value, 0.1f, 0.01f);
5655 value = g_hash_table_lookup (hash_table, "2");
5656 g_assert_cmpfloat_with_epsilon (*value, 0.2f, 0.01f);
5657 }
5658
5659 /**
5660 * gi_marshalling_tests_ghashtable_int64_in:
5661 * @hash_table: (element-type utf8 gint64) (transfer none):
5662 *
5663 * Meant to test a value type that doesn't fit inside a pointer.
5664 */
5665 void
5666 gi_marshalling_tests_ghashtable_int64_in (GHashTable *hash_table)
5667 {
5668 gint64 *value;
5669
5670 value = g_hash_table_lookup (hash_table, "-1");
5671 g_assert_cmpint (*value, ==, -1);
5672 value = g_hash_table_lookup (hash_table, "0");
5673 g_assert_cmpint (*value, ==, 0);
5674 value = g_hash_table_lookup (hash_table, "1");
5675 g_assert_cmpint (*value, ==, 1);
5676 value = g_hash_table_lookup (hash_table, "2");
5677 g_assert_cmpint (*value, ==, (gint64) G_MAXUINT32 + 1);
5678 }
5679
5680 /**
5681 * gi_marshalling_tests_ghashtable_uint64_in:
5682 * @hash_table: (element-type utf8 guint64) (transfer none):
5683 *
5684 * Meant to test a value type that doesn't fit inside a pointer.
5685 */
5686 void
5687 gi_marshalling_tests_ghashtable_uint64_in (GHashTable *hash_table)
5688 {
5689 guint64 *value;
5690
5691 value = g_hash_table_lookup (hash_table, "-1");
5692 g_assert_cmpuint (*value, ==, (guint64) G_MAXUINT32 + 1);
5693 value = g_hash_table_lookup (hash_table, "0");
5694 g_assert_cmpuint (*value, ==, 0);
5695 value = g_hash_table_lookup (hash_table, "1");
5696 g_assert_cmpuint (*value, ==, 1);
5697 value = g_hash_table_lookup (hash_table, "2");
5698 g_assert_cmpuint (*value, ==, 2);
5699 }
5700
5701 /**
5702 * gi_marshalling_tests_ghashtable_utf8_none_out:
5703 * @hash_table: (out) (element-type utf8 utf8) (transfer none):
5704 */
5705 void
5706 gi_marshalling_tests_ghashtable_utf8_none_out (GHashTable **hash_table)
5707 {
5708 static GHashTable *new_hash_table = NULL;
5709
5710 if (new_hash_table == NULL)
5711 {
5712 new_hash_table = g_hash_table_new (g_str_hash, g_str_equal);
5713 g_hash_table_insert (new_hash_table, (gpointer) "-1", (gpointer) "1");
5714 g_hash_table_insert (new_hash_table, (gpointer) "0", (gpointer) "0");
5715 g_hash_table_insert (new_hash_table, (gpointer) "1", (gpointer) "-1");
5716 g_hash_table_insert (new_hash_table, (gpointer) "2", (gpointer) "-2");
5717 }
5718
5719 *hash_table = new_hash_table;
5720 }
5721
5722 /**
5723 * gi_marshalling_tests_ghashtable_utf8_none_out_uninitialized:
5724 * @v: (out) (element-type utf8 utf8) (transfer none):
5725 */
5726 gboolean
5727 gi_marshalling_tests_ghashtable_utf8_none_out_uninitialized (GHashTable **v G_GNUC_UNUSED)
5728 {
5729 return FALSE;
5730 }
5731
5732 /**
5733 * gi_marshalling_tests_ghashtable_utf8_container_out:
5734 * @hash_table: (out) (element-type utf8 utf8) (transfer container):
5735 */
5736 void
5737 gi_marshalling_tests_ghashtable_utf8_container_out (GHashTable **hash_table)
5738 {
5739 *hash_table = g_hash_table_new (g_str_hash, g_str_equal);
5740 g_hash_table_insert (*hash_table, (gpointer) "-1", (gpointer) "1");
5741 g_hash_table_insert (*hash_table, (gpointer) "0", (gpointer) "0");
5742 g_hash_table_insert (*hash_table, (gpointer) "1", (gpointer) "-1");
5743 g_hash_table_insert (*hash_table, (gpointer) "2", (gpointer) "-2");
5744 }
5745
5746 /**
5747 * gi_marshalling_tests_ghashtable_utf8_container_out_uninitialized:
5748 * @v: (out) (element-type utf8 utf8) (transfer container):
5749 */
5750 gboolean
5751 gi_marshalling_tests_ghashtable_utf8_container_out_uninitialized (GHashTable **v G_GNUC_UNUSED)
5752 {
5753 return FALSE;
5754 }
5755
5756 /**
5757 * gi_marshalling_tests_ghashtable_utf8_full_out:
5758 * @hash_table: (out) (element-type utf8 utf8) (transfer full):
5759 */
5760 void
5761 gi_marshalling_tests_ghashtable_utf8_full_out (GHashTable **hash_table)
5762 {
5763 *hash_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
5764 g_hash_table_insert (*hash_table, g_strdup ("-1"), g_strdup ("1"));
5765 g_hash_table_insert (*hash_table, g_strdup ("0"), g_strdup ("0"));
5766 g_hash_table_insert (*hash_table, g_strdup ("1"), g_strdup ("-1"));
5767 g_hash_table_insert (*hash_table, g_strdup ("2"), g_strdup ("-2"));
5768 }
5769
5770 /**
5771 * gi_marshalling_tests_ghashtable_utf8_full_out_uninitialized:
5772 * @v: (out) (element-type utf8 utf8) (transfer full):
5773 */
5774 gboolean
5775 gi_marshalling_tests_ghashtable_utf8_full_out_uninitialized (GHashTable **v G_GNUC_UNUSED)
5776 {
5777 return FALSE;
5778 }
5779
5780 /**
5781 * gi_marshalling_tests_ghashtable_utf8_none_inout:
5782 * @hash_table: (inout) (element-type utf8 utf8) (transfer none):
5783 */
5784 void
5785 gi_marshalling_tests_ghashtable_utf8_none_inout (GHashTable **hash_table)
5786 {
5787 static GHashTable *new_hash_table = NULL;
5788
5789 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "-1"), ==, "1");
5790 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "0"), ==, "0");
5791 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "1"), ==, "-1");
5792 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "2"), ==, "-2");
5793
5794 if (new_hash_table == NULL)
5795 {
5796 new_hash_table = g_hash_table_new (g_str_hash, g_str_equal);
5797 g_hash_table_insert (new_hash_table, (gpointer) "-1", (gpointer) "1");
5798 g_hash_table_insert (new_hash_table, (gpointer) "0", (gpointer) "0");
5799 g_hash_table_insert (new_hash_table, (gpointer) "1", (gpointer) "1");
5800 }
5801
5802 *hash_table = new_hash_table;
5803 }
5804
5805 /**
5806 * gi_marshalling_tests_ghashtable_utf8_container_inout:
5807 * @hash_table: (inout) (element-type utf8 utf8) (transfer container):
5808 */
5809 void
5810 gi_marshalling_tests_ghashtable_utf8_container_inout (GHashTable **hash_table)
5811 {
5812 GHashTable *result = g_hash_table_new (g_str_hash, g_str_equal);
5813
5814 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "-1"), ==, "1");
5815 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "0"), ==, "0");
5816 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "1"), ==, "-1");
5817 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "2"), ==, "-2");
5818
5819 g_hash_table_insert (result, (gpointer) "-1", (gpointer) "1");
5820 g_hash_table_insert (result, (gpointer) "0", (gpointer) "0");
5821 g_hash_table_insert (result, (gpointer) "1", (gpointer) "1");
5822
5823 g_hash_table_unref (*hash_table);
5824 *hash_table = result;
5825 }
5826
5827 /**
5828 * gi_marshalling_tests_ghashtable_utf8_full_inout:
5829 * @hash_table: (inout) (element-type utf8 utf8) (transfer full):
5830 */
5831 void
5832 gi_marshalling_tests_ghashtable_utf8_full_inout (GHashTable **hash_table)
5833 {
5834 GHashTable *result = g_hash_table_new_full (g_str_hash, g_str_equal,
5835 g_free, g_free);
5836
5837 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "-1"), ==, "1");
5838 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "0"), ==, "0");
5839 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "1"), ==, "-1");
5840 g_assert_cmpstr (g_hash_table_lookup (*hash_table, "2"), ==, "-2");
5841
5842 g_hash_table_insert (result, g_strdup ("-1"), g_strdup ("1"));
5843 g_hash_table_insert (result, g_strdup ("0"), g_strdup ("0"));
5844 g_hash_table_insert (result, g_strdup ("1"), g_strdup ("1"));
5845
5846 g_hash_table_unref (*hash_table);
5847 *hash_table = result;
5848 }
5849
5850 /**
5851 * gi_marshalling_tests_gvalue_return:
5852 *
5853 * Returns: (transfer none):
5854 */
5855 GValue *
5856 gi_marshalling_tests_gvalue_return (void)
5857 {
5858 static GValue *value = NULL;
5859
5860 if (value == NULL)
5861 {
5862 value = g_new0 (GValue, 1);
5863 g_value_init (value, G_TYPE_INT);
5864 g_value_set_int (value, 42);
5865 }
5866
5867 return value;
5868 }
5869
5870 /**
5871 * gi_marshalling_tests_gvalue_noncanonical_nan_float:
5872 *
5873 * Returns: (transfer none):
5874 */
5875 GValue *
5876 gi_marshalling_tests_gvalue_noncanonical_nan_float (void)
5877 {
5878 static GValue *value = NULL;
5879
5880 if (value == NULL)
5881 {
5882 value = g_new0 (GValue, 1);
5883 g_value_init (value, G_TYPE_FLOAT);
5884 g_value_set_float (value, noncanonical_nan_float ());
5885 }
5886
5887 return value;
5888 }
5889
5890 /**
5891 * gi_marshalling_tests_gvalue_noncanonical_nan_double:
5892 *
5893 * Returns: (transfer none):
5894 */
5895 GValue *
5896 gi_marshalling_tests_gvalue_noncanonical_nan_double (void)
5897 {
5898 static GValue *value = NULL;
5899
5900 if (value == NULL)
5901 {
5902 value = g_new0 (GValue, 1);
5903 g_value_init (value, G_TYPE_DOUBLE);
5904 g_value_set_double (value, noncanonical_nan_double ());
5905 }
5906
5907 return value;
5908 }
5909
5910 /**
5911 * gi_marshalling_tests_gvalue_in:
5912 * @value: (transfer none):
5913 */
5914 void
5915 gi_marshalling_tests_gvalue_in (GValue *value)
5916 {
5917 g_assert_cmpint (g_value_get_int (value), ==, 42);
5918 }
5919
5920 /**
5921 * gi_marshalling_tests_gvalue_int64_in:
5922 * @value: (transfer none):
5923 */
5924 void
5925 gi_marshalling_tests_gvalue_int64_in (GValue *value)
5926 {
5927 g_assert_cmpint (g_value_get_int64 (value), ==, G_MAXINT64);
5928 }
5929
5930 /**
5931 * gi_marshalling_tests_gvalue_in_with_type:
5932 * @value: (transfer none):
5933 * @type:
5934 */
5935 void
5936 gi_marshalling_tests_gvalue_in_with_type (GValue *value, GType type)
5937 {
5938 g_assert (g_type_is_a (G_VALUE_TYPE (value), type));
5939 }
5940
5941 /**
5942 * gi_marshalling_tests_gvalue_in_with_modification:
5943 * @value: (transfer none):
5944 *
5945 * Expects a GValue passed by reference which is then modified by
5946 * this function.
5947 */
5948 void
5949 gi_marshalling_tests_gvalue_in_with_modification (GValue *value)
5950 {
5951 g_assert_cmpint (g_value_get_int (value), ==, 42);
5952 g_value_set_int (value, 24);
5953 }
5954
5955 /**
5956 * gi_marshalling_tests_gvalue_in_enum:
5957 * @value: (transfer none):
5958 */
5959 void
5960 gi_marshalling_tests_gvalue_in_enum (GValue *value)
5961 {
5962 if (!G_VALUE_HOLDS_ENUM (value))
5963 g_critical ("Expected enum, got %s", G_VALUE_TYPE_NAME (value));
5964 g_assert (g_value_get_enum (value) == GI_MARSHALLING_TESTS_ENUM_VALUE3);
5965 }
5966
5967 /**
5968 * gi_marshalling_tests_gvalue_in_flags:
5969 * @value: (transfer none):
5970 */
5971 void
5972 gi_marshalling_tests_gvalue_in_flags (GValue *value)
5973 {
5974 if (!G_VALUE_HOLDS_FLAGS (value))
5975 g_critical ("Expected flags, got %s", G_VALUE_TYPE_NAME (value));
5976 g_assert_cmpint (g_value_get_flags (value), ==, GI_MARSHALLING_TESTS_FLAGS_VALUE3);
5977 }
5978
5979 /**
5980 * gi_marshalling_tests_gvalue_out:
5981 * @value: (out) (transfer none):
5982 */
5983 void
5984 gi_marshalling_tests_gvalue_out (GValue **value)
5985 {
5986 static GValue *new_value = NULL;
5987
5988 if (new_value == NULL)
5989 {
5990 new_value = g_new0 (GValue, 1);
5991 g_value_init (new_value, G_TYPE_INT);
5992 g_value_set_int (new_value, 42);
5993 }
5994
5995 *value = new_value;
5996 }
5997
5998 /**
5999 * gi_marshalling_tests_gvalue_out_uninitialized:
6000 * @v: (out) (transfer none):
6001 */
6002 gboolean
6003 gi_marshalling_tests_gvalue_out_uninitialized (GValue **v G_GNUC_UNUSED)
6004 {
6005 return FALSE;
6006 }
6007
6008 /**
6009 * gi_marshalling_tests_gvalue_int64_out:
6010 * @value: (out) (transfer none):
6011 */
6012 void
6013 gi_marshalling_tests_gvalue_int64_out (GValue **value)
6014 {
6015 static GValue *new_value = NULL;
6016
6017 if (new_value == NULL)
6018 {
6019 new_value = g_new0 (GValue, 1);
6020 g_value_init (new_value, G_TYPE_INT64);
6021 g_value_set_int64 (new_value, G_MAXINT64);
6022 }
6023
6024 *value = new_value;
6025 }
6026
6027 /**
6028 * gi_marshalling_tests_gvalue_out_caller_allocates:
6029 * @value: (out) (transfer none):
6030 */
6031 void
6032 gi_marshalling_tests_gvalue_out_caller_allocates (GValue *value)
6033 {
6034 g_value_init (value, G_TYPE_INT);
6035 g_value_set_int (value, 42);
6036 }
6037
6038 /**
6039 * gi_marshalling_tests_gvalue_inout:
6040 * @value: (inout) (transfer none):
6041 */
6042 void
6043 gi_marshalling_tests_gvalue_inout (GValue **value)
6044 {
6045 g_assert_cmpint (g_value_get_int (*value), ==, 42);
6046 g_value_unset (*value);
6047 g_value_init (*value, G_TYPE_STRING);
6048 g_value_set_string (*value, "42");
6049 }
6050
6051 /**
6052 * gi_marshalling_tests_gvalue_flat_array:
6053 * @n_values: number of values
6054 * @values: (array length=n_values): an array containing values
6055 */
6056 void
6057 gi_marshalling_tests_gvalue_flat_array (guint n_values, const GValue *values)
6058 {
6059 g_assert (n_values == 3);
6060
6061 g_assert_cmpint (g_value_get_int (&values[0]), ==, 42);
6062 g_assert_cmpstr (g_value_get_string (&values[1]), ==, "42");
6063 g_assert_cmpint (g_value_get_boolean (&values[2]), ==, TRUE);
6064 }
6065
6066 /**
6067 * gi_marshalling_tests_return_gvalue_flat_array:
6068 *
6069 * Returns: (array fixed-size=3) (transfer full): a flat GValue array
6070 */
6071 GValue *
6072 gi_marshalling_tests_return_gvalue_flat_array (void)
6073 {
6074 GValue *array = g_new0 (GValue, 3);
6075
6076 g_value_init (&array[0], G_TYPE_INT);
6077 g_value_set_int (&array[0], 42);
6078
6079 g_value_init (&array[1], G_TYPE_STRING);
6080 g_value_set_static_string (&array[1], "42");
6081
6082 g_value_init (&array[2], G_TYPE_BOOLEAN);
6083 g_value_set_boolean (&array[2], TRUE);
6084
6085 return array;
6086 }
6087
6088 /**
6089 * gi_marshalling_tests_return_gvalue_zero_terminated_array:
6090 *
6091 * Returns: (array zero-terminated) (transfer full): a flat GValue array
6092 */
6093 GValue *
6094 gi_marshalling_tests_return_gvalue_zero_terminated_array (void)
6095 {
6096 GValue *array = g_new0 (GValue, 4);
6097
6098 g_value_init (&array[0], G_TYPE_INT);
6099 g_value_set_int (&array[0], 42);
6100
6101 g_value_init (&array[1], G_TYPE_STRING);
6102 g_value_set_static_string (&array[1], "42");
6103
6104 g_value_init (&array[2], G_TYPE_BOOLEAN);
6105 g_value_set_boolean (&array[2], TRUE);
6106
6107 return array;
6108 }
6109
6110 /**
6111 * gi_marshalling_tests_gvalue_round_trip:
6112 * @value: The first GValue
6113 *
6114 * Returns: (transfer none):
6115 */
6116 GValue *
6117 gi_marshalling_tests_gvalue_round_trip (GValue *value)
6118 {
6119 return value;
6120 }
6121
6122 /**
6123 * gi_marshalling_tests_gvalue_copy:
6124 * @value: The first GValue
6125 *
6126 * Returns: (transfer full):
6127 */
6128 GValue *
6129 gi_marshalling_tests_gvalue_copy (GValue *value)
6130 {
6131 GValue *return_value = g_new0 (GValue, 1);
6132
6133 g_value_init (return_value, G_VALUE_TYPE (value));
6134 g_value_copy (value, return_value);
6135
6136 return return_value;
6137 }
6138
6139 /**
6140 * gi_marshalling_tests_gvalue_flat_array_round_trip:
6141 * @one: The first GValue
6142 * @two: The second GValue
6143 * @three: The third GValue
6144 *
6145 * Returns: (array fixed-size=3) (transfer full): a flat array of [@one, @two, @three]
6146 */
6147 GValue *
6148 gi_marshalling_tests_gvalue_flat_array_round_trip (const GValue one, const GValue two, const GValue three)
6149 {
6150 GValue *array = g_new (GValue, 3);
6151 array[0] = one;
6152 array[1] = two;
6153 array[2] = three;
6154
6155 return array;
6156 }
6157
6158 /**
6159 * gi_marshalling_tests_gvalue_float:
6160 * @float_value: A G_TYPE_FLOAT GValue
6161 * @double_value: A G_TYPE_DOUBLE GValue
6162 */
6163 void
6164 gi_marshalling_tests_gvalue_float (const GValue *float_value, const GValue *double_value)
6165 {
6166 g_assert_cmpfloat_with_epsilon (g_value_get_float (float_value), 3.14, 0.001);
6167 g_assert_cmpfloat_with_epsilon (g_value_get_double (double_value), 3.14, 0.001);
6168 }
6169
6170 /**
6171 * gi_marshalling_tests_gclosure_in:
6172 * @closure: (transfer none):
6173 */
6174 void
6175 gi_marshalling_tests_gclosure_in (GClosure *closure)
6176 {
6177 GValue return_value = {
6178 0,
6179 };
6180
6181 g_value_init (&return_value, G_TYPE_INT);
6182
6183 g_closure_invoke (closure, &return_value, 0, NULL, NULL);
6184
6185 g_assert_cmpint (g_value_get_int (&return_value), ==, 42);
6186
6187 g_value_unset (&return_value);
6188 }
6189
6190 static gint
6191 _closure_return_42 (void)
6192 {
6193 return 42;
6194 }
6195
6196 static void
6197 _marshal_INT__VOID (GClosure *closure,
6198 GValue *return_value,
6199 guint n_param_values G_GNUC_UNUSED,
6200 const GValue *param_values G_GNUC_UNUSED,
6201 gpointer invocation_hint G_GNUC_UNUSED,
6202 gpointer marshal_data G_GNUC_UNUSED)
6203 {
6204 typedef gint (*GMarshalFunc_INT__VOID) (void);
6205 register GMarshalFunc_INT__VOID callback;
6206 register GCClosure *cc = (GCClosure *) closure;
6207
6208 callback = (GMarshalFunc_INT__VOID) cc->callback;
6209 g_value_set_int (return_value, callback ());
6210 }
6211
6212 /**
6213 * gi_marshalling_tests_gclosure_return:
6214 *
6215 * Return: a #GClosure
6216 */
6217 GClosure *
6218 gi_marshalling_tests_gclosure_return (void)
6219 {
6220 GClosure *closure = g_cclosure_new ((GCallback) _closure_return_42,
6221 NULL, NULL);
6222 g_closure_set_marshal (closure, _marshal_INT__VOID);
6223
6224 return closure;
6225 }
6226
6227 /**
6228 * gi_marshalling_tests_callback_return_value_only:
6229 * @callback: (scope call):
6230 */
6231 glong
6232 gi_marshalling_tests_callback_return_value_only (GIMarshallingTestsCallbackReturnValueOnly callback)
6233 {
6234 return callback ();
6235 }
6236
6237 /**
6238 * gi_marshalling_tests_callback_one_out_parameter:
6239 * @callback: (scope call):
6240 * @a: (out):
6241 */
6242 void
6243 gi_marshalling_tests_callback_one_out_parameter (GIMarshallingTestsCallbackOneOutParameter callback, gfloat *a)
6244 {
6245 callback (a);
6246 }
6247
6248 /**
6249 * gi_marshalling_tests_callback_multiple_out_parameters:
6250 * @callback: (scope call):
6251 * @a: (out):
6252 * @b: (out):
6253 */
6254 void
6255 gi_marshalling_tests_callback_multiple_out_parameters (GIMarshallingTestsCallbackMultipleOutParameters callback, gfloat *a, gfloat *b)
6256 {
6257 callback (a, b);
6258 }
6259
6260 /**
6261 * gi_marshalling_tests_callback_return_value_and_one_out_parameter:
6262 * @callback: (scope call):
6263 * @a: (out):
6264 */
6265 glong
6266 gi_marshalling_tests_callback_return_value_and_one_out_parameter (GIMarshallingTestsCallbackReturnValueAndOneOutParameter callback, glong *a)
6267 {
6268 return callback (a);
6269 }
6270
6271 /**
6272 * gi_marshalling_tests_callback_return_value_and_multiple_out_parameters:
6273 * @callback: (scope call):
6274 * @a: (out):
6275 * @b: (out):
6276 */
6277 glong
6278 gi_marshalling_tests_callback_return_value_and_multiple_out_parameters (GIMarshallingTestsCallbackReturnValueAndMultipleOutParameters callback, glong *a, glong *b)
6279 {
6280 return callback (a, b);
6281 }
6282
6283 /**
6284 * gi_marshalling_tests_pointer_in_return:
6285 *
6286 * Returns: The same pointer
6287 */
6288 gpointer
6289 gi_marshalling_tests_pointer_in_return (gpointer pointer)
6290 {
6291 return pointer;
6292 }
6293
6294 GType
6295 gi_marshalling_tests_genum_get_type (void)
6296 {
6297 static GType type = 0;
6298 if (G_UNLIKELY (type == 0))
6299 {
6300 static const GEnumValue values[] = {
6301 { GI_MARSHALLING_TESTS_GENUM_VALUE1,
6302 "GI_MARSHALLING_TESTS_GENUM_VALUE1", "value1" },
6303 { GI_MARSHALLING_TESTS_GENUM_VALUE2,
6304 "GI_MARSHALLING_TESTS_GENUM_VALUE2", "value2" },
6305 { GI_MARSHALLING_TESTS_GENUM_VALUE3,
6306 "GI_MARSHALLING_TESTS_GENUM_VALUE3", "value3" },
6307 { 0, NULL, NULL }
6308 };
6309 type = g_enum_register_static (g_intern_static_string ("GIMarshallingTestsGEnum"), values);
6310 }
6311
6312 return type;
6313 }
6314
6315 GIMarshallingTestsGEnum
6316 gi_marshalling_tests_genum_returnv (void)
6317 {
6318 return GI_MARSHALLING_TESTS_GENUM_VALUE3;
6319 }
6320
6321 void
6322 gi_marshalling_tests_genum_in (GIMarshallingTestsGEnum v)
6323 {
6324 g_assert_cmpint (v, ==, GI_MARSHALLING_TESTS_GENUM_VALUE3);
6325 }
6326
6327 /**
6328 * gi_marshalling_tests_genum_out:
6329 * @v: (out):
6330 */
6331 void
6332 gi_marshalling_tests_genum_out (GIMarshallingTestsGEnum *v)
6333 {
6334 *v = GI_MARSHALLING_TESTS_GENUM_VALUE3;
6335 }
6336
6337 /**
6338 * gi_marshalling_tests_genum_out_uninitialized:
6339 * @v: (out):
6340 */
6341 gboolean
6342 gi_marshalling_tests_genum_out_uninitialized (GIMarshallingTestsGEnum *v G_GNUC_UNUSED)
6343 {
6344 return FALSE;
6345 }
6346
6347 /**
6348 * gi_marshalling_tests_genum_inout:
6349 * @v: (inout):
6350 */
6351 void
6352 gi_marshalling_tests_genum_inout (GIMarshallingTestsGEnum *v)
6353 {
6354 g_assert_cmpint (*v, ==, GI_MARSHALLING_TESTS_GENUM_VALUE3);
6355 *v = GI_MARSHALLING_TESTS_GENUM_VALUE1;
6356 }
6357
6358 GIMarshallingTestsEnum
6359 gi_marshalling_tests_enum_returnv (void)
6360 {
6361 return GI_MARSHALLING_TESTS_ENUM_VALUE3;
6362 }
6363
6364 void
6365 gi_marshalling_tests_enum_in (GIMarshallingTestsEnum v)
6366 {
6367 g_assert_cmpint (v, ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
6368 }
6369
6370 /**
6371 * gi_marshalling_tests_enum_out:
6372 * @v: (out):
6373 */
6374 void
6375 gi_marshalling_tests_enum_out (GIMarshallingTestsEnum *v)
6376 {
6377 *v = GI_MARSHALLING_TESTS_ENUM_VALUE3;
6378 }
6379
6380 /**
6381 * gi_marshalling_tests_enum_out_uninitialized:
6382 * @v: (out):
6383 */
6384 gboolean
6385 gi_marshalling_tests_enum_out_uninitialized (GIMarshallingTestsEnum **v G_GNUC_UNUSED)
6386 {
6387 return FALSE;
6388 }
6389
6390 /**
6391 * gi_marshalling_tests_enum_inout:
6392 * @v: (inout):
6393 */
6394 void
6395 gi_marshalling_tests_enum_inout (GIMarshallingTestsEnum *v)
6396 {
6397 g_assert_cmpint (*v, ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
6398 *v = GI_MARSHALLING_TESTS_ENUM_VALUE1;
6399 }
6400
6401 GType
6402 gi_marshalling_tests_flags_get_type (void)
6403 {
6404 static GType type = 0;
6405 if (G_UNLIKELY (type == 0))
6406 {
6407 static const GFlagsValue values[] = {
6408 { GI_MARSHALLING_TESTS_FLAGS_VALUE1,
6409 "GI_MARSHALLING_TESTS_FLAGS_VALUE1", "value1" },
6410 { GI_MARSHALLING_TESTS_FLAGS_VALUE2,
6411 "GI_MARSHALLING_TESTS_FLAGS_VALUE2", "value2" },
6412 { GI_MARSHALLING_TESTS_FLAGS_VALUE3,
6413 "GI_MARSHALLING_TESTS_FLAGS_VALUE3", "value3" },
6414 { GI_MARSHALLING_TESTS_FLAGS_MASK, "GI_MARSHALLING_TESTS_FLAGS_MASK",
6415 "mask" },
6416 { GI_MARSHALLING_TESTS_FLAGS_MASK2, "GI_MARSHALLING_TESTS_FLAGS_MASK2",
6417 "mask2" },
6418 { 0, NULL, NULL }
6419 };
6420 type = g_flags_register_static (g_intern_static_string ("GIMarshallingTestsFlags"), values);
6421 }
6422
6423 return type;
6424 }
6425
6426 GIMarshallingTestsFlags
6427 gi_marshalling_tests_flags_returnv (void)
6428 {
6429 return GI_MARSHALLING_TESTS_FLAGS_VALUE2;
6430 }
6431
6432 void
6433 gi_marshalling_tests_flags_in (GIMarshallingTestsFlags v)
6434 {
6435 g_assert (v == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
6436 }
6437
6438 void
6439 gi_marshalling_tests_flags_in_zero (GIMarshallingTestsFlags v)
6440 {
6441 g_assert (v == 0);
6442 }
6443
6444 /**
6445 * gi_marshalling_tests_flags_out:
6446 * @v: (out):
6447 */
6448 void
6449 gi_marshalling_tests_flags_out (GIMarshallingTestsFlags *v)
6450 {
6451 *v = GI_MARSHALLING_TESTS_FLAGS_VALUE2;
6452 }
6453
6454 /**
6455 * gi_marshalling_tests_flags_out_uninitialized:
6456 * @v: (out):
6457 */
6458 gboolean
6459 gi_marshalling_tests_flags_out_uninitialized (GIMarshallingTestsFlags *v G_GNUC_UNUSED)
6460 {
6461 return FALSE;
6462 }
6463
6464 /**
6465 * gi_marshalling_tests_flags_inout:
6466 * @v: (inout):
6467 */
6468 void
6469 gi_marshalling_tests_flags_inout (GIMarshallingTestsFlags *v)
6470 {
6471 g_assert (*v == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
6472 *v = GI_MARSHALLING_TESTS_FLAGS_VALUE1;
6473 }
6474
6475 GIMarshallingTestsNoTypeFlags
6476 gi_marshalling_tests_no_type_flags_returnv (void)
6477 {
6478 return GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
6479 }
6480
6481 void
6482 gi_marshalling_tests_no_type_flags_in (GIMarshallingTestsNoTypeFlags v)
6483 {
6484 g_assert (v == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
6485 }
6486
6487 void
6488 gi_marshalling_tests_no_type_flags_in_zero (GIMarshallingTestsNoTypeFlags v)
6489 {
6490 g_assert (v == 0);
6491 }
6492
6493 /**
6494 * gi_marshalling_tests_no_type_flags_out:
6495 * @v: (out):
6496 */
6497 void
6498 gi_marshalling_tests_no_type_flags_out (GIMarshallingTestsNoTypeFlags *v)
6499 {
6500 *v = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
6501 }
6502
6503 /**
6504 * gi_marshalling_tests_no_type_flags_out_uninitialized:
6505 * @v: (out):
6506 */
6507 gboolean
6508 gi_marshalling_tests_no_type_flags_out_uninitialized (GIMarshallingTestsNoTypeFlags **v G_GNUC_UNUSED)
6509 {
6510 return FALSE;
6511 }
6512
6513 /**
6514 * gi_marshalling_tests_no_type_flags_inout:
6515 * @v: (inout):
6516 */
6517 void
6518 gi_marshalling_tests_no_type_flags_inout (GIMarshallingTestsNoTypeFlags *v)
6519 {
6520 g_assert (*v == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
6521 *v = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE1;
6522 }
6523
6524 /**
6525 * gi_marshalling_tests_simple_struct_returnv:
6526 *
6527 * Returns: (transfer none):
6528 */
6529 GIMarshallingTestsSimpleStruct *
6530 gi_marshalling_tests_simple_struct_returnv (void)
6531 {
6532 static GIMarshallingTestsSimpleStruct *struct_ = NULL;
6533
6534 if (struct_ == NULL)
6535 {
6536 struct_ = g_new (GIMarshallingTestsSimpleStruct, 1);
6537
6538 struct_->long_ = 6;
6539 struct_->int8 = 7;
6540 }
6541
6542 return struct_;
6543 }
6544
6545 /**
6546 * gi_marshalling_tests_simple_struct_inv:
6547 * @struct_: (transfer none):
6548 */
6549 void
6550 gi_marshalling_tests_simple_struct_inv (GIMarshallingTestsSimpleStruct *struct_)
6551 {
6552 g_assert_cmpint (struct_->long_, ==, 6);
6553 g_assert_cmpint (struct_->int8, ==, 7);
6554 }
6555
6556 void
6557 gi_marshalling_tests_simple_struct_method (GIMarshallingTestsSimpleStruct *struct_)
6558 {
6559 g_assert_cmpint (struct_->long_, ==, 6);
6560 g_assert_cmpint (struct_->int8, ==, 7);
6561 }
6562
6563 GType
6564 gi_marshalling_tests_pointer_struct_get_type (void)
6565 {
6566 static GType type = 0;
6567
6568 if (type == 0)
6569 {
6570 type = g_pointer_type_register_static ("GIMarshallingTestsPointerStruct");
6571 }
6572
6573 return type;
6574 }
6575
6576 /**
6577 * gi_marshalling_tests_pointer_struct_returnv:
6578 *
6579 * Returns: (transfer none):
6580 */
6581 GIMarshallingTestsPointerStruct *
6582 gi_marshalling_tests_pointer_struct_returnv (void)
6583 {
6584 static GIMarshallingTestsPointerStruct *struct_ = NULL;
6585
6586 if (struct_ == NULL)
6587 {
6588 struct_ = g_new (GIMarshallingTestsPointerStruct, 1);
6589
6590 struct_->long_ = 42;
6591 }
6592
6593 return struct_;
6594 }
6595
6596 /**
6597 * gi_marshalling_tests_pointer_struct_inv:
6598 * @struct_: (transfer none):
6599 */
6600 void
6601 gi_marshalling_tests_pointer_struct_inv (GIMarshallingTestsPointerStruct *struct_)
6602 {
6603 g_assert_cmpint (struct_->long_, ==, 42);
6604 }
6605
6606 static GIMarshallingTestsBoxedStruct *
6607 gi_marshalling_tests_boxed_struct_copy (GIMarshallingTestsBoxedStruct *struct_)
6608 {
6609 GIMarshallingTestsBoxedStruct *new_struct;
6610
6611 if (struct_ == NULL)
6612 return NULL;
6613
6614 new_struct = g_slice_new (GIMarshallingTestsBoxedStruct);
6615
6616 *new_struct = *struct_;
6617 new_struct->string_ = g_strdup (struct_->string_);
6618 new_struct->g_strv = g_strdupv (struct_->g_strv);
6619
6620 return new_struct;
6621 }
6622
6623 static void
6624 gi_marshalling_tests_boxed_struct_free (GIMarshallingTestsBoxedStruct *struct_)
6625 {
6626 if (struct_ != NULL)
6627 {
6628 g_free (struct_->string_);
6629 g_clear_pointer (&struct_->g_strv, g_strfreev);
6630 g_slice_free (GIMarshallingTestsBoxedStruct, struct_);
6631 }
6632 }
6633
6634 GType
6635 gi_marshalling_tests_boxed_struct_get_type (void)
6636 {
6637 static GType type = 0;
6638
6639 if (type == 0)
6640 {
6641 type = g_boxed_type_register_static ("GIMarshallingTestsBoxedStruct",
6642 (GBoxedCopyFunc)
6643 gi_marshalling_tests_boxed_struct_copy,
6644 (GBoxedFreeFunc) gi_marshalling_tests_boxed_struct_free);
6645 }
6646
6647 return type;
6648 }
6649
6650 static GType
6651 gi_marshalling_tests_boxed_glist_get_type (void)
6652 {
6653 static GType type = 0;
6654
6655 if (type == 0)
6656 {
6657 type = g_boxed_type_register_static ("GIMarshallingTestsBoxedGList",
6658 (GBoxedCopyFunc) g_list_copy, (GBoxedFreeFunc) g_list_free);
6659 }
6660
6661 return type;
6662 }
6663
6664 GIMarshallingTestsBoxedStruct *
6665 gi_marshalling_tests_boxed_struct_new (void)
6666 {
6667 return g_slice_new0 (GIMarshallingTestsBoxedStruct);
6668 }
6669
6670 /**
6671 * gi_marshalling_tests_boxed_struct_returnv:
6672 *
6673 * Returns: (transfer none):
6674 */
6675 GIMarshallingTestsBoxedStruct *
6676 gi_marshalling_tests_boxed_struct_returnv (void)
6677 {
6678 static GIMarshallingTestsBoxedStruct *struct_ = NULL;
6679
6680 if (struct_ == NULL)
6681 {
6682 struct_ = g_new (GIMarshallingTestsBoxedStruct, 1);
6683
6684 struct_->long_ = 42;
6685 struct_->string_ = g_strdup ("hello");
6686 struct_->g_strv = g_new0 (gchar *, 4);
6687 struct_->g_strv[0] = g_strdup ("0");
6688 struct_->g_strv[1] = g_strdup ("1");
6689 struct_->g_strv[2] = g_strdup ("2");
6690 struct_->g_strv[3] = NULL;
6691 }
6692
6693 return struct_;
6694 }
6695
6696 /**
6697 * gi_marshalling_tests_boxed_struct_inv:
6698 * @struct_: (transfer none):
6699 */
6700 void
6701 gi_marshalling_tests_boxed_struct_inv (GIMarshallingTestsBoxedStruct *struct_)
6702 {
6703 g_assert_cmpint (struct_->long_, ==, 42);
6704 }
6705
6706 /**
6707 * gi_marshalling_tests_boxed_struct_out:
6708 * @struct_: (out) (transfer none):
6709 */
6710 void
6711 gi_marshalling_tests_boxed_struct_out (GIMarshallingTestsBoxedStruct **struct_)
6712 {
6713 static GIMarshallingTestsBoxedStruct *new_struct = NULL;
6714
6715 if (new_struct == NULL)
6716 {
6717 new_struct = g_new0 (GIMarshallingTestsBoxedStruct, 1);
6718
6719 new_struct->long_ = 42;
6720 }
6721
6722 *struct_ = new_struct;
6723 }
6724
6725 /**
6726 * gi_marshalling_tests_boxed_struct_out_uninitialized:
6727 * @v: (out) (transfer none):
6728 */
6729 gboolean
6730 gi_marshalling_tests_boxed_struct_out_uninitialized (GIMarshallingTestsBoxedStruct **v G_GNUC_UNUSED)
6731 {
6732 return FALSE;
6733 }
6734
6735 /**
6736 * gi_marshalling_tests_boxed_struct_inout:
6737 * @struct_: (inout) (transfer full):
6738 */
6739 void
6740 gi_marshalling_tests_boxed_struct_inout (GIMarshallingTestsBoxedStruct **struct_)
6741 {
6742 g_assert_cmpint ((*struct_)->long_, ==, 42);
6743
6744 g_boxed_free (gi_marshalling_tests_boxed_struct_get_type (), *struct_);
6745 (*struct_) = g_slice_new0 (GIMarshallingTestsBoxedStruct);
6746 (*struct_)->long_ = 0;
6747 }
6748
6749 static GIMarshallingTestsPointerArrayStruct *
6750 gi_marshalling_tests_pointer_array_struct_copy (GIMarshallingTestsPointerArrayStruct *struct_)
6751 {
6752 struct_->ref_count += 1;
6753 return struct_;
6754 }
6755
6756 static void
6757 gi_marshalling_tests_pointer_array_struct_free (GIMarshallingTestsPointerArrayStruct *struct_)
6758 {
6759 if (struct_ && struct_->ref_count > 0)
6760 {
6761 struct_->ref_count -= 1;
6762 if (struct_->ref_count == 0)
6763 {
6764 g_clear_pointer (&struct_->array, g_array_unref);
6765 g_free (struct_);
6766 }
6767 }
6768 }
6769
6770 GType
6771 gi_marshalling_tests_pointer_array_struct_get_type (void)
6772 {
6773 static GType type = 0;
6774
6775 if (type == 0)
6776 {
6777 type = g_boxed_type_register_static ("GIMarshallingTestsPointerArrayStruct",
6778 (GBoxedCopyFunc) gi_marshalling_tests_pointer_array_struct_copy,
6779 (GBoxedFreeFunc) gi_marshalling_tests_pointer_array_struct_free);
6780 }
6781
6782 return type;
6783 }
6784
6785 /**
6786 * gi_marshalling_tests_pointer_array_struct_with_uint8_array:
6787 * Returns: (transfer full):
6788 */
6789 GIMarshallingTestsPointerArrayStruct *
6790 gi_marshalling_tests_pointer_array_struct_with_uint8_array (void)
6791 {
6792 GIMarshallingTestsPointerArrayStruct *struct_;
6793 static const gchar values[] = "0123456789";
6794 gint i;
6795
6796 struct_ = g_new0 (GIMarshallingTestsPointerArrayStruct, 1);
6797
6798 struct_->array = g_array_new (TRUE, TRUE, sizeof (guint8));
6799 for (i = 0; values[i]; i++)
6800 g_array_append_val (struct_->array, values[i]);
6801
6802 struct_->ref_count = 1;
6803 return struct_;
6804 }
6805
6806 static GIMarshallingTestsUnion *
6807 gi_marshalling_tests_union_copy (GIMarshallingTestsUnion *union_)
6808 {
6809 GIMarshallingTestsUnion *new_union;
6810
6811 new_union = g_slice_new (GIMarshallingTestsUnion);
6812
6813 *new_union = *union_;
6814
6815 return new_union;
6816 }
6817
6818 static void
6819 gi_marshalling_tests_union_free (GIMarshallingTestsUnion *union_)
6820 {
6821 g_slice_free (GIMarshallingTestsUnion, union_);
6822 }
6823
6824 GType
6825 gi_marshalling_tests_union_get_type (void)
6826 {
6827 static GType type = 0;
6828
6829 if (type == 0)
6830 {
6831 type = g_boxed_type_register_static ("GIMarshallingTestsUnion",
6832 (GBoxedCopyFunc)
6833 gi_marshalling_tests_union_copy,
6834 (GBoxedFreeFunc) gi_marshalling_tests_union_free);
6835 }
6836
6837 return type;
6838 }
6839
6840 /**
6841 * gi_marshalling_tests_union_returnv:
6842 *
6843 * Returns: (transfer none):
6844 */
6845 GIMarshallingTestsUnion *
6846 gi_marshalling_tests_union_returnv (void)
6847 {
6848 static GIMarshallingTestsUnion *union_ = NULL;
6849
6850 if (union_ == NULL)
6851 {
6852 union_ = g_new (GIMarshallingTestsUnion, 1);
6853
6854 union_->long_ = 42;
6855 }
6856
6857 return union_;
6858 }
6859
6860 /**
6861 * gi_marshalling_tests_union_inv:
6862 * @union_: (transfer none):
6863 */
6864 void
6865 gi_marshalling_tests_union_inv (GIMarshallingTestsUnion *union_)
6866 {
6867 g_assert_cmpint (union_->long_, ==, 42);
6868 }
6869
6870 void
6871 gi_marshalling_tests_union_method (GIMarshallingTestsUnion *union_)
6872 {
6873 g_assert_cmpint (union_->long_, ==, 42);
6874 }
6875
6876 /**
6877 * gi_marshalling_tests_structured_union_new:
6878 * @type: Type of #GIMarshallingTestsStructuredUnion to create
6879 */
6880 GIMarshallingTestsStructuredUnion *
6881 gi_marshalling_tests_structured_union_new (GIMarshallingTestsStructuredUnionType type)
6882 {
6883 GIMarshallingTestsStructuredUnion *new_union;
6884
6885 new_union = g_new0 (GIMarshallingTestsStructuredUnion, 1);
6886 new_union->type = type;
6887
6888 switch (type)
6889 {
6890 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_NONE:
6891 break;
6892
6893 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_SIMPLE_STRUCT:
6894 new_union->simple_struct.parent.long_ = 6;
6895 new_union->simple_struct.parent.int8 = 7;
6896 break;
6897
6898 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_NESTED_STRUCT:
6899 new_union->nested_struct.parent.simple_struct.long_ = 6;
6900 new_union->nested_struct.parent.simple_struct.int8 = 7;
6901 break;
6902
6903 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_BOXED_STRUCT:
6904 new_union->boxed_struct.parent.long_ = 42;
6905 new_union->boxed_struct.parent.string_ = g_strdup ("hello");
6906 new_union->boxed_struct.parent.g_strv = g_new0 (gchar *, 4);
6907 new_union->boxed_struct.parent.g_strv[0] = g_strdup ("0");
6908 new_union->boxed_struct.parent.g_strv[1] = g_strdup ("1");
6909 new_union->boxed_struct.parent.g_strv[2] = g_strdup ("2");
6910 new_union->boxed_struct.parent.g_strv[3] = NULL;
6911 break;
6912
6913 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_BOXED_STRUCT_PTR:
6914 new_union->boxed_struct_ptr.parent = g_boxed_copy (
6915 gi_marshalling_tests_boxed_struct_get_type (),
6916 gi_marshalling_tests_boxed_struct_returnv ());
6917 break;
6918
6919 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_POINTER_STRUCT:
6920 new_union->pointer_struct.parent.long_ = 42;
6921 break;
6922
6923 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_SINGLE_UNION:
6924 new_union->single_union.parent.union_.long_ = 42;
6925 break;
6926
6927 default:
6928 g_free (new_union);
6929 g_return_val_if_reached (NULL);
6930 }
6931
6932 return new_union;
6933 }
6934
6935 static GIMarshallingTestsStructuredUnion *
6936 gi_marshalling_tests_structured_union_copy (GIMarshallingTestsStructuredUnion *union_)
6937 {
6938 GIMarshallingTestsStructuredUnion *new_union;
6939
6940 new_union = g_new (GIMarshallingTestsStructuredUnion, 1);
6941 *new_union = *union_;
6942
6943 switch (union_->type)
6944 {
6945 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_BOXED_STRUCT:
6946 new_union->boxed_struct.parent.string_ = g_strdup (union_->boxed_struct.parent.string_);
6947 if (union_->boxed_struct.parent.g_strv)
6948 {
6949 guint length = g_strv_length (union_->boxed_struct.parent.g_strv);
6950 guint i;
6951
6952 new_union->boxed_struct.parent.g_strv = g_new0 (gchar *, length + 1);
6953 for (i = 0; i < length; i++)
6954 new_union->boxed_struct.parent.g_strv[i] = g_strdup (union_->boxed_struct.parent.g_strv[i]);
6955 new_union->boxed_struct.parent.g_strv[i] = NULL;
6956 }
6957 break;
6958
6959 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_BOXED_STRUCT_PTR:
6960 new_union->boxed_struct_ptr.parent = g_boxed_copy (
6961 gi_marshalling_tests_boxed_struct_get_type (), union_->boxed_struct_ptr.parent);
6962 break;
6963
6964 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_NONE:
6965 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_SINGLE_UNION:
6966 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_POINTER_STRUCT:
6967 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_SIMPLE_STRUCT:
6968 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_NESTED_STRUCT:
6969 break;
6970
6971 default:
6972 g_return_val_if_reached (new_union);
6973 }
6974
6975 return new_union;
6976 }
6977
6978 static void
6979 gi_marshalling_tests_structured_union_free (GIMarshallingTestsStructuredUnion *union_)
6980 {
6981 switch (union_->type)
6982 {
6983 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_BOXED_STRUCT:
6984 g_free (union_->boxed_struct.parent.string_);
6985 g_strfreev (union_->boxed_struct.parent.g_strv);
6986 break;
6987
6988 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_BOXED_STRUCT_PTR:
6989 g_boxed_free (gi_marshalling_tests_boxed_struct_get_type (), union_->boxed_struct_ptr.parent);
6990 break;
6991
6992 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_NONE:
6993 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_SINGLE_UNION:
6994 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_POINTER_STRUCT:
6995 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_SIMPLE_STRUCT:
6996 case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_NESTED_STRUCT:
6997 break;
6998
6999 default:
7000 g_assert_not_reached ();
7001 }
7002
7003 g_free (union_);
7004 }
7005
7006 GType
7007 gi_marshalling_tests_structured_union_get_type (void)
7008 {
7009 static GType type = 0;
7010
7011 if (type == 0)
7012 {
7013 type = g_boxed_type_register_static ("GIMarshallingTestsStructuredUnion",
7014 (GBoxedCopyFunc)
7015 gi_marshalling_tests_structured_union_copy,
7016 (GBoxedFreeFunc) gi_marshalling_tests_structured_union_free);
7017 }
7018
7019 return type;
7020 }
7021
7022 GIMarshallingTestsStructuredUnionType
7023 gi_marshalling_tests_structured_union_type (GIMarshallingTestsStructuredUnion *structured_union)
7024 {
7025 return structured_union->type;
7026 }
7027
7028 enum
7029 {
7030 PROP_0,
7031 PROP_INT_
7032 };
7033
7034 static void
7035 gi_marshalling_tests_object_real_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in);
7036
7037 G_DEFINE_TYPE (GIMarshallingTestsObject, gi_marshalling_tests_object, G_TYPE_OBJECT);
7038
7039 static void
7040 gi_marshalling_tests_object_init (GIMarshallingTestsObject *self G_GNUC_UNUSED)
7041 {
7042 }
7043
7044 static void
7045 gi_marshalling_tests_object_finalize (GObject *object)
7046 {
7047 G_OBJECT_CLASS (gi_marshalling_tests_object_parent_class)->finalize (object);
7048 }
7049
7050 static void
7051 gi_marshalling_tests_object_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
7052 {
7053 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
7054
7055 switch (prop_id)
7056 {
7057 case PROP_INT_:
7058 GI_MARSHALLING_TESTS_OBJECT (object)->int_ = g_value_get_int (value);
7059 break;
7060 default:
7061 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
7062 break;
7063 }
7064 }
7065
7066 static void
7067 gi_marshalling_tests_object_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
7068 {
7069 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
7070
7071 switch (prop_id)
7072 {
7073 case PROP_INT_:
7074 g_value_set_int (value, GI_MARSHALLING_TESTS_OBJECT (object)->int_);
7075 break;
7076 default:
7077 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
7078 break;
7079 }
7080 }
7081
7082 static void
7083 gi_marshalling_tests_object_class_init (GIMarshallingTestsObjectClass *klass)
7084 {
7085 GObjectClass *object_class = G_OBJECT_CLASS (klass);
7086 #if 0
7087 GObjectClass *parent_class = G_OBJECT_CLASS (klass);
7088 #endif
7089
7090 object_class->finalize = gi_marshalling_tests_object_finalize;
7091 object_class->set_property = gi_marshalling_tests_object_set_property;
7092 object_class->get_property = gi_marshalling_tests_object_get_property;
7093
7094 g_object_class_install_property (object_class, PROP_INT_,
7095 g_param_spec_int ("int", "Integer",
7096 "An integer", G_MININT,
7097 G_MAXINT, 0,
7098 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
7099
7100 klass->method_with_default_implementation = gi_marshalling_tests_object_real_method_with_default_implementation;
7101 }
7102
7103 void
7104 gi_marshalling_tests_object_static_method (void)
7105 {
7106 }
7107
7108 void
7109 gi_marshalling_tests_object_method (GIMarshallingTestsObject *object)
7110 {
7111 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
7112 g_assert_cmpint (object->int_, ==, 42);
7113 }
7114
7115 void
7116 gi_marshalling_tests_object_overridden_method (GIMarshallingTestsObject *object)
7117 {
7118 g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
7119 g_assert_cmpint (object->int_, ==, 0);
7120 }
7121
7122 GIMarshallingTestsObject *
7123 gi_marshalling_tests_object_new (gint int_)
7124 {
7125 return g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, "int", int_, NULL);
7126 }
7127
7128 GIMarshallingTestsObject *
7129 gi_marshalling_tests_object_new_fail (gint int_ G_GNUC_UNUSED,
7130 GError **error)
7131 {
7132 g_return_val_if_fail (error == NULL || *error == NULL, NULL);
7133
7134 g_set_error_literal (error,
7135 g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN),
7136 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
7137 GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
7138
7139 return NULL;
7140 }
7141
7142 /**
7143 * gi_marshalling_tests_object_method_array_in:
7144 * @ints: (array length=length):
7145 */
7146 void
7147 gi_marshalling_tests_object_method_array_in (GIMarshallingTestsObject *self G_GNUC_UNUSED,
7148 const gint *ints,
7149 gint length)
7150 {
7151 g_assert_cmpint (length, ==, 4);
7152 g_assert_cmpint (ints[0], ==, -1);
7153 g_assert_cmpint (ints[1], ==, 0);
7154 g_assert_cmpint (ints[2], ==, 1);
7155 g_assert_cmpint (ints[3], ==, 2);
7156 }
7157
7158 /**
7159 * gi_marshalling_tests_object_method_array_out:
7160 * @ints: (out) (array length=length) (transfer none):
7161 */
7162 void
7163 gi_marshalling_tests_object_method_array_out (GIMarshallingTestsObject *self G_GNUC_UNUSED,
7164 gint **ints,
7165 gint *length)
7166 {
7167 static gint values[] = { -1, 0, 1, 2 };
7168
7169 *length = 4;
7170 *ints = values;
7171 }
7172
7173 /**
7174 * gi_marshalling_tests_object_method_array_inout:
7175 * @ints: (inout) (array length=length) (transfer none):
7176 * @length: (inout):
7177 */
7178 void
7179 gi_marshalling_tests_object_method_array_inout (GIMarshallingTestsObject *self G_GNUC_UNUSED,
7180 gint **ints,
7181 gint *length)
7182 {
7183 static gint values[] = { -2, -1, 0, 1, 2 };
7184
7185 g_assert_cmpint (*length, ==, 4);
7186 g_assert_cmpint ((*ints)[0], ==, -1);
7187 g_assert_cmpint ((*ints)[1], ==, 0);
7188 g_assert_cmpint ((*ints)[2], ==, 1);
7189 g_assert_cmpint ((*ints)[3], ==, 2);
7190
7191 *length = 5;
7192 *ints = values;
7193 }
7194
7195 /**
7196 * gi_marshalling_tests_object_method_array_return:
7197 *
7198 * Returns: (array length=length):
7199 */
7200 const gint *
7201 gi_marshalling_tests_object_method_array_return (GIMarshallingTestsObject *self G_GNUC_UNUSED,
7202 gint *length)
7203 {
7204 static gint ints[] = { -1, 0, 1, 2 };
7205
7206 *length = 4;
7207 return ints;
7208 }
7209
7210 /**
7211 * gi_marshalling_tests_object_method_int8_in:
7212 * @in: (in):
7213 */
7214 void
7215 gi_marshalling_tests_object_method_int8_in (GIMarshallingTestsObject *self, gint8 in)
7216 {
7217 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_in (self, in);
7218 }
7219
7220 /**
7221 * gi_marshalling_tests_object_method_int8_out:
7222 * @out: (out):
7223 */
7224 void
7225 gi_marshalling_tests_object_method_int8_out (GIMarshallingTestsObject *self, gint8 *out)
7226 {
7227 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_out (self, out);
7228 }
7229
7230 /**
7231 * gi_marshalling_tests_object_method_int8_arg_and_out_caller:
7232 * @out: (out):
7233 */
7234 void
7235 gi_marshalling_tests_object_method_int8_arg_and_out_caller (GIMarshallingTestsObject *self, gint8 arg, gint8 *out)
7236 {
7237 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_arg_and_out_caller (self, arg, out);
7238 }
7239
7240 /**
7241 * gi_marshalling_tests_object_method_int8_arg_and_out_callee:
7242 * @out: (out):
7243 */
7244 void
7245 gi_marshalling_tests_object_method_int8_arg_and_out_callee (GIMarshallingTestsObject *self, gint8 arg, gint8 **out)
7246 {
7247 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_arg_and_out_callee (self, arg, out);
7248 }
7249
7250 /**
7251 * gi_marshalling_tests_object_method_str_arg_out_ret:
7252 * @out: (out):
7253 *
7254 * Returns: (transfer none)
7255 */
7256 const gchar *
7257 gi_marshalling_tests_object_method_str_arg_out_ret (GIMarshallingTestsObject *self, const gchar *arg, guint *out)
7258 {
7259 return GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_str_arg_out_ret (self, arg, out);
7260 }
7261
7262 /**
7263 * gi_marshalling_tests_object_method_with_default_implementation:
7264 * @in: (in):
7265 */
7266 void
7267 gi_marshalling_tests_object_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
7268 {
7269 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_with_default_implementation (self, in);
7270 }
7271
7272 static void
7273 gi_marshalling_tests_object_real_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
7274 {
7275 GValue val = {
7276 0,
7277 };
7278 g_value_init (&val, G_TYPE_INT);
7279 g_value_set_int (&val, in);
7280 g_object_set_property (G_OBJECT (self), "int", &val);
7281 }
7282
7283 /**
7284 * gi_marshalling_tests_object_vfunc_with_callback: (virtual vfunc_with_callback)
7285 * @callback: (scope call) (closure callback_data):
7286 * @callback_data: (allow-none):
7287 */
7288 void
7289 gi_marshalling_tests_object_vfunc_with_callback (GIMarshallingTestsObject *self G_GNUC_UNUSED,
7290 GIMarshallingTestsCallbackIntInt callback G_GNUC_UNUSED,
7291 void *callback_data G_GNUC_UNUSED)
7292 {
7293 }
7294
7295 static int
7296 _callback (int val, void *user_data)
7297 {
7298 g_assert (user_data == (gpointer) 0xdeadbeef);
7299 return val;
7300 }
7301
7302 void
7303 gi_marshalling_tests_object_call_vfunc_with_callback (GIMarshallingTestsObject *object)
7304 {
7305 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (object)->vfunc_with_callback (object, _callback, (void *) 0xdeadbeef);
7306 }
7307
7308 /**
7309 * gi_marshalling_tests_object_none_return:
7310 *
7311 * Returns: (transfer none):
7312 */
7313 GIMarshallingTestsObject *
7314 gi_marshalling_tests_object_none_return (void)
7315 {
7316 static GIMarshallingTestsObject *object = NULL;
7317
7318 if (object == NULL)
7319 {
7320 object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
7321 }
7322
7323 return object;
7324 }
7325
7326 /**
7327 * gi_marshalling_tests_object_full_return:
7328 *
7329 * Returns: (transfer full):
7330 */
7331 GIMarshallingTestsObject *
7332 gi_marshalling_tests_object_full_return (void)
7333 {
7334 return g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
7335 }
7336
7337 /**
7338 * gi_marshalling_tests_object_none_in:
7339 * @object: (transfer none):
7340 */
7341 void
7342 gi_marshalling_tests_object_none_in (GIMarshallingTestsObject *object)
7343 {
7344 g_assert_cmpint (object->int_, ==, 42);
7345 }
7346
7347 /**
7348 * gi_marshalling_tests_object_none_out:
7349 * @object: (out) (transfer none):
7350 */
7351 void
7352 gi_marshalling_tests_object_none_out (GIMarshallingTestsObject **object)
7353 {
7354 static GIMarshallingTestsObject *new_object = NULL;
7355
7356 if (new_object == NULL)
7357 {
7358 new_object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
7359 }
7360
7361 *object = new_object;
7362 }
7363
7364 /**
7365 * gi_marshalling_tests_object_none_out_uninitialized:
7366 * @v: (out) (transfer none):
7367 */
7368 gboolean
7369 gi_marshalling_tests_object_none_out_uninitialized (GIMarshallingTestsObject **v G_GNUC_UNUSED)
7370 {
7371 return FALSE;
7372 }
7373
7374 /**
7375 * gi_marshalling_tests_object_full_out:
7376 * @object: (out) (transfer full):
7377 */
7378 void
7379 gi_marshalling_tests_object_full_out (GIMarshallingTestsObject **object)
7380 {
7381 *object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
7382 }
7383
7384 /**
7385 * gi_marshalling_tests_object_full_out_uninitialized:
7386 * @v: (out) (transfer full):
7387 */
7388 gboolean
7389 gi_marshalling_tests_object_full_out_uninitialized (GIMarshallingTestsObject **v G_GNUC_UNUSED)
7390 {
7391 return FALSE;
7392 }
7393
7394 /**
7395 * gi_marshalling_tests_object_none_inout:
7396 * @object: (inout) (transfer none):
7397 */
7398 void
7399 gi_marshalling_tests_object_none_inout (GIMarshallingTestsObject **object)
7400 {
7401 static GIMarshallingTestsObject *new_object = NULL;
7402
7403 g_assert_cmpint ((*object)->int_, ==, 42);
7404
7405 if (new_object == NULL)
7406 {
7407 new_object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
7408 new_object->int_ = 0;
7409 }
7410
7411 *object = new_object;
7412 }
7413
7414 /**
7415 * gi_marshalling_tests_object_full_inout:
7416 * @object: (inout) (transfer full):
7417 */
7418 void
7419 gi_marshalling_tests_object_full_inout (GIMarshallingTestsObject **object)
7420 {
7421 g_assert_cmpint ((*object)->int_, ==, 42);
7422
7423 g_object_unref (*object);
7424 *object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
7425 }
7426
7427 /**
7428 * gi_marshalling_tests_object_int8_in:
7429 * @in: (in):
7430 */
7431 void
7432 gi_marshalling_tests_object_int8_in (GIMarshallingTestsObject *object, gint8 in)
7433 {
7434 gi_marshalling_tests_object_method_int8_in (object, in);
7435 }
7436
7437 /**
7438 * gi_marshalling_tests_object_int8_out:
7439 * @out: (out):
7440 */
7441 void
7442 gi_marshalling_tests_object_int8_out (GIMarshallingTestsObject *object, gint8 *out)
7443 {
7444 gi_marshalling_tests_object_method_int8_out (object, out);
7445 }
7446
7447 /**
7448 * gi_marshalling_tests_object_vfunc_return_value_only:
7449 */
7450 glong
7451 gi_marshalling_tests_object_vfunc_return_value_only (GIMarshallingTestsObject *self)
7452 {
7453 /* make sure that local variables don't get smashed */
7454 glong return_value;
7455 gulong local = 0x12345678;
7456 return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_only (self);
7457 g_assert_cmpint (local, ==, 0x12345678);
7458 return return_value;
7459 }
7460
7461 /**
7462 * gi_marshalling_tests_object_vfunc_one_out_parameter:
7463 * @a: (out):
7464 */
7465 void
7466 gi_marshalling_tests_object_vfunc_one_out_parameter (GIMarshallingTestsObject *self, gfloat *a)
7467 {
7468 /* make sure that local variables don't get smashed */
7469 gulong local = 0x12345678;
7470 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_one_out_parameter (self, a);
7471 g_assert_cmpint (local, ==, 0x12345678);
7472 }
7473
7474 /**
7475 * gi_marshalling_tests_object_vfunc_one_inout_parameter:
7476 * @a: (inout):
7477 */
7478 void
7479 gi_marshalling_tests_object_vfunc_one_inout_parameter (GIMarshallingTestsObject *self, gfloat *a)
7480 {
7481 /* make sure that local variables don't get smashed */
7482 gulong local = 0x12345678;
7483 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_one_inout_parameter (self, a);
7484 g_assert_cmpint (local, ==, 0x12345678);
7485 }
7486
7487 /**
7488 * gi_marshalling_tests_object_vfunc_multiple_inout_parameters:
7489 * @a: (inout):
7490 * @b: (inout):
7491 */
7492 void
7493 gi_marshalling_tests_object_vfunc_multiple_inout_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b)
7494 {
7495 /* make sure that local variables don't get smashed */
7496 gulong local = 0x12345678;
7497 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_multiple_inout_parameters (self, a, b);
7498 g_assert_cmpint (local, ==, 0x12345678);
7499 }
7500
7501 /**
7502 * gi_marshalling_tests_object_vfunc_multiple_out_parameters:
7503 * @a: (out):
7504 * @b: (out):
7505 */
7506 void
7507 gi_marshalling_tests_object_vfunc_multiple_out_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b)
7508 {
7509 /* make sure that local variables don't get smashed */
7510 gulong local = 0x12345678;
7511 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_multiple_out_parameters (self, a, b);
7512 g_assert_cmpint (local, ==, 0x12345678);
7513 }
7514
7515 /**
7516 * gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter:
7517 * @a: (out):
7518 */
7519 void
7520 gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter (GIMarshallingTestsObject *self, GValue *a)
7521 {
7522 /* make sure that local variables don't get smashed */
7523 gulong local = 0x12345678;
7524 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_caller_allocated_out_parameter (self, a);
7525 g_assert_cmpint (local, ==, 0x12345678);
7526 }
7527
7528 /**
7529 * gi_marshalling_tests_object_vfunc_array_out_parameter:
7530 * @a: (out) (array zero-terminated):
7531 */
7532 void
7533 gi_marshalling_tests_object_vfunc_array_out_parameter (GIMarshallingTestsObject *self, gfloat **a)
7534 {
7535 /* make sure that local variables don't get smashed */
7536 gulong local = 0x12345678;
7537 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_array_out_parameter (self, a);
7538 g_assert_cmpint (local, ==, 0x12345678);
7539 }
7540
7541 /**
7542 * gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter:
7543 * @a: (out):
7544 */
7545 glong
7546 gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter (GIMarshallingTestsObject *self, glong *a)
7547 {
7548 /* make sure that local variables don't get smashed */
7549 gulong return_value;
7550 gulong local = 0x12345678;
7551 return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_one_out_parameter (self, a);
7552 g_assert_cmpint (local, ==, 0x12345678);
7553 return return_value;
7554 }
7555
7556 /**
7557 * gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters:
7558 * @a: (out):
7559 * @b: (out):
7560 */
7561 glong
7562 gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters (GIMarshallingTestsObject *self, glong *a, glong *b)
7563 {
7564 gulong return_value;
7565 gulong local = 0x12345678;
7566 return_value =
7567 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_multiple_out_parameters (self, a, b);
7568 g_assert_cmpint (local, ==, 0x12345678);
7569 return return_value;
7570 }
7571
7572 /**
7573 * gi_marshalling_tests_object_vfunc_return_value_and_one_inout_parameter:
7574 * @a: (inout):
7575 */
7576 glong
7577 gi_marshalling_tests_object_vfunc_return_value_and_one_inout_parameter (GIMarshallingTestsObject *self, glong *a)
7578 {
7579 /* make sure that local variables don't get smashed */
7580 gulong return_value;
7581 gulong local = 0x12345678;
7582 return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_one_inout_parameter (self, a);
7583 g_assert_cmpint (local, ==, 0x12345678);
7584 return return_value;
7585 }
7586
7587 /**
7588 * gi_marshalling_tests_object_vfunc_return_value_and_multiple_inout_parameters:
7589 * @a: (inout):
7590 * @b: (inout):
7591 */
7592 glong
7593 gi_marshalling_tests_object_vfunc_return_value_and_multiple_inout_parameters (GIMarshallingTestsObject *self, glong *a, glong *b)
7594 {
7595 gulong return_value;
7596 gulong local = 0x12345678;
7597 return_value =
7598 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_multiple_inout_parameters (self, a, b);
7599 g_assert_cmpint (local, ==, 0x12345678);
7600 return return_value;
7601 }
7602
7603 /**
7604 * gi_marshalling_tests_callback_owned_boxed:
7605 * @callback: (scope call) (closure callback_data):
7606 * @callback_data: (allow-none):
7607 */
7608 glong
7609 gi_marshalling_tests_callback_owned_boxed (GIMarshallingTestsCallbackOwnedBoxed callback,
7610 void *callback_data)
7611 {
7612 static GIMarshallingTestsBoxedStruct *box = NULL;
7613 glong ret;
7614
7615 if (!box)
7616 box = gi_marshalling_tests_boxed_struct_new ();
7617 box->long_++;
7618 callback (box, callback_data);
7619 ret = box->long_;
7620 return ret;
7621 }
7622
7623 /**
7624 * gi_marshalling_tests_callback_user_data_after_callback:
7625 * @a:
7626 * @b:
7627 * @callback: (scope call) (closure user_data):
7628 * @user_data:
7629 */
7630 void
7631 gi_marshalling_tests_callback_user_data_after_callback (gint a,
7632 gint b,
7633 GIMarshallingTestsCallbackWithTwoParametersAndUserData callback,
7634 gpointer user_data)
7635 {
7636 callback (a, b, user_data);
7637 }
7638
7639 /**
7640 * gi_marshalling_tests_callback_user_data_before_callback:
7641 * @a:
7642 * @b:
7643 * @user_data:
7644 * @callback: (scope call) (closure user_data):
7645 */
7646 void
7647 gi_marshalling_tests_callback_user_data_before_callback (gint a,
7648 gint b,
7649 gpointer user_data,
7650 GIMarshallingTestsCallbackWithTwoParametersAndUserData callback)
7651 {
7652 callback (a, b, user_data);
7653 }
7654
7655 gboolean
7656 gi_marshalling_tests_object_vfunc_meth_with_error (GIMarshallingTestsObject *self, gint x, GError **error)
7657 {
7658 gulong local = 0x12345678;
7659 gboolean ret = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_meth_with_err (self,
7660 x,
7661 error);
7662 g_assert_cmpint (local, ==, 0x12345678);
7663 return ret;
7664 }
7665
7666 /**
7667 * gi_marshalling_tests_object_vfunc_return_enum:
7668 */
7669 GIMarshallingTestsEnum
7670 gi_marshalling_tests_object_vfunc_return_enum (GIMarshallingTestsObject *self)
7671 {
7672 /* make sure that local variables don't get smashed */
7673 GIMarshallingTestsEnum return_value;
7674 glong local = 0x12345678;
7675 return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_enum (self);
7676 g_assert_cmpint (local, ==, 0x12345678);
7677 return return_value;
7678 }
7679
7680 /**
7681 * gi_marshalling_tests_object_vfunc_out_enum:
7682 * @_enum: (out):
7683 */
7684 void
7685 gi_marshalling_tests_object_vfunc_out_enum (GIMarshallingTestsObject *self, GIMarshallingTestsEnum *_enum)
7686 {
7687 /* make sure that local variables don't get smashed */
7688 gulong local = 0x12345678;
7689 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_out_enum (self, _enum);
7690 g_assert_cmpint (local, ==, 0x12345678);
7691 }
7692
7693 /**
7694 * gi_marshalling_tests_object_vfunc_return_flags:
7695 */
7696 GIMarshallingTestsFlags
7697 gi_marshalling_tests_object_vfunc_return_flags (GIMarshallingTestsObject *self)
7698 {
7699 /* make sure that local variables don't get smashed */
7700 GIMarshallingTestsFlags return_value;
7701 glong local = 0x12345678;
7702 return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_flags (self);
7703 g_assert_cmpint (local, ==, 0x12345678);
7704 return return_value;
7705 }
7706
7707 /**
7708 * gi_marshalling_tests_object_vfunc_static_name:
7709 */
7710 gchar *
7711 gi_marshalling_tests_object_vfunc_static_name (void)
7712 {
7713 GIMarshallingTestsObjectClass *klass;
7714 klass = g_type_class_peek_static (GI_MARSHALLING_TESTS_TYPE_OBJECT);
7715 if (klass->vfunc_static_name)
7716 return klass->vfunc_static_name ();
7717
7718 return g_strdup (g_type_name (GI_MARSHALLING_TESTS_TYPE_OBJECT));
7719 }
7720
7721 /**
7722 * gi_marshalling_tests_object_vfunc_static_typed_name:
7723 * @gtype:
7724 */
7725 gchar *
7726 gi_marshalling_tests_object_vfunc_static_typed_name (GType gtype)
7727 {
7728 GIMarshallingTestsObjectClass *klass;
7729
7730 g_return_val_if_fail (g_type_is_a (gtype, GI_MARSHALLING_TESTS_TYPE_OBJECT),
7731 NULL);
7732
7733 klass = g_type_class_peek_static (gtype);
7734 if (klass->vfunc_static_name)
7735 return klass->vfunc_static_name ();
7736
7737 return g_strdup (g_type_name (GI_MARSHALLING_TESTS_TYPE_OBJECT));
7738 }
7739
7740 /**
7741 * gi_marshalling_tests_object_vfunc_static_create_new:
7742 * @gtype:
7743 * @int_:
7744 */
7745 GIMarshallingTestsObject *
7746 gi_marshalling_tests_object_vfunc_static_create_new (GType gtype, gint int_)
7747 {
7748 GIMarshallingTestsObjectClass *klass;
7749
7750 g_return_val_if_fail (g_type_is_a (gtype, GI_MARSHALLING_TESTS_TYPE_OBJECT),
7751 NULL);
7752
7753 klass = g_type_class_peek (gtype);
7754 if (klass->vfunc_static_create_new)
7755 return klass->vfunc_static_create_new (int_);
7756
7757 return gi_marshalling_tests_object_new (int_);
7758 }
7759
7760 /**
7761 * gi_marshalling_tests_object_vfunc_static_create_new_out:
7762 * @out: (out): We keep this as first parameter to ensure it's parsed properly
7763 * @gtype:
7764 * @int_:
7765 */
7766 void
7767 gi_marshalling_tests_object_vfunc_static_create_new_out (GIMarshallingTestsObject **out,
7768 GType gtype,
7769 gint int_)
7770 {
7771 GIMarshallingTestsObjectClass *klass;
7772
7773 g_return_if_fail (g_type_is_a (gtype, GI_MARSHALLING_TESTS_TYPE_OBJECT));
7774
7775 klass = g_type_class_peek (gtype);
7776 if (klass->vfunc_static_create_new_out)
7777 return klass->vfunc_static_create_new_out (out, int_);
7778
7779 *out = gi_marshalling_tests_object_new (int_);
7780 }
7781
7782 /**
7783 * gi_marshalling_tests_object_vfunc_out_flags:
7784 * @flags: (out):
7785 */
7786 void
7787 gi_marshalling_tests_object_vfunc_out_flags (GIMarshallingTestsObject *self, GIMarshallingTestsFlags *flags)
7788 {
7789 /* make sure that local variables don't get smashed */
7790 gulong local = 0x12345678;
7791 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_out_flags (self, flags);
7792 g_assert_cmpuint (local, ==, 0x12345678);
7793 }
7794
7795 /* NOTE:
7796 *
7797 * The following (get_ref_info_for_*) methods are designed to call vfuncs related
7798 * to object argument marshaling. They do not pass the resulting objects through them
7799 * as regular vfunc wrapper method do, but rather return reference count and floating
7800 * information back to the callers. This is useful because callers can do testing of
7801 * expected reference counts in isolation and from the perspective of C. This is important
7802 * because if there are bugs in the reverse marshaling, they can obfuscate or compound
7803 * bugs in marshaling from the vfuncs.
7804 */
7805
7806 /**
7807 * gi_marshalling_tests_object_get_ref_info_for_vfunc_return_object_transfer_none:
7808 * @ref_count: (out): Ref count of the object returned from the vfunc directly after vfunc call.
7809 * @is_floating: (out): Floating state object returned from the vfunc directly after vfunc call.
7810 */
7811 void
7812 gi_marshalling_tests_object_get_ref_info_for_vfunc_return_object_transfer_none (GIMarshallingTestsObject *self, guint *ref_count, gboolean *is_floating)
7813 {
7814 GObject *object = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_object_transfer_none (self);
7815 *ref_count = object->ref_count;
7816 *is_floating = g_object_is_floating (object);
7817
7818 /* Attempt to sink and unref the returned object and avoid any potential leaks */
7819 g_object_ref_sink (object);
7820 g_object_unref (object);
7821 }
7822
7823 /**
7824 * gi_marshalling_tests_object_get_ref_info_for_vfunc_return_object_transfer_full:
7825 * @ref_count: (out): Ref count of the object returned from the vfunc directly after vfunc call.
7826 * @is_floating: (out): Floating state object returned from the vfunc directly after vfunc call.
7827 */
7828 void
7829 gi_marshalling_tests_object_get_ref_info_for_vfunc_return_object_transfer_full (GIMarshallingTestsObject *self, guint *ref_count, gboolean *is_floating)
7830 {
7831 GObject *object = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_object_transfer_full (self);
7832 *ref_count = object->ref_count;
7833 *is_floating = g_object_is_floating (object);
7834 g_object_unref (object);
7835 }
7836
7837 /**
7838 * gi_marshalling_tests_object_get_ref_info_for_vfunc_out_object_transfer_none:
7839 * @ref_count: (out): Ref count of the object returned from the vfunc directly after vfunc call.
7840 * @is_floating: (out): Floating state object returned from the vfunc directly after vfunc call.
7841 */
7842 void
7843 gi_marshalling_tests_object_get_ref_info_for_vfunc_out_object_transfer_none (GIMarshallingTestsObject *self, guint *ref_count, gboolean *is_floating)
7844 {
7845 GObject *object = NULL;
7846 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_out_object_transfer_none (self, &object);
7847 *ref_count = object->ref_count;
7848 *is_floating = g_object_is_floating (object);
7849
7850 /* Attempt to sink and unref the returned object and avoid any potential leaks */
7851 g_object_ref_sink (object);
7852 g_object_unref (object);
7853 }
7854
7855 /**
7856 * gi_marshalling_tests_object_get_ref_info_for_vfunc_out_object_transfer_full:
7857 * @ref_count: (out): Ref count of the object returned from the vfunc directly after vfunc call.
7858 * @is_floating: (out): Floating state object returned from the vfunc directly after vfunc call.
7859 */
7860 void
7861 gi_marshalling_tests_object_get_ref_info_for_vfunc_out_object_transfer_full (GIMarshallingTestsObject *self, guint *ref_count, gboolean *is_floating)
7862 {
7863 GObject *object = NULL;
7864 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_out_object_transfer_full (self, &object);
7865 *ref_count = object->ref_count;
7866 *is_floating = g_object_is_floating (object);
7867 g_object_unref (object);
7868 }
7869
7870 static void
7871 _vfunc_in_object_destroy_callback (gboolean *destroy_called,
7872 GObject *where_the_object_was G_GNUC_UNUSED)
7873 {
7874 *destroy_called = TRUE;
7875 }
7876
7877 /**
7878 * gi_marshalling_tests_object_get_ref_info_for_vfunc_in_object_transfer_none:
7879 * @type: GType of object to create and pass as in argument to the vfunc
7880 * @ref_count: (out): Ref count of the in object directly after vfunc call.
7881 * @is_floating: (out): Floating state of in object directly after vfunc call.
7882 *
7883 * Calls vfunc_in_object_transfer_none with a new object of the given type.
7884 */
7885 void
7886 gi_marshalling_tests_object_get_ref_info_for_vfunc_in_object_transfer_none (GIMarshallingTestsObject *self, GType type, guint *ref_count, gboolean *is_floating)
7887 {
7888 static gboolean destroy_called;
7889 GObject *object;
7890 destroy_called = FALSE;
7891
7892 object = g_object_new (type, NULL);
7893 g_object_weak_ref (object, (GWeakNotify) _vfunc_in_object_destroy_callback, &destroy_called);
7894
7895 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_in_object_transfer_none (self, object);
7896 if (destroy_called)
7897 {
7898 *ref_count = 0;
7899 *is_floating = FALSE;
7900 }
7901 else
7902 {
7903 *ref_count = object->ref_count;
7904 *is_floating = g_object_is_floating (object);
7905 g_object_unref (object);
7906 }
7907 }
7908
7909 /**
7910 * gi_marshalling_tests_object_get_ref_info_for_vfunc_in_object_transfer_full:
7911 * @type: GType of object to create and pass as in argument to the vfunc
7912 * @ref_count: (out): Ref count of the in object directly after vfunc call.
7913 * @is_floating: (out): Floating state of in object directly after vfunc call.
7914 */
7915 void
7916 gi_marshalling_tests_object_get_ref_info_for_vfunc_in_object_transfer_full (GIMarshallingTestsObject *self, GType type, guint *ref_count, gboolean *is_floating)
7917 {
7918 static gboolean destroy_called;
7919 GObject *object;
7920 destroy_called = FALSE;
7921
7922 object = g_object_new (type, NULL);
7923 g_object_weak_ref (object, (GWeakNotify) _vfunc_in_object_destroy_callback, &destroy_called);
7924
7925 /* Calling the vfunc takes ownership of the object, so we use a weak_ref to determine
7926 * if the object gets destroyed after the call and appropriately return 0 as the ref count.
7927 */
7928 GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_in_object_transfer_full (self, object);
7929 if (destroy_called)
7930 {
7931 *ref_count = 0;
7932 *is_floating = FALSE;
7933 }
7934 else
7935 {
7936 *ref_count = object->ref_count;
7937 *is_floating = g_object_is_floating (object);
7938 }
7939 }
7940
7941 G_DEFINE_TYPE (GIMarshallingTestsSubObject, gi_marshalling_tests_sub_object, GI_MARSHALLING_TESTS_TYPE_OBJECT);
7942
7943 static void
7944 gi_marshalling_tests_sub_object_init (GIMarshallingTestsSubObject *self G_GNUC_UNUSED)
7945 {
7946 }
7947
7948 static void
7949 gi_marshalling_tests_sub_object_finalize (GObject *object)
7950 {
7951 G_OBJECT_CLASS (gi_marshalling_tests_sub_object_parent_class)->finalize (object);
7952 }
7953
7954 static void
7955 method_deep_hierarchy (GIMarshallingTestsObject *self, gint8 in)
7956 {
7957 GValue val = {
7958 0,
7959 };
7960 g_value_init (&val, G_TYPE_INT);
7961 g_value_set_int (&val, in);
7962 g_object_set_property (G_OBJECT (self), "int", &val);
7963 }
7964
7965 static void
7966 gi_marshalling_tests_sub_object_class_init (GIMarshallingTestsSubObjectClass *klass)
7967 {
7968 G_OBJECT_CLASS (klass)->finalize = gi_marshalling_tests_sub_object_finalize;
7969 GI_MARSHALLING_TESTS_OBJECT_CLASS (klass)->method_deep_hierarchy = method_deep_hierarchy;
7970 }
7971
7972 void
7973 gi_marshalling_tests_sub_object_sub_method (GIMarshallingTestsSubObject *object)
7974 {
7975 g_assert_cmpint (GI_MARSHALLING_TESTS_OBJECT (object)->int_, ==, 0);
7976 }
7977
7978 void
7979 gi_marshalling_tests_sub_object_overwritten_method (GIMarshallingTestsSubObject *object)
7980 {
7981 g_assert_cmpint (GI_MARSHALLING_TESTS_OBJECT (object)->int_, ==, 0);
7982 }
7983
7984 G_DEFINE_TYPE (GIMarshallingTestsSubSubObject,
7985 gi_marshalling_tests_sub_sub_object,
7986 GI_MARSHALLING_TESTS_TYPE_SUB_OBJECT);
7987
7988 static void
7989 gi_marshalling_tests_sub_sub_object_init (GIMarshallingTestsSubSubObject *self G_GNUC_UNUSED)
7990 {
7991 }
7992
7993 static void
7994 gi_marshalling_tests_sub_sub_object_class_init (GIMarshallingTestsSubSubObjectClass *klass G_GNUC_UNUSED)
7995 {
7996 }
7997
7998 /* Interfaces */
7999
8000 static void
8001 gi_marshalling_tests_interface_class_init (void *g_iface G_GNUC_UNUSED,
8002 void *data G_GNUC_UNUSED)
8003 {
8004 }
8005
8006 GType
8007 gi_marshalling_tests_interface_get_type (void)
8008 {
8009 static GType type = 0;
8010 if (type == 0)
8011 {
8012 /* Not adding prerequisite here for test purposes */
8013 type = g_type_register_static_simple (G_TYPE_INTERFACE,
8014 "GIMarshallingTestsInterface",
8015 sizeof (GIMarshallingTestsInterfaceIface),
8016 (GClassInitFunc) gi_marshalling_tests_interface_class_init, 0, NULL, 0);
8017 }
8018
8019 return type;
8020 }
8021
8022 /**
8023 * gi_marshalling_tests_interface_test_int8_in:
8024 * @in: (in):
8025 */
8026 void
8027 gi_marshalling_tests_interface_test_int8_in (GIMarshallingTestsInterface *self, gint8 in)
8028 {
8029 GI_MARSHALLING_TESTS_INTERFACE_GET_IFACE (self)->test_int8_in (self, in);
8030 }
8031
8032 /**
8033 * gi_marshalling_tests_test_interface_test_int8_in:
8034 * @in: (in):
8035 */
8036 void
8037 gi_marshalling_tests_test_interface_test_int8_in (GIMarshallingTestsInterface *test_iface, gint8 in)
8038 {
8039 gi_marshalling_tests_interface_test_int8_in (test_iface, in);
8040 }
8041
8042 static void test_interface_init (GIMarshallingTestsInterfaceIface *iface);
8043
8044 G_DEFINE_TYPE_WITH_CODE (GIMarshallingTestsInterfaceImpl, gi_marshalling_tests_interface_impl, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (GI_MARSHALLING_TESTS_TYPE_INTERFACE, test_interface_init))
8045
8046 static void
8047 gi_marshalling_tests_interface_impl_test_int8_in (GIMarshallingTestsInterface *self G_GNUC_UNUSED,
8048 gint8 in G_GNUC_UNUSED)
8049 {
8050 }
8051
8052 static void
8053 test_interface_init (GIMarshallingTestsInterfaceIface *iface)
8054 {
8055 iface->test_int8_in = gi_marshalling_tests_interface_impl_test_int8_in;
8056 }
8057
8058 static void
8059 gi_marshalling_tests_interface_impl_init (GIMarshallingTestsInterfaceImpl *self G_GNUC_UNUSED)
8060 {
8061 }
8062
8063 static void
8064 gi_marshalling_tests_interface_impl_class_init (GIMarshallingTestsInterfaceImplClass *klass G_GNUC_UNUSED)
8065 {
8066 }
8067
8068 /**
8069 * gi_marshalling_tests_interface_impl_get_as_interface:
8070 *
8071 * Returns: (transfer none):
8072 */
8073 GIMarshallingTestsInterface *
8074 gi_marshalling_tests_interface_impl_get_as_interface (GIMarshallingTestsInterfaceImpl *self)
8075 {
8076 return (GIMarshallingTestsInterface *) self;
8077 }
8078
8079 static void
8080 gi_marshalling_tests_interface2_class_init (void *g_iface G_GNUC_UNUSED,
8081 void *data G_GNUC_UNUSED)
8082 {
8083 }
8084
8085 GType
8086 gi_marshalling_tests_interface2_get_type (void)
8087 {
8088 static GType type = 0;
8089 if (type == 0)
8090 {
8091 type = g_type_register_static_simple (G_TYPE_INTERFACE,
8092 "GIMarshallingTestsInterface2",
8093 sizeof (GIMarshallingTestsInterface2Iface),
8094 (GClassInitFunc) gi_marshalling_tests_interface2_class_init, 0, NULL, 0);
8095 }
8096
8097 return type;
8098 }
8099
8100 static void
8101 gi_marshalling_tests_interface3_class_init (void *g_iface G_GNUC_UNUSED,
8102 void *data G_GNUC_UNUSED)
8103 {
8104 }
8105
8106 GType
8107 gi_marshalling_tests_interface3_get_type (void)
8108 {
8109 static GType type = 0;
8110 if (type == 0)
8111 {
8112 type = g_type_register_static_simple (G_TYPE_INTERFACE,
8113 "GIMarshallingTestsInterface3",
8114 sizeof (GIMarshallingTestsInterface3Iface),
8115 (GClassInitFunc) gi_marshalling_tests_interface3_class_init, 0, NULL, 0);
8116 }
8117
8118 return type;
8119 }
8120
8121 /**
8122 * gi_marshalling_tests_interface3_test_variant_array_in:
8123 * @in: (array length=n_in):
8124 * @n_in:
8125 */
8126 void
8127 gi_marshalling_tests_interface3_test_variant_array_in (GIMarshallingTestsInterface3 *self, GVariant **in, gsize n_in)
8128 {
8129 GI_MARSHALLING_TESTS_INTERFACE3_GET_IFACE (self)->test_variant_array_in (self, in, n_in);
8130 }
8131
8132 /**
8133 * gi_marshalling_tests_int_out_out:
8134 * @int0: (out):
8135 * @int1: (out):
8136 */
8137 void
8138 gi_marshalling_tests_int_out_out (gint *int0, gint *int1)
8139 {
8140 *int0 = 6;
8141 *int1 = 7;
8142 }
8143
8144 /**
8145 * gi_marshalling_tests_int_three_in_three_out:
8146 * @a: (in):
8147 * @b: (in):
8148 * @c: (in):
8149 * @out0: (out):
8150 * @out1: (out):
8151 * @out2: (out):
8152 */
8153 void
8154 gi_marshalling_tests_int_three_in_three_out (gint a, gint b, gint c, gint *out0, gint *out1, gint *out2)
8155 {
8156 *out0 = a;
8157 *out1 = b;
8158 *out2 = c;
8159 }
8160
8161 /**
8162 * gi_marshalling_tests_int_return_out:
8163 * @int_: (out):
8164 */
8165 gint
8166 gi_marshalling_tests_int_return_out (gint *int_)
8167 {
8168 *int_ = 7;
8169 return 6;
8170 }
8171
8172 /**
8173 * gi_marshalling_tests_int_two_in_utf8_two_in_with_allow_none:
8174 * @a: (in): Must be 1
8175 * @b: (in): Must be 2
8176 * @c: (in) (allow-none): Must be "3" or NULL
8177 * @d: (in) (allow-none): Must be "4" or NULL
8178 */
8179 void
8180 gi_marshalling_tests_int_two_in_utf8_two_in_with_allow_none (gint a, gint b, const gchar *c, const gchar *d)
8181 {
8182 g_assert_cmpint (a, ==, 1);
8183 g_assert_cmpint (b, ==, 2);
8184 if (c != NULL)
8185 g_assert_cmpstr (c, ==, "3");
8186 if (d != NULL)
8187 g_assert_cmpstr (d, ==, "4");
8188 }
8189
8190 /**
8191 * gi_marshalling_tests_int_one_in_utf8_two_in_one_allows_none:
8192 * @a: (in): Must be 1
8193 * @b: (in) (allow-none): Must be "2" or NULL
8194 * @c: (in): Must be "3"
8195 */
8196 void
8197 gi_marshalling_tests_int_one_in_utf8_two_in_one_allows_none (gint a, const gchar *b, const gchar *c)
8198 {
8199 g_assert_cmpint (a, ==, 1);
8200 if (b != NULL)
8201 g_assert_cmpstr (b, ==, "2");
8202 g_assert_cmpstr (c, ==, "3");
8203 }
8204
8205 /**
8206 * gi_marshalling_tests_array_in_utf8_two_in:
8207 * @ints: (array length=length):
8208 * @length:
8209 * @a: (in) (allow-none): Must be "1" or NULL
8210 * @b: (in) (allow-none): Must be "2" or NULL
8211 */
8212 void
8213 gi_marshalling_tests_array_in_utf8_two_in (const gint *ints, gint length, const gchar *a, const gchar *b)
8214 {
8215 g_assert_cmpint (length, ==, 4);
8216 g_assert_cmpint (ints[0], ==, -1);
8217 g_assert_cmpint (ints[1], ==, 0);
8218 g_assert_cmpint (ints[2], ==, 1);
8219 g_assert_cmpint (ints[3], ==, 2);
8220
8221 if (a != NULL)
8222 g_assert_cmpstr (a, ==, "1");
8223 if (b != NULL)
8224 g_assert_cmpstr (b, ==, "2");
8225 }
8226
8227 /**
8228 * gi_marshalling_tests_array_in_utf8_two_in_out_of_order:
8229 * @length:
8230 * @a: (in) (allow-none): Must be "1" or NULL
8231 * @ints: (array length=length):
8232 * @b: (in) (allow-none): Must be "2" or NULL
8233 */
8234 void
8235 gi_marshalling_tests_array_in_utf8_two_in_out_of_order (gint length, const gchar *a, const gint *ints, const gchar *b)
8236 {
8237 g_assert_cmpint (length, ==, 4);
8238 g_assert_cmpint (ints[0], ==, -1);
8239 g_assert_cmpint (ints[1], ==, 0);
8240 g_assert_cmpint (ints[2], ==, 1);
8241 g_assert_cmpint (ints[3], ==, 2);
8242
8243 if (a != NULL)
8244 g_assert_cmpstr (a, ==, "1");
8245 if (b != NULL)
8246 g_assert_cmpstr (b, ==, "2");
8247 }
8248
8249 /* GError */
8250
8251 void
8252 gi_marshalling_tests_gerror (GError **error)
8253 {
8254 GQuark quark = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
8255 g_set_error_literal (error, quark,
8256 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE, GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
8257 }
8258
8259 /**
8260 * gi_marshalling_tests_gerror_array_in:
8261 * @in_ints: (array zero-terminated):
8262 */
8263 void
8264 gi_marshalling_tests_gerror_array_in (gint *in_ints G_GNUC_UNUSED,
8265 GError **error)
8266 {
8267 GQuark quark = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
8268 g_set_error_literal (error, quark,
8269 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE, GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
8270 }
8271
8272 /**
8273 * gi_marshalling_tests_gerror_out:
8274 * @error: (out) (allow-none) (transfer full): location for the GError.
8275 * @debug: (out) (allow-none) (transfer full): location for the debug message
8276 *
8277 * Inspired by gst_message_parse_error.
8278 */
8279 void
8280 gi_marshalling_tests_gerror_out (GError **error, gchar **debug)
8281 {
8282 GQuark quark = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
8283 g_set_error_literal (error, quark,
8284 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE, GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
8285
8286 if (debug != NULL)
8287 {
8288 *debug = g_strdup (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE);
8289 }
8290 }
8291
8292 /**
8293 * gi_marshalling_tests_gerror_out_uninitialized:
8294 * @v: (out) (allow-none) (transfer full):
8295 * @v2: (out) (allow-none) (transfer full):
8296 */
8297 gboolean
8298 gi_marshalling_tests_gerror_out_uninitialized (GError **v G_GNUC_UNUSED, gchar **v2 G_GNUC_UNUSED)
8299 {
8300 return FALSE;
8301 }
8302
8303 /**
8304 * gi_marshalling_tests_gerror_out_transfer_none:
8305 * @err: (out) (allow-none) (transfer none): location for the GError.
8306 * @debug: (out) (allow-none) (transfer none): location for the debug message
8307 *
8308 * A variant of gi_marshalling_tests_gerror_out() which returns data the caller
8309 * must not free.
8310 */
8311 void
8312 gi_marshalling_tests_gerror_out_transfer_none (GError **err, const gchar **debug)
8313 {
8314 static GError error = { 0,
8315 GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
8316 (gchar *) GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE };
8317 error.domain = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
8318 *err = &error;
8319 *debug = GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE;
8320 }
8321
8322 /**
8323 * gi_marshalling_tests_gerror_out_transfer_none_uninitialized:
8324 * @v: (out) (allow-none) (transfer none):
8325 * @v2: (out) (allow-none) (transfer none):
8326 */
8327 gboolean
8328 gi_marshalling_tests_gerror_out_transfer_none_uninitialized (GError **v G_GNUC_UNUSED, const gchar **v2 G_GNUC_UNUSED)
8329 {
8330 return FALSE;
8331 }
8332
8333 /**
8334 * gi_marshalling_tests_gerror_return:
8335 *
8336 * Yet another variant of gi_marshalling_tests_gerror_out().
8337 *
8338 * Returns: (transfer full): a GError
8339 */
8340 GError *
8341 gi_marshalling_tests_gerror_return (void)
8342 {
8343 GQuark quark = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
8344
8345 return g_error_new_literal (quark, GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE, GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
8346 }
8347
8348 static GIMarshallingTestsOverridesStruct *
8349 gi_marshalling_tests_overrides_struct_copy (GIMarshallingTestsOverridesStruct *struct_)
8350 {
8351 GIMarshallingTestsOverridesStruct *new_struct;
8352
8353 new_struct = g_slice_new (GIMarshallingTestsOverridesStruct);
8354
8355 *new_struct = *struct_;
8356
8357 return new_struct;
8358 }
8359
8360 static void
8361 gi_marshalling_tests_overrides_struct_free (GIMarshallingTestsOverridesStruct *struct_)
8362 {
8363 g_slice_free (GIMarshallingTestsOverridesStruct, struct_);
8364 }
8365
8366 GType
8367 gi_marshalling_tests_overrides_struct_get_type (void)
8368 {
8369 static GType type = 0;
8370
8371 if (type == 0)
8372 {
8373 type =
8374 g_boxed_type_register_static ("GIMarshallingTestsOverridesStruct",
8375 (GBoxedCopyFunc)
8376 gi_marshalling_tests_overrides_struct_copy,
8377 (GBoxedFreeFunc) gi_marshalling_tests_overrides_struct_free);
8378 }
8379
8380 return type;
8381 }
8382
8383 GIMarshallingTestsOverridesStruct *
8384 gi_marshalling_tests_overrides_struct_new (void)
8385 {
8386 return g_slice_new (GIMarshallingTestsOverridesStruct);
8387 }
8388
8389 glong
8390 gi_marshalling_tests_overrides_struct_method (GIMarshallingTestsOverridesStruct *self G_GNUC_UNUSED)
8391 {
8392 return 42;
8393 }
8394
8395 /**
8396 * gi_marshalling_tests_overrides_struct_returnv:
8397 *
8398 * Returns: (transfer full):
8399 */
8400 GIMarshallingTestsOverridesStruct *
8401 gi_marshalling_tests_overrides_struct_returnv (void)
8402 {
8403 return gi_marshalling_tests_overrides_struct_new ();
8404 }
8405
8406 G_DEFINE_TYPE (GIMarshallingTestsOverridesObject, gi_marshalling_tests_overrides_object, G_TYPE_OBJECT);
8407
8408 static void
8409 gi_marshalling_tests_overrides_object_init (GIMarshallingTestsOverridesObject *self G_GNUC_UNUSED)
8410 {
8411 }
8412
8413 static void
8414 gi_marshalling_tests_overrides_object_finalize (GObject *object)
8415 {
8416 G_OBJECT_CLASS (gi_marshalling_tests_overrides_object_parent_class)->finalize (object);
8417 }
8418
8419 static void
8420 gi_marshalling_tests_overrides_object_class_init (GIMarshallingTestsOverridesObjectClass *klass)
8421 {
8422 GObjectClass *object_class = G_OBJECT_CLASS (klass);
8423 #if 0
8424 GObjectClass *parent_class = G_OBJECT_CLASS (klass);
8425 #endif
8426
8427 object_class->finalize = gi_marshalling_tests_overrides_object_finalize;
8428 }
8429
8430 GIMarshallingTestsOverridesObject *
8431 gi_marshalling_tests_overrides_object_new (void)
8432 {
8433 return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
8434 }
8435
8436 glong
8437 gi_marshalling_tests_overrides_object_method (GIMarshallingTestsOverridesObject *self G_GNUC_UNUSED)
8438 {
8439 return 42;
8440 }
8441
8442 /**
8443 * gi_marshalling_tests_overrides_object_returnv:
8444 *
8445 * Returns: (transfer full):
8446 */
8447 GIMarshallingTestsOverridesObject *
8448 gi_marshalling_tests_overrides_object_returnv (void)
8449 {
8450 return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
8451 }
8452
8453 /**
8454 * gi_marshalling_tests_filename_list_return:
8455 *
8456 * Returns: (transfer none) (element-type filename): List of filenames
8457 */
8458 GSList *
8459 gi_marshalling_tests_filename_list_return (void)
8460 {
8461 return NULL;
8462 }
8463
8464 /**
8465 * gi_marshalling_tests_param_spec_in_bool:
8466 */
8467 void
8468 gi_marshalling_tests_param_spec_in_bool (const GParamSpec *param)
8469 {
8470 g_assert (G_IS_PARAM_SPEC (param));
8471 g_assert_cmpint (G_PARAM_SPEC_VALUE_TYPE (param), ==, G_TYPE_BOOLEAN);
8472 g_assert_cmpstr (g_param_spec_get_name ((GParamSpec *) param), ==, "mybool");
8473 }
8474
8475 /**
8476 * gi_marshalling_tests_param_spec_return:
8477 *
8478 * Returns: (transfer full): a #GParamSpec
8479 */
8480 GParamSpec *
8481 gi_marshalling_tests_param_spec_return (void)
8482 {
8483 return g_param_spec_string ("test-param", "test", "This is a test", "42", G_PARAM_READABLE);
8484 }
8485
8486 /**
8487 * gi_marshalling_tests_param_spec_out:
8488 * @param: (out):
8489 */
8490 void
8491 gi_marshalling_tests_param_spec_out (GParamSpec **param)
8492 {
8493 *param = g_param_spec_string ("test-param", "test", "This is a test", "42", G_PARAM_READABLE);
8494 }
8495
8496 /**
8497 * gi_marshalling_tests_param_spec_out_uninitialized:
8498 * @v: (out):
8499 */
8500 gboolean
8501 gi_marshalling_tests_param_spec_out_uninitialized (GParamSpec **v G_GNUC_UNUSED)
8502 {
8503 return FALSE;
8504 }
8505
8506 enum
8507 {
8508 DUMMY_PROPERTY,
8509 SOME_BOOLEAN_PROPERTY,
8510 SOME_CHAR_PROPERTY,
8511 SOME_UCHAR_PROPERTY,
8512 SOME_INT_PROPERTY,
8513 SOME_UINT_PROPERTY,
8514 SOME_LONG_PROPERTY,
8515 SOME_ULONG_PROPERTY,
8516 SOME_INT64_PROPERTY,
8517 SOME_UINT64_PROPERTY,
8518 SOME_FLOAT_PROPERTY,
8519 SOME_STRING_PROPERTY,
8520 SOME_DOUBLE_PROPERTY,
8521 SOME_STRV_PROPERTY,
8522 SOME_BOXED_STRUCT_PROPERTY,
8523 SOME_VARIANT_PROPERTY,
8524 SOME_BOXED_GLIST_PROPERTY,
8525 SOME_GVALUE_PROPERTY,
8526 SOME_OBJECT_PROPERTY,
8527 SOME_FLAGS_PROPERTY,
8528 SOME_ENUM_PROPERTY,
8529 SOME_BYTE_ARRAY_PROPERTY,
8530 SOME_HASH_TABLE_PROPERTY,
8531 SOME_READONLY_PROPERTY,
8532 SOME_DEPRECATED_INT_PROPERTY,
8533 N_PROPERTIES
8534 };
8535
8536 G_DEFINE_TYPE (GIMarshallingTestsPropertiesObject, gi_marshalling_tests_properties_object, G_TYPE_OBJECT);
8537
8538 static void
8539 gi_marshalling_tests_properties_object_init (GIMarshallingTestsPropertiesObject *self G_GNUC_UNUSED)
8540 {
8541 }
8542
8543 static void
8544 gi_marshalling_tests_properties_object_finalize (GObject *obj)
8545 {
8546 GIMarshallingTestsPropertiesObject *self;
8547 self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (obj);
8548
8549 if (self->some_gvalue)
8550 {
8551 g_boxed_free (G_TYPE_VALUE, self->some_gvalue);
8552 self->some_gvalue = NULL;
8553 }
8554
8555 g_clear_pointer (&self->some_string, g_free);
8556 g_clear_pointer (&self->some_strv, g_strfreev);
8557 g_clear_pointer (&self->some_boxed_struct, gi_marshalling_tests_boxed_struct_free);
8558 g_clear_pointer (&self->some_byte_array, g_byte_array_unref);
8559 g_clear_pointer (&self->some_hash_table, g_hash_table_unref);
8560 g_clear_pointer (&self->some_variant, g_variant_unref);
8561 g_clear_pointer (&self->some_boxed_glist, g_list_free);
8562 g_clear_object (&self->some_object);
8563
8564 G_OBJECT_CLASS (gi_marshalling_tests_properties_object_parent_class)->finalize (obj);
8565 }
8566
8567 static void
8568 gi_marshalling_tests_properties_object_get_property (GObject *object,
8569 guint property_id,
8570 GValue *value,
8571 GParamSpec *pspec)
8572 {
8573 GIMarshallingTestsPropertiesObject *self;
8574 self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
8575 switch (property_id)
8576 {
8577 case SOME_BOOLEAN_PROPERTY:
8578 g_value_set_boolean (value, self->some_boolean);
8579 break;
8580 case SOME_CHAR_PROPERTY:
8581 g_value_set_schar (value, self->some_char);
8582 break;
8583 case SOME_UCHAR_PROPERTY:
8584 g_value_set_uchar (value, self->some_uchar);
8585 break;
8586 case SOME_INT_PROPERTY:
8587 g_value_set_int (value, self->some_int);
8588 break;
8589 case SOME_UINT_PROPERTY:
8590 g_value_set_uint (value, self->some_uint);
8591 break;
8592 case SOME_LONG_PROPERTY:
8593 g_value_set_long (value, self->some_long);
8594 break;
8595 case SOME_ULONG_PROPERTY:
8596 g_value_set_ulong (value, self->some_ulong);
8597 break;
8598 case SOME_INT64_PROPERTY:
8599 g_value_set_int64 (value, self->some_int64);
8600 break;
8601 case SOME_UINT64_PROPERTY:
8602 g_value_set_uint64 (value, self->some_uint64);
8603 break;
8604 case SOME_FLOAT_PROPERTY:
8605 g_value_set_float (value, self->some_float);
8606 break;
8607 case SOME_DOUBLE_PROPERTY:
8608 g_value_set_double (value, self->some_double);
8609 break;
8610 case SOME_STRING_PROPERTY:
8611 g_value_set_string (value, self->some_string);
8612 break;
8613 case SOME_STRV_PROPERTY:
8614 g_value_set_boxed (value, self->some_strv);
8615 break;
8616 case SOME_BOXED_STRUCT_PROPERTY:
8617 g_value_set_boxed (value, self->some_boxed_struct);
8618 break;
8619 case SOME_BOXED_GLIST_PROPERTY:
8620 g_value_set_boxed (value, self->some_boxed_glist);
8621 break;
8622 case SOME_GVALUE_PROPERTY:
8623 g_value_set_boxed (value, self->some_gvalue);
8624 break;
8625 case SOME_VARIANT_PROPERTY:
8626 g_value_set_variant (value, self->some_variant);
8627 break;
8628 case SOME_OBJECT_PROPERTY:
8629 g_value_set_object (value, self->some_object);
8630 break;
8631 case SOME_FLAGS_PROPERTY:
8632 g_value_set_flags (value, self->some_flags);
8633 break;
8634 case SOME_ENUM_PROPERTY:
8635 g_value_set_enum (value, self->some_enum);
8636 break;
8637 case SOME_BYTE_ARRAY_PROPERTY:
8638 g_value_set_boxed (value, self->some_byte_array);
8639 break;
8640 case SOME_HASH_TABLE_PROPERTY:
8641 g_value_set_boxed (value, self->some_hash_table);
8642 break;
8643 case SOME_READONLY_PROPERTY:
8644 g_value_set_int (value, 42);
8645 break;
8646 case SOME_DEPRECATED_INT_PROPERTY:
8647 g_value_set_int (value, self->some_deprecated_int);
8648 break;
8649 default:
8650 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
8651 break;
8652 }
8653 }
8654
8655 static void
8656 gi_marshalling_tests_properties_object_set_property (GObject *object,
8657 guint property_id,
8658 const GValue *value,
8659 GParamSpec *pspec)
8660 {
8661 GIMarshallingTestsPropertiesObject *self;
8662 self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
8663 switch (property_id)
8664 {
8665 case SOME_BOOLEAN_PROPERTY:
8666 self->some_boolean = g_value_get_boolean (value);
8667 break;
8668 case SOME_CHAR_PROPERTY:
8669 self->some_char = g_value_get_schar (value);
8670 break;
8671 case SOME_UCHAR_PROPERTY:
8672 self->some_uchar = g_value_get_uchar (value);
8673 break;
8674 case SOME_INT_PROPERTY:
8675 self->some_int = g_value_get_int (value);
8676 break;
8677 case SOME_UINT_PROPERTY:
8678 self->some_uint = g_value_get_uint (value);
8679 break;
8680 case SOME_LONG_PROPERTY:
8681 self->some_long = g_value_get_long (value);
8682 break;
8683 case SOME_ULONG_PROPERTY:
8684 self->some_ulong = g_value_get_ulong (value);
8685 break;
8686 case SOME_INT64_PROPERTY:
8687 self->some_int64 = g_value_get_int64 (value);
8688 break;
8689 case SOME_UINT64_PROPERTY:
8690 self->some_uint64 = g_value_get_uint64 (value);
8691 break;
8692 case SOME_FLOAT_PROPERTY:
8693 self->some_float = g_value_get_float (value);
8694 break;
8695 case SOME_DOUBLE_PROPERTY:
8696 self->some_double = g_value_get_double (value);
8697 break;
8698 case SOME_STRING_PROPERTY:
8699 g_clear_pointer (&self->some_string, g_free);
8700 self->some_string = g_value_dup_string (value);
8701 break;
8702 case SOME_STRV_PROPERTY:
8703 g_strfreev (self->some_strv);
8704 self->some_strv = g_strdupv (g_value_get_boxed (value));
8705 break;
8706 case SOME_BOXED_STRUCT_PROPERTY:
8707 gi_marshalling_tests_boxed_struct_free (self->some_boxed_struct);
8708 self->some_boxed_struct = gi_marshalling_tests_boxed_struct_copy (g_value_get_boxed (value));
8709 break;
8710 case SOME_BOXED_GLIST_PROPERTY:
8711 g_list_free (self->some_boxed_glist);
8712 self->some_boxed_glist = g_list_copy (g_value_get_boxed (value));
8713 break;
8714 case SOME_GVALUE_PROPERTY:
8715 if (self->some_gvalue)
8716 g_boxed_free (G_TYPE_VALUE, self->some_gvalue);
8717 self->some_gvalue = g_value_dup_boxed (value);
8718 break;
8719 case SOME_VARIANT_PROPERTY:
8720 if (self->some_variant != NULL)
8721 g_variant_unref (self->some_variant);
8722 self->some_variant = g_value_get_variant (value);
8723 if (self->some_variant != NULL)
8724 g_variant_ref (self->some_variant);
8725 break;
8726 case SOME_OBJECT_PROPERTY:
8727 if (self->some_object != NULL)
8728 g_object_unref (self->some_object);
8729 self->some_object = g_value_dup_object (value);
8730 break;
8731 case SOME_FLAGS_PROPERTY:
8732 self->some_flags = g_value_get_flags (value);
8733 break;
8734 case SOME_ENUM_PROPERTY:
8735 self->some_enum = g_value_get_enum (value);
8736 break;
8737 case SOME_BYTE_ARRAY_PROPERTY:
8738 if (self->some_byte_array != NULL)
8739 g_byte_array_unref (self->some_byte_array);
8740 self->some_byte_array = g_value_dup_boxed (value);
8741 break;
8742 case SOME_HASH_TABLE_PROPERTY:
8743 g_clear_pointer (&self->some_hash_table, g_hash_table_unref);
8744 self->some_hash_table = g_value_dup_boxed (value);
8745 break;
8746 case SOME_DEPRECATED_INT_PROPERTY:
8747 self->some_deprecated_int = g_value_get_int (value);
8748 break;
8749 default:
8750 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
8751 break;
8752 }
8753 }
8754
8755 static GParamSpec *properties_object_properties[N_PROPERTIES] = {
8756 NULL,
8757 };
8758
8759 static void
8760 gi_marshalling_tests_properties_object_class_init (GIMarshallingTestsPropertiesObjectClass *klass)
8761 {
8762 GObjectClass *object_class = G_OBJECT_CLASS (klass);
8763
8764 object_class->finalize = gi_marshalling_tests_properties_object_finalize;
8765 object_class->get_property = gi_marshalling_tests_properties_object_get_property;
8766 object_class->set_property = gi_marshalling_tests_properties_object_set_property;
8767
8768 properties_object_properties[SOME_BOOLEAN_PROPERTY] =
8769 g_param_spec_boolean ("some-boolean",
8770 "some-boolean",
8771 "some-boolean",
8772 FALSE,
8773 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8774
8775 properties_object_properties[SOME_CHAR_PROPERTY] =
8776 g_param_spec_char ("some-char",
8777 "some-char",
8778 "some-char", G_MININT8,
8779 G_MAXINT8, 0,
8780 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8781
8782 properties_object_properties[SOME_UCHAR_PROPERTY] =
8783 g_param_spec_uchar ("some-uchar",
8784 "some-uchar",
8785 "some-uchar", 0,
8786 G_MAXUINT8, 0,
8787 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8788
8789 properties_object_properties[SOME_INT_PROPERTY] =
8790 g_param_spec_int ("some-int", "some-int",
8791 "some-int", G_MININT,
8792 G_MAXINT, 0,
8793 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8794
8795 properties_object_properties[SOME_UINT_PROPERTY] =
8796 g_param_spec_uint ("some-uint",
8797 "some-uint",
8798 "some-uint", 0,
8799 G_MAXUINT, 0,
8800 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8801
8802 properties_object_properties[SOME_LONG_PROPERTY] =
8803 g_param_spec_long ("some-long",
8804 "some-long",
8805 "some-long", G_MINLONG,
8806 G_MAXLONG, 0,
8807 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8808
8809 properties_object_properties[SOME_ULONG_PROPERTY] =
8810 g_param_spec_ulong ("some-ulong",
8811 "some-ulong",
8812 "some-ulong", 0,
8813 G_MAXULONG, 0,
8814 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8815
8816 properties_object_properties[SOME_INT64_PROPERTY] =
8817 g_param_spec_int64 ("some-int64",
8818 "some-int64",
8819 "some-int64",
8820 G_MININT64, G_MAXINT64,
8821 0, G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8822
8823 properties_object_properties[SOME_UINT64_PROPERTY] =
8824 g_param_spec_uint64 ("some-uint64",
8825 "some-uint64",
8826 "some-uint64", 0,
8827 G_MAXUINT64, 0,
8828 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8829
8830 properties_object_properties[SOME_FLOAT_PROPERTY] =
8831 g_param_spec_float ("some-float",
8832 "some-float",
8833 "some-float",
8834 -1 * G_MAXFLOAT,
8835 G_MAXFLOAT, 0,
8836 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8837
8838 properties_object_properties[SOME_DOUBLE_PROPERTY] =
8839 g_param_spec_double ("some-double",
8840 "some-double",
8841 "some-double",
8842 -1 * G_MAXDOUBLE,
8843 G_MAXDOUBLE, 0,
8844 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8845
8846 properties_object_properties[SOME_STRING_PROPERTY] =
8847 g_param_spec_string ("some-string",
8848 "some-string",
8849 "some-string",
8850 NULL,
8851 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8852
8853 properties_object_properties[SOME_STRV_PROPERTY] =
8854 g_param_spec_boxed ("some-strv",
8855 "some-strv",
8856 "some-strv",
8857 G_TYPE_STRV,
8858 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8859
8860 properties_object_properties[SOME_BOXED_STRUCT_PROPERTY] =
8861 g_param_spec_boxed ("some-boxed-struct",
8862 "some-boxed-struct",
8863 "some-boxed-struct",
8864 gi_marshalling_tests_boxed_struct_get_type (), G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8865
8866 /**
8867 * GIMarshallingTestsPropertiesObject:some-boxed-glist: (type GLib.List(gint)) (transfer none):
8868 */
8869 properties_object_properties[SOME_BOXED_GLIST_PROPERTY] =
8870 g_param_spec_boxed ("some-boxed-glist",
8871 "some-boxed-glist",
8872 "some-boxed-glist",
8873 gi_marshalling_tests_boxed_glist_get_type (), G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8874
8875 properties_object_properties[SOME_GVALUE_PROPERTY] =
8876 g_param_spec_boxed ("some-gvalue",
8877 "some-gvalue",
8878 "some-gvalue",
8879 G_TYPE_VALUE,
8880 G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
8881
8882 properties_object_properties[SOME_VARIANT_PROPERTY] =
8883 g_param_spec_variant ("some-variant",
8884 "some-variant",
8885 "some-variant",
8886 G_VARIANT_TYPE_ANY,
8887 NULL,
8888 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8889
8890 properties_object_properties[SOME_OBJECT_PROPERTY] =
8891 g_param_spec_object ("some-object",
8892 "some-object",
8893 "some-object",
8894 G_TYPE_OBJECT,
8895 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8896
8897 properties_object_properties[SOME_FLAGS_PROPERTY] =
8898 g_param_spec_flags ("some-flags",
8899 "some-flags",
8900 "some-flags",
8901 GI_MARSHALLING_TESTS_TYPE_FLAGS,
8902 GI_MARSHALLING_TESTS_FLAGS_VALUE1,
8903 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8904
8905 properties_object_properties[SOME_ENUM_PROPERTY] =
8906 g_param_spec_enum ("some-enum",
8907 "some-enum",
8908 "some-enum",
8909 GI_MARSHALLING_TESTS_TYPE_GENUM,
8910 GI_MARSHALLING_TESTS_GENUM_VALUE1,
8911 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
8912
8913 properties_object_properties[SOME_BYTE_ARRAY_PROPERTY] =
8914 g_param_spec_boxed ("some-byte-array",
8915 "some-byte-array",
8916 "some-byte-array",
8917 G_TYPE_BYTE_ARRAY,
8918 G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
8919
8920 /**
8921 * GIMarshallingTestsPropertiesObject:some-hash-table: (type GLib.HashTable(gint32,utf8))
8922 */
8923 properties_object_properties[SOME_HASH_TABLE_PROPERTY] =
8924 g_param_spec_boxed ("some-hash-table",
8925 "some-hash-table",
8926 "some-hash-table",
8927 G_TYPE_HASH_TABLE,
8928 G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
8929
8930 properties_object_properties[SOME_READONLY_PROPERTY] =
8931 g_param_spec_int ("some-readonly",
8932 "some-readonly",
8933 "some-readonly",
8934 G_MININT, G_MAXINT, 0,
8935 G_PARAM_READABLE);
8936
8937 properties_object_properties[SOME_DEPRECATED_INT_PROPERTY] =
8938 g_param_spec_int ("some-deprecated-int", "some-deprecated-int",
8939 "some-deprecated-int", G_MININT,
8940 G_MAXINT, 0,
8941 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT | G_PARAM_DEPRECATED);
8942
8943 g_object_class_install_properties (object_class, N_PROPERTIES, properties_object_properties);
8944 }
8945
8946 GIMarshallingTestsPropertiesObject *
8947 gi_marshalling_tests_properties_object_new (void)
8948 {
8949 return g_object_new (GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT, NULL);
8950 }
8951
8952 G_DEFINE_FINAL_TYPE (GIMarshallingTestsPropertiesAccessorsObject,
8953 gi_marshalling_tests_properties_accessors_object,
8954 G_TYPE_OBJECT)
8955
8956 GIMarshallingTestsPropertiesAccessorsObject *
8957 gi_marshalling_tests_properties_accessors_object_new (void)
8958 {
8959 return g_object_new (GI_MARSHALLING_TESTS_TYPE_ACCESSORS_TESTS_PROPERTIES_OBJECT, NULL);
8960 }
8961
8962 static void
8963 gi_marshalling_tests_properties_accessors_object_init (GIMarshallingTestsPropertiesAccessorsObject *self G_GNUC_UNUSED)
8964 {
8965 }
8966
8967 static void
8968 gi_marshalling_tests_properties_accessors_object_get_property (GObject *object,
8969 guint property_id,
8970 GValue *value,
8971 GParamSpec *pspec)
8972 {
8973 GIMarshallingTestsPropertiesAccessorsObject *self;
8974 self = GI_MARSHALLING_TESTS_PROPERTIES_ACCESSORS_OBJECT (object);
8975
8976 switch (property_id)
8977 {
8978 case SOME_BOOLEAN_PROPERTY:
8979 g_value_set_boolean (value, self->some_boolean);
8980 break;
8981 case SOME_CHAR_PROPERTY:
8982 g_value_set_schar (value, self->some_char);
8983 break;
8984 case SOME_UCHAR_PROPERTY:
8985 g_value_set_uchar (value, self->some_uchar);
8986 break;
8987 case SOME_INT_PROPERTY:
8988 g_value_set_int (value, self->some_int);
8989 break;
8990 case SOME_UINT_PROPERTY:
8991 g_value_set_uint (value, self->some_uint);
8992 break;
8993 case SOME_LONG_PROPERTY:
8994 g_value_set_long (value, self->some_long);
8995 break;
8996 case SOME_ULONG_PROPERTY:
8997 g_value_set_ulong (value, self->some_ulong);
8998 break;
8999 case SOME_INT64_PROPERTY:
9000 g_value_set_int64 (value, self->some_int64);
9001 break;
9002 case SOME_UINT64_PROPERTY:
9003 g_value_set_uint64 (value, self->some_uint64);
9004 break;
9005 case SOME_FLOAT_PROPERTY:
9006 g_value_set_float (value, self->some_float);
9007 break;
9008 case SOME_DOUBLE_PROPERTY:
9009 g_value_set_double (value, self->some_double);
9010 break;
9011 case SOME_STRING_PROPERTY:
9012 g_value_set_string (value, self->some_string);
9013 break;
9014 case SOME_STRV_PROPERTY:
9015 g_value_set_boxed (value, self->some_strv);
9016 break;
9017 case SOME_BOXED_STRUCT_PROPERTY:
9018 g_value_set_boxed (value, self->some_boxed_struct);
9019 break;
9020 case SOME_BOXED_GLIST_PROPERTY:
9021 g_value_set_boxed (value, self->some_boxed_glist);
9022 break;
9023 case SOME_GVALUE_PROPERTY:
9024 g_value_set_boxed (value, self->some_gvalue);
9025 break;
9026 case SOME_VARIANT_PROPERTY:
9027 g_value_set_variant (value, self->some_variant);
9028 break;
9029 case SOME_OBJECT_PROPERTY:
9030 g_value_set_object (value, self->some_object);
9031 break;
9032 case SOME_FLAGS_PROPERTY:
9033 g_value_set_flags (value, self->some_flags);
9034 break;
9035 case SOME_ENUM_PROPERTY:
9036 g_value_set_enum (value, self->some_enum);
9037 break;
9038 case SOME_BYTE_ARRAY_PROPERTY:
9039 g_value_set_boxed (value, self->some_byte_array);
9040 break;
9041 case SOME_HASH_TABLE_PROPERTY:
9042 g_value_set_boxed (value, self->some_hash_table);
9043 break;
9044 case SOME_READONLY_PROPERTY:
9045 g_value_set_int (value, 42);
9046 break;
9047 case SOME_DEPRECATED_INT_PROPERTY:
9048 g_value_set_int (value, self->some_deprecated_int);
9049 break;
9050 default:
9051 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
9052 break;
9053 }
9054 }
9055
9056 static void
9057 gi_marshalling_tests_properties_accessors_object_set_property (GObject *object,
9058 guint property_id,
9059 const GValue *value,
9060 GParamSpec *pspec)
9061 {
9062 GIMarshallingTestsPropertiesAccessorsObject *self;
9063 self = GI_MARSHALLING_TESTS_PROPERTIES_ACCESSORS_OBJECT (object);
9064
9065 switch (property_id)
9066 {
9067 case SOME_BOOLEAN_PROPERTY:
9068 self->some_boolean = g_value_get_boolean (value);
9069 break;
9070 case SOME_CHAR_PROPERTY:
9071 self->some_char = g_value_get_schar (value);
9072 break;
9073 case SOME_UCHAR_PROPERTY:
9074 self->some_uchar = g_value_get_uchar (value);
9075 break;
9076 case SOME_INT_PROPERTY:
9077 self->some_int = g_value_get_int (value);
9078 break;
9079 case SOME_UINT_PROPERTY:
9080 self->some_uint = g_value_get_uint (value);
9081 break;
9082 case SOME_LONG_PROPERTY:
9083 self->some_long = g_value_get_long (value);
9084 break;
9085 case SOME_ULONG_PROPERTY:
9086 self->some_ulong = g_value_get_ulong (value);
9087 break;
9088 case SOME_INT64_PROPERTY:
9089 self->some_int64 = g_value_get_int64 (value);
9090 break;
9091 case SOME_UINT64_PROPERTY:
9092 self->some_uint64 = g_value_get_uint64 (value);
9093 break;
9094 case SOME_FLOAT_PROPERTY:
9095 self->some_float = g_value_get_float (value);
9096 break;
9097 case SOME_DOUBLE_PROPERTY:
9098 self->some_double = g_value_get_double (value);
9099 break;
9100 case SOME_STRING_PROPERTY:
9101 g_clear_pointer (&self->some_string, g_free);
9102 self->some_string = g_value_dup_string (value);
9103 break;
9104 case SOME_STRV_PROPERTY:
9105 g_strfreev (self->some_strv);
9106 self->some_strv = g_strdupv (g_value_get_boxed (value));
9107 break;
9108 case SOME_BOXED_STRUCT_PROPERTY:
9109 gi_marshalling_tests_boxed_struct_free (self->some_boxed_struct);
9110 self->some_boxed_struct = gi_marshalling_tests_boxed_struct_copy (g_value_get_boxed (value));
9111 break;
9112 case SOME_BOXED_GLIST_PROPERTY:
9113 g_list_free (self->some_boxed_glist);
9114 self->some_boxed_glist = g_list_copy (g_value_get_boxed (value));
9115 break;
9116 case SOME_GVALUE_PROPERTY:
9117 if (self->some_gvalue)
9118 g_boxed_free (G_TYPE_VALUE, self->some_gvalue);
9119 self->some_gvalue = g_value_dup_boxed (value);
9120 break;
9121 case SOME_VARIANT_PROPERTY:
9122 if (self->some_variant != NULL)
9123 g_variant_unref (self->some_variant);
9124 self->some_variant = g_value_get_variant (value);
9125 if (self->some_variant != NULL)
9126 g_variant_ref (self->some_variant);
9127 break;
9128 case SOME_OBJECT_PROPERTY:
9129 if (self->some_object != NULL)
9130 g_object_unref (self->some_object);
9131 self->some_object = g_value_dup_object (value);
9132 break;
9133 case SOME_FLAGS_PROPERTY:
9134 self->some_flags = g_value_get_flags (value);
9135 break;
9136 case SOME_ENUM_PROPERTY:
9137 self->some_enum = g_value_get_enum (value);
9138 break;
9139 case SOME_BYTE_ARRAY_PROPERTY:
9140 if (self->some_byte_array != NULL)
9141 g_byte_array_unref (self->some_byte_array);
9142 self->some_byte_array = g_value_dup_boxed (value);
9143 break;
9144 case SOME_HASH_TABLE_PROPERTY:
9145 g_clear_pointer (&self->some_hash_table, g_hash_table_unref);
9146 self->some_hash_table = g_value_dup_boxed (value);
9147 break;
9148 case SOME_DEPRECATED_INT_PROPERTY:
9149 self->some_deprecated_int = g_value_get_int (value);
9150 break;
9151 default:
9152 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
9153 break;
9154 }
9155 }
9156
9157 static void
9158 gi_marshalling_tests_properties_accessors_object_dispose (GObject *obj)
9159 {
9160 GIMarshallingTestsPropertiesAccessorsObject *self;
9161 self = GI_MARSHALLING_TESTS_PROPERTIES_ACCESSORS_OBJECT (obj);
9162
9163 if (self->some_gvalue)
9164 {
9165 g_boxed_free (G_TYPE_VALUE, self->some_gvalue);
9166 self->some_gvalue = NULL;
9167 }
9168
9169 g_clear_pointer (&self->some_string, g_free);
9170 g_clear_pointer (&self->some_strv, g_strfreev);
9171 g_clear_pointer (&self->some_boxed_struct, gi_marshalling_tests_boxed_struct_free);
9172 g_clear_pointer (&self->some_byte_array, g_byte_array_unref);
9173 g_clear_pointer (&self->some_variant, g_variant_unref);
9174 g_clear_pointer (&self->some_boxed_glist, g_list_free);
9175 g_clear_object (&self->some_object);
9176
9177 G_OBJECT_CLASS (gi_marshalling_tests_properties_accessors_object_parent_class)->dispose (obj);
9178 }
9179
9180 static GParamSpec *accessors_object_properties[N_PROPERTIES] = {
9181 NULL,
9182 };
9183
9184 static void
9185 gi_marshalling_tests_properties_accessors_object_class_init (GIMarshallingTestsPropertiesAccessorsObjectClass *klass)
9186 {
9187 GObjectClass *object_class = G_OBJECT_CLASS (klass);
9188
9189 object_class->dispose = gi_marshalling_tests_properties_accessors_object_dispose;
9190 object_class->get_property = gi_marshalling_tests_properties_accessors_object_get_property;
9191 object_class->set_property = gi_marshalling_tests_properties_accessors_object_set_property;
9192
9193 /**
9194 * GIMarshallingTestsPropertiesAccessorsObject:some-boolean: (setter set_boolean) (getter get_boolean):
9195 */
9196 accessors_object_properties[SOME_BOOLEAN_PROPERTY] =
9197 g_param_spec_boolean ("some-boolean",
9198 "some-boolean",
9199 "some-boolean",
9200 FALSE,
9201 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9202
9203 /**
9204 * GIMarshallingTestsPropertiesAccessorsObject:some-char: (setter set_char) (getter get_char):
9205 */
9206 accessors_object_properties[SOME_CHAR_PROPERTY] =
9207 g_param_spec_char ("some-char",
9208 "some-char",
9209 "some-char",
9210 G_MININT8,
9211 G_MAXINT8, 0,
9212 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9213
9214 /**
9215 * GIMarshallingTestsPropertiesAccessorsObject:some-uchar: (setter set_uchar) (getter get_uchar):
9216 */
9217 accessors_object_properties[SOME_UCHAR_PROPERTY] =
9218 g_param_spec_uchar ("some-uchar",
9219 "some-uchar",
9220 "some-uchar", 0,
9221 G_MAXUINT8, 0,
9222 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9223
9224 /**
9225 * GIMarshallingTestsPropertiesAccessorsObject:some-int: (setter set_int) (getter get_int):
9226 */
9227 accessors_object_properties[SOME_INT_PROPERTY] =
9228 g_param_spec_int ("some-int", "some-int",
9229 "some-int", G_MININT,
9230 G_MAXINT, 0,
9231 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9232
9233 /**
9234 * GIMarshallingTestsPropertiesAccessorsObject:some-uint: (setter set_uint) (getter get_uint):
9235 */
9236 accessors_object_properties[SOME_UINT_PROPERTY] =
9237 g_param_spec_uint ("some-uint",
9238 "some-uint",
9239 "some-uint", 0,
9240 G_MAXUINT, 0,
9241 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9242
9243 /**
9244 * GIMarshallingTestsPropertiesAccessorsObject:some-long: (setter set_long) (getter get_long):
9245 */
9246 accessors_object_properties[SOME_LONG_PROPERTY] =
9247 g_param_spec_long ("some-long",
9248 "some-long",
9249 "some-long", G_MINLONG,
9250 G_MAXLONG, 0,
9251 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9252
9253 /**
9254 * GIMarshallingTestsPropertiesAccessorsObject:some-ulong: (setter set_ulong) (getter get_ulong):
9255 */
9256 accessors_object_properties[SOME_ULONG_PROPERTY] =
9257 g_param_spec_ulong ("some-ulong",
9258 "some-ulong",
9259 "some-ulong", 0,
9260 G_MAXULONG, 0,
9261 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9262
9263 /**
9264 * GIMarshallingTestsPropertiesAccessorsObject:some-int64: (setter set_int64) (getter get_int64):
9265 */
9266 accessors_object_properties[SOME_INT64_PROPERTY] =
9267 g_param_spec_int64 ("some-int64",
9268 "some-int64",
9269 "some-int64",
9270 G_MININT64, G_MAXINT64,
9271 0, G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9272
9273 /**
9274 * GIMarshallingTestsPropertiesAccessorsObject:some-uint64: (setter set_uint64) (getter get_uint64):
9275 */
9276 accessors_object_properties[SOME_UINT64_PROPERTY] =
9277 g_param_spec_uint64 ("some-uint64",
9278 "some-uint64",
9279 "some-uint64", 0,
9280 G_MAXUINT64, 0,
9281 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9282
9283 /**
9284 * GIMarshallingTestsPropertiesAccessorsObject:some-float: (setter set_float) (getter get_float):
9285 */
9286 accessors_object_properties[SOME_FLOAT_PROPERTY] =
9287 g_param_spec_float ("some-float",
9288 "some-float",
9289 "some-float",
9290 -1 * G_MAXFLOAT,
9291 G_MAXFLOAT, 0,
9292 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9293
9294 /**
9295 * GIMarshallingTestsPropertiesAccessorsObject:some-double: (setter set_double) (getter get_double):
9296 */
9297 accessors_object_properties[SOME_DOUBLE_PROPERTY] =
9298 g_param_spec_double ("some-double",
9299 "some-double",
9300 "some-double",
9301 -1 * G_MAXDOUBLE,
9302 G_MAXDOUBLE, 0,
9303 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9304
9305 /**
9306 * GIMarshallingTestsPropertiesAccessorsObject:some-string: (setter set_string) (getter get_string):
9307 */
9308 accessors_object_properties[SOME_STRING_PROPERTY] =
9309 g_param_spec_string ("some-string",
9310 "some-string",
9311 "some-string",
9312 NULL,
9313 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9314
9315 /**
9316 * GIMarshallingTestsPropertiesAccessorsObject:some-strv: (setter set_strv) (getter get_strv):
9317 */
9318 accessors_object_properties[SOME_STRV_PROPERTY] =
9319 g_param_spec_boxed ("some-strv",
9320 "some-strv",
9321 "some-strv",
9322 G_TYPE_STRV,
9323 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9324
9325 /**
9326 * GIMarshallingTestsPropertiesAccessorsObject:some-boxed-struct: (setter set_boxed_struct) (getter get_boxed_struct):
9327 */
9328 accessors_object_properties[SOME_BOXED_STRUCT_PROPERTY] =
9329 g_param_spec_boxed ("some-boxed-struct",
9330 "some-boxed-struct",
9331 "some-boxed-struct",
9332 gi_marshalling_tests_boxed_struct_get_type (),
9333 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9334
9335 /**
9336 * GIMarshallingTestsPropertiesAccessorsObject:some-boxed-glist: (type GLib.List(gint)) (transfer none) (setter set_boxed_glist) (getter get_boxed_glist):
9337 */
9338 accessors_object_properties[SOME_BOXED_GLIST_PROPERTY] =
9339 g_param_spec_boxed ("some-boxed-glist",
9340 "some-boxed-glist",
9341 "some-boxed-glist",
9342 gi_marshalling_tests_boxed_glist_get_type (),
9343 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9344
9345 /**
9346 * GIMarshallingTestsPropertiesAccessorsObject:some-gvalue: (setter set_gvalue) (getter get_gvalue):
9347 */
9348 accessors_object_properties[SOME_GVALUE_PROPERTY] =
9349 g_param_spec_boxed ("some-gvalue",
9350 "some-gvalue",
9351 "some-gvalue",
9352 G_TYPE_VALUE,
9353 G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
9354
9355 /**
9356 * GIMarshallingTestsPropertiesAccessorsObject:some-variant: (setter set_variant) (getter get_variant):
9357 */
9358 accessors_object_properties[SOME_VARIANT_PROPERTY] =
9359 g_param_spec_variant ("some-variant",
9360 "some-variant",
9361 "some-variant",
9362 G_VARIANT_TYPE_ANY,
9363 NULL,
9364 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9365
9366 /**
9367 * GIMarshallingTestsPropertiesAccessorsObject:some-object: (setter set_object) (getter get_object):
9368 */
9369 accessors_object_properties[SOME_OBJECT_PROPERTY] =
9370 g_param_spec_object ("some-object",
9371 "some-object",
9372 "some-object",
9373 G_TYPE_OBJECT,
9374 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9375
9376 /**
9377 * GIMarshallingTestsPropertiesAccessorsObject:some-flags: (setter set_flags) (getter get_flags):
9378 */
9379 accessors_object_properties[SOME_FLAGS_PROPERTY] =
9380 g_param_spec_flags ("some-flags",
9381 "some-flags",
9382 "some-flags",
9383 GI_MARSHALLING_TESTS_TYPE_FLAGS,
9384 GI_MARSHALLING_TESTS_FLAGS_VALUE1,
9385 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9386
9387 /**
9388 * GIMarshallingTestsPropertiesAccessorsObject:some-enum: (setter set_enum) (getter get_enum):
9389 */
9390 accessors_object_properties[SOME_ENUM_PROPERTY] =
9391 g_param_spec_enum ("some-enum",
9392 "some-enum",
9393 "some-enum",
9394 GI_MARSHALLING_TESTS_TYPE_GENUM,
9395 GI_MARSHALLING_TESTS_GENUM_VALUE1,
9396 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
9397
9398 /**
9399 * GIMarshallingTestsPropertiesAccessorsObject:some-byte_array: (setter set_byte_array) (getter get_byte_array):
9400 */
9401 accessors_object_properties[SOME_BYTE_ARRAY_PROPERTY] =
9402 g_param_spec_boxed ("some-byte-array",
9403 "some-byte-array",
9404 "some-byte-array",
9405 G_TYPE_BYTE_ARRAY,
9406 G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
9407
9408 /**
9409 * GIMarshallingTestsPropertiesAccessorsObject:some-hash-table: (type GLib.HashTable(gint32,utf8)) (setter set_hash_table) (getter get_hash_table):
9410 */
9411 accessors_object_properties[SOME_HASH_TABLE_PROPERTY] =
9412 g_param_spec_boxed ("some-hash-table",
9413 "some-hash-table",
9414 "some-hash-table",
9415 G_TYPE_HASH_TABLE,
9416 G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
9417
9418 /**
9419 * GIMarshallingTestsPropertiesAccessorsObject:some-readonly: (getter get_readonly):
9420 */
9421 accessors_object_properties[SOME_READONLY_PROPERTY] =
9422 g_param_spec_int ("some-readonly",
9423 "some-readonly",
9424 "some-readonly",
9425 G_MININT, G_MAXINT, 0,
9426 G_PARAM_READABLE);
9427
9428 /**
9429 * GIMarshallingTestsPropertiesAccessorsObject:some-deprecated-int: (setter set_deprecated_int) (getter get_deprecated_int):
9430 * Deprecated: 0.1
9431 */
9432 accessors_object_properties[SOME_DEPRECATED_INT_PROPERTY] =
9433 g_param_spec_int ("some-deprecated-int",
9434 "some-deprecated-int",
9435 "some-deprecated-int",
9436 G_MININT, G_MAXINT, 0,
9437 G_PARAM_READWRITE |
9438 G_PARAM_DEPRECATED);
9439
9440 g_object_class_install_properties (object_class, N_PROPERTIES, accessors_object_properties);
9441 }
9442
9443 /**
9444 * gi_marshalling_tests_properties_accessors_object_set_boolean: (set-property some-boolean)
9445 * @self:
9446 * @some_boolean:
9447 */
9448 void
9449 gi_marshalling_tests_properties_accessors_object_set_boolean (GIMarshallingTestsPropertiesAccessorsObject *self, gboolean some_boolean)
9450 {
9451 if (self->some_boolean == some_boolean)
9452 return;
9453
9454 self->some_boolean = some_boolean;
9455 g_object_notify (G_OBJECT (self), "some-boolean");
9456 }
9457
9458 /**
9459 * gi_marshalling_tests_properties_accessors_object_set_char: (set-property some-char)
9460 * @self:
9461 * @some_char:
9462 */
9463 void
9464 gi_marshalling_tests_properties_accessors_object_set_char (GIMarshallingTestsPropertiesAccessorsObject *self, gchar some_char)
9465 {
9466 if (self->some_char == some_char)
9467 return;
9468
9469 self->some_char = some_char;
9470 g_object_notify (G_OBJECT (self), "some-char");
9471 }
9472
9473 /**
9474 * gi_marshalling_tests_properties_accessors_object_set_uchar: (set-property some-uchar)
9475 * @self:
9476 * @some_uchar:
9477 */
9478 void
9479 gi_marshalling_tests_properties_accessors_object_set_uchar (GIMarshallingTestsPropertiesAccessorsObject *self, guchar some_uchar)
9480 {
9481 if (self->some_uchar == some_uchar)
9482 return;
9483
9484 self->some_uchar = some_uchar;
9485 g_object_notify (G_OBJECT (self), "some-uchar");
9486 }
9487
9488 /**
9489 * gi_marshalling_tests_properties_accessors_object_set_int: (set-property some-int)
9490 * @self:
9491 * @some_int:
9492 */
9493 void
9494 gi_marshalling_tests_properties_accessors_object_set_int (GIMarshallingTestsPropertiesAccessorsObject *self, gint some_int)
9495 {
9496 if (self->some_int == some_int)
9497 return;
9498
9499 self->some_int = some_int;
9500 g_object_notify (G_OBJECT (self), "some-int");
9501 }
9502
9503 /**
9504 * gi_marshalling_tests_properties_accessors_object_set_uint: (set-property some-uint)
9505 * @self:
9506 * @some_uint:
9507 */
9508 void
9509 gi_marshalling_tests_properties_accessors_object_set_uint (GIMarshallingTestsPropertiesAccessorsObject *self, guint some_uint)
9510 {
9511 if (self->some_uint == some_uint)
9512 return;
9513
9514 self->some_uint = some_uint;
9515 g_object_notify (G_OBJECT (self), "some-uint");
9516 }
9517
9518 /**
9519 * gi_marshalling_tests_properties_accessors_object_set_long: (set-property some-long)
9520 * @self:
9521 * @some_long:
9522 */
9523 void
9524 gi_marshalling_tests_properties_accessors_object_set_long (GIMarshallingTestsPropertiesAccessorsObject *self, glong some_long)
9525 {
9526 if (self->some_long == some_long)
9527 return;
9528
9529 self->some_long = some_long;
9530 g_object_notify (G_OBJECT (self), "some-long");
9531 }
9532
9533 /**
9534 * gi_marshalling_tests_properties_accessors_object_set_ulong: (set-property some-ulong)
9535 * @self:
9536 * @some_ulong:
9537 */
9538 void
9539 gi_marshalling_tests_properties_accessors_object_set_ulong (GIMarshallingTestsPropertiesAccessorsObject *self, gulong some_ulong)
9540 {
9541 if (self->some_ulong == some_ulong)
9542 return;
9543
9544 self->some_ulong = some_ulong;
9545 g_object_notify (G_OBJECT (self), "some-ulong");
9546 }
9547
9548 /**
9549 * gi_marshalling_tests_properties_accessors_object_set_int64: (set-property some-int64)
9550 * @self:
9551 * @some_int64:
9552 */
9553 void
9554 gi_marshalling_tests_properties_accessors_object_set_int64 (GIMarshallingTestsPropertiesAccessorsObject *self, gint64 some_int64)
9555 {
9556 if (self->some_int64 == some_int64)
9557 return;
9558
9559 self->some_int64 = some_int64;
9560 g_object_notify (G_OBJECT (self), "some-int64");
9561 }
9562
9563 /**
9564 * gi_marshalling_tests_properties_accessors_object_set_uint64: (set-property some-uint64)
9565 * @self:
9566 * @some_uint64:
9567 */
9568 void
9569 gi_marshalling_tests_properties_accessors_object_set_uint64 (GIMarshallingTestsPropertiesAccessorsObject *self, guint64 some_uint64)
9570 {
9571 if (self->some_uint64 == some_uint64)
9572 return;
9573
9574 self->some_uint64 = some_uint64;
9575 g_object_notify (G_OBJECT (self), "some-uint64");
9576 }
9577
9578 /**
9579 * gi_marshalling_tests_properties_accessors_object_set_float: (set-property some-float)
9580 * @self:
9581 * @some_float:
9582 */
9583 void
9584 gi_marshalling_tests_properties_accessors_object_set_float (GIMarshallingTestsPropertiesAccessorsObject *self, gfloat some_float)
9585 {
9586 if (self->some_float == some_float)
9587 return;
9588
9589 self->some_float = some_float;
9590 g_object_notify (G_OBJECT (self), "some-float");
9591 }
9592
9593 /**
9594 * gi_marshalling_tests_properties_accessors_object_set_double: (set-property some-double)
9595 * @self:
9596 * @some_double:
9597 */
9598 void
9599 gi_marshalling_tests_properties_accessors_object_set_double (GIMarshallingTestsPropertiesAccessorsObject *self, gdouble some_double)
9600 {
9601 if (self->some_double == some_double)
9602 return;
9603
9604 self->some_double = some_double;
9605 g_object_notify (G_OBJECT (self), "some-double");
9606 }
9607
9608 /**
9609 * gi_marshalling_tests_properties_accessors_object_set_string: (set-property some-string)
9610 * @self:
9611 * @some_string:
9612 */
9613 void
9614 gi_marshalling_tests_properties_accessors_object_set_string (GIMarshallingTestsPropertiesAccessorsObject *self, gchar *some_string)
9615 {
9616 if (g_strcmp0 (self->some_string, some_string) == 0)
9617 return;
9618
9619 g_set_str (&self->some_string, some_string);
9620 g_object_notify (G_OBJECT (self), "some-string");
9621 }
9622
9623 /**
9624 * gi_marshalling_tests_properties_accessors_object_set_strv: (set-property some-strv)
9625 * @self:
9626 * @some_strv:
9627 */
9628 void
9629 gi_marshalling_tests_properties_accessors_object_set_strv (GIMarshallingTestsPropertiesAccessorsObject *self, GStrv some_strv)
9630 {
9631 if (self->some_strv == some_strv)
9632 return;
9633
9634 if (self->some_strv && some_strv &&
9635 g_strv_equal ((const char **) self->some_strv, (const char **) some_strv))
9636 return;
9637
9638 g_clear_pointer (&self->some_strv, g_strfreev);
9639 self->some_strv = g_strdupv (some_strv);
9640 g_object_notify (G_OBJECT (self), "some-strv");
9641 }
9642
9643 /**
9644 * gi_marshalling_tests_properties_accessors_object_set_boxed_struct: (set-property some-boxed-struct)
9645 * @self:
9646 * @some_boxed_struct:
9647 */
9648 void
9649 gi_marshalling_tests_properties_accessors_object_set_boxed_struct (GIMarshallingTestsPropertiesAccessorsObject *self, GIMarshallingTestsBoxedStruct *some_boxed_struct)
9650 {
9651 if (self->some_boxed_struct == some_boxed_struct)
9652 return;
9653
9654 g_clear_pointer (&self->some_boxed_struct, gi_marshalling_tests_boxed_struct_free);
9655 self->some_boxed_struct = gi_marshalling_tests_boxed_struct_copy (some_boxed_struct);
9656 g_object_notify (G_OBJECT (self), "some-boxed-struct");
9657 }
9658
9659 /**
9660 * gi_marshalling_tests_properties_accessors_object_set_boxed_glist: (set-property some-boxed-glist)
9661 * @self:
9662 * @some_boxed_glist: (element-type int):
9663 */
9664 void
9665 gi_marshalling_tests_properties_accessors_object_set_boxed_glist (GIMarshallingTestsPropertiesAccessorsObject *self, GList *some_boxed_glist)
9666 {
9667 if (self->some_boxed_glist == some_boxed_glist)
9668 return;
9669
9670 g_clear_pointer (&self->some_boxed_glist, g_list_free);
9671 self->some_boxed_glist = g_list_copy (some_boxed_glist);
9672 g_object_notify (G_OBJECT (self), "some-boxed-glist");
9673 }
9674
9675 /**
9676 * gi_marshalling_tests_properties_accessors_object_set_gvalue: (set-property some-gvalue)
9677 * @self:
9678 * @some_gvalue:
9679 */
9680 void
9681 gi_marshalling_tests_properties_accessors_object_set_gvalue (GIMarshallingTestsPropertiesAccessorsObject *self, GValue *some_gvalue)
9682 {
9683 if (self->some_gvalue == some_gvalue)
9684 return;
9685
9686 if (self->some_gvalue)
9687 g_boxed_free (G_TYPE_VALUE, self->some_gvalue);
9688
9689 self->some_gvalue = g_boxed_copy (G_TYPE_VALUE, some_gvalue);
9690 g_object_notify (G_OBJECT (self), "some-gvalue");
9691 }
9692
9693 /**
9694 * gi_marshalling_tests_properties_accessors_object_set_variant: (set-property some-variant)
9695 * @self:
9696 * @some_variant:
9697 */
9698 void
9699 gi_marshalling_tests_properties_accessors_object_set_variant (GIMarshallingTestsPropertiesAccessorsObject *self, GVariant *some_variant)
9700 {
9701 if (self->some_variant == some_variant)
9702 return;
9703
9704 g_clear_pointer (&self->some_variant, g_variant_unref);
9705 self->some_variant = g_variant_ref_sink (some_variant);
9706 g_object_notify (G_OBJECT (self), "some-variant");
9707 }
9708
9709 /**
9710 * gi_marshalling_tests_properties_accessors_object_set_object: (set-property some-object)
9711 * @self:
9712 * @some_object:
9713 */
9714 void
9715 gi_marshalling_tests_properties_accessors_object_set_object (GIMarshallingTestsPropertiesAccessorsObject *self, GObject *some_object)
9716 {
9717 if (self->some_object == some_object)
9718 return;
9719
9720 g_set_object (&self->some_object, some_object);
9721 g_object_notify (G_OBJECT (self), "some-object");
9722 }
9723
9724 /**
9725 * gi_marshalling_tests_properties_accessors_object_set_flags: (set-property some-flags)
9726 * @self:
9727 * @some_flags:
9728 */
9729 void
9730 gi_marshalling_tests_properties_accessors_object_set_flags (GIMarshallingTestsPropertiesAccessorsObject *self, GIMarshallingTestsFlags some_flags)
9731 {
9732 if (self->some_flags == some_flags)
9733 return;
9734
9735 self->some_flags = some_flags;
9736 g_object_notify (G_OBJECT (self), "some-flags");
9737 }
9738
9739 /**
9740 * gi_marshalling_tests_properties_accessors_object_set_enum: (set-property some-enum)
9741 * @self:
9742 * @some_enum:
9743 */
9744 void
9745 gi_marshalling_tests_properties_accessors_object_set_enum (GIMarshallingTestsPropertiesAccessorsObject *self, GIMarshallingTestsGEnum some_enum)
9746 {
9747 if (self->some_enum == some_enum)
9748 return;
9749
9750 self->some_enum = some_enum;
9751 g_object_notify (G_OBJECT (self), "some-enum");
9752 }
9753
9754 /**
9755 * gi_marshalling_tests_properties_accessors_object_set_byte_array: (set-property some-byte-array)
9756 * @self:
9757 * @some_byte_array:
9758 */
9759 void
9760 gi_marshalling_tests_properties_accessors_object_set_byte_array (GIMarshallingTestsPropertiesAccessorsObject *self, GByteArray *some_byte_array)
9761 {
9762 if (self->some_byte_array == some_byte_array)
9763 return;
9764
9765 g_clear_pointer (&self->some_byte_array, g_byte_array_unref);
9766 self->some_byte_array = g_byte_array_ref (some_byte_array);
9767 g_object_notify (G_OBJECT (self), "some-byte-array");
9768 }
9769
9770 /**
9771 * gi_marshalling_tests_properties_accessors_object_set_hash_table: (set-property some-hash-table)
9772 * @self:
9773 * @some_hash_table:
9774 */
9775 void
9776 gi_marshalling_tests_properties_accessors_object_set_hash_table (GIMarshallingTestsPropertiesAccessorsObject *self, GHashTable *some_hash_table)
9777 {
9778 if (self->some_hash_table == some_hash_table)
9779 return;
9780
9781 g_clear_pointer (&self->some_hash_table, g_hash_table_unref);
9782 self->some_hash_table = g_hash_table_ref (some_hash_table);
9783 g_object_notify (G_OBJECT (self), "some-hash-table");
9784 }
9785
9786 /**
9787 * gi_marshalling_tests_properties_accessors_object_set_deprecated_int: (set-property some-deprecated-int)
9788 * @self:
9789 * @some_deprecated_int:
9790 */
9791 void
9792 gi_marshalling_tests_properties_accessors_object_set_deprecated_int (GIMarshallingTestsPropertiesAccessorsObject *self, gint some_deprecated_int)
9793 {
9794 if (self->some_deprecated_int == some_deprecated_int)
9795 return;
9796
9797 self->some_deprecated_int = some_deprecated_int;
9798 g_object_notify (G_OBJECT (self), "some-deprecated-int");
9799 }
9800
9801 /**
9802 * gi_marshalling_tests_properties_accessors_object_get_boolean: (get-property some-boolean)
9803 * @self:
9804 */
9805 gboolean
9806 gi_marshalling_tests_properties_accessors_object_get_boolean (GIMarshallingTestsPropertiesAccessorsObject *self)
9807 {
9808 return self->some_boolean;
9809 }
9810
9811 /**
9812 * gi_marshalling_tests_properties_accessors_object_get_char: (get-property some-char)
9813 * @self:
9814 */
9815 gchar
9816 gi_marshalling_tests_properties_accessors_object_get_char (GIMarshallingTestsPropertiesAccessorsObject *self)
9817 {
9818 return self->some_char;
9819 }
9820
9821 /**
9822 * gi_marshalling_tests_properties_accessors_object_get_uchar: (get-property some-uchar)
9823 * @self:
9824 */
9825 guchar
9826 gi_marshalling_tests_properties_accessors_object_get_uchar (GIMarshallingTestsPropertiesAccessorsObject *self)
9827 {
9828 return self->some_uchar;
9829 }
9830
9831 /**
9832 * gi_marshalling_tests_properties_accessors_object_get_int: (get-property some-int)
9833 * @self:
9834 */
9835 gint
9836 gi_marshalling_tests_properties_accessors_object_get_int (GIMarshallingTestsPropertiesAccessorsObject *self)
9837 {
9838 return self->some_int;
9839 }
9840
9841 /**
9842 * gi_marshalling_tests_properties_accessors_object_get_uint: (get-property some-uint)
9843 * @self:
9844 */
9845 guint
9846 gi_marshalling_tests_properties_accessors_object_get_uint (GIMarshallingTestsPropertiesAccessorsObject *self)
9847 {
9848 return self->some_uint;
9849 }
9850
9851 /**
9852 * gi_marshalling_tests_properties_accessors_object_get_long: (get-property some-long)
9853 * @self:
9854 */
9855 glong
9856 gi_marshalling_tests_properties_accessors_object_get_long (GIMarshallingTestsPropertiesAccessorsObject *self)
9857 {
9858 return self->some_long;
9859 }
9860
9861 /**
9862 * gi_marshalling_tests_properties_accessors_object_get_ulong: (get-property some-ulong)
9863 * @self:
9864 */
9865 gulong
9866 gi_marshalling_tests_properties_accessors_object_get_ulong (GIMarshallingTestsPropertiesAccessorsObject *self)
9867 {
9868 return self->some_ulong;
9869 }
9870
9871 /**
9872 * gi_marshalling_tests_properties_accessors_object_get_int64: (get-property some-int64)
9873 * @self:
9874 */
9875 gint64
9876 gi_marshalling_tests_properties_accessors_object_get_int64 (GIMarshallingTestsPropertiesAccessorsObject *self)
9877 {
9878 return self->some_int64;
9879 }
9880
9881 /**
9882 * gi_marshalling_tests_properties_accessors_object_get_uint64: (get-property some-uint64)
9883 * @self:
9884 */
9885 guint64
9886 gi_marshalling_tests_properties_accessors_object_get_uint64 (GIMarshallingTestsPropertiesAccessorsObject *self)
9887 {
9888 return self->some_uint64;
9889 }
9890
9891 /**
9892 * gi_marshalling_tests_properties_accessors_object_get_float: (get-property some-float)
9893 * @self:
9894 */
9895 gfloat
9896 gi_marshalling_tests_properties_accessors_object_get_float (GIMarshallingTestsPropertiesAccessorsObject *self)
9897 {
9898 return self->some_float;
9899 }
9900
9901 /**
9902 * gi_marshalling_tests_properties_accessors_object_get_double: (get-property some-double)
9903 * @self:
9904 */
9905 gdouble
9906 gi_marshalling_tests_properties_accessors_object_get_double (GIMarshallingTestsPropertiesAccessorsObject *self)
9907 {
9908 return self->some_double;
9909 }
9910
9911 /**
9912 * gi_marshalling_tests_properties_accessors_object_get_string: (get-property some-string)
9913 * @self:
9914 */
9915 const gchar *
9916 gi_marshalling_tests_properties_accessors_object_get_string (GIMarshallingTestsPropertiesAccessorsObject *self)
9917 {
9918 return self->some_string;
9919 }
9920
9921 /**
9922 * gi_marshalling_tests_properties_accessors_object_get_strv: (get-property some-strv)
9923 * @self:
9924 *
9925 * Returns: (transfer none):
9926 */
9927 gchar **
9928 gi_marshalling_tests_properties_accessors_object_get_strv (GIMarshallingTestsPropertiesAccessorsObject *self)
9929 {
9930 return self->some_strv;
9931 }
9932
9933 /**
9934 * gi_marshalling_tests_properties_accessors_object_get_boxed_struct: (get-property some-boxed-struct)
9935 * @self:
9936 *
9937 * Returns: (transfer none):
9938 */
9939 GIMarshallingTestsBoxedStruct *
9940 gi_marshalling_tests_properties_accessors_object_get_boxed_struct (GIMarshallingTestsPropertiesAccessorsObject *self)
9941 {
9942 return self->some_boxed_struct;
9943 }
9944
9945 /**
9946 * gi_marshalling_tests_properties_accessors_object_get_boxed_glist: (get-property some-boxed-glist)
9947 * @self:
9948 *
9949 * Returns: (element-type int) (transfer none):
9950 */
9951 GList *
9952 gi_marshalling_tests_properties_accessors_object_get_boxed_glist (GIMarshallingTestsPropertiesAccessorsObject *self)
9953 {
9954 return self->some_boxed_glist;
9955 }
9956
9957 /**
9958 * gi_marshalling_tests_properties_accessors_object_get_gvalue: (get-property some-gvalue)
9959 * @self:
9960 *
9961 * Returns: (transfer none):
9962 */
9963 GValue *
9964 gi_marshalling_tests_properties_accessors_object_get_gvalue (GIMarshallingTestsPropertiesAccessorsObject *self)
9965 {
9966 return self->some_gvalue;
9967 }
9968
9969 /**
9970 * gi_marshalling_tests_properties_accessors_object_get_variant: (get-property some-variant)
9971 * @self:
9972 *
9973 * Returns: (transfer none):
9974 */
9975 GVariant *
9976 gi_marshalling_tests_properties_accessors_object_get_variant (GIMarshallingTestsPropertiesAccessorsObject *self)
9977 {
9978 return self->some_variant;
9979 }
9980
9981 /**
9982 * gi_marshalling_tests_properties_accessors_object_get_object: (get-property some-object)
9983 * @self:
9984 *
9985 * Returns: (transfer none):
9986 */
9987 GObject *
9988 gi_marshalling_tests_properties_accessors_object_get_object (GIMarshallingTestsPropertiesAccessorsObject *self)
9989 {
9990 return self->some_object;
9991 }
9992
9993 /**
9994 * gi_marshalling_tests_properties_accessors_object_get_flags: (get-property some-flags)
9995 * @self:
9996 */
9997 GIMarshallingTestsFlags
9998 gi_marshalling_tests_properties_accessors_object_get_flags (GIMarshallingTestsPropertiesAccessorsObject *self)
9999 {
10000 return self->some_flags;
10001 }
10002
10003 /**
10004 * gi_marshalling_tests_properties_accessors_object_get_enum: (get-property some-enum)
10005 * @self:
10006 */
10007 GIMarshallingTestsGEnum
10008 gi_marshalling_tests_properties_accessors_object_get_enum (GIMarshallingTestsPropertiesAccessorsObject *self)
10009 {
10010 return self->some_enum;
10011 }
10012
10013 /**
10014 * gi_marshalling_tests_properties_accessors_object_get_byte_array: (get-property some-byte-array)
10015 * @self:
10016 *
10017 * Returns: (transfer none):
10018 */
10019 GByteArray *
10020 gi_marshalling_tests_properties_accessors_object_get_byte_array (GIMarshallingTestsPropertiesAccessorsObject *self)
10021 {
10022 return self->some_byte_array;
10023 }
10024
10025 /**
10026 * gi_marshalling_tests_properties_accessors_object_get_hash_table: (get-property some-hash-table)
10027 * @self:
10028 *
10029 * Returns: (transfer none):
10030 */
10031 GHashTable *
10032 gi_marshalling_tests_properties_accessors_object_get_hash_table (GIMarshallingTestsPropertiesAccessorsObject *self)
10033 {
10034 return self->some_hash_table;
10035 }
10036
10037 /**
10038 * gi_marshalling_tests_properties_accessors_object_get_readonly: (get-property some-readonly)
10039 * @self:
10040 */
10041 gint
10042 gi_marshalling_tests_properties_accessors_object_get_readonly (GIMarshallingTestsPropertiesAccessorsObject *self G_GNUC_UNUSED)
10043 {
10044 return 42;
10045 }
10046
10047 /**
10048 * gi_marshalling_tests_properties_accessors_object_get_deprecated_int: (get-property some-deprecated-int)
10049 * @self:
10050 */
10051 gint
10052 gi_marshalling_tests_properties_accessors_object_get_deprecated_int (GIMarshallingTestsPropertiesAccessorsObject *self)
10053 {
10054 return self->some_deprecated_int;
10055 }
10056
10057 G_DEFINE_TYPE (GIMarshallingTestsSignalsObject, gi_marshalling_tests_signals_object, G_TYPE_OBJECT);
10058
10059 static void
10060 gi_marshalling_tests_signals_object_init (GIMarshallingTestsSignalsObject *object G_GNUC_UNUSED)
10061 {
10062 }
10063
10064 static void
10065 gi_marshalling_tests_signals_object_finalize (GObject *object)
10066 {
10067 G_OBJECT_CLASS (gi_marshalling_tests_signals_object_parent_class)->finalize (object);
10068 }
10069
10070 static void
10071 gi_marshalling_tests_signals_object_class_init (GIMarshallingTestsSignalsObjectClass *klass)
10072 {
10073 GObjectClass *object_class = G_OBJECT_CLASS (klass);
10074
10075 object_class->finalize = gi_marshalling_tests_signals_object_finalize;
10076
10077 /**
10078 * GIMarshallingTestsSignalsObject::some-boxed-gptrarray-utf8:
10079 * @self:
10080 * @arg: (element-type utf8):
10081 */
10082 g_signal_new ("some-boxed-gptrarray-utf8",
10083 G_TYPE_FROM_CLASS (klass),
10084 G_SIGNAL_RUN_LAST,
10085 0, NULL, NULL, NULL,
10086 G_TYPE_NONE, 1,
10087 G_TYPE_PTR_ARRAY);
10088
10089 /**
10090 * GIMarshallingTestsSignalsObject::some-boxed-gptrarray-utf8-container:
10091 * @self:
10092 * @arg: (element-type utf8) (transfer container):
10093 */
10094 g_signal_new ("some-boxed-gptrarray-utf8-container",
10095 G_TYPE_FROM_CLASS (klass),
10096 G_SIGNAL_RUN_LAST,
10097 0, NULL, NULL, NULL,
10098 G_TYPE_NONE, 1,
10099 G_TYPE_PTR_ARRAY);
10100
10101 /**
10102 * GIMarshallingTestsSignalsObject::some-boxed-gptrarray-utf8-full:
10103 * @self:
10104 * @arg: (element-type utf8) (transfer full):
10105 */
10106 g_signal_new ("some-boxed-gptrarray-utf8-full",
10107 G_TYPE_FROM_CLASS (klass),
10108 G_SIGNAL_RUN_LAST,
10109 0, NULL, NULL, NULL,
10110 G_TYPE_NONE, 1,
10111 G_TYPE_PTR_ARRAY);
10112
10113 /**
10114 * GIMarshallingTestsSignalsObject::some-boxed-gptrarray-boxed-struct:
10115 * @self:
10116 * @arg: (element-type GIMarshallingTestsBoxedStruct):
10117 */
10118 g_signal_new ("some-boxed-gptrarray-boxed-struct",
10119 G_TYPE_FROM_CLASS (klass),
10120 G_SIGNAL_RUN_LAST,
10121 0, NULL, NULL, NULL,
10122 G_TYPE_NONE, 1,
10123 G_TYPE_PTR_ARRAY);
10124
10125 /**
10126 * GIMarshallingTestsSignalsObject::some-boxed-gptrarray-boxed-struct-container:
10127 * @self:
10128 * @arg: (element-type GIMarshallingTestsBoxedStruct) (transfer container):
10129 */
10130 g_signal_new ("some-boxed-gptrarray-boxed-struct-container",
10131 G_TYPE_FROM_CLASS (klass),
10132 G_SIGNAL_RUN_LAST,
10133 0, NULL, NULL, NULL,
10134 G_TYPE_NONE, 1,
10135 G_TYPE_PTR_ARRAY);
10136 /**
10137 * GIMarshallingTestsSignalsObject::some-boxed-gptrarray-boxed-struct-full:
10138 * @self:
10139 * @arg: (element-type GIMarshallingTestsBoxedStruct) (transfer full):
10140 */
10141 g_signal_new ("some-boxed-gptrarray-boxed-struct-full",
10142 G_TYPE_FROM_CLASS (klass),
10143 G_SIGNAL_RUN_LAST,
10144 0, NULL, NULL, NULL,
10145 G_TYPE_NONE, 1,
10146 G_TYPE_PTR_ARRAY);
10147
10148 /**
10149 * GIMarshallingTestsSignalsObject::some-hash-table-utf8-int:
10150 * @self:
10151 * @arg: (type GHashTable) (element-type utf8 int):
10152 */
10153 g_signal_new ("some-hash-table-utf8-int",
10154 G_TYPE_FROM_CLASS (klass),
10155 G_SIGNAL_RUN_LAST,
10156 0, NULL, NULL, NULL,
10157 G_TYPE_NONE, 1,
10158 G_TYPE_HASH_TABLE);
10159
10160 /**
10161 * GIMarshallingTestsSignalsObject::some-hash-table-utf8-int-container:
10162 * @self:
10163 * @arg: (type GHashTable) (element-type utf8 int) (transfer container):
10164 */
10165 g_signal_new ("some-hash-table-utf8-int-container",
10166 G_TYPE_FROM_CLASS (klass),
10167 G_SIGNAL_RUN_LAST,
10168 0, NULL, NULL, NULL,
10169 G_TYPE_NONE, 1,
10170 G_TYPE_HASH_TABLE);
10171
10172 /**
10173 * GIMarshallingTestsSignalsObject::some-hash-table-utf8-int-full:
10174 * @self:
10175 * @arg: (type GHashTable) (element-type utf8 int) (transfer full):
10176 */
10177 g_signal_new ("some-hash-table-utf8-int-full",
10178 G_TYPE_FROM_CLASS (klass),
10179 G_SIGNAL_RUN_LAST,
10180 0, NULL, NULL, NULL,
10181 G_TYPE_NONE, 1,
10182 G_TYPE_HASH_TABLE);
10183
10184 /**
10185 * GIMarshallingTestsSignalsObject::some-boxed-struct:
10186 * @self:
10187 * @arg:
10188 */
10189 g_signal_new ("some-boxed-struct",
10190 G_TYPE_FROM_CLASS (klass),
10191 G_SIGNAL_RUN_LAST,
10192 0, NULL, NULL, NULL,
10193 G_TYPE_NONE, 1,
10194 gi_marshalling_tests_boxed_struct_get_type ());
10195
10196 /**
10197 * GIMarshallingTestsSignalsObject::some-boxed-struct-full:
10198 * @self:
10199 * @arg: (transfer full):
10200 */
10201 g_signal_new ("some-boxed-struct-full",
10202 G_TYPE_FROM_CLASS (klass),
10203 G_SIGNAL_RUN_LAST,
10204 0, NULL, NULL, NULL,
10205 G_TYPE_NONE, 1,
10206 gi_marshalling_tests_boxed_struct_get_type ());
10207 }
10208
10209 GIMarshallingTestsSignalsObject *
10210 gi_marshalling_tests_signals_object_new (void)
10211 {
10212 return g_object_new (GI_MARSHALLING_TESTS_TYPE_SIGNALS_OBJECT, NULL);
10213 }
10214
10215 void
10216 gi_marshalling_tests_signals_object_emit_boxed_gptrarray_utf8 (GIMarshallingTestsSignalsObject *object)
10217 {
10218 GPtrArray *ptrarray;
10219
10220 ptrarray = gi_marshalling_tests_gptrarray_utf8_container_return ();
10221 g_signal_emit_by_name (object, "some-boxed-gptrarray-utf8",
10222 ptrarray);
10223 g_ptr_array_unref (ptrarray);
10224 }
10225
10226 void
10227 gi_marshalling_tests_signals_object_emit_boxed_gptrarray_utf8_container (GIMarshallingTestsSignalsObject *object)
10228 {
10229 g_signal_emit_by_name (object, "some-boxed-gptrarray-utf8-container",
10230 gi_marshalling_tests_gptrarray_utf8_container_return ());
10231 }
10232
10233 void
10234 gi_marshalling_tests_signals_object_emit_boxed_gptrarray_utf8_full (GIMarshallingTestsSignalsObject *object)
10235 {
10236 g_signal_emit_by_name (object, "some-boxed-gptrarray-utf8-full",
10237 gi_marshalling_tests_gptrarray_utf8_full_return ());
10238 }
10239
10240 void
10241 gi_marshalling_tests_signals_object_emit_boxed_gptrarray_boxed_struct (GIMarshallingTestsSignalsObject *object)
10242 {
10243 GPtrArray *ptrarray;
10244
10245 ptrarray = gi_marshalling_tests_gptrarray_boxed_struct_full_return ();
10246 g_signal_emit_by_name (object, "some-boxed-gptrarray-boxed-struct",
10247 ptrarray);
10248 g_ptr_array_set_free_func (ptrarray, (GDestroyNotify) gi_marshalling_tests_boxed_struct_free);
10249 g_ptr_array_unref (ptrarray);
10250 }
10251
10252 void
10253 gi_marshalling_tests_signals_object_emit_boxed_gptrarray_boxed_struct_container (GIMarshallingTestsSignalsObject *object)
10254 {
10255 GPtrArray *ptrarray;
10256
10257 ptrarray = gi_marshalling_tests_gptrarray_boxed_struct_full_return ();
10258 g_ptr_array_set_free_func (ptrarray, (GDestroyNotify) gi_marshalling_tests_boxed_struct_free);
10259 g_signal_emit_by_name (object, "some-boxed-gptrarray-boxed-struct-container",
10260 g_steal_pointer (&ptrarray));
10261 }
10262
10263 void
10264 gi_marshalling_tests_signals_object_emit_boxed_gptrarray_boxed_struct_full (GIMarshallingTestsSignalsObject *object)
10265 {
10266 g_signal_emit_by_name (object, "some-boxed-gptrarray-boxed-struct-full",
10267 gi_marshalling_tests_gptrarray_boxed_struct_full_return ());
10268 }
10269
10270 void
10271 gi_marshalling_tests_signals_object_emit_hash_table_utf8_int (GIMarshallingTestsSignalsObject *object)
10272 {
10273 GHashTable *hash_table;
10274
10275 hash_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
10276 g_hash_table_insert (hash_table, g_strdup ("-1"), GINT_TO_POINTER (1));
10277 g_hash_table_insert (hash_table, g_strdup ("0"), GINT_TO_POINTER (0));
10278 g_hash_table_insert (hash_table, g_strdup ("1"), GINT_TO_POINTER (-1));
10279 g_hash_table_insert (hash_table, g_strdup ("2"), GINT_TO_POINTER (-2));
10280
10281 g_signal_emit_by_name (object, "some-hash-table-utf8-int", hash_table);
10282 g_hash_table_unref (hash_table);
10283 }
10284
10285 void
10286 gi_marshalling_tests_signals_object_emit_hash_table_utf8_int_container (GIMarshallingTestsSignalsObject *object)
10287 {
10288 GHashTable *hash_table;
10289
10290 hash_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
10291 g_hash_table_insert (hash_table, g_strdup ("-1"), GINT_TO_POINTER (1));
10292 g_hash_table_insert (hash_table, g_strdup ("0"), GINT_TO_POINTER (0));
10293 g_hash_table_insert (hash_table, g_strdup ("1"), GINT_TO_POINTER (-1));
10294 g_hash_table_insert (hash_table, g_strdup ("2"), GINT_TO_POINTER (-2));
10295
10296 g_signal_emit_by_name (object, "some-hash-table-utf8-int-container",
10297 g_steal_pointer (&hash_table));
10298 }
10299
10300 void
10301 gi_marshalling_tests_signals_object_emit_hash_table_utf8_int_full (GIMarshallingTestsSignalsObject *object)
10302 {
10303 GHashTable *hash_table;
10304
10305 hash_table = g_hash_table_new (g_str_hash, g_str_equal);
10306 g_hash_table_insert (hash_table, g_strdup ("-1"), GINT_TO_POINTER (1));
10307 g_hash_table_insert (hash_table, g_strdup ("0"), GINT_TO_POINTER (0));
10308 g_hash_table_insert (hash_table, g_strdup ("1"), GINT_TO_POINTER (-1));
10309 g_hash_table_insert (hash_table, g_strdup ("2"), GINT_TO_POINTER (-2));
10310
10311 g_signal_emit_by_name (object, "some-hash-table-utf8-int-full",
10312 g_steal_pointer (&hash_table));
10313 }
10314
10315 void
10316 gi_marshalling_tests_signals_object_emit_boxed_struct (GIMarshallingTestsSignalsObject *object)
10317 {
10318 GIMarshallingTestsBoxedStruct *boxed = gi_marshalling_tests_boxed_struct_new ();
10319 boxed->long_ = 99;
10320 boxed->string_ = g_strdup ("a string");
10321 boxed->g_strv = g_strdupv ((GStrv) (const char *[]) { "foo", "bar", "baz", NULL });
10322
10323 g_signal_emit_by_name (object, "some-boxed-struct", boxed);
10324 g_clear_pointer (&boxed, gi_marshalling_tests_boxed_struct_free);
10325 }
10326
10327 void
10328 gi_marshalling_tests_signals_object_emit_boxed_struct_full (GIMarshallingTestsSignalsObject *object)
10329 {
10330 GIMarshallingTestsBoxedStruct *boxed = gi_marshalling_tests_boxed_struct_new ();
10331
10332 boxed->long_ = 99;
10333 boxed->string_ = g_strdup ("a string");
10334 boxed->g_strv = g_strdupv ((GStrv) (const char *[]) { "foo", "bar", "baz", NULL });
10335 g_signal_emit_by_name (object, "some-boxed-struct-full", g_steal_pointer (&boxed));
10336 }