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