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 : 1 : container[0] = variants[0];
1860 : 1 : container[1] = variants[1];
1861 : 1 : g_free (variants);
1862 : :
1863 : 1 : return container;
1864 : : }
1865 : :
1866 : : /**
1867 : : * gi_marshalling_tests_array_gvariant_full_in:
1868 : : * @variants: (array zero-terminated) (transfer full):
1869 : : *
1870 : : * Returns: (array zero-terminated) (transfer full):
1871 : : */
1872 : : GVariant **
1873 : 0 : gi_marshalling_tests_array_gvariant_full_in (GVariant **variants)
1874 : : {
1875 : : GVariant **container;
1876 : :
1877 : 0 : g_assert (variants != NULL);
1878 : 0 : g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
1879 : 0 : g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
1880 : 0 : g_assert (variants[2] == NULL);
1881 : :
1882 : : /* To catch different behaviors we reconstruct one variant from scratch,
1883 : : * while leaving the other untouched. Both approaches are legal with full
1884 : : * transfer in and out */
1885 : 0 : container = g_new0 (GVariant *, 3);
1886 : 0 : container[0] = g_variant_new_int32 (g_variant_get_int32 (variants[0]));
1887 : 0 : g_variant_unref (variants[0]);
1888 : 0 : container[1] = variants[1];
1889 : 0 : g_free (variants);
1890 : :
1891 : 0 : return container;
1892 : : }
1893 : :
1894 : : /**
1895 : : * gi_marshalling_tests_garray_int_none_return:
1896 : : *
1897 : : * Returns: (element-type gint) (transfer none):
1898 : : */
1899 : : GArray *
1900 : 1 : gi_marshalling_tests_garray_int_none_return (void)
1901 : : {
1902 : : static GArray *v = NULL;
1903 : : gint i;
1904 : :
1905 [ + - ]: 1 : if (v == NULL)
1906 : : {
1907 : 1 : v = g_array_new (TRUE, TRUE, sizeof (gint));
1908 [ + + ]: 5 : for (i = -1; i < 3; i++)
1909 : 4 : g_array_append_val (v, i);
1910 : : }
1911 : :
1912 : 1 : return v;
1913 : : }
1914 : :
1915 : : /**
1916 : : * gi_marshalling_tests_garray_uint64_none_return:
1917 : : *
1918 : : * Returns: (element-type guint64) (transfer none):
1919 : : */
1920 : : GArray *
1921 : 1 : gi_marshalling_tests_garray_uint64_none_return (void)
1922 : : {
1923 : : static GArray *array = NULL;
1924 : : guint64 i;
1925 : :
1926 [ + - ]: 1 : if (array == NULL)
1927 : : {
1928 : 1 : array = g_array_new (TRUE, TRUE, sizeof (guint64));
1929 : 1 : i = 0;
1930 : 1 : g_array_append_val (array, i);
1931 : 1 : i = G_MAXUINT64;
1932 : 1 : g_array_append_val (array, i);
1933 : : }
1934 : :
1935 : 1 : return array;
1936 : : }
1937 : :
1938 : : /**
1939 : : * gi_marshalling_tests_garray_utf8_none_return:
1940 : : *
1941 : : * Returns: (element-type utf8) (transfer none):
1942 : : */
1943 : : GArray *
1944 : 1 : gi_marshalling_tests_garray_utf8_none_return (void)
1945 : : {
1946 : : static GArray *array = NULL;
1947 : : static const gchar *values[] = { "0", "1", "2", NULL };
1948 : : gint i;
1949 : :
1950 [ + - ]: 1 : if (array == NULL)
1951 : : {
1952 : 1 : array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1953 [ + + ]: 4 : for (i = 0; values[i]; i++)
1954 : 3 : g_array_append_val (array, values[i]);
1955 : : }
1956 : :
1957 : 1 : return array;
1958 : : }
1959 : :
1960 : : /**
1961 : : * gi_marshalling_tests_garray_utf8_container_return:
1962 : : *
1963 : : * Returns: (element-type utf8) (transfer container):
1964 : : */
1965 : : GArray *
1966 : 1 : gi_marshalling_tests_garray_utf8_container_return (void)
1967 : : {
1968 : 1 : GArray *array = NULL;
1969 : : static const gchar *values[] = { "0", "1", "2", NULL };
1970 : : gint i;
1971 : :
1972 : 1 : array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1973 [ + + ]: 4 : for (i = 0; values[i]; i++)
1974 : 3 : g_array_append_val (array, values[i]);
1975 : :
1976 : 1 : return array;
1977 : : }
1978 : :
1979 : : /**
1980 : : * gi_marshalling_tests_garray_utf8_full_return:
1981 : : *
1982 : : * Returns: (element-type utf8) (transfer full):
1983 : : */
1984 : : GArray *
1985 : 1 : gi_marshalling_tests_garray_utf8_full_return (void)
1986 : : {
1987 : 1 : GArray *array = NULL;
1988 : : static const gchar *values[] = { "0", "1", "2", NULL };
1989 : : gint i;
1990 : :
1991 : 1 : array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1992 [ + + ]: 4 : for (i = 0; values[i]; i++)
1993 : : {
1994 : 3 : gchar *str = g_strdup (values[i]);
1995 : 3 : g_array_append_val (array, str);
1996 : : }
1997 : :
1998 : 1 : return array;
1999 : : }
2000 : :
2001 : : /**
2002 : : * gi_marshalling_tests_garray_boxed_struct_full_return:
2003 : : *
2004 : : * Returns: (element-type GIMarshallingTestsBoxedStruct) (transfer full):
2005 : : */
2006 : : GArray *
2007 : 1 : gi_marshalling_tests_garray_boxed_struct_full_return (void)
2008 : : {
2009 : 1 : GArray *array = NULL;
2010 : : static const glong long_values[] = { 42, 43, 44 };
2011 : : gint i;
2012 : :
2013 : 1 : array = g_array_new (TRUE, TRUE, sizeof (GIMarshallingTestsBoxedStruct));
2014 [ + + ]: 4 : for (i = 0; i < 3; i++)
2015 : : {
2016 : 3 : GIMarshallingTestsBoxedStruct *new_struct = gi_marshalling_tests_boxed_struct_new ();
2017 : 3 : new_struct->long_ = long_values[i];
2018 : 3 : g_array_append_val (array, *new_struct);
2019 : : }
2020 : :
2021 : 1 : return array;
2022 : : }
2023 : :
2024 : : /**
2025 : : * gi_marshalling_tests_garray_int_none_in:
2026 : : * @array_: (element-type gint) (transfer none):
2027 : : */
2028 : : void
2029 : 1 : gi_marshalling_tests_garray_int_none_in (GArray *array_)
2030 : : {
2031 : 1 : g_assert_cmpint (array_->len, ==, 4);
2032 : 1 : g_assert_cmpint (g_array_index (array_, gint, 0), ==, -1);
2033 : 1 : g_assert_cmpint (g_array_index (array_, gint, 1), ==, 0);
2034 : 1 : g_assert_cmpint (g_array_index (array_, gint, 2), ==, 1);
2035 : 1 : g_assert_cmpint (g_array_index (array_, gint, 3), ==, 2);
2036 : 1 : }
2037 : :
2038 : : /**
2039 : : * gi_marshalling_tests_garray_uint64_none_in:
2040 : : * @array_: (element-type guint64) (transfer none):
2041 : : */
2042 : : void
2043 : 0 : gi_marshalling_tests_garray_uint64_none_in (GArray *array_)
2044 : : {
2045 : 0 : g_assert_cmpint (array_->len, ==, 2);
2046 : 0 : g_assert_cmpint (g_array_index (array_, guint64, 0), ==, 0);
2047 : 0 : g_assert_cmpint (g_array_index (array_, guint64, 1), ==, G_MAXUINT64);
2048 : 0 : }
2049 : :
2050 : : /**
2051 : : * gi_marshalling_tests_garray_utf8_none_in:
2052 : : * @array_: (element-type utf8) (transfer none):
2053 : : */
2054 : : void
2055 : 1 : gi_marshalling_tests_garray_utf8_none_in (GArray *array_)
2056 : : {
2057 : 1 : g_assert_cmpint (array_->len, ==, 3);
2058 : 1 : g_assert_cmpstr (g_array_index (array_, gchar *, 0), ==, "0");
2059 : 1 : g_assert_cmpstr (g_array_index (array_, gchar *, 1), ==, "1");
2060 : 1 : g_assert_cmpstr (g_array_index (array_, gchar *, 2), ==, "2");
2061 : 1 : }
2062 : :
2063 : : /**
2064 : : * gi_marshalling_tests_garray_utf8_none_out:
2065 : : * @array_: (out) (element-type utf8) (transfer none):
2066 : : */
2067 : : void
2068 : 1 : gi_marshalling_tests_garray_utf8_none_out (GArray **array_)
2069 : : {
2070 : : static GArray *internal = NULL;
2071 : : static const gchar *values[] = { "0", "1", "2", NULL };
2072 : : gint i;
2073 : :
2074 [ + - ]: 1 : if (internal == NULL)
2075 : : {
2076 : 1 : internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
2077 [ + + ]: 4 : for (i = 0; values[i]; i++)
2078 : 3 : g_array_append_val (internal, values[i]);
2079 : : }
2080 : :
2081 : 1 : *array_ = internal;
2082 : 1 : }
2083 : :
2084 : : /**
2085 : : * gi_marshalling_tests_garray_utf8_container_out:
2086 : : * @array_: (out) (element-type utf8) (transfer container):
2087 : : */
2088 : : void
2089 : 1 : gi_marshalling_tests_garray_utf8_container_out (GArray **array_)
2090 : : {
2091 : : static const gchar *values[] = { "0", "1", "2", NULL };
2092 : : gint i;
2093 : :
2094 : 1 : *array_ = NULL;
2095 : :
2096 : 1 : *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
2097 [ + + ]: 4 : for (i = 0; values[i]; i++)
2098 : 3 : g_array_append_val (*array_, values[i]);
2099 : 1 : }
2100 : :
2101 : : /**
2102 : : * gi_marshalling_tests_garray_utf8_full_out:
2103 : : * @array_: (out) (element-type utf8) (transfer full):
2104 : : */
2105 : : void
2106 : 1 : gi_marshalling_tests_garray_utf8_full_out (GArray **array_)
2107 : : {
2108 : : static const gchar *values[] = { "0", "1", "2", NULL };
2109 : : gint i;
2110 : :
2111 : 1 : *array_ = NULL;
2112 : :
2113 : 1 : *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
2114 [ + + ]: 4 : for (i = 0; values[i]; i++)
2115 : : {
2116 : 3 : gchar *str = g_strdup (values[i]);
2117 : 3 : g_array_append_val (*array_, str);
2118 : : }
2119 : 1 : }
2120 : :
2121 : : /**
2122 : : * gi_marshalling_tests_garray_utf8_full_out_caller_allocated:
2123 : : * @array_: (out caller-allocates) (array) (element-type utf8) (transfer full):
2124 : : */
2125 : : void
2126 : 0 : gi_marshalling_tests_garray_utf8_full_out_caller_allocated (GArray *array_)
2127 : : {
2128 : : static const gchar *values[] = { "0", "1", "2", NULL };
2129 : : gint i;
2130 : :
2131 : 0 : g_array_set_size (array_, 0);
2132 [ # # ]: 0 : for (i = 0; values[i]; i++)
2133 : : {
2134 : 0 : gchar *str = g_strdup (values[i]);
2135 : 0 : g_array_append_val (array_, str);
2136 : : }
2137 : 0 : }
2138 : :
2139 : : /**
2140 : : * gi_marshalling_tests_garray_utf8_none_inout:
2141 : : * @array_: (inout) (element-type utf8) (transfer none):
2142 : : */
2143 : : void
2144 : 1 : gi_marshalling_tests_garray_utf8_none_inout (GArray **array_)
2145 : : {
2146 : : static GArray *internal = NULL;
2147 : : static const gchar *values[] = { "-2", "-1", "0", "1", NULL };
2148 : : gint i;
2149 : :
2150 : 1 : g_assert_cmpint ((*array_)->len, ==, 3);
2151 : 1 : g_assert_cmpstr (g_array_index (*array_, gchar *, 0), ==, "0");
2152 : 1 : g_assert_cmpstr (g_array_index (*array_, gchar *, 1), ==, "1");
2153 : 1 : g_assert_cmpstr (g_array_index (*array_, gchar *, 2), ==, "2");
2154 : :
2155 [ + - ]: 1 : if (internal == NULL)
2156 : : {
2157 : 1 : internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
2158 [ + + ]: 5 : for (i = 0; values[i]; i++)
2159 : 4 : g_array_append_val (internal, values[i]);
2160 : : }
2161 : :
2162 : 1 : *array_ = internal;
2163 : 1 : }
2164 : :
2165 : : /**
2166 : : * gi_marshalling_tests_garray_utf8_container_inout:
2167 : : * @array_: (inout) (element-type utf8) (transfer container):
2168 : : */
2169 : : void
2170 : 0 : gi_marshalling_tests_garray_utf8_container_inout (GArray **array_)
2171 : : {
2172 : : static const gchar *val1 = "-2";
2173 : : static const gchar *val2 = "-1";
2174 : : static const gchar *val3 = "0";
2175 : : static const gchar *val4 = "1";
2176 : : GArray *result;
2177 : :
2178 : 0 : g_assert_cmpint ((*array_)->len, ==, 3);
2179 : 0 : g_assert_cmpstr (g_array_index (*array_, gchar *, 0), ==, "0");
2180 : 0 : g_assert_cmpstr (g_array_index (*array_, gchar *, 1), ==, "1");
2181 : 0 : g_assert_cmpstr (g_array_index (*array_, gchar *, 2), ==, "2");
2182 : :
2183 : 0 : result = g_array_new (TRUE, TRUE, sizeof (gchar *));
2184 : 0 : g_array_append_val (result, val1);
2185 : 0 : g_array_append_val (result, val2);
2186 : 0 : g_array_append_val (result, val3);
2187 : 0 : g_array_append_val (result, val4);
2188 : :
2189 : 0 : g_array_unref (*array_);
2190 : 0 : *array_ = result;
2191 : 0 : }
2192 : :
2193 : : /**
2194 : : * gi_marshalling_tests_garray_utf8_full_inout:
2195 : : * @array_: (inout) (element-type utf8) (transfer full):
2196 : : */
2197 : : void
2198 : 0 : gi_marshalling_tests_garray_utf8_full_inout (GArray **array_)
2199 : : {
2200 : : static const gchar *val1 = "-1";
2201 : : static const gchar *val2 = "-2";
2202 : : gchar *val;
2203 : : GArray *result;
2204 : :
2205 : 0 : g_assert_cmpint ((*array_)->len, ==, 3);
2206 : 0 : g_assert_cmpstr (g_array_index (*array_, gchar *, 0), ==, "0");
2207 : 0 : g_assert_cmpstr (g_array_index (*array_, gchar *, 1), ==, "1");
2208 : 0 : g_assert_cmpstr (g_array_index (*array_, gchar *, 2), ==, "2");
2209 : :
2210 : 0 : result = g_array_new (TRUE, TRUE, sizeof (gchar *));
2211 : 0 : val = g_strdup (val2);
2212 : 0 : g_array_append_val (result, val);
2213 : 0 : val = g_strdup (val1);
2214 : 0 : g_array_append_val (result, val);
2215 : 0 : val = g_strdup ("0");
2216 : 0 : g_array_append_val (result, val);
2217 : 0 : val = g_strdup ("1");
2218 : 0 : g_array_append_val (result, val);
2219 : :
2220 : 0 : g_array_unref (*array_);
2221 : 0 : *array_ = result;
2222 : 0 : }
2223 : :
2224 : : /**
2225 : : * gi_marshalling_tests_garray_bool_none_in:
2226 : : * @array_: (element-type gboolean) (transfer none):
2227 : : */
2228 : : void
2229 : 1 : gi_marshalling_tests_garray_bool_none_in (GArray *array_)
2230 : : {
2231 : 1 : g_assert_cmpint (array_->len, ==, 4);
2232 : 1 : g_assert_cmpint (g_array_index (array_, gboolean, 0), ==, TRUE);
2233 : 1 : g_assert_cmpint (g_array_index (array_, gboolean, 1), ==, FALSE);
2234 : 1 : g_assert_cmpint (g_array_index (array_, gboolean, 2), ==, TRUE);
2235 : 1 : g_assert_cmpint (g_array_index (array_, gboolean, 3), ==, TRUE);
2236 : 1 : }
2237 : :
2238 : : /**
2239 : : * gi_marshalling_tests_garray_unichar_none_in:
2240 : : * @array_: (element-type gunichar) (transfer none):
2241 : : */
2242 : : void
2243 : 2 : gi_marshalling_tests_garray_unichar_none_in (GArray *array_)
2244 : : {
2245 : : unsigned ix;
2246 : : static const gunichar expected[] = GI_MARSHALLING_TESTS_CONSTANT_UCS4;
2247 : 2 : g_assert_cmpint (array_->len, ==, 12);
2248 [ + + ]: 26 : for (ix = 0; ix < array_->len; ix++)
2249 : 24 : g_assert_cmpuint (g_array_index (array_, gunichar, ix), ==, expected[ix]);
2250 : 2 : }
2251 : :
2252 : : /**
2253 : : * gi_marshalling_tests_gptrarray_utf8_none_return:
2254 : : *
2255 : : * Returns: (element-type utf8) (transfer none):
2256 : : */
2257 : : GPtrArray *
2258 : 1 : gi_marshalling_tests_gptrarray_utf8_none_return (void)
2259 : : {
2260 : : static GPtrArray *parray = NULL;
2261 : : static const gchar *values[] = { "0", "1", "2" };
2262 : : gint i;
2263 : :
2264 [ + - ]: 1 : if (parray == NULL)
2265 : : {
2266 : 1 : parray = g_ptr_array_new ();
2267 [ + + ]: 4 : for (i = 0; i < 3; i++)
2268 : 3 : g_ptr_array_add (parray, (gpointer) values[i]);
2269 : : }
2270 : :
2271 : 1 : return parray;
2272 : : }
2273 : :
2274 : : /**
2275 : : * gi_marshalling_tests_gptrarray_utf8_container_return:
2276 : : *
2277 : : * Returns: (element-type utf8) (transfer container):
2278 : : */
2279 : : GPtrArray *
2280 : 1 : gi_marshalling_tests_gptrarray_utf8_container_return (void)
2281 : : {
2282 : 1 : GPtrArray *parray = NULL;
2283 : : static const gchar *values[] = { "0", "1", "2", NULL };
2284 : : gint i;
2285 : :
2286 : 1 : parray = g_ptr_array_new ();
2287 [ + + ]: 4 : for (i = 0; values[i]; i++)
2288 : 3 : g_ptr_array_add (parray, (gpointer) values[i]);
2289 : :
2290 : 1 : return parray;
2291 : : }
2292 : :
2293 : : /**
2294 : : * gi_marshalling_tests_gptrarray_utf8_full_return:
2295 : : *
2296 : : * Returns: (element-type utf8) (transfer full):
2297 : : */
2298 : : GPtrArray *
2299 : 2 : gi_marshalling_tests_gptrarray_utf8_full_return (void)
2300 : : {
2301 : 2 : GPtrArray *parray = NULL;
2302 : : static const gchar *values[] = { "0", "1", "2", NULL };
2303 : : gint i;
2304 : :
2305 : 2 : parray = g_ptr_array_new ();
2306 [ + + ]: 8 : for (i = 0; values[i]; i++)
2307 : : {
2308 : 6 : gchar *str = g_strdup (values[i]);
2309 : 6 : g_ptr_array_add (parray, (gpointer) str);
2310 : : }
2311 : :
2312 : 2 : return parray;
2313 : : }
2314 : :
2315 : : /**
2316 : : * gi_marshalling_tests_gptrarray_boxed_struct_full_return:
2317 : : *
2318 : : * Returns: (element-type GIMarshallingTestsBoxedStruct) (transfer full):
2319 : : */
2320 : : GPtrArray *
2321 : 2 : gi_marshalling_tests_gptrarray_boxed_struct_full_return (void)
2322 : : {
2323 : 2 : GPtrArray *parray = NULL;
2324 : : static const glong long_values[] = { 42, 43, 44 };
2325 : : gint i;
2326 : :
2327 : 2 : parray = g_ptr_array_new ();
2328 [ + + ]: 8 : for (i = 0; i < 3; i++)
2329 : : {
2330 : 6 : GIMarshallingTestsBoxedStruct *new_struct = gi_marshalling_tests_boxed_struct_new ();
2331 : 6 : new_struct->long_ = long_values[i];
2332 : 6 : g_ptr_array_add (parray, (gpointer) new_struct);
2333 : : }
2334 : :
2335 : 2 : return parray;
2336 : : }
2337 : :
2338 : : /**
2339 : : * gi_marshalling_tests_gptrarray_utf8_none_in:
2340 : : * @parray_: (element-type utf8) (transfer none):
2341 : : */
2342 : : void
2343 : 1 : gi_marshalling_tests_gptrarray_utf8_none_in (GPtrArray *parray_)
2344 : : {
2345 : 1 : g_assert_cmpint (parray_->len, ==, 3);
2346 : 1 : g_assert_cmpstr (g_ptr_array_index (parray_, 0), ==, "0");
2347 : 1 : g_assert_cmpstr (g_ptr_array_index (parray_, 1), ==, "1");
2348 : 1 : g_assert_cmpstr (g_ptr_array_index (parray_, 2), ==, "2");
2349 : 1 : }
2350 : :
2351 : : /**
2352 : : * gi_marshalling_tests_gptrarray_utf8_none_out:
2353 : : * @parray_: (out) (element-type utf8) (transfer none):
2354 : : */
2355 : : void
2356 : 1 : gi_marshalling_tests_gptrarray_utf8_none_out (GPtrArray **parray_)
2357 : : {
2358 : : static GPtrArray *internal = NULL;
2359 : : static const gchar *values[] = { "0", "1", "2", NULL };
2360 : : gint i;
2361 : :
2362 [ + - ]: 1 : if (internal == NULL)
2363 : : {
2364 : 1 : internal = g_ptr_array_new ();
2365 [ + + ]: 4 : for (i = 0; values[i]; i++)
2366 : 3 : g_ptr_array_add (internal, (gpointer) values[i]);
2367 : : }
2368 : :
2369 : 1 : *parray_ = internal;
2370 : 1 : }
2371 : :
2372 : : /**
2373 : : * gi_marshalling_tests_gptrarray_utf8_container_out:
2374 : : * @parray_: (out) (element-type utf8) (transfer container):
2375 : : */
2376 : : void
2377 : 1 : gi_marshalling_tests_gptrarray_utf8_container_out (GPtrArray **parray_)
2378 : : {
2379 : : static const gchar *values[] = { "0", "1", "2", NULL };
2380 : : gint i;
2381 : :
2382 : 1 : *parray_ = NULL;
2383 : :
2384 : 1 : *parray_ = g_ptr_array_new ();
2385 [ + + ]: 4 : for (i = 0; values[i]; i++)
2386 : 3 : g_ptr_array_add (*parray_, (gpointer) values[i]);
2387 : 1 : }
2388 : :
2389 : : /**
2390 : : * gi_marshalling_tests_gptrarray_utf8_full_out:
2391 : : * @parray_: (out) (element-type utf8) (transfer full):
2392 : : */
2393 : : void
2394 : 1 : gi_marshalling_tests_gptrarray_utf8_full_out (GPtrArray **parray_)
2395 : : {
2396 : : static const gchar *values[] = { "0", "1", "2", NULL };
2397 : : gint i;
2398 : :
2399 : 1 : *parray_ = NULL;
2400 : :
2401 : 1 : *parray_ = g_ptr_array_new ();
2402 [ + + ]: 4 : for (i = 0; values[i]; i++)
2403 : : {
2404 : 3 : gchar *str = g_strdup (values[i]);
2405 : 3 : g_ptr_array_add (*parray_, (gpointer) str);
2406 : : }
2407 : 1 : }
2408 : :
2409 : : /**
2410 : : * gi_marshalling_tests_gptrarray_utf8_none_inout:
2411 : : * @parray_: (inout) (element-type utf8) (transfer none):
2412 : : */
2413 : : void
2414 : 1 : gi_marshalling_tests_gptrarray_utf8_none_inout (GPtrArray **parray_)
2415 : : {
2416 : : static GPtrArray *internal = NULL;
2417 : : static const gchar *values[] = { "-2", "-1", "0", "1", NULL };
2418 : : gint i;
2419 : :
2420 : 1 : g_assert_cmpint ((*parray_)->len, ==, 3);
2421 : 1 : g_assert_cmpstr (g_ptr_array_index (*parray_, 0), ==, "0");
2422 : 1 : g_assert_cmpstr (g_ptr_array_index (*parray_, 1), ==, "1");
2423 : 1 : g_assert_cmpstr (g_ptr_array_index (*parray_, 2), ==, "2");
2424 : :
2425 [ + - ]: 1 : if (internal == NULL)
2426 : : {
2427 : 1 : internal = g_ptr_array_new ();
2428 [ + + ]: 5 : for (i = 0; values[i]; i++)
2429 : 4 : g_ptr_array_add (internal, (gpointer) values[i]);
2430 : : }
2431 : :
2432 : 1 : *parray_ = internal;
2433 : 1 : }
2434 : :
2435 : : /**
2436 : : * gi_marshalling_tests_gptrarray_utf8_container_inout:
2437 : : * @parray_: (inout) (element-type utf8) (transfer container):
2438 : : */
2439 : : void
2440 : 0 : gi_marshalling_tests_gptrarray_utf8_container_inout (GPtrArray **parray_)
2441 : : {
2442 : : static const gchar *val1 = "-2";
2443 : : static const gchar *val2 = "-1";
2444 : : static const gchar *val3 = "0";
2445 : : static const gchar *val4 = "1";
2446 : : GPtrArray *result;
2447 : :
2448 : 0 : g_assert_cmpint ((*parray_)->len, ==, 3);
2449 : 0 : g_assert_cmpstr (g_ptr_array_index (*parray_, 0), ==, "0");
2450 : 0 : g_assert_cmpstr (g_ptr_array_index (*parray_, 1), ==, "1");
2451 : 0 : g_assert_cmpstr (g_ptr_array_index (*parray_, 2), ==, "2");
2452 : :
2453 : 0 : result = g_ptr_array_new ();
2454 : 0 : g_ptr_array_add (result, (gpointer) val1);
2455 : 0 : g_ptr_array_add (result, (gpointer) val2);
2456 : 0 : g_ptr_array_add (result, (gpointer) val3);
2457 : 0 : g_ptr_array_add (result, (gpointer) val4);
2458 : :
2459 : 0 : g_ptr_array_unref (*parray_);
2460 : 0 : *parray_ = result;
2461 : 0 : }
2462 : :
2463 : : /**
2464 : : * gi_marshalling_tests_gptrarray_utf8_full_inout:
2465 : : * @parray_: (inout) (element-type utf8) (transfer full):
2466 : : */
2467 : : void
2468 : 0 : gi_marshalling_tests_gptrarray_utf8_full_inout (GPtrArray **parray_)
2469 : : {
2470 : : static const gchar *val1 = "-1";
2471 : : static const gchar *val2 = "-2";
2472 : : gchar *val;
2473 : : GPtrArray *result;
2474 : :
2475 : 0 : g_assert_cmpint ((*parray_)->len, ==, 3);
2476 : 0 : g_assert_cmpstr (g_ptr_array_index (*parray_, 0), ==, "0");
2477 : 0 : g_assert_cmpstr (g_ptr_array_index (*parray_, 1), ==, "1");
2478 : 0 : g_assert_cmpstr (g_ptr_array_index (*parray_, 2), ==, "2");
2479 : :
2480 : 0 : result = g_ptr_array_new ();
2481 : 0 : val = g_strdup (val2);
2482 : 0 : g_ptr_array_add (result, (gpointer) val);
2483 : 0 : val = g_strdup (val1);
2484 : 0 : g_ptr_array_add (result, (gpointer) val);
2485 : 0 : val = g_strdup ("0");
2486 : 0 : g_ptr_array_add (result, (gpointer) val);
2487 : 0 : val = g_strdup ("1");
2488 : 0 : g_ptr_array_add (result, (gpointer) val);
2489 : :
2490 : 0 : g_ptr_array_unref (*parray_);
2491 : 0 : *parray_ = result;
2492 : 0 : }
2493 : :
2494 : : /**
2495 : : * gi_marshalling_tests_bytearray_full_return:
2496 : : *
2497 : : * Returns: (transfer full):
2498 : : */
2499 : : GByteArray *
2500 : 2 : gi_marshalling_tests_bytearray_full_return (void)
2501 : : {
2502 : 2 : GByteArray *array = NULL;
2503 : 2 : guint8 data[] = { '\0', '1', '\xFF', '3' };
2504 : :
2505 : 2 : array = g_byte_array_new ();
2506 : 2 : g_byte_array_append (array, (const guint8 *) data, G_N_ELEMENTS (data));
2507 : :
2508 : 2 : return array;
2509 : :
2510 : : }
2511 : :
2512 : : /**
2513 : : * gi_marshalling_tests_bytearray_none_in:
2514 : : * @v: (element-type gint8) (transfer none):
2515 : : */
2516 : : void
2517 : 3 : gi_marshalling_tests_bytearray_none_in (GByteArray *v)
2518 : : {
2519 : 3 : g_assert_cmpuint (v->len, ==, 4);
2520 : 3 : g_assert_cmpuint (g_array_index (v, unsigned char, 0), ==, 0);
2521 : 3 : g_assert_cmpuint (g_array_index (v, unsigned char, 1), ==, 49);
2522 : 3 : g_assert_cmpuint (g_array_index (v, unsigned char, 2), ==, 0xFF);
2523 : 3 : g_assert_cmpuint (g_array_index (v, unsigned char, 3), ==, 51);
2524 : 3 : }
2525 : :
2526 : : /**
2527 : : * gi_marshalling_tests_gbytes_full_return:
2528 : : *
2529 : : * Returns: (transfer full):
2530 : : */
2531 : : GBytes *
2532 : 3 : gi_marshalling_tests_gbytes_full_return (void)
2533 : : {
2534 : : static guint8 data[] = { 0, 49, 0xFF, 51 };
2535 : :
2536 : 3 : return g_bytes_new_static (data, G_N_ELEMENTS (data));
2537 : : }
2538 : :
2539 : : /**
2540 : : * gi_marshalling_tests_gbytes_none_in:
2541 : : */
2542 : : void
2543 : 4 : gi_marshalling_tests_gbytes_none_in (GBytes *v)
2544 : : {
2545 : : const guint8 *data;
2546 : : gsize len;
2547 : 4 : data = g_bytes_get_data (v, &len);
2548 : :
2549 : 4 : g_assert_cmpuint (len, ==, 4);
2550 : 4 : g_assert_cmpuint (data[0], ==, 0);
2551 : 4 : g_assert_cmpuint (data[1], ==, 49);
2552 : 4 : g_assert_cmpuint (data[2], ==, 0xFF);
2553 : 4 : g_assert_cmpuint (data[3], ==, 51);
2554 : 4 : }
2555 : :
2556 : : /**
2557 : : * gi_marshalling_tests_gstrv_return:
2558 : : *
2559 : : * Returns: (transfer full): an array of strings
2560 : : */
2561 : : GStrv
2562 : 1 : gi_marshalling_tests_gstrv_return (void)
2563 : : {
2564 : 1 : GStrv values = g_new0 (gchar *, 4);
2565 : 1 : values[0] = g_strdup ("0");
2566 : 1 : values[1] = g_strdup ("1");
2567 : 1 : values[2] = g_strdup ("2");
2568 : 1 : values[3] = NULL;
2569 : 1 : return values;
2570 : : }
2571 : :
2572 : : /**
2573 : : * gi_marshalling_tests_gstrv_in:
2574 : : * @g_strv:
2575 : : */
2576 : : void
2577 : 1 : gi_marshalling_tests_gstrv_in (GStrv g_strv)
2578 : : {
2579 : 1 : g_assert_cmpint (g_strv_length (g_strv), ==, 3);
2580 : 1 : g_assert_cmpstr (g_strv[0], ==, "0");
2581 : 1 : g_assert_cmpstr (g_strv[1], ==, "1");
2582 : 1 : g_assert_cmpstr (g_strv[2], ==, "2");
2583 : 1 : }
2584 : :
2585 : : /**
2586 : : * gi_marshalling_tests_gstrv_out:
2587 : : * @g_strv: (out) (transfer none):
2588 : : */
2589 : : void
2590 : 1 : gi_marshalling_tests_gstrv_out (GStrv *g_strv)
2591 : : {
2592 : : static const gchar *values[] = { "0", "1", "2", NULL };
2593 : 1 : *g_strv = (gchar **) values;
2594 : 1 : }
2595 : :
2596 : : /**
2597 : : * gi_marshalling_tests_gstrv_inout:
2598 : : * @g_strv: (inout) (transfer none):
2599 : : */
2600 : : void
2601 : 1 : gi_marshalling_tests_gstrv_inout (GStrv *g_strv)
2602 : : {
2603 : : static const gchar *values[] = { "-1", "0", "1", "2", NULL };
2604 : :
2605 : 1 : g_assert (g_strv_length (*g_strv) == 3);
2606 : 1 : g_assert (strcmp ((*g_strv)[0], "0") == 0);
2607 : 1 : g_assert (strcmp ((*g_strv)[1], "1") == 0);
2608 : 1 : g_assert (strcmp ((*g_strv)[2], "2") == 0);
2609 : :
2610 : 1 : *g_strv = (gchar **) values;
2611 : 1 : }
2612 : :
2613 : : /**
2614 : : * gi_marshalling_tests_glist_int_none_return:
2615 : : *
2616 : : * Returns: (element-type gint) (transfer none):
2617 : : */
2618 : : GList *
2619 : 1 : gi_marshalling_tests_glist_int_none_return (void)
2620 : : {
2621 : : static GList *list = NULL;
2622 : :
2623 [ + - ]: 1 : if (list == NULL)
2624 : : {
2625 : 1 : list = g_list_append (list, GINT_TO_POINTER (-1));
2626 : 1 : list = g_list_append (list, GINT_TO_POINTER (0));
2627 : 1 : list = g_list_append (list, GINT_TO_POINTER (1));
2628 : 1 : list = g_list_append (list, GINT_TO_POINTER (2));
2629 : : }
2630 : :
2631 : 1 : return list;
2632 : : }
2633 : :
2634 : : /**
2635 : : * gi_marshalling_tests_glist_uint32_none_return:
2636 : : *
2637 : : * Returns: (element-type guint32) (transfer none):
2638 : : */
2639 : : GList *
2640 : 1 : gi_marshalling_tests_glist_uint32_none_return (void)
2641 : : {
2642 : : static GList *list = NULL;
2643 : :
2644 [ + - ]: 1 : if (list == NULL)
2645 : : {
2646 : 1 : list = g_list_append (list, GUINT_TO_POINTER (0));
2647 : 1 : list = g_list_append (list, GUINT_TO_POINTER (G_MAXUINT32));
2648 : : }
2649 : :
2650 : 1 : return list;
2651 : : }
2652 : :
2653 : : /**
2654 : : * gi_marshalling_tests_glist_utf8_none_return:
2655 : : *
2656 : : * Returns: (element-type utf8) (transfer none):
2657 : : */
2658 : : GList *
2659 : 1 : gi_marshalling_tests_glist_utf8_none_return (void)
2660 : : {
2661 : : static GList *list = NULL;
2662 : :
2663 [ + - ]: 1 : if (list == NULL)
2664 : : {
2665 : 1 : list = g_list_append (list, (gpointer) "0");
2666 : 1 : list = g_list_append (list, (gpointer) "1");
2667 : 1 : list = g_list_append (list, (gpointer) "2");
2668 : : }
2669 : :
2670 : 1 : return list;
2671 : : }
2672 : :
2673 : : /**
2674 : : * gi_marshalling_tests_glist_utf8_container_return:
2675 : : *
2676 : : * Returns: (element-type utf8) (transfer container):
2677 : : */
2678 : : GList *
2679 : 1 : gi_marshalling_tests_glist_utf8_container_return (void)
2680 : : {
2681 : 1 : GList *list = NULL;
2682 : :
2683 : 1 : list = g_list_append (list, (gpointer) "0");
2684 : 1 : list = g_list_append (list, (gpointer) "1");
2685 : 1 : list = g_list_append (list, (gpointer) "2");
2686 : :
2687 : 1 : return list;
2688 : : }
2689 : :
2690 : : /**
2691 : : * gi_marshalling_tests_glist_utf8_full_return:
2692 : : *
2693 : : * Returns: (element-type utf8) (transfer full):
2694 : : */
2695 : : GList *
2696 : 1 : gi_marshalling_tests_glist_utf8_full_return (void)
2697 : : {
2698 : 1 : GList *list = NULL;
2699 : :
2700 : 1 : list = g_list_append (list, g_strdup ("0"));
2701 : 1 : list = g_list_append (list, g_strdup ("1"));
2702 : 1 : list = g_list_append (list, g_strdup ("2"));
2703 : :
2704 : 1 : return list;
2705 : : }
2706 : :
2707 : : /**
2708 : : * gi_marshalling_tests_glist_int_none_in:
2709 : : * @list: (element-type gint) (transfer none):
2710 : : */
2711 : : void
2712 : 1 : gi_marshalling_tests_glist_int_none_in (GList *list)
2713 : : {
2714 : 1 : g_assert_cmpint (g_list_length (list), ==, 4);
2715 : 1 : g_assert_cmpint (GPOINTER_TO_INT (g_list_nth_data (list, 0)), ==, -1);
2716 : 1 : g_assert_cmpint (GPOINTER_TO_INT (g_list_nth_data (list, 1)), ==, 0);
2717 : 1 : g_assert_cmpint (GPOINTER_TO_INT (g_list_nth_data (list, 2)), ==, 1);
2718 : 1 : g_assert_cmpint (GPOINTER_TO_INT (g_list_nth_data (list, 3)), ==, 2);
2719 : 1 : }
2720 : :
2721 : : /**
2722 : : * gi_marshalling_tests_glist_uint32_none_in:
2723 : : * @list: (element-type guint32) (transfer none):
2724 : : */
2725 : : void
2726 : 1 : gi_marshalling_tests_glist_uint32_none_in (GList *list)
2727 : : {
2728 : 1 : g_assert_cmpint (g_list_length (list), ==, 2);
2729 : 1 : g_assert_cmpint (GPOINTER_TO_UINT (g_list_nth_data (list, 0)), ==, 0);
2730 : 1 : g_assert_cmpint (GPOINTER_TO_UINT (g_list_nth_data (list, 1)), ==, G_MAXUINT32);
2731 : 1 : }
2732 : :
2733 : : /**
2734 : : * gi_marshalling_tests_glist_utf8_none_in:
2735 : : * @list: (element-type utf8) (transfer none):
2736 : : */
2737 : : void
2738 : 1 : gi_marshalling_tests_glist_utf8_none_in (GList *list)
2739 : : {
2740 : 1 : g_assert_cmpint (g_list_length (list), ==, 3);
2741 : 1 : g_assert_cmpint (strcmp (g_list_nth_data (list, 0), "0"), ==, 0);
2742 : 1 : g_assert_cmpint (strcmp (g_list_nth_data (list, 1), "1"), ==, 0);
2743 : 1 : g_assert_cmpint (strcmp (g_list_nth_data (list, 2), "2"), ==, 0);
2744 : 1 : }
2745 : :
2746 : : /**
2747 : : * gi_marshalling_tests_glist_utf8_none_out:
2748 : : * @list: (out) (element-type utf8) (transfer none):
2749 : : */
2750 : : void
2751 : 1 : gi_marshalling_tests_glist_utf8_none_out (GList **list)
2752 : : {
2753 : : static GList *values = NULL;
2754 : :
2755 [ + - ]: 1 : if (values == NULL)
2756 : : {
2757 : 1 : values = g_list_append (values, (gpointer) "0");
2758 : 1 : values = g_list_append (values, (gpointer) "1");
2759 : 1 : values = g_list_append (values, (gpointer) "2");
2760 : : }
2761 : :
2762 : 1 : *list = values;
2763 : 1 : }
2764 : :
2765 : : /**
2766 : : * gi_marshalling_tests_glist_utf8_container_out:
2767 : : * @list: (out) (element-type utf8) (transfer container):
2768 : : */
2769 : : void
2770 : 1 : gi_marshalling_tests_glist_utf8_container_out (GList **list)
2771 : : {
2772 : 1 : *list = NULL;
2773 : :
2774 : 1 : *list = g_list_append (*list, (gpointer) "0");
2775 : 1 : *list = g_list_append (*list, (gpointer) "1");
2776 : 1 : *list = g_list_append (*list, (gpointer) "2");
2777 : 1 : }
2778 : :
2779 : : /**
2780 : : * gi_marshalling_tests_glist_utf8_full_out:
2781 : : * @list: (out) (element-type utf8) (transfer full):
2782 : : */
2783 : : void
2784 : 1 : gi_marshalling_tests_glist_utf8_full_out (GList **list)
2785 : : {
2786 : 1 : *list = NULL;
2787 : :
2788 : 1 : *list = g_list_append (*list, g_strdup ("0"));
2789 : 1 : *list = g_list_append (*list, g_strdup ("1"));
2790 : 1 : *list = g_list_append (*list, g_strdup ("2"));
2791 : 1 : }
2792 : :
2793 : : /**
2794 : : * gi_marshalling_tests_glist_utf8_none_inout:
2795 : : * @list: (inout) (element-type utf8) (transfer none):
2796 : : */
2797 : : void
2798 : 1 : gi_marshalling_tests_glist_utf8_none_inout (GList **list)
2799 : : {
2800 : : static GList *values = NULL;
2801 : :
2802 : 1 : g_assert_cmpint (g_list_length (*list), ==, 3);
2803 : 1 : g_assert_cmpstr (g_list_nth_data (*list, 0), ==, "0");
2804 : 1 : g_assert_cmpstr (g_list_nth_data (*list, 1), ==, "1");
2805 : 1 : g_assert_cmpstr (g_list_nth_data (*list, 2), ==, "2");
2806 : :
2807 [ + - ]: 1 : if (values == NULL)
2808 : : {
2809 : 1 : values = g_list_append (values, (gpointer) "-2");
2810 : 1 : values = g_list_append (values, (gpointer) "-1");
2811 : 1 : values = g_list_append (values, (gpointer) "0");
2812 : 1 : values = g_list_append (values, (gpointer) "1");
2813 : : }
2814 : :
2815 : 1 : *list = values;
2816 : 1 : }
2817 : :
2818 : : /**
2819 : : * gi_marshalling_tests_glist_utf8_container_inout:
2820 : : * @list: (inout) (element-type utf8) (transfer container):
2821 : : */
2822 : : void
2823 : 0 : gi_marshalling_tests_glist_utf8_container_inout (GList **list)
2824 : : {
2825 : 0 : GList *result = NULL;
2826 : :
2827 : 0 : g_assert_cmpint (g_list_length (*list), ==, 3);
2828 : 0 : g_assert_cmpstr (g_list_nth_data (*list, 0), ==, "0");
2829 : 0 : g_assert_cmpstr (g_list_nth_data (*list, 1), ==, "1");
2830 : 0 : g_assert_cmpstr (g_list_nth_data (*list, 2), ==, "2");
2831 : :
2832 : 0 : result = g_list_prepend (result, (gpointer) "1");
2833 : 0 : result = g_list_prepend (result, (gpointer) "0");
2834 : 0 : result = g_list_prepend (result, (gpointer) "-1");
2835 : 0 : result = g_list_prepend (result, (gpointer) "-2");
2836 : :
2837 : 0 : g_list_free (*list);
2838 : 0 : *list = result;
2839 : 0 : }
2840 : :
2841 : : /**
2842 : : * gi_marshalling_tests_glist_utf8_full_inout:
2843 : : * @list: (inout) (element-type utf8) (transfer full):
2844 : : */
2845 : : void
2846 : 0 : gi_marshalling_tests_glist_utf8_full_inout (GList **list)
2847 : : {
2848 : 0 : GList *result = NULL;
2849 : :
2850 : 0 : g_assert_cmpint (g_list_length (*list), ==, 3);
2851 : 0 : g_assert_cmpstr (g_list_nth_data (*list, 0), ==, "0");
2852 : 0 : g_assert_cmpstr (g_list_nth_data (*list, 1), ==, "1");
2853 : 0 : g_assert_cmpstr (g_list_nth_data (*list, 2), ==, "2");
2854 : :
2855 : 0 : result = g_list_prepend (result, g_strdup ("1"));
2856 : 0 : result = g_list_prepend (result, g_strdup ("0"));
2857 : 0 : result = g_list_prepend (result, g_strdup ("-1"));
2858 : 0 : result = g_list_prepend (result, g_strdup ("-2"));
2859 : :
2860 : 0 : g_list_free_full (*list, g_free);
2861 : 0 : *list = result;
2862 : 0 : }
2863 : :
2864 : :
2865 : : /**
2866 : : * gi_marshalling_tests_gslist_int_none_return:
2867 : : *
2868 : : * Returns: (element-type gint) (transfer none):
2869 : : */
2870 : : GSList *
2871 : 1 : gi_marshalling_tests_gslist_int_none_return (void)
2872 : : {
2873 : : static GSList *list = NULL;
2874 : :
2875 [ + - ]: 1 : if (list == NULL)
2876 : : {
2877 : 1 : list = g_slist_prepend (list, GINT_TO_POINTER (-1));
2878 : 1 : list = g_slist_prepend (list, GINT_TO_POINTER (0));
2879 : 1 : list = g_slist_prepend (list, GINT_TO_POINTER (1));
2880 : 1 : list = g_slist_prepend (list, GINT_TO_POINTER (2));
2881 : 1 : list = g_slist_reverse (list);
2882 : : }
2883 : :
2884 : 1 : return list;
2885 : : }
2886 : :
2887 : : /**
2888 : : * gi_marshalling_tests_gslist_utf8_none_return:
2889 : : *
2890 : : * Returns: (element-type utf8) (transfer none):
2891 : : */
2892 : : GSList *
2893 : 1 : gi_marshalling_tests_gslist_utf8_none_return (void)
2894 : : {
2895 : : static GSList *list = NULL;
2896 : :
2897 [ + - ]: 1 : if (list == NULL)
2898 : : {
2899 : 1 : list = g_slist_prepend (list, (gpointer) "0");
2900 : 1 : list = g_slist_prepend (list, (gpointer) "1");
2901 : 1 : list = g_slist_prepend (list, (gpointer) "2");
2902 : 1 : list = g_slist_reverse (list);
2903 : : }
2904 : :
2905 : 1 : return list;
2906 : : }
2907 : :
2908 : : /**
2909 : : * gi_marshalling_tests_gslist_utf8_container_return:
2910 : : *
2911 : : * Returns: (element-type utf8) (transfer container):
2912 : : */
2913 : : GSList *
2914 : 1 : gi_marshalling_tests_gslist_utf8_container_return (void)
2915 : : {
2916 : 1 : GSList *list = NULL;
2917 : :
2918 : 1 : list = g_slist_prepend (list, (gpointer) "0");
2919 : 1 : list = g_slist_prepend (list, (gpointer) "1");
2920 : 1 : list = g_slist_prepend (list, (gpointer) "2");
2921 : 1 : list = g_slist_reverse (list);
2922 : :
2923 : 1 : return list;
2924 : : }
2925 : :
2926 : : /**
2927 : : * gi_marshalling_tests_gslist_utf8_full_return:
2928 : : *
2929 : : * Returns: (element-type utf8) (transfer full):
2930 : : */
2931 : : GSList *
2932 : 1 : gi_marshalling_tests_gslist_utf8_full_return (void)
2933 : : {
2934 : 1 : GSList *list = NULL;
2935 : :
2936 : 1 : list = g_slist_prepend (list, g_strdup ("0"));
2937 : 1 : list = g_slist_prepend (list, g_strdup ("1"));
2938 : 1 : list = g_slist_prepend (list, g_strdup ("2"));
2939 : 1 : list = g_slist_reverse (list);
2940 : :
2941 : 1 : return list;
2942 : : }
2943 : :
2944 : : /**
2945 : : * gi_marshalling_tests_gslist_int_none_in:
2946 : : * @list: (element-type gint) (transfer none):
2947 : : */
2948 : : void
2949 : 1 : gi_marshalling_tests_gslist_int_none_in (GSList *list)
2950 : : {
2951 : 1 : g_assert_cmpint (g_slist_length (list), ==, 4);
2952 : 1 : g_assert_cmpint (GPOINTER_TO_INT (g_slist_nth_data (list, 0)), ==, -1);
2953 : 1 : g_assert_cmpint (GPOINTER_TO_INT (g_slist_nth_data (list, 1)), ==, 0);
2954 : 1 : g_assert_cmpint (GPOINTER_TO_INT (g_slist_nth_data (list, 2)), ==, 1);
2955 : 1 : g_assert_cmpint (GPOINTER_TO_INT (g_slist_nth_data (list, 3)), ==, 2);
2956 : 1 : }
2957 : :
2958 : : /**
2959 : : * gi_marshalling_tests_gslist_utf8_none_in:
2960 : : * @list: (element-type utf8) (transfer none):
2961 : : */
2962 : : void
2963 : 1 : gi_marshalling_tests_gslist_utf8_none_in (GSList *list)
2964 : : {
2965 : 1 : g_assert_cmpint (g_slist_length (list), ==, 3);
2966 : 1 : g_assert_cmpstr (g_slist_nth_data (list, 0), ==, "0");
2967 : 1 : g_assert_cmpstr (g_slist_nth_data (list, 1), ==, "1");
2968 : 1 : g_assert_cmpstr (g_slist_nth_data (list, 2), ==, "2");
2969 : 1 : }
2970 : :
2971 : : /**
2972 : : * gi_marshalling_tests_gslist_utf8_none_out:
2973 : : * @list: (out) (element-type utf8) (transfer none):
2974 : : */
2975 : : void
2976 : 1 : gi_marshalling_tests_gslist_utf8_none_out (GSList **list)
2977 : : {
2978 : : static GSList *values = NULL;
2979 : :
2980 [ + - ]: 1 : if (values == NULL)
2981 : : {
2982 : 1 : values = g_slist_prepend (values, (gpointer) "0");
2983 : 1 : values = g_slist_prepend (values, (gpointer) "1");
2984 : 1 : values = g_slist_prepend (values, (gpointer) "2");
2985 : 1 : values = g_slist_reverse (values);
2986 : : }
2987 : :
2988 : 1 : *list = values;
2989 : 1 : }
2990 : :
2991 : : /**
2992 : : * gi_marshalling_tests_gslist_utf8_container_out:
2993 : : * @list: (out) (element-type utf8) (transfer container):
2994 : : */
2995 : : void
2996 : 1 : gi_marshalling_tests_gslist_utf8_container_out (GSList **list)
2997 : : {
2998 : 1 : *list = NULL;
2999 : :
3000 : 1 : *list = g_slist_prepend (*list, (gpointer) "0");
3001 : 1 : *list = g_slist_prepend (*list, (gpointer) "1");
3002 : 1 : *list = g_slist_prepend (*list, (gpointer) "2");
3003 : 1 : *list = g_slist_reverse (*list);
3004 : 1 : }
3005 : :
3006 : : /**
3007 : : * gi_marshalling_tests_gslist_utf8_full_out:
3008 : : * @list: (out) (element-type utf8) (transfer full):
3009 : : */
3010 : : void
3011 : 1 : gi_marshalling_tests_gslist_utf8_full_out (GSList **list)
3012 : : {
3013 : 1 : *list = NULL;
3014 : :
3015 : 1 : *list = g_slist_prepend (*list, g_strdup ("0"));
3016 : 1 : *list = g_slist_prepend (*list, g_strdup ("1"));
3017 : 1 : *list = g_slist_prepend (*list, g_strdup ("2"));
3018 : 1 : *list = g_slist_reverse (*list);
3019 : 1 : }
3020 : :
3021 : : /**
3022 : : * gi_marshalling_tests_gslist_utf8_none_inout:
3023 : : * @list: (inout) (element-type utf8) (transfer none):
3024 : : */
3025 : : void
3026 : 1 : gi_marshalling_tests_gslist_utf8_none_inout (GSList **list)
3027 : : {
3028 : : static GSList *values = NULL;
3029 : :
3030 : 1 : g_assert_cmpint (g_slist_length (*list), ==, 3);
3031 : 1 : g_assert_cmpstr (g_slist_nth_data (*list, 0), ==, "0");
3032 : 1 : g_assert_cmpstr (g_slist_nth_data (*list, 1), ==, "1");
3033 : 1 : g_assert_cmpstr (g_slist_nth_data (*list, 2), ==, "2");
3034 : :
3035 [ + - ]: 1 : if (values == NULL)
3036 : : {
3037 : 1 : values = g_slist_prepend (values, (gpointer) "-2");
3038 : 1 : values = g_slist_prepend (values, (gpointer) "-1");
3039 : 1 : values = g_slist_prepend (values, (gpointer) "0");
3040 : 1 : values = g_slist_prepend (values, (gpointer) "1");
3041 : 1 : values = g_slist_reverse (values);
3042 : : }
3043 : :
3044 : 1 : *list = values;
3045 : 1 : }
3046 : :
3047 : : /**
3048 : : * gi_marshalling_tests_gslist_utf8_container_inout:
3049 : : * @list: (inout) (element-type utf8) (transfer container):
3050 : : */
3051 : : void
3052 : 0 : gi_marshalling_tests_gslist_utf8_container_inout (GSList **list)
3053 : : {
3054 : 0 : GSList *result = NULL;
3055 : :
3056 : 0 : g_assert_cmpint (g_slist_length (*list), ==, 3);
3057 : 0 : g_assert_cmpstr (g_slist_nth_data (*list, 0), ==, "0");
3058 : 0 : g_assert_cmpstr (g_slist_nth_data (*list, 1), ==, "1");
3059 : 0 : g_assert_cmpstr (g_slist_nth_data (*list, 2), ==, "2");
3060 : :
3061 : 0 : result = g_slist_prepend (result, (gpointer) "1");
3062 : 0 : result = g_slist_prepend (result, (gpointer) "0");
3063 : 0 : result = g_slist_prepend (result, (gpointer) "-1");
3064 : 0 : result = g_slist_prepend (result, (gpointer) "-2");
3065 : :
3066 : 0 : g_slist_free (*list);
3067 : 0 : *list = result;
3068 : 0 : }
3069 : :
3070 : : /**
3071 : : * gi_marshalling_tests_gslist_utf8_full_inout:
3072 : : * @list: (inout) (element-type utf8) (transfer full):
3073 : : */
3074 : : void
3075 : 0 : gi_marshalling_tests_gslist_utf8_full_inout (GSList **list)
3076 : : {
3077 : 0 : GSList *result = NULL;
3078 : :
3079 : 0 : g_assert_cmpint (g_slist_length (*list), ==, 3);
3080 : 0 : g_assert_cmpstr (g_slist_nth_data (*list, 0), ==, "0");
3081 : 0 : g_assert_cmpstr (g_slist_nth_data (*list, 1), ==, "1");
3082 : 0 : g_assert_cmpstr (g_slist_nth_data (*list, 2), ==, "2");
3083 : :
3084 : 0 : result = g_slist_prepend (result, g_strdup ("1"));
3085 : 0 : result = g_slist_prepend (result, g_strdup ("0"));
3086 : 0 : result = g_slist_prepend (result, g_strdup ("-1"));
3087 : 0 : result = g_slist_prepend (result, g_strdup ("-2"));
3088 : :
3089 : 0 : g_slist_free_full (*list, g_free);
3090 : 0 : *list = result;
3091 : 0 : }
3092 : :
3093 : :
3094 : : /**
3095 : : * gi_marshalling_tests_ghashtable_int_none_return:
3096 : : *
3097 : : * Returns: (element-type gint gint) (transfer none):
3098 : : */
3099 : : GHashTable *
3100 : 1 : gi_marshalling_tests_ghashtable_int_none_return (void)
3101 : : {
3102 : : static GHashTable *hash_table = NULL;
3103 : :
3104 [ + - ]: 1 : if (hash_table == NULL)
3105 : : {
3106 : 1 : hash_table = g_hash_table_new (NULL, NULL);
3107 : 1 : g_hash_table_insert (hash_table, GINT_TO_POINTER (-1), GINT_TO_POINTER (1));
3108 : 1 : g_hash_table_insert (hash_table, GINT_TO_POINTER (0), GINT_TO_POINTER (0));
3109 : 1 : g_hash_table_insert (hash_table, GINT_TO_POINTER (1), GINT_TO_POINTER (-1));
3110 : 1 : g_hash_table_insert (hash_table, GINT_TO_POINTER (2), GINT_TO_POINTER (-2));
3111 : : }
3112 : :
3113 : 1 : return hash_table;
3114 : : }
3115 : :
3116 : : /**
3117 : : * gi_marshalling_tests_ghashtable_utf8_none_return:
3118 : : *
3119 : : * Returns: (element-type utf8 utf8) (transfer none):
3120 : : */
3121 : : GHashTable *
3122 : 1 : gi_marshalling_tests_ghashtable_utf8_none_return (void)
3123 : : {
3124 : : static GHashTable *hash_table = NULL;
3125 : :
3126 [ + - ]: 1 : if (hash_table == NULL)
3127 : : {
3128 : 1 : hash_table = g_hash_table_new (g_str_hash, g_str_equal);
3129 : 1 : g_hash_table_insert (hash_table, (gpointer) "-1", (gpointer) "1");
3130 : 1 : g_hash_table_insert (hash_table, (gpointer) "0", (gpointer) "0");
3131 : 1 : g_hash_table_insert (hash_table, (gpointer) "1", (gpointer) "-1");
3132 : 1 : g_hash_table_insert (hash_table, (gpointer) "2", (gpointer) "-2");
3133 : : }
3134 : :
3135 : 1 : return hash_table;
3136 : : }
3137 : :
3138 : : /**
3139 : : * gi_marshalling_tests_ghashtable_utf8_container_return:
3140 : : *
3141 : : * Returns: (element-type utf8 utf8) (transfer container):
3142 : : */
3143 : : GHashTable *
3144 : 1 : gi_marshalling_tests_ghashtable_utf8_container_return (void)
3145 : : {
3146 : 1 : GHashTable *hash_table = NULL;
3147 : :
3148 : 1 : hash_table = g_hash_table_new (g_str_hash, g_str_equal);
3149 : 1 : g_hash_table_insert (hash_table, (gpointer) "-1", (gpointer) "1");
3150 : 1 : g_hash_table_insert (hash_table, (gpointer) "0", (gpointer) "0");
3151 : 1 : g_hash_table_insert (hash_table, (gpointer) "1", (gpointer) "-1");
3152 : 1 : g_hash_table_insert (hash_table, (gpointer) "2", (gpointer) "-2");
3153 : :
3154 : 1 : return hash_table;
3155 : : }
3156 : :
3157 : : /**
3158 : : * gi_marshalling_tests_ghashtable_utf8_full_return:
3159 : : *
3160 : : * Returns: (element-type utf8 utf8) (transfer full):
3161 : : */
3162 : : GHashTable *
3163 : 1 : gi_marshalling_tests_ghashtable_utf8_full_return (void)
3164 : : {
3165 : 1 : GHashTable *hash_table = NULL;
3166 : :
3167 : 1 : hash_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
3168 : 1 : g_hash_table_insert (hash_table, g_strdup ("-1"), g_strdup ("1"));
3169 : 1 : g_hash_table_insert (hash_table, g_strdup ("0"), g_strdup ("0"));
3170 : 1 : g_hash_table_insert (hash_table, g_strdup ("1"), g_strdup ("-1"));
3171 : 1 : g_hash_table_insert (hash_table, g_strdup ("2"), g_strdup ("-2"));
3172 : :
3173 : 1 : return hash_table;
3174 : : }
3175 : :
3176 : : /**
3177 : : * gi_marshalling_tests_ghashtable_int_none_in:
3178 : : * @hash_table: (element-type gint gint) (transfer none):
3179 : : */
3180 : : void
3181 : 2 : gi_marshalling_tests_ghashtable_int_none_in (GHashTable *hash_table)
3182 : : {
3183 : 2 : g_assert_cmpint (GPOINTER_TO_INT (g_hash_table_lookup (hash_table, GINT_TO_POINTER (-1))), ==, 1);
3184 : 2 : g_assert_cmpint (GPOINTER_TO_INT (g_hash_table_lookup (hash_table, GINT_TO_POINTER (0))), ==, 0);
3185 : 2 : g_assert_cmpint (GPOINTER_TO_INT (g_hash_table_lookup (hash_table, GINT_TO_POINTER (1))), ==, -1);
3186 : 2 : g_assert_cmpint (GPOINTER_TO_INT (g_hash_table_lookup (hash_table, GINT_TO_POINTER (2))), ==, -2);
3187 : 2 : }
3188 : :
3189 : : /**
3190 : : * gi_marshalling_tests_ghashtable_utf8_none_in:
3191 : : * @hash_table: (element-type utf8 utf8) (transfer none):
3192 : : */
3193 : : void
3194 : 1 : gi_marshalling_tests_ghashtable_utf8_none_in (GHashTable *hash_table)
3195 : : {
3196 : 1 : g_assert_cmpstr (g_hash_table_lookup (hash_table, "-1"), ==, "1");
3197 : 1 : g_assert_cmpstr (g_hash_table_lookup (hash_table, "0"), ==, "0");
3198 : 1 : g_assert_cmpstr (g_hash_table_lookup (hash_table, "1"), ==, "-1");
3199 : 1 : g_assert_cmpstr (g_hash_table_lookup (hash_table, "2"), ==, "-2");
3200 : 1 : }
3201 : :
3202 : : /**
3203 : : * gi_marshalling_tests_ghashtable_double_in:
3204 : : * @hash_table: (element-type utf8 double) (transfer none):
3205 : : *
3206 : : * Meant to test a value type that doesn't fit inside a pointer.
3207 : : */
3208 : : void
3209 : 1 : gi_marshalling_tests_ghashtable_double_in (GHashTable *hash_table)
3210 : : {
3211 : : double *value;
3212 : :
3213 : 1 : value = g_hash_table_lookup (hash_table, "-1");
3214 : 1 : g_assert_cmpfloat_with_epsilon (*value, -0.1, 0.01);
3215 : 1 : value = g_hash_table_lookup (hash_table, "0");
3216 : 1 : g_assert_cmpfloat (*value, ==, 0.0);
3217 : 1 : value = g_hash_table_lookup (hash_table, "1");
3218 : 1 : g_assert_cmpfloat_with_epsilon (*value, 0.1, 0.01);
3219 : 1 : value = g_hash_table_lookup (hash_table, "2");
3220 : 1 : g_assert_cmpfloat_with_epsilon (*value, 0.2, 0.01);
3221 : 1 : }
3222 : :
3223 : : /**
3224 : : * gi_marshalling_tests_ghashtable_float_in:
3225 : : * @hash_table: (element-type utf8 float) (transfer none):
3226 : : *
3227 : : * Meant to test a value type that doesn't fit inside a pointer.
3228 : : */
3229 : : void
3230 : 1 : gi_marshalling_tests_ghashtable_float_in (GHashTable *hash_table)
3231 : : {
3232 : : float *value;
3233 : :
3234 : 1 : value = g_hash_table_lookup (hash_table, "-1");
3235 : 1 : g_assert_cmpfloat_with_epsilon (*value, -0.1f, 0.01f);
3236 : 1 : value = g_hash_table_lookup (hash_table, "0");
3237 : 1 : g_assert_cmpfloat (*value, ==, 0.0f);
3238 : 1 : value = g_hash_table_lookup (hash_table, "1");
3239 : 1 : g_assert_cmpfloat_with_epsilon (*value, 0.1f, 0.01f);
3240 : 1 : value = g_hash_table_lookup (hash_table, "2");
3241 : 1 : g_assert_cmpfloat_with_epsilon (*value, 0.2f, 0.01f);
3242 : 1 : }
3243 : :
3244 : : /**
3245 : : * gi_marshalling_tests_ghashtable_int64_in:
3246 : : * @hash_table: (element-type utf8 gint64) (transfer none):
3247 : : *
3248 : : * Meant to test a value type that doesn't fit inside a pointer.
3249 : : */
3250 : : void
3251 : 1 : gi_marshalling_tests_ghashtable_int64_in (GHashTable *hash_table)
3252 : : {
3253 : : gint64 *value;
3254 : :
3255 : 1 : value = g_hash_table_lookup (hash_table, "-1");
3256 : 1 : g_assert_cmpint (*value, ==, -1);
3257 : 1 : value = g_hash_table_lookup (hash_table, "0");
3258 : 1 : g_assert_cmpint (*value, ==, 0);
3259 : 1 : value = g_hash_table_lookup (hash_table, "1");
3260 : 1 : g_assert_cmpint (*value, ==, 1);
3261 : 1 : value = g_hash_table_lookup (hash_table, "2");
3262 : 1 : g_assert_cmpint (*value, ==, (gint64) G_MAXUINT32 + 1);
3263 : 1 : }
3264 : :
3265 : : /**
3266 : : * gi_marshalling_tests_ghashtable_uint64_in:
3267 : : * @hash_table: (element-type utf8 guint64) (transfer none):
3268 : : *
3269 : : * Meant to test a value type that doesn't fit inside a pointer.
3270 : : */
3271 : : void
3272 : 1 : gi_marshalling_tests_ghashtable_uint64_in (GHashTable *hash_table)
3273 : : {
3274 : : guint64 *value;
3275 : :
3276 : 1 : value = g_hash_table_lookup (hash_table, "-1");
3277 : 1 : g_assert_cmpuint (*value, ==, (guint64) G_MAXUINT32 + 1);
3278 : 1 : value = g_hash_table_lookup (hash_table, "0");
3279 : 1 : g_assert_cmpuint (*value, ==, 0);
3280 : 1 : value = g_hash_table_lookup (hash_table, "1");
3281 : 1 : g_assert_cmpuint (*value, ==, 1);
3282 : 1 : value = g_hash_table_lookup (hash_table, "2");
3283 : 1 : g_assert_cmpuint (*value, ==, 2);
3284 : 1 : }
3285 : :
3286 : : /**
3287 : : * gi_marshalling_tests_ghashtable_utf8_none_out:
3288 : : * @hash_table: (out) (element-type utf8 utf8) (transfer none):
3289 : : */
3290 : : void
3291 : 1 : gi_marshalling_tests_ghashtable_utf8_none_out (GHashTable **hash_table)
3292 : : {
3293 : : static GHashTable *new_hash_table = NULL;
3294 : :
3295 [ + - ]: 1 : if (new_hash_table == NULL)
3296 : : {
3297 : 1 : new_hash_table = g_hash_table_new (g_str_hash, g_str_equal);
3298 : 1 : g_hash_table_insert (new_hash_table, (gpointer) "-1", (gpointer) "1");
3299 : 1 : g_hash_table_insert (new_hash_table, (gpointer) "0", (gpointer) "0");
3300 : 1 : g_hash_table_insert (new_hash_table, (gpointer) "1", (gpointer) "-1");
3301 : 1 : g_hash_table_insert (new_hash_table, (gpointer) "2", (gpointer) "-2");
3302 : : }
3303 : :
3304 : 1 : *hash_table = new_hash_table;
3305 : 1 : }
3306 : :
3307 : : /**
3308 : : * gi_marshalling_tests_ghashtable_utf8_container_out:
3309 : : * @hash_table: (out) (element-type utf8 utf8) (transfer container):
3310 : : */
3311 : : void
3312 : 1 : gi_marshalling_tests_ghashtable_utf8_container_out (GHashTable **hash_table)
3313 : : {
3314 : 1 : *hash_table = g_hash_table_new (g_str_hash, g_str_equal);
3315 : 1 : g_hash_table_insert (*hash_table, (gpointer) "-1", (gpointer) "1");
3316 : 1 : g_hash_table_insert (*hash_table, (gpointer) "0", (gpointer) "0");
3317 : 1 : g_hash_table_insert (*hash_table, (gpointer) "1", (gpointer) "-1");
3318 : 1 : g_hash_table_insert (*hash_table, (gpointer) "2", (gpointer) "-2");
3319 : 1 : }
3320 : :
3321 : : /**
3322 : : * gi_marshalling_tests_ghashtable_utf8_full_out:
3323 : : * @hash_table: (out) (element-type utf8 utf8) (transfer full):
3324 : : */
3325 : : void
3326 : 1 : gi_marshalling_tests_ghashtable_utf8_full_out (GHashTable **hash_table)
3327 : : {
3328 : 1 : *hash_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
3329 : 1 : g_hash_table_insert (*hash_table, g_strdup ("-1"), g_strdup ("1"));
3330 : 1 : g_hash_table_insert (*hash_table, g_strdup ("0"), g_strdup ("0"));
3331 : 1 : g_hash_table_insert (*hash_table, g_strdup ("1"), g_strdup ("-1"));
3332 : 1 : g_hash_table_insert (*hash_table, g_strdup ("2"), g_strdup ("-2"));
3333 : 1 : }
3334 : :
3335 : : /**
3336 : : * gi_marshalling_tests_ghashtable_utf8_none_inout:
3337 : : * @hash_table: (inout) (element-type utf8 utf8) (transfer none):
3338 : : */
3339 : : void
3340 : 1 : gi_marshalling_tests_ghashtable_utf8_none_inout (GHashTable **hash_table)
3341 : : {
3342 : : static GHashTable *new_hash_table = NULL;
3343 : :
3344 : 1 : g_assert_cmpstr (g_hash_table_lookup (*hash_table, "-1"), ==, "1");
3345 : 1 : g_assert_cmpstr (g_hash_table_lookup (*hash_table, "0"), ==, "0");
3346 : 1 : g_assert_cmpstr (g_hash_table_lookup (*hash_table, "1"), ==, "-1");
3347 : 1 : g_assert_cmpstr (g_hash_table_lookup (*hash_table, "2"), ==, "-2");
3348 : :
3349 [ + - ]: 1 : if (new_hash_table == NULL)
3350 : : {
3351 : 1 : new_hash_table = g_hash_table_new (g_str_hash, g_str_equal);
3352 : 1 : g_hash_table_insert (new_hash_table, (gpointer) "-1", (gpointer) "1");
3353 : 1 : g_hash_table_insert (new_hash_table, (gpointer) "0", (gpointer) "0");
3354 : 1 : g_hash_table_insert (new_hash_table, (gpointer) "1", (gpointer) "1");
3355 : : }
3356 : :
3357 : 1 : *hash_table = new_hash_table;
3358 : 1 : }
3359 : :
3360 : : /**
3361 : : * gi_marshalling_tests_ghashtable_utf8_container_inout:
3362 : : * @hash_table: (inout) (element-type utf8 utf8) (transfer container):
3363 : : */
3364 : : void
3365 : 0 : gi_marshalling_tests_ghashtable_utf8_container_inout (GHashTable **hash_table)
3366 : : {
3367 : 0 : GHashTable *result = g_hash_table_new (g_str_hash, g_str_equal);
3368 : :
3369 : 0 : g_assert_cmpstr (g_hash_table_lookup (*hash_table, "-1"), ==, "1");
3370 : 0 : g_assert_cmpstr (g_hash_table_lookup (*hash_table, "0"), ==, "0");
3371 : 0 : g_assert_cmpstr (g_hash_table_lookup (*hash_table, "1"), ==, "-1");
3372 : 0 : g_assert_cmpstr (g_hash_table_lookup (*hash_table, "2"), ==, "-2");
3373 : :
3374 : 0 : g_hash_table_insert (result, (gpointer) "-1", (gpointer) "1");
3375 : 0 : g_hash_table_insert (result, (gpointer) "0", (gpointer) "0");
3376 : 0 : g_hash_table_insert (result, (gpointer) "1", (gpointer) "1");
3377 : :
3378 : 0 : g_hash_table_unref (*hash_table);
3379 : 0 : *hash_table = result;
3380 : 0 : }
3381 : :
3382 : : /**
3383 : : * gi_marshalling_tests_ghashtable_utf8_full_inout:
3384 : : * @hash_table: (inout) (element-type utf8 utf8) (transfer full):
3385 : : */
3386 : : void
3387 : 0 : gi_marshalling_tests_ghashtable_utf8_full_inout (GHashTable **hash_table)
3388 : : {
3389 : 0 : GHashTable *result = g_hash_table_new_full (g_str_hash, g_str_equal,
3390 : : g_free, g_free);
3391 : :
3392 : 0 : g_assert_cmpstr (g_hash_table_lookup (*hash_table, "-1"), ==, "1");
3393 : 0 : g_assert_cmpstr (g_hash_table_lookup (*hash_table, "0"), ==, "0");
3394 : 0 : g_assert_cmpstr (g_hash_table_lookup (*hash_table, "1"), ==, "-1");
3395 : 0 : g_assert_cmpstr (g_hash_table_lookup (*hash_table, "2"), ==, "-2");
3396 : :
3397 : 0 : g_hash_table_insert (result, g_strdup ("-1"), g_strdup ("1"));
3398 : 0 : g_hash_table_insert (result, g_strdup ("0"), g_strdup ("0"));
3399 : 0 : g_hash_table_insert (result, g_strdup ("1"), g_strdup ("1"));
3400 : :
3401 : 0 : g_hash_table_unref (*hash_table);
3402 : 0 : *hash_table = result;
3403 : 0 : }
3404 : :
3405 : :
3406 : : /**
3407 : : * gi_marshalling_tests_gvalue_return:
3408 : : *
3409 : : * Returns: (transfer none):
3410 : : */
3411 : : GValue *
3412 : 1 : gi_marshalling_tests_gvalue_return (void)
3413 : : {
3414 : : static GValue *value = NULL;
3415 : :
3416 [ + - ]: 1 : if (value == NULL)
3417 : : {
3418 : 1 : value = g_new0 (GValue, 1);
3419 : 1 : g_value_init (value, G_TYPE_INT);
3420 : 1 : g_value_set_int (value, 42);
3421 : : }
3422 : :
3423 : 1 : return value;
3424 : : }
3425 : :
3426 : : /**
3427 : : * gi_marshalling_tests_gvalue_in:
3428 : : * @value: (transfer none):
3429 : : */
3430 : : void
3431 : 1 : gi_marshalling_tests_gvalue_in (GValue *value)
3432 : : {
3433 : 1 : g_assert_cmpint (g_value_get_int (value), ==, 42);
3434 : 1 : }
3435 : :
3436 : : /**
3437 : : * gi_marshalling_tests_gvalue_int64_in:
3438 : : * @value: (transfer none):
3439 : : */
3440 : : void
3441 : 1 : gi_marshalling_tests_gvalue_int64_in (GValue *value)
3442 : : {
3443 : 1 : g_assert_cmpint (g_value_get_int64 (value), ==, G_MAXINT64);
3444 : 1 : }
3445 : :
3446 : : /**
3447 : : * gi_marshalling_tests_gvalue_in_with_type:
3448 : : * @value: (transfer none):
3449 : : * @type:
3450 : : */
3451 : : void
3452 : 22 : gi_marshalling_tests_gvalue_in_with_type (GValue *value, GType type)
3453 : : {
3454 : 22 : g_assert (g_type_is_a (G_VALUE_TYPE (value), type));
3455 : 22 : }
3456 : :
3457 : : /**
3458 : : * gi_marshalling_tests_gvalue_in_with_modification:
3459 : : * @value: (transfer none):
3460 : : *
3461 : : * Expects a GValue passed by reference which is then modified by
3462 : : * this function.
3463 : : */
3464 : : void
3465 : 2 : gi_marshalling_tests_gvalue_in_with_modification (GValue *value)
3466 : : {
3467 : 2 : g_assert_cmpint (g_value_get_int (value), ==, 42);
3468 : 2 : g_value_set_int (value, 24);
3469 : 2 : }
3470 : :
3471 : : /**
3472 : : * gi_marshalling_tests_gvalue_in_enum:
3473 : : * @value: (transfer none):
3474 : : */
3475 : : void
3476 : 1 : gi_marshalling_tests_gvalue_in_enum (GValue *value)
3477 : : {
3478 [ - + + - : 1 : if (!G_VALUE_HOLDS_ENUM (value))
- + ]
3479 : 0 : g_critical ("Expected enum, got %s", G_VALUE_TYPE_NAME (value));
3480 : 1 : g_assert (g_value_get_enum (value) == GI_MARSHALLING_TESTS_ENUM_VALUE3);
3481 : 1 : }
3482 : :
3483 : : /**
3484 : : * gi_marshalling_tests_gvalue_in_flags:
3485 : : * @value: (transfer none):
3486 : : */
3487 : : void
3488 : 1 : gi_marshalling_tests_gvalue_in_flags (GValue *value)
3489 : : {
3490 [ - + - + : 1 : if (!G_VALUE_HOLDS_FLAGS (value))
- + ]
3491 : 0 : g_critical ("Expected flags, got %s", G_VALUE_TYPE_NAME (value));
3492 : 1 : g_assert_cmpint (g_value_get_flags (value), ==, GI_MARSHALLING_TESTS_FLAGS_VALUE3);
3493 : 1 : }
3494 : :
3495 : : /**
3496 : : * gi_marshalling_tests_gvalue_out:
3497 : : * @value: (out) (transfer none):
3498 : : */
3499 : : void
3500 : 1 : gi_marshalling_tests_gvalue_out (GValue **value)
3501 : : {
3502 : : static GValue *new_value = NULL;
3503 : :
3504 [ + - ]: 1 : if (new_value == NULL)
3505 : : {
3506 : 1 : new_value = g_new0 (GValue, 1);
3507 : 1 : g_value_init (new_value, G_TYPE_INT);
3508 : 1 : g_value_set_int (new_value, 42);
3509 : : }
3510 : :
3511 : 1 : *value = new_value;
3512 : 1 : }
3513 : :
3514 : : /**
3515 : : * gi_marshalling_tests_gvalue_int64_out:
3516 : : * @value: (out) (transfer none):
3517 : : */
3518 : : void
3519 : 1 : gi_marshalling_tests_gvalue_int64_out (GValue **value)
3520 : : {
3521 : : static GValue *new_value = NULL;
3522 : :
3523 [ + - ]: 1 : if (new_value == NULL)
3524 : : {
3525 : 1 : new_value = g_new0 (GValue, 1);
3526 : 1 : g_value_init (new_value, G_TYPE_INT64);
3527 : 1 : g_value_set_int64 (new_value, G_MAXINT64);
3528 : : }
3529 : :
3530 : 1 : *value = new_value;
3531 : 1 : }
3532 : :
3533 : : /**
3534 : : * gi_marshalling_tests_gvalue_out_caller_allocates:
3535 : : * @value: (out) (transfer none):
3536 : : */
3537 : : void
3538 : 1 : gi_marshalling_tests_gvalue_out_caller_allocates (GValue *value)
3539 : : {
3540 : 1 : g_value_init (value, G_TYPE_INT);
3541 : 1 : g_value_set_int (value, 42);
3542 : 1 : }
3543 : :
3544 : : /**
3545 : : * gi_marshalling_tests_gvalue_inout:
3546 : : * @value: (inout) (transfer none):
3547 : : */
3548 : : void
3549 : 0 : gi_marshalling_tests_gvalue_inout (GValue **value)
3550 : : {
3551 : 0 : g_assert_cmpint (g_value_get_int (*value), ==, 42);
3552 : 0 : g_value_unset (*value);
3553 : 0 : g_value_init (*value, G_TYPE_STRING);
3554 : 0 : g_value_set_string (*value, "42");
3555 : 0 : }
3556 : :
3557 : : /**
3558 : : * gi_marshalling_tests_gvalue_flat_array:
3559 : : * @n_values: number of values
3560 : : * @values: (array length=n_values): an array containing values
3561 : : */
3562 : : void
3563 : 2 : gi_marshalling_tests_gvalue_flat_array (guint n_values, const GValue *values)
3564 : : {
3565 : 2 : g_assert (n_values == 3);
3566 : :
3567 : 2 : g_assert_cmpint (g_value_get_int (&values[0]), ==, 42);
3568 : 2 : g_assert_cmpstr (g_value_get_string (&values[1]), ==, "42");
3569 : 2 : g_assert_cmpint (g_value_get_boolean (&values[2]), ==, TRUE);
3570 : 2 : }
3571 : :
3572 : : /**
3573 : : * gi_marshalling_tests_return_gvalue_flat_array:
3574 : : *
3575 : : * Returns: (array fixed-size=3) (transfer full): a flat GValue array
3576 : : */
3577 : : GValue *
3578 : 1 : gi_marshalling_tests_return_gvalue_flat_array (void)
3579 : : {
3580 : 1 : GValue *array = g_new0 (GValue, 3);
3581 : :
3582 : 1 : g_value_init (&array[0], G_TYPE_INT);
3583 : 1 : g_value_set_int (&array[0], 42);
3584 : :
3585 : 1 : g_value_init (&array[1], G_TYPE_STRING);
3586 : 1 : g_value_set_static_string (&array[1], "42");
3587 : :
3588 : 1 : g_value_init (&array[2], G_TYPE_BOOLEAN);
3589 : 1 : g_value_set_boolean (&array[2], TRUE);
3590 : :
3591 : 1 : return array;
3592 : : }
3593 : :
3594 : : /**
3595 : : * gi_marshalling_tests_gvalue_round_trip:
3596 : : * @value: The first GValue
3597 : : *
3598 : : * Returns: (transfer none):
3599 : : */
3600 : : GValue *
3601 : 42 : gi_marshalling_tests_gvalue_round_trip (GValue *value)
3602 : : {
3603 : 42 : return value;
3604 : : }
3605 : :
3606 : : /**
3607 : : * gi_marshalling_tests_gvalue_copy:
3608 : : * @value: The first GValue
3609 : : *
3610 : : * Returns: (transfer full):
3611 : : */
3612 : : GValue *
3613 : 17 : gi_marshalling_tests_gvalue_copy (GValue *value)
3614 : : {
3615 : 17 : GValue *return_value = g_new0 (GValue, 1);
3616 : :
3617 : 17 : g_value_init (return_value, G_VALUE_TYPE (value));
3618 : 17 : g_value_copy (value, return_value);
3619 : :
3620 : 17 : return return_value;
3621 : : }
3622 : :
3623 : : /**
3624 : : * gi_marshalling_tests_gvalue_flat_array_round_trip:
3625 : : * @one: The first GValue
3626 : : * @two: The second GValue
3627 : : * @three: The third GValue
3628 : : *
3629 : : * Returns: (array fixed-size=3) (transfer full): a flat array of [@one, @two, @three]
3630 : : */
3631 : : GValue *
3632 : 0 : gi_marshalling_tests_gvalue_flat_array_round_trip (const GValue one, const GValue two, const GValue three)
3633 : : {
3634 : 0 : GValue *array = g_new (GValue, 3);
3635 : 0 : array[0] = one;
3636 : 0 : array[1] = two;
3637 : 0 : array[2] = three;
3638 : :
3639 : 0 : return array;
3640 : : }
3641 : :
3642 : : /**
3643 : : * gi_marshalling_tests_gclosure_in:
3644 : : * @closure: (transfer none):
3645 : : */
3646 : : void
3647 : 1 : gi_marshalling_tests_gclosure_in (GClosure *closure)
3648 : : {
3649 : 1 : GValue return_value = { 0, };
3650 : :
3651 : 1 : g_value_init (&return_value, G_TYPE_INT);
3652 : :
3653 : 1 : g_closure_invoke (closure, &return_value, 0, NULL, NULL);
3654 : :
3655 : 1 : g_assert_cmpint (g_value_get_int (&return_value), ==, 42);
3656 : :
3657 : 1 : g_value_unset (&return_value);
3658 : 1 : }
3659 : :
3660 : : static gint
3661 : 0 : _closure_return_42 (void)
3662 : : {
3663 : 0 : return 42;
3664 : : }
3665 : :
3666 : : static void
3667 : 0 : _marshal_INT__VOID (GClosure *closure,
3668 : : GValue *return_value,
3669 : : guint n_param_values G_GNUC_UNUSED,
3670 : : const GValue *param_values G_GNUC_UNUSED,
3671 : : gpointer invocation_hint G_GNUC_UNUSED,
3672 : : gpointer marshal_data G_GNUC_UNUSED)
3673 : : {
3674 : : typedef gint (*GMarshalFunc_INT__VOID) (void);
3675 : : register GMarshalFunc_INT__VOID callback;
3676 : 0 : register GCClosure *cc = (GCClosure *) closure;
3677 : :
3678 : 0 : callback = (GMarshalFunc_INT__VOID) cc->callback;
3679 : 0 : g_value_set_int (return_value, callback ());
3680 : 0 : }
3681 : :
3682 : : /**
3683 : : * gi_marshalling_tests_gclosure_return:
3684 : : *
3685 : : * Return: a #GClosure
3686 : : */
3687 : : GClosure *
3688 : 0 : gi_marshalling_tests_gclosure_return (void)
3689 : : {
3690 : 0 : GClosure *closure = g_cclosure_new ((GCallback) _closure_return_42,
3691 : : NULL, NULL);
3692 : 0 : g_closure_set_marshal (closure, _marshal_INT__VOID);
3693 : :
3694 : 0 : return closure;
3695 : : }
3696 : :
3697 : :
3698 : : /**
3699 : : * gi_marshalling_tests_callback_return_value_only:
3700 : : * @callback: (scope call):
3701 : : */
3702 : 1 : glong gi_marshalling_tests_callback_return_value_only (GIMarshallingTestsCallbackReturnValueOnly callback)
3703 : : {
3704 : 1 : return callback ();
3705 : : }
3706 : :
3707 : : /**
3708 : : * gi_marshalling_tests_callback_one_out_parameter:
3709 : : * @callback: (scope call):
3710 : : * @a: (out):
3711 : : */
3712 : 1 : void gi_marshalling_tests_callback_one_out_parameter (GIMarshallingTestsCallbackOneOutParameter callback, gfloat *a)
3713 : : {
3714 : 1 : callback (a);
3715 : 1 : }
3716 : :
3717 : : /**
3718 : : * gi_marshalling_tests_callback_multiple_out_parameters:
3719 : : * @callback: (scope call):
3720 : : * @a: (out):
3721 : : * @b: (out):
3722 : : */
3723 : : void
3724 : 1 : gi_marshalling_tests_callback_multiple_out_parameters
3725 : : (GIMarshallingTestsCallbackMultipleOutParameters callback, gfloat *a, gfloat *b)
3726 : : {
3727 : 1 : callback (a, b);
3728 : 1 : }
3729 : :
3730 : : /**
3731 : : * gi_marshalling_tests_callback_return_value_and_one_out_parameter:
3732 : : * @callback: (scope call):
3733 : : * @a: (out):
3734 : : */
3735 : : glong
3736 : 1 : gi_marshalling_tests_callback_return_value_and_one_out_parameter
3737 : : (GIMarshallingTestsCallbackReturnValueAndOneOutParameter callback, glong *a)
3738 : : {
3739 : 1 : return callback (a);
3740 : : }
3741 : :
3742 : : /**
3743 : : * gi_marshalling_tests_callback_return_value_and_multiple_out_parameters:
3744 : : * @callback: (scope call):
3745 : : * @a: (out):
3746 : : * @b: (out):
3747 : : */
3748 : : glong
3749 : 1 : gi_marshalling_tests_callback_return_value_and_multiple_out_parameters
3750 : : (GIMarshallingTestsCallbackReturnValueAndMultipleOutParameters callback, glong *a, glong *b)
3751 : : {
3752 : 1 : return callback (a, b);
3753 : : }
3754 : :
3755 : :
3756 : :
3757 : : /**
3758 : : * gi_marshalling_tests_pointer_in_return:
3759 : : *
3760 : : * Returns: The same pointer
3761 : : */
3762 : : gpointer
3763 : 2 : gi_marshalling_tests_pointer_in_return (gpointer pointer)
3764 : : {
3765 : 2 : return pointer;
3766 : : }
3767 : :
3768 : : GType
3769 : 7 : gi_marshalling_tests_genum_get_type (void)
3770 : : {
3771 : : static GType type = 0;
3772 [ + + ]: 7 : if (G_UNLIKELY (type == 0))
3773 : : {
3774 : : static const GEnumValue values[] = {
3775 : : {GI_MARSHALLING_TESTS_GENUM_VALUE1,
3776 : : "GI_MARSHALLING_TESTS_GENUM_VALUE1", "value1"},
3777 : : {GI_MARSHALLING_TESTS_GENUM_VALUE2,
3778 : : "GI_MARSHALLING_TESTS_GENUM_VALUE2", "value2"},
3779 : : {GI_MARSHALLING_TESTS_GENUM_VALUE3,
3780 : : "GI_MARSHALLING_TESTS_GENUM_VALUE3", "value3"},
3781 : : {0, NULL, NULL}
3782 : : };
3783 : 3 : type = g_enum_register_static (g_intern_static_string ("GIMarshallingTestsGEnum"), values);
3784 : : }
3785 : :
3786 : 7 : return type;
3787 : : }
3788 : :
3789 : : GIMarshallingTestsGEnum
3790 : 1 : gi_marshalling_tests_genum_returnv (void)
3791 : : {
3792 : 1 : return GI_MARSHALLING_TESTS_GENUM_VALUE3;
3793 : : }
3794 : :
3795 : : void
3796 : 1 : gi_marshalling_tests_genum_in (GIMarshallingTestsGEnum v)
3797 : : {
3798 : 1 : g_assert_cmpint (v, ==, GI_MARSHALLING_TESTS_GENUM_VALUE3);
3799 : 1 : }
3800 : :
3801 : : /**
3802 : : * gi_marshalling_tests_genum_out:
3803 : : * @v: (out):
3804 : : */
3805 : : void
3806 : 1 : gi_marshalling_tests_genum_out (GIMarshallingTestsGEnum *v)
3807 : : {
3808 : 1 : *v = GI_MARSHALLING_TESTS_GENUM_VALUE3;
3809 : 1 : }
3810 : :
3811 : : /**
3812 : : * gi_marshalling_tests_genum_inout:
3813 : : * @v: (inout):
3814 : : */
3815 : : void
3816 : 1 : gi_marshalling_tests_genum_inout (GIMarshallingTestsGEnum *v)
3817 : : {
3818 : 1 : g_assert_cmpint (*v, ==, GI_MARSHALLING_TESTS_GENUM_VALUE3);
3819 : 1 : *v = GI_MARSHALLING_TESTS_GENUM_VALUE1;
3820 : 1 : }
3821 : :
3822 : :
3823 : : GIMarshallingTestsEnum
3824 : 1 : gi_marshalling_tests_enum_returnv (void)
3825 : : {
3826 : 1 : return GI_MARSHALLING_TESTS_ENUM_VALUE3;
3827 : : }
3828 : :
3829 : : void
3830 : 1 : gi_marshalling_tests_enum_in (GIMarshallingTestsEnum v)
3831 : : {
3832 : 1 : g_assert_cmpint (v, ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
3833 : 1 : }
3834 : :
3835 : : /**
3836 : : * gi_marshalling_tests_enum_out:
3837 : : * @v: (out):
3838 : : */
3839 : : void
3840 : 1 : gi_marshalling_tests_enum_out (GIMarshallingTestsEnum *v)
3841 : : {
3842 : 1 : *v = GI_MARSHALLING_TESTS_ENUM_VALUE3;
3843 : 1 : }
3844 : :
3845 : : /**
3846 : : * gi_marshalling_tests_enum_inout:
3847 : : * @v: (inout):
3848 : : */
3849 : : void
3850 : 1 : gi_marshalling_tests_enum_inout (GIMarshallingTestsEnum *v)
3851 : : {
3852 : 1 : g_assert_cmpint (*v, ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
3853 : 1 : *v = GI_MARSHALLING_TESTS_ENUM_VALUE1;
3854 : 1 : }
3855 : :
3856 : :
3857 : : GType
3858 : 19 : gi_marshalling_tests_flags_get_type (void)
3859 : : {
3860 : : static GType type = 0;
3861 [ + + ]: 19 : if (G_UNLIKELY (type == 0))
3862 : : {
3863 : : static const GFlagsValue values[] = {
3864 : : {GI_MARSHALLING_TESTS_FLAGS_VALUE1,
3865 : : "GI_MARSHALLING_TESTS_FLAGS_VALUE1", "value1"},
3866 : : {GI_MARSHALLING_TESTS_FLAGS_VALUE2,
3867 : : "GI_MARSHALLING_TESTS_FLAGS_VALUE2", "value2"},
3868 : : {GI_MARSHALLING_TESTS_FLAGS_VALUE3,
3869 : : "GI_MARSHALLING_TESTS_FLAGS_VALUE3", "value3"},
3870 : : {GI_MARSHALLING_TESTS_FLAGS_MASK, "GI_MARSHALLING_TESTS_FLAGS_MASK",
3871 : : "mask"},
3872 : : {GI_MARSHALLING_TESTS_FLAGS_MASK2, "GI_MARSHALLING_TESTS_FLAGS_MASK2",
3873 : : "mask2"},
3874 : : {0, NULL, NULL}
3875 : : };
3876 : 3 : type = g_flags_register_static (g_intern_static_string ("GIMarshallingTestsFlags"), values);
3877 : : }
3878 : :
3879 : 19 : return type;
3880 : : }
3881 : :
3882 : : GIMarshallingTestsFlags
3883 : 1 : gi_marshalling_tests_flags_returnv (void)
3884 : : {
3885 : 1 : return GI_MARSHALLING_TESTS_FLAGS_VALUE2;
3886 : : }
3887 : :
3888 : : void
3889 : 1 : gi_marshalling_tests_flags_in (GIMarshallingTestsFlags v)
3890 : : {
3891 : 1 : g_assert (v == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
3892 : 1 : }
3893 : :
3894 : : void
3895 : 1 : gi_marshalling_tests_flags_in_zero (GIMarshallingTestsFlags v)
3896 : : {
3897 : 1 : g_assert (v == 0);
3898 : 1 : }
3899 : :
3900 : : /**
3901 : : * gi_marshalling_tests_flags_out:
3902 : : * @v: (out):
3903 : : */
3904 : : void
3905 : 1 : gi_marshalling_tests_flags_out (GIMarshallingTestsFlags *v)
3906 : : {
3907 : 1 : *v = GI_MARSHALLING_TESTS_FLAGS_VALUE2;
3908 : 1 : }
3909 : :
3910 : : /**
3911 : : * gi_marshalling_tests_flags_inout:
3912 : : * @v: (inout):
3913 : : */
3914 : : void
3915 : 1 : gi_marshalling_tests_flags_inout (GIMarshallingTestsFlags *v)
3916 : : {
3917 : 1 : g_assert (*v == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
3918 : 1 : *v = GI_MARSHALLING_TESTS_FLAGS_VALUE1;
3919 : 1 : }
3920 : :
3921 : :
3922 : : GIMarshallingTestsNoTypeFlags
3923 : 1 : gi_marshalling_tests_no_type_flags_returnv (void)
3924 : : {
3925 : 1 : return GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
3926 : : }
3927 : :
3928 : : void
3929 : 1 : gi_marshalling_tests_no_type_flags_in (GIMarshallingTestsNoTypeFlags v)
3930 : : {
3931 : 1 : g_assert (v == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
3932 : 1 : }
3933 : :
3934 : : void
3935 : 1 : gi_marshalling_tests_no_type_flags_in_zero (GIMarshallingTestsNoTypeFlags v)
3936 : : {
3937 : 1 : g_assert (v == 0);
3938 : 1 : }
3939 : :
3940 : : /**
3941 : : * gi_marshalling_tests_no_type_flags_out:
3942 : : * @v: (out):
3943 : : */
3944 : : void
3945 : 1 : gi_marshalling_tests_no_type_flags_out (GIMarshallingTestsNoTypeFlags *v)
3946 : : {
3947 : 1 : *v = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
3948 : 1 : }
3949 : :
3950 : : /**
3951 : : * gi_marshalling_tests_no_type_flags_inout:
3952 : : * @v: (inout):
3953 : : */
3954 : : void
3955 : 1 : gi_marshalling_tests_no_type_flags_inout (GIMarshallingTestsNoTypeFlags *v)
3956 : : {
3957 : 1 : g_assert (*v == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
3958 : 1 : *v = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE1;
3959 : 1 : }
3960 : :
3961 : :
3962 : : /**
3963 : : * gi_marshalling_tests_simple_struct_returnv:
3964 : : *
3965 : : * Returns: (transfer none):
3966 : : */
3967 : : GIMarshallingTestsSimpleStruct *
3968 : 1 : gi_marshalling_tests_simple_struct_returnv (void)
3969 : : {
3970 : : static GIMarshallingTestsSimpleStruct *struct_ = NULL;
3971 : :
3972 [ + - ]: 1 : if (struct_ == NULL)
3973 : : {
3974 : 1 : struct_ = g_new (GIMarshallingTestsSimpleStruct, 1);
3975 : :
3976 : 1 : struct_->long_ = 6;
3977 : 1 : struct_->int8 = 7;
3978 : : }
3979 : :
3980 : 1 : return struct_;
3981 : : }
3982 : :
3983 : : /**
3984 : : * gi_marshalling_tests_simple_struct_inv:
3985 : : * @struct_: (transfer none):
3986 : : */
3987 : : void
3988 : 1 : gi_marshalling_tests_simple_struct_inv (GIMarshallingTestsSimpleStruct *struct_)
3989 : : {
3990 : 1 : g_assert_cmpint (struct_->long_, ==, 6);
3991 : 1 : g_assert_cmpint (struct_->int8, ==, 7);
3992 : 1 : }
3993 : :
3994 : : void
3995 : 1 : gi_marshalling_tests_simple_struct_method (GIMarshallingTestsSimpleStruct *struct_)
3996 : : {
3997 : 1 : g_assert_cmpint (struct_->long_, ==, 6);
3998 : 1 : g_assert_cmpint (struct_->int8, ==, 7);
3999 : 1 : }
4000 : :
4001 : :
4002 : : GType
4003 : 1 : gi_marshalling_tests_pointer_struct_get_type (void)
4004 : : {
4005 : : static GType type = 0;
4006 : :
4007 [ + - ]: 1 : if (type == 0)
4008 : : {
4009 : 1 : type = g_pointer_type_register_static ("GIMarshallingTestsPointerStruct");
4010 : : }
4011 : :
4012 : 1 : return type;
4013 : : }
4014 : :
4015 : : /**
4016 : : * gi_marshalling_tests_pointer_struct_returnv:
4017 : : *
4018 : : * Returns: (transfer none):
4019 : : */
4020 : : GIMarshallingTestsPointerStruct *
4021 : 1 : gi_marshalling_tests_pointer_struct_returnv (void)
4022 : : {
4023 : : static GIMarshallingTestsPointerStruct *struct_ = NULL;
4024 : :
4025 [ + - ]: 1 : if (struct_ == NULL)
4026 : : {
4027 : 1 : struct_ = g_new (GIMarshallingTestsPointerStruct, 1);
4028 : :
4029 : 1 : struct_->long_ = 42;
4030 : : }
4031 : :
4032 : 1 : return struct_;
4033 : : }
4034 : :
4035 : : /**
4036 : : * gi_marshalling_tests_pointer_struct_inv:
4037 : : * @struct_: (transfer none):
4038 : : */
4039 : : void
4040 : 1 : gi_marshalling_tests_pointer_struct_inv (GIMarshallingTestsPointerStruct *struct_)
4041 : : {
4042 : 1 : g_assert_cmpint (struct_->long_, ==, 42);
4043 : 1 : }
4044 : :
4045 : : static GIMarshallingTestsBoxedStruct *
4046 : 142 : gi_marshalling_tests_boxed_struct_copy (GIMarshallingTestsBoxedStruct *struct_)
4047 : : {
4048 : : GIMarshallingTestsBoxedStruct *new_struct;
4049 : :
4050 [ + + ]: 142 : if (struct_ == NULL)
4051 : 74 : return NULL;
4052 : :
4053 : 68 : new_struct = g_slice_new (GIMarshallingTestsBoxedStruct);
4054 : :
4055 : 68 : *new_struct = *struct_;
4056 : 68 : new_struct->string_ = g_strdup (struct_->string_);
4057 : 68 : new_struct->g_strv = g_strdupv (struct_->g_strv);
4058 : :
4059 : 68 : return new_struct;
4060 : : }
4061 : :
4062 : : static void
4063 : 194 : gi_marshalling_tests_boxed_struct_free (GIMarshallingTestsBoxedStruct *struct_)
4064 : : {
4065 [ + + ]: 194 : if (struct_ != NULL)
4066 : : {
4067 : 107 : g_free (struct_->string_);
4068 [ + + ]: 107 : g_clear_pointer (&struct_->g_strv, g_strfreev);
4069 : 107 : g_slice_free (GIMarshallingTestsBoxedStruct, struct_);
4070 : : }
4071 : 194 : }
4072 : :
4073 : : GType
4074 : 44 : gi_marshalling_tests_boxed_struct_get_type (void)
4075 : : {
4076 : : static GType type = 0;
4077 : :
4078 [ + + ]: 44 : if (type == 0)
4079 : : {
4080 : 3 : type = g_boxed_type_register_static ("GIMarshallingTestsBoxedStruct",
4081 : : (GBoxedCopyFunc)
4082 : : gi_marshalling_tests_boxed_struct_copy,
4083 : : (GBoxedFreeFunc) gi_marshalling_tests_boxed_struct_free);
4084 : : }
4085 : :
4086 : 44 : return type;
4087 : : }
4088 : :
4089 : : static GType
4090 : 3 : gi_marshalling_tests_boxed_glist_get_type (void)
4091 : : {
4092 : : static GType type = 0;
4093 : :
4094 [ + - ]: 3 : if (type == 0)
4095 : : {
4096 : 3 : type = g_boxed_type_register_static ("GIMarshallingTestsBoxedGList",
4097 : : (GBoxedCopyFunc) g_list_copy, (GBoxedFreeFunc) g_list_free);
4098 : : }
4099 : :
4100 : 3 : return type;
4101 : : }
4102 : :
4103 : : GIMarshallingTestsBoxedStruct *
4104 : 45 : gi_marshalling_tests_boxed_struct_new (void)
4105 : : {
4106 : 45 : return g_slice_new0 (GIMarshallingTestsBoxedStruct);
4107 : : }
4108 : :
4109 : : /**
4110 : : * gi_marshalling_tests_boxed_struct_returnv:
4111 : : *
4112 : : * Returns: (transfer none):
4113 : : */
4114 : : GIMarshallingTestsBoxedStruct *
4115 : 1 : gi_marshalling_tests_boxed_struct_returnv (void)
4116 : : {
4117 : : static GIMarshallingTestsBoxedStruct *struct_ = NULL;
4118 : :
4119 [ + - ]: 1 : if (struct_ == NULL)
4120 : : {
4121 : 1 : struct_ = g_new (GIMarshallingTestsBoxedStruct, 1);
4122 : :
4123 : 1 : struct_->long_ = 42;
4124 : 1 : struct_->string_ = g_strdup ("hello");
4125 : 1 : struct_->g_strv = g_new0 (gchar *, 4);
4126 : 1 : struct_->g_strv[0] = g_strdup ("0");
4127 : 1 : struct_->g_strv[1] = g_strdup ("1");
4128 : 1 : struct_->g_strv[2] = g_strdup ("2");
4129 : 1 : struct_->g_strv[3] = NULL;
4130 : : }
4131 : :
4132 : 1 : return struct_;
4133 : : }
4134 : :
4135 : : /**
4136 : : * gi_marshalling_tests_boxed_struct_inv:
4137 : : * @struct_: (transfer none):
4138 : : */
4139 : : void
4140 : 1 : gi_marshalling_tests_boxed_struct_inv (GIMarshallingTestsBoxedStruct *struct_)
4141 : : {
4142 : 1 : g_assert_cmpint (struct_->long_, ==, 42);
4143 : 1 : }
4144 : :
4145 : : /**
4146 : : * gi_marshalling_tests_boxed_struct_out:
4147 : : * @struct_: (out) (transfer none):
4148 : : */
4149 : : void
4150 : 1 : gi_marshalling_tests_boxed_struct_out (GIMarshallingTestsBoxedStruct **struct_)
4151 : : {
4152 : : static GIMarshallingTestsBoxedStruct *new_struct = NULL;
4153 : :
4154 [ + - ]: 1 : if (new_struct == NULL)
4155 : : {
4156 : 1 : new_struct = g_new0 (GIMarshallingTestsBoxedStruct, 1);
4157 : :
4158 : 1 : new_struct->long_ = 42;
4159 : : }
4160 : :
4161 : 1 : *struct_ = new_struct;
4162 : 1 : }
4163 : :
4164 : : /**
4165 : : * gi_marshalling_tests_boxed_struct_inout:
4166 : : * @struct_: (inout) (transfer full):
4167 : : */
4168 : : void
4169 : 1 : gi_marshalling_tests_boxed_struct_inout (GIMarshallingTestsBoxedStruct **struct_)
4170 : : {
4171 : 1 : g_assert_cmpint ((*struct_)->long_, ==, 42);
4172 : :
4173 : 1 : g_boxed_free (gi_marshalling_tests_boxed_struct_get_type(), *struct_);
4174 : 1 : (*struct_) = g_slice_new0 (GIMarshallingTestsBoxedStruct);
4175 : 1 : (*struct_)->long_ = 0;
4176 : 1 : }
4177 : :
4178 : : static GIMarshallingTestsUnion *
4179 : 4 : gi_marshalling_tests_union_copy (GIMarshallingTestsUnion *union_)
4180 : : {
4181 : : GIMarshallingTestsUnion *new_union;
4182 : :
4183 : 4 : new_union = g_slice_new (GIMarshallingTestsUnion);
4184 : :
4185 : 4 : *new_union = *union_;
4186 : :
4187 : 4 : return new_union;
4188 : : }
4189 : :
4190 : : static void
4191 : 4 : gi_marshalling_tests_union_free (GIMarshallingTestsUnion *union_)
4192 : : {
4193 : 4 : g_slice_free (GIMarshallingTestsUnion, union_);
4194 : 4 : }
4195 : :
4196 : : GType
4197 : 10 : gi_marshalling_tests_union_get_type (void)
4198 : : {
4199 : : static GType type = 0;
4200 : :
4201 [ + + ]: 10 : if (type == 0)
4202 : : {
4203 : 2 : type = g_boxed_type_register_static ("GIMarshallingTestsUnion",
4204 : : (GBoxedCopyFunc)
4205 : : gi_marshalling_tests_union_copy,
4206 : : (GBoxedFreeFunc) gi_marshalling_tests_union_free);
4207 : : }
4208 : :
4209 : 10 : return type;
4210 : : }
4211 : :
4212 : : /**
4213 : : * gi_marshalling_tests_union_returnv:
4214 : : *
4215 : : * Returns: (transfer none):
4216 : : */
4217 : : GIMarshallingTestsUnion *
4218 : 2 : gi_marshalling_tests_union_returnv (void)
4219 : : {
4220 : : static GIMarshallingTestsUnion *union_ = NULL;
4221 : :
4222 [ + + ]: 2 : if (union_ == NULL)
4223 : : {
4224 : 1 : union_ = g_new (GIMarshallingTestsUnion, 1);
4225 : :
4226 : 1 : union_->long_ = 42;
4227 : : }
4228 : :
4229 : 2 : return union_;
4230 : : }
4231 : :
4232 : : /**
4233 : : * gi_marshalling_tests_union_inv:
4234 : : * @union_: (transfer none):
4235 : : */
4236 : : void
4237 : 1 : gi_marshalling_tests_union_inv (GIMarshallingTestsUnion *union_)
4238 : : {
4239 : 1 : g_assert_cmpint (union_->long_, ==, 42);
4240 : 1 : }
4241 : :
4242 : : void
4243 : 1 : gi_marshalling_tests_union_method (GIMarshallingTestsUnion *union_)
4244 : : {
4245 : 1 : g_assert_cmpint (union_->long_, ==, 42);
4246 : 1 : }
4247 : :
4248 : : /**
4249 : : * gi_marshalling_tests_structured_union_new:
4250 : : * @type: Type of #GIMarshallingTestsStructuredUnion to create
4251 : : */
4252 : : GIMarshallingTestsStructuredUnion *
4253 : 0 : gi_marshalling_tests_structured_union_new (GIMarshallingTestsStructuredUnionType type)
4254 : : {
4255 : : GIMarshallingTestsStructuredUnion *new_union;
4256 : :
4257 : 0 : new_union = g_new0 (GIMarshallingTestsStructuredUnion, 1);
4258 : 0 : new_union->type = type;
4259 : :
4260 [ # # # # : 0 : switch (type)
# # # # ]
4261 : : {
4262 : 0 : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_NONE:
4263 : 0 : break;
4264 : :
4265 : 0 : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_SIMPLE_STRUCT:
4266 : 0 : new_union->simple_struct.parent.long_ = 6;
4267 : 0 : new_union->simple_struct.parent.int8 = 7;
4268 : 0 : break;
4269 : :
4270 : 0 : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_NESTED_STRUCT:
4271 : 0 : new_union->nested_struct.parent.simple_struct.long_ = 6;
4272 : 0 : new_union->nested_struct.parent.simple_struct.int8 = 7;
4273 : 0 : break;
4274 : :
4275 : 0 : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_BOXED_STRUCT:
4276 : 0 : new_union->boxed_struct.parent.long_ = 42;
4277 : 0 : new_union->boxed_struct.parent.string_ = g_strdup ("hello");
4278 : 0 : new_union->boxed_struct.parent.g_strv = g_new0 (gchar *, 4);
4279 : 0 : new_union->boxed_struct.parent.g_strv[0] = g_strdup ("0");
4280 : 0 : new_union->boxed_struct.parent.g_strv[1] = g_strdup ("1");
4281 : 0 : new_union->boxed_struct.parent.g_strv[2] = g_strdup ("2");
4282 : 0 : new_union->boxed_struct.parent.g_strv[3] = NULL;
4283 : 0 : break;
4284 : :
4285 : 0 : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_BOXED_STRUCT_PTR:
4286 : 0 : new_union->boxed_struct_ptr.parent = g_boxed_copy (
4287 : : gi_marshalling_tests_boxed_struct_get_type(),
4288 : 0 : gi_marshalling_tests_boxed_struct_returnv ());
4289 : 0 : break;
4290 : :
4291 : 0 : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_POINTER_STRUCT:
4292 : 0 : new_union->pointer_struct.parent.long_ = 42;
4293 : 0 : break;
4294 : :
4295 : 0 : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_SINGLE_UNION:
4296 : 0 : new_union->single_union.parent.union_.long_ = 42;
4297 : 0 : break;
4298 : :
4299 : 0 : default:
4300 : 0 : g_free (new_union);
4301 : : g_return_val_if_reached (NULL);
4302 : : }
4303 : :
4304 : 0 : return new_union;
4305 : : }
4306 : :
4307 : : static GIMarshallingTestsStructuredUnion *
4308 : 0 : gi_marshalling_tests_structured_union_copy (GIMarshallingTestsStructuredUnion *union_)
4309 : : {
4310 : : GIMarshallingTestsStructuredUnion *new_union;
4311 : :
4312 : 0 : new_union = g_new (GIMarshallingTestsStructuredUnion, 1);
4313 : 0 : *new_union = *union_;
4314 : :
4315 [ # # # # ]: 0 : switch (union_->type)
4316 : : {
4317 : 0 : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_BOXED_STRUCT:
4318 : 0 : new_union->boxed_struct.parent.string_ = g_strdup (union_->boxed_struct.parent.string_);
4319 [ # # ]: 0 : if (union_->boxed_struct.parent.g_strv)
4320 : : {
4321 : 0 : guint length = g_strv_length (union_->boxed_struct.parent.g_strv);
4322 : : guint i;
4323 : :
4324 : 0 : new_union->boxed_struct.parent.g_strv = g_new0 (gchar *, length + 1);
4325 [ # # ]: 0 : for (i = 0; i < length; i++)
4326 : 0 : new_union->boxed_struct.parent.g_strv[i] = g_strdup (union_->boxed_struct.parent.g_strv[i]);
4327 : 0 : new_union->boxed_struct.parent.g_strv[i] = NULL;
4328 : : }
4329 : 0 : break;
4330 : :
4331 : 0 : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_BOXED_STRUCT_PTR:
4332 : 0 : new_union->boxed_struct_ptr.parent = g_boxed_copy (
4333 : 0 : gi_marshalling_tests_boxed_struct_get_type(), union_->boxed_struct_ptr.parent);
4334 : 0 : break;
4335 : :
4336 : 0 : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_NONE:
4337 : : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_SINGLE_UNION:
4338 : : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_POINTER_STRUCT:
4339 : : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_SIMPLE_STRUCT:
4340 : : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_NESTED_STRUCT:
4341 : 0 : break;
4342 : :
4343 : 0 : default:
4344 : : g_return_val_if_reached (new_union);
4345 : : }
4346 : :
4347 : 0 : return new_union;
4348 : : }
4349 : :
4350 : : static void
4351 : 0 : gi_marshalling_tests_structured_union_free (GIMarshallingTestsStructuredUnion *union_)
4352 : : {
4353 [ # # # # ]: 0 : switch (union_->type)
4354 : : {
4355 : 0 : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_BOXED_STRUCT:
4356 : 0 : g_free (union_->boxed_struct.parent.string_);
4357 : 0 : g_strfreev (union_->boxed_struct.parent.g_strv);
4358 : 0 : break;
4359 : :
4360 : 0 : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_BOXED_STRUCT_PTR:
4361 : 0 : g_boxed_free (gi_marshalling_tests_boxed_struct_get_type(), union_->boxed_struct_ptr.parent);
4362 : 0 : break;
4363 : :
4364 : 0 : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_NONE:
4365 : : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_SINGLE_UNION:
4366 : : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_POINTER_STRUCT:
4367 : : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_SIMPLE_STRUCT:
4368 : : case GI_MARSHALLING_TESTS_STRUCTURED_UNION_TYPE_NESTED_STRUCT:
4369 : 0 : break;
4370 : :
4371 : 0 : default:
4372 : : g_assert_not_reached ();
4373 : : }
4374 : :
4375 : 0 : g_free (union_);
4376 : 0 : }
4377 : :
4378 : 1 : GType gi_marshalling_tests_structured_union_get_type (void)
4379 : : {
4380 : : static GType type = 0;
4381 : :
4382 [ + - ]: 1 : if (type == 0)
4383 : : {
4384 : 1 : type = g_boxed_type_register_static ("GIMarshallingTestsStructuredUnion",
4385 : : (GBoxedCopyFunc)
4386 : : gi_marshalling_tests_structured_union_copy,
4387 : : (GBoxedFreeFunc) gi_marshalling_tests_structured_union_free);
4388 : : }
4389 : :
4390 : 1 : return type;
4391 : : }
4392 : :
4393 : : GIMarshallingTestsStructuredUnionType
4394 : 0 : gi_marshalling_tests_structured_union_type (GIMarshallingTestsStructuredUnion *structured_union)
4395 : : {
4396 : 0 : return structured_union->type;
4397 : : }
4398 : :
4399 : :
4400 : : enum
4401 : : {
4402 : : PROP_0,
4403 : : PROP_INT_
4404 : : };
4405 : :
4406 : : static void
4407 : : gi_marshalling_tests_object_real_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in);
4408 : :
4409 [ + + + - : 364 : G_DEFINE_TYPE (GIMarshallingTestsObject, gi_marshalling_tests_object, G_TYPE_OBJECT);
+ + ]
4410 : :
4411 : : static void
4412 : 72 : gi_marshalling_tests_object_init (GIMarshallingTestsObject *self G_GNUC_UNUSED)
4413 : : {
4414 : 72 : }
4415 : :
4416 : : static void
4417 : 69 : gi_marshalling_tests_object_finalize (GObject *object)
4418 : : {
4419 : 69 : G_OBJECT_CLASS (gi_marshalling_tests_object_parent_class)->finalize (object);
4420 : 69 : }
4421 : :
4422 : : static void
4423 : 77 : gi_marshalling_tests_object_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
4424 : : {
4425 : 77 : g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
4426 : :
4427 [ + - ]: 77 : switch (prop_id)
4428 : : {
4429 : 77 : case PROP_INT_:
4430 : 77 : GI_MARSHALLING_TESTS_OBJECT (object)->int_ = g_value_get_int (value);
4431 : 77 : break;
4432 : 0 : default:
4433 : 0 : G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
4434 : 0 : break;
4435 : : }
4436 : : }
4437 : :
4438 : : static void
4439 : 12 : gi_marshalling_tests_object_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
4440 : : {
4441 : 12 : g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
4442 : :
4443 [ + - ]: 12 : switch (prop_id)
4444 : : {
4445 : 12 : case PROP_INT_:
4446 : 12 : g_value_set_int (value, GI_MARSHALLING_TESTS_OBJECT (object)->int_);
4447 : 12 : break;
4448 : 0 : default:
4449 : 0 : G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
4450 : 0 : break;
4451 : : }
4452 : : }
4453 : :
4454 : : static void
4455 : 2 : gi_marshalling_tests_object_class_init (GIMarshallingTestsObjectClass *klass)
4456 : : {
4457 : 2 : GObjectClass *object_class = G_OBJECT_CLASS (klass);
4458 : : #if 0
4459 : : GObjectClass *parent_class = G_OBJECT_CLASS (klass);
4460 : : #endif
4461 : :
4462 : 2 : object_class->finalize = gi_marshalling_tests_object_finalize;
4463 : 2 : object_class->set_property = gi_marshalling_tests_object_set_property;
4464 : 2 : object_class->get_property = gi_marshalling_tests_object_get_property;
4465 : :
4466 : 2 : g_object_class_install_property (object_class, PROP_INT_,
4467 : : g_param_spec_int ("int", "Integer",
4468 : : "An integer", G_MININT,
4469 : : G_MAXINT, 0,
4470 : : G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
4471 : :
4472 : 2 : klass->method_with_default_implementation = gi_marshalling_tests_object_real_method_with_default_implementation;
4473 : 2 : }
4474 : :
4475 : :
4476 : : void
4477 : 1 : gi_marshalling_tests_object_static_method (void)
4478 : : {
4479 : 1 : }
4480 : :
4481 : : void
4482 : 3 : gi_marshalling_tests_object_method (GIMarshallingTestsObject *object)
4483 : : {
4484 : 3 : g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
4485 : 3 : g_assert_cmpint (object->int_, ==, 42);
4486 : : }
4487 : :
4488 : : void
4489 : 1 : gi_marshalling_tests_object_overridden_method (GIMarshallingTestsObject *object)
4490 : : {
4491 : 1 : g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
4492 : 1 : g_assert_cmpint (object->int_, ==, 0);
4493 : : }
4494 : :
4495 : : GIMarshallingTestsObject *
4496 : 1 : gi_marshalling_tests_object_new (gint int_)
4497 : : {
4498 : 1 : return g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, "int", int_, NULL);
4499 : : }
4500 : :
4501 : : GIMarshallingTestsObject *
4502 : 1 : gi_marshalling_tests_object_new_fail (gint int_ G_GNUC_UNUSED,
4503 : : GError **error)
4504 : : {
4505 : 1 : g_return_val_if_fail (error == NULL || *error == NULL, NULL);
4506 : :
4507 : 1 : g_set_error_literal (error,
4508 : : g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN),
4509 : : GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
4510 : : GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
4511 : :
4512 : 1 : return NULL;
4513 : : }
4514 : :
4515 : : /**
4516 : : * gi_marshalling_tests_object_method_array_in:
4517 : : * @ints: (array length=length):
4518 : : */
4519 : : void
4520 : 1 : gi_marshalling_tests_object_method_array_in (GIMarshallingTestsObject *self G_GNUC_UNUSED,
4521 : : const gint *ints,
4522 : : gint length)
4523 : : {
4524 : 1 : g_assert_cmpint (length, ==, 4);
4525 : 1 : g_assert_cmpint (ints[0], ==, -1);
4526 : 1 : g_assert_cmpint (ints[1], ==, 0);
4527 : 1 : g_assert_cmpint (ints[2], ==, 1);
4528 : 1 : g_assert_cmpint (ints[3], ==, 2);
4529 : 1 : }
4530 : :
4531 : : /**
4532 : : * gi_marshalling_tests_object_method_array_out:
4533 : : * @ints: (out) (array length=length) (transfer none):
4534 : : */
4535 : : void
4536 : 1 : gi_marshalling_tests_object_method_array_out (GIMarshallingTestsObject *self G_GNUC_UNUSED,
4537 : : gint **ints,
4538 : : gint *length)
4539 : : {
4540 : : static gint values[] = { -1, 0, 1, 2 };
4541 : :
4542 : 1 : *length = 4;
4543 : 1 : *ints = values;
4544 : 1 : }
4545 : :
4546 : : /**
4547 : : * gi_marshalling_tests_object_method_array_inout:
4548 : : * @ints: (inout) (array length=length) (transfer none):
4549 : : * @length: (inout):
4550 : : */
4551 : : void
4552 : 1 : gi_marshalling_tests_object_method_array_inout (GIMarshallingTestsObject *self G_GNUC_UNUSED,
4553 : : gint **ints,
4554 : : gint *length)
4555 : : {
4556 : : static gint values[] = { -2, -1, 0, 1, 2 };
4557 : :
4558 : 1 : g_assert_cmpint (*length, ==, 4);
4559 : 1 : g_assert_cmpint ((*ints)[0], ==, -1);
4560 : 1 : g_assert_cmpint ((*ints)[1], ==, 0);
4561 : 1 : g_assert_cmpint ((*ints)[2], ==, 1);
4562 : 1 : g_assert_cmpint ((*ints)[3], ==, 2);
4563 : :
4564 : 1 : *length = 5;
4565 : 1 : *ints = values;
4566 : 1 : }
4567 : :
4568 : : /**
4569 : : * gi_marshalling_tests_object_method_array_return:
4570 : : *
4571 : : * Returns: (array length=length):
4572 : : */
4573 : : const gint *
4574 : 1 : gi_marshalling_tests_object_method_array_return (GIMarshallingTestsObject *self G_GNUC_UNUSED,
4575 : : gint *length)
4576 : : {
4577 : : static gint ints[] = { -1, 0, 1, 2 };
4578 : :
4579 : 1 : *length = 4;
4580 : 1 : return ints;
4581 : : }
4582 : :
4583 : : /**
4584 : : * gi_marshalling_tests_object_method_int8_in:
4585 : : * @in: (in):
4586 : : */
4587 : : void
4588 : 1 : gi_marshalling_tests_object_method_int8_in (GIMarshallingTestsObject *self, gint8 in)
4589 : : {
4590 : 1 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_in (self, in);
4591 : 1 : }
4592 : :
4593 : : /**
4594 : : * gi_marshalling_tests_object_method_int8_out:
4595 : : * @out: (out):
4596 : : */
4597 : : void
4598 : 1 : gi_marshalling_tests_object_method_int8_out (GIMarshallingTestsObject *self, gint8 *out)
4599 : : {
4600 : 1 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_out (self, out);
4601 : 1 : }
4602 : :
4603 : : /**
4604 : : * gi_marshalling_tests_object_method_int8_arg_and_out_caller:
4605 : : * @out: (out):
4606 : : */
4607 : : void
4608 : 1 : gi_marshalling_tests_object_method_int8_arg_and_out_caller (GIMarshallingTestsObject *self, gint8 arg, gint8 *out)
4609 : : {
4610 : 1 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_arg_and_out_caller (self, arg, out);
4611 : 1 : }
4612 : :
4613 : : /**
4614 : : * gi_marshalling_tests_object_method_int8_arg_and_out_callee:
4615 : : * @out: (out):
4616 : : */
4617 : : void
4618 : 1 : gi_marshalling_tests_object_method_int8_arg_and_out_callee (GIMarshallingTestsObject *self, gint8 arg, gint8 **out)
4619 : : {
4620 : 1 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_arg_and_out_callee (self, arg, out);
4621 : 1 : }
4622 : :
4623 : : /**
4624 : : * gi_marshalling_tests_object_method_str_arg_out_ret:
4625 : : * @out: (out):
4626 : : *
4627 : : * Returns: (transfer none)
4628 : : */
4629 : : const gchar *
4630 : 2 : gi_marshalling_tests_object_method_str_arg_out_ret (GIMarshallingTestsObject *self, const gchar *arg, guint *out)
4631 : : {
4632 : 2 : return GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_str_arg_out_ret (self, arg, out);
4633 : : }
4634 : :
4635 : : /**
4636 : : * gi_marshalling_tests_object_method_with_default_implementation:
4637 : : * @in: (in):
4638 : : */
4639 : 4 : void gi_marshalling_tests_object_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
4640 : : {
4641 : 4 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_with_default_implementation (self, in);
4642 : 4 : }
4643 : :
4644 : : static void
4645 : 3 : gi_marshalling_tests_object_real_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
4646 : : {
4647 : 3 : GValue val = { 0, };
4648 : 3 : g_value_init (&val, G_TYPE_INT);
4649 : 3 : g_value_set_int (&val, in);
4650 : 3 : g_object_set_property (G_OBJECT (self), "int", &val);
4651 : 3 : }
4652 : :
4653 : : /**
4654 : : * gi_marshalling_tests_object_vfunc_with_callback: (virtual vfunc_with_callback)
4655 : : * @callback: (scope call) (closure callback_data):
4656 : : * @callback_data: (allow-none):
4657 : : */
4658 : : void
4659 : 0 : gi_marshalling_tests_object_vfunc_with_callback (GIMarshallingTestsObject *self G_GNUC_UNUSED,
4660 : : GIMarshallingTestsCallbackIntInt callback G_GNUC_UNUSED,
4661 : : void *callback_data G_GNUC_UNUSED)
4662 : : {
4663 : :
4664 : 0 : }
4665 : :
4666 : : static int
4667 : 0 : _callback (int val, void *user_data)
4668 : : {
4669 : 0 : g_assert (user_data == (gpointer) 0xdeadbeef);
4670 : 0 : return val;
4671 : : }
4672 : :
4673 : : void
4674 : 0 : gi_marshalling_tests_object_call_vfunc_with_callback (GIMarshallingTestsObject *object)
4675 : : {
4676 : 0 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (object)->vfunc_with_callback (object, _callback, (void *) 0xdeadbeef);
4677 : 0 : }
4678 : :
4679 : : /**
4680 : : * gi_marshalling_tests_object_none_return:
4681 : : *
4682 : : * Returns: (transfer none):
4683 : : */
4684 : : GIMarshallingTestsObject *
4685 : 1 : gi_marshalling_tests_object_none_return (void)
4686 : : {
4687 : : static GIMarshallingTestsObject *object = NULL;
4688 : :
4689 [ + - ]: 1 : if (object == NULL)
4690 : : {
4691 : 1 : object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4692 : : }
4693 : :
4694 : 1 : return object;
4695 : : }
4696 : :
4697 : : /**
4698 : : * gi_marshalling_tests_object_full_return:
4699 : : *
4700 : : * Returns: (transfer full):
4701 : : */
4702 : : GIMarshallingTestsObject *
4703 : 1 : gi_marshalling_tests_object_full_return (void)
4704 : : {
4705 : 1 : return g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4706 : : }
4707 : :
4708 : : /**
4709 : : * gi_marshalling_tests_object_none_in:
4710 : : * @object: (transfer none):
4711 : : */
4712 : : void
4713 : 1 : gi_marshalling_tests_object_none_in (GIMarshallingTestsObject *object)
4714 : : {
4715 : 1 : g_assert_cmpint (object->int_, ==, 42);
4716 : 1 : }
4717 : :
4718 : : /**
4719 : : * gi_marshalling_tests_object_none_out:
4720 : : * @object: (out) (transfer none):
4721 : : */
4722 : : void
4723 : 1 : gi_marshalling_tests_object_none_out (GIMarshallingTestsObject **object)
4724 : : {
4725 : : static GIMarshallingTestsObject *new_object = NULL;
4726 : :
4727 [ + - ]: 1 : if (new_object == NULL)
4728 : : {
4729 : 1 : new_object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4730 : : }
4731 : :
4732 : 1 : *object = new_object;
4733 : 1 : }
4734 : :
4735 : : /**
4736 : : * gi_marshalling_tests_object_full_out:
4737 : : * @object: (out) (transfer full):
4738 : : */
4739 : : void
4740 : 1 : gi_marshalling_tests_object_full_out (GIMarshallingTestsObject **object)
4741 : : {
4742 : 1 : *object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4743 : 1 : }
4744 : :
4745 : : /**
4746 : : * gi_marshalling_tests_object_none_inout:
4747 : : * @object: (inout) (transfer none):
4748 : : */
4749 : : void
4750 : 1 : gi_marshalling_tests_object_none_inout (GIMarshallingTestsObject **object)
4751 : : {
4752 : : static GIMarshallingTestsObject *new_object = NULL;
4753 : :
4754 : 1 : g_assert_cmpint ((*object)->int_, ==, 42);
4755 : :
4756 [ + - ]: 1 : if (new_object == NULL)
4757 : : {
4758 : 1 : new_object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4759 : 1 : new_object->int_ = 0;
4760 : : }
4761 : :
4762 : 1 : *object = new_object;
4763 : 1 : }
4764 : :
4765 : : /**
4766 : : * gi_marshalling_tests_object_full_inout:
4767 : : * @object: (inout) (transfer full):
4768 : : */
4769 : : void
4770 : 1 : gi_marshalling_tests_object_full_inout (GIMarshallingTestsObject **object)
4771 : : {
4772 : 1 : g_assert_cmpint ((*object)->int_, ==, 42);
4773 : :
4774 : 1 : g_object_unref (*object);
4775 : 1 : *object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
4776 : 1 : }
4777 : :
4778 : : /**
4779 : : * gi_marshalling_tests_object_int8_in:
4780 : : * @in: (in):
4781 : : */
4782 : : void
4783 : 0 : gi_marshalling_tests_object_int8_in (GIMarshallingTestsObject *object, gint8 in)
4784 : : {
4785 : 0 : gi_marshalling_tests_object_method_int8_in (object, in);
4786 : 0 : }
4787 : :
4788 : : /**
4789 : : * gi_marshalling_tests_object_int8_out:
4790 : : * @out: (out):
4791 : : */
4792 : : void
4793 : 0 : gi_marshalling_tests_object_int8_out (GIMarshallingTestsObject *object, gint8 *out)
4794 : : {
4795 : 0 : gi_marshalling_tests_object_method_int8_out (object, out);
4796 : 0 : }
4797 : :
4798 : : /**
4799 : : * gi_marshalling_tests_object_vfunc_return_value_only:
4800 : : */
4801 : : glong
4802 : 1 : gi_marshalling_tests_object_vfunc_return_value_only (GIMarshallingTestsObject *self)
4803 : : {
4804 : : /* make sure that local variables don't get smashed */
4805 : : glong return_value;
4806 : 1 : gulong local = 0x12345678;
4807 : 1 : return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_only (self);
4808 : 1 : g_assert_cmpint (local, ==, 0x12345678);
4809 : 1 : return return_value;
4810 : : }
4811 : :
4812 : : /**
4813 : : * gi_marshalling_tests_object_vfunc_one_out_parameter:
4814 : : * @a: (out):
4815 : : */
4816 : : void
4817 : 1 : gi_marshalling_tests_object_vfunc_one_out_parameter (GIMarshallingTestsObject *self, gfloat *a)
4818 : : {
4819 : : /* make sure that local variables don't get smashed */
4820 : 1 : gulong local = 0x12345678;
4821 : 1 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_one_out_parameter (self, a);
4822 : 1 : g_assert_cmpint (local, ==, 0x12345678);
4823 : 1 : }
4824 : :
4825 : : /**
4826 : : * gi_marshalling_tests_object_vfunc_one_inout_parameter:
4827 : : * @a: (inout):
4828 : : */
4829 : : void
4830 : 1 : gi_marshalling_tests_object_vfunc_one_inout_parameter (GIMarshallingTestsObject *self, gfloat *a)
4831 : : {
4832 : : /* make sure that local variables don't get smashed */
4833 : 1 : gulong local = 0x12345678;
4834 : 1 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_one_inout_parameter (self, a);
4835 : 1 : g_assert_cmpint (local, ==, 0x12345678);
4836 : 1 : }
4837 : :
4838 : : /**
4839 : : * gi_marshalling_tests_object_vfunc_multiple_inout_parameters:
4840 : : * @a: (inout):
4841 : : * @b: (inout):
4842 : : */
4843 : : void
4844 : 1 : gi_marshalling_tests_object_vfunc_multiple_inout_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b)
4845 : : {
4846 : : /* make sure that local variables don't get smashed */
4847 : 1 : gulong local = 0x12345678;
4848 : 1 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_multiple_inout_parameters (self, a, b);
4849 : 1 : g_assert_cmpint (local, ==, 0x12345678);
4850 : 1 : }
4851 : :
4852 : : /**
4853 : : * gi_marshalling_tests_object_vfunc_multiple_out_parameters:
4854 : : * @a: (out):
4855 : : * @b: (out):
4856 : : */
4857 : 2 : void gi_marshalling_tests_object_vfunc_multiple_out_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b)
4858 : : {
4859 : : /* make sure that local variables don't get smashed */
4860 : 2 : gulong local = 0x12345678;
4861 : 2 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_multiple_out_parameters (self, a, b);
4862 : 2 : g_assert_cmpint (local, ==, 0x12345678);
4863 : 2 : }
4864 : :
4865 : : /**
4866 : : * gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter:
4867 : : * @a: (out):
4868 : : */
4869 : 1 : void gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter (GIMarshallingTestsObject *self, GValue *a)
4870 : : {
4871 : : /* make sure that local variables don't get smashed */
4872 : 1 : gulong local = 0x12345678;
4873 : 1 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_caller_allocated_out_parameter (self, a);
4874 : 1 : g_assert_cmpint (local, ==, 0x12345678);
4875 : 1 : }
4876 : :
4877 : : /**
4878 : : * gi_marshalling_tests_object_vfunc_array_out_parameter:
4879 : : * @a: (out) (array zero-terminated):
4880 : : */
4881 : 2 : void gi_marshalling_tests_object_vfunc_array_out_parameter (GIMarshallingTestsObject *self, gfloat **a)
4882 : : {
4883 : : /* make sure that local variables don't get smashed */
4884 : 2 : gulong local = 0x12345678;
4885 : 2 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_array_out_parameter (self, a);
4886 : 2 : g_assert_cmpint (local, ==, 0x12345678);
4887 : 2 : }
4888 : :
4889 : : /**
4890 : : * gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter:
4891 : : * @a: (out):
4892 : : */
4893 : 2 : glong gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter (GIMarshallingTestsObject *self, glong *a)
4894 : : {
4895 : : /* make sure that local variables don't get smashed */
4896 : : gulong return_value;
4897 : 2 : gulong local = 0x12345678;
4898 : 2 : return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_one_out_parameter (self, a);
4899 : 2 : g_assert_cmpint (local, ==, 0x12345678);
4900 : 2 : return return_value;
4901 : : }
4902 : :
4903 : : /**
4904 : : * gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters:
4905 : : * @a: (out):
4906 : : * @b: (out):
4907 : : */
4908 : : glong
4909 : 2 : gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters
4910 : : (GIMarshallingTestsObject *self, glong *a, glong *b)
4911 : : {
4912 : : gulong return_value;
4913 : 2 : gulong local = 0x12345678;
4914 : 2 : return_value =
4915 : 2 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_multiple_out_parameters (self, a, b);
4916 : 2 : g_assert_cmpint (local, ==, 0x12345678);
4917 : 2 : return return_value;
4918 : : }
4919 : :
4920 : : /**
4921 : : * gi_marshalling_tests_object_vfunc_return_value_and_one_inout_parameter:
4922 : : * @a: (inout):
4923 : : */
4924 : 1 : glong gi_marshalling_tests_object_vfunc_return_value_and_one_inout_parameter (GIMarshallingTestsObject *self, glong *a)
4925 : : {
4926 : : /* make sure that local variables don't get smashed */
4927 : : gulong return_value;
4928 : 1 : gulong local = 0x12345678;
4929 : 1 : return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_one_inout_parameter (self, a);
4930 : 1 : g_assert_cmpint (local, ==, 0x12345678);
4931 : 1 : return return_value;
4932 : : }
4933 : :
4934 : : /**
4935 : : * gi_marshalling_tests_object_vfunc_return_value_and_multiple_inout_parameters:
4936 : : * @a: (inout):
4937 : : * @b: (inout):
4938 : : */
4939 : : glong
4940 : 1 : gi_marshalling_tests_object_vfunc_return_value_and_multiple_inout_parameters
4941 : : (GIMarshallingTestsObject *self, glong *a, glong *b)
4942 : : {
4943 : : gulong return_value;
4944 : 1 : gulong local = 0x12345678;
4945 : 1 : return_value =
4946 : 1 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_multiple_inout_parameters (self, a, b);
4947 : 1 : g_assert_cmpint (local, ==, 0x12345678);
4948 : 1 : return return_value;
4949 : : }
4950 : :
4951 : : /**
4952 : : * gi_marshalling_tests_callback_owned_boxed:
4953 : : * @callback: (scope call) (closure callback_data):
4954 : : * @callback_data: (allow-none):
4955 : : */
4956 : : glong
4957 : 1 : gi_marshalling_tests_callback_owned_boxed (GIMarshallingTestsCallbackOwnedBoxed callback,
4958 : : void *callback_data)
4959 : : {
4960 : : static GIMarshallingTestsBoxedStruct *box = NULL;
4961 : : glong ret;
4962 : :
4963 [ + - ]: 1 : if (!box)
4964 : 1 : box = gi_marshalling_tests_boxed_struct_new ();
4965 : 1 : box->long_++;
4966 : 1 : callback (box, callback_data);
4967 : 1 : ret = box->long_;
4968 : 1 : return ret;
4969 : : }
4970 : :
4971 : : gboolean
4972 : 16 : gi_marshalling_tests_object_vfunc_meth_with_error (GIMarshallingTestsObject *self, gint x, GError **error)
4973 : : {
4974 : 16 : gulong local = 0x12345678;
4975 : 16 : gboolean ret = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_meth_with_err (self,
4976 : : x,
4977 : : error);
4978 : 16 : g_assert_cmpint (local, ==, 0x12345678);
4979 : 16 : return ret;
4980 : : }
4981 : :
4982 : : /**
4983 : : * gi_marshalling_tests_object_vfunc_return_enum:
4984 : : */
4985 : : GIMarshallingTestsEnum
4986 : 2 : gi_marshalling_tests_object_vfunc_return_enum (GIMarshallingTestsObject *self)
4987 : : {
4988 : : /* make sure that local variables don't get smashed */
4989 : : GIMarshallingTestsEnum return_value;
4990 : 2 : glong local = 0x12345678;
4991 : 2 : return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_enum (self);
4992 : 2 : g_assert_cmpint (local, ==, 0x12345678);
4993 : 2 : return return_value;
4994 : : }
4995 : :
4996 : : /**
4997 : : * gi_marshalling_tests_object_vfunc_out_enum:
4998 : : * @_enum: (out):
4999 : : */
5000 : : void
5001 : 2 : gi_marshalling_tests_object_vfunc_out_enum (GIMarshallingTestsObject *self, GIMarshallingTestsEnum *_enum)
5002 : : {
5003 : : /* make sure that local variables don't get smashed */
5004 : 2 : gulong local = 0x12345678;
5005 : 2 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_out_enum (self, _enum);
5006 : 2 : g_assert_cmpint (local, ==, 0x12345678);
5007 : 2 : }
5008 : :
5009 : : /**
5010 : : * gi_marshalling_tests_object_vfunc_return_flags:
5011 : : */
5012 : : GIMarshallingTestsFlags
5013 : 2 : gi_marshalling_tests_object_vfunc_return_flags (GIMarshallingTestsObject *self)
5014 : : {
5015 : : /* make sure that local variables don't get smashed */
5016 : : GIMarshallingTestsFlags return_value;
5017 : 2 : glong local = 0x12345678;
5018 : 2 : return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_flags (self);
5019 : 2 : g_assert_cmpint (local, ==, 0x12345678);
5020 : 2 : return return_value;
5021 : : }
5022 : :
5023 : : /**
5024 : : * gi_marshalling_tests_object_vfunc_out_flags:
5025 : : * @flags: (out):
5026 : : */
5027 : : void
5028 : 2 : gi_marshalling_tests_object_vfunc_out_flags (GIMarshallingTestsObject *self, GIMarshallingTestsFlags *flags)
5029 : : {
5030 : : /* make sure that local variables don't get smashed */
5031 : 2 : gulong local = 0x12345678;
5032 : 2 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_out_flags (self, flags);
5033 : 2 : g_assert_cmpuint (local, ==, 0x12345678);
5034 : 2 : }
5035 : :
5036 : :
5037 : : /* NOTE:
5038 : : *
5039 : : * The following (get_ref_info_for_*) methods are designed to call vfuncs related
5040 : : * to object argument marshaling. They do not pass the resulting objects through them
5041 : : * as regular vfunc wrapper method do, but rather return reference count and floating
5042 : : * information back to the callers. This is useful because callers can do testing of
5043 : : * expected reference counts in isolation and from the perspective of C. This is important
5044 : : * because if there are bugs in the reverse marshaling, they can obfuscate or compound
5045 : : * bugs in marshaling from the vfuncs.
5046 : : */
5047 : :
5048 : : /**
5049 : : * gi_marshalling_tests_object_get_ref_info_for_vfunc_return_object_transfer_none:
5050 : : * @ref_count: (out): Ref count of the object returned from the vfunc directly after vfunc call.
5051 : : * @is_floating: (out): Floating state object returned from the vfunc directly after vfunc call.
5052 : : */
5053 : : void
5054 : 1 : gi_marshalling_tests_object_get_ref_info_for_vfunc_return_object_transfer_none
5055 : : (GIMarshallingTestsObject *self, guint *ref_count, gboolean *is_floating)
5056 : : {
5057 : 1 : GObject *object = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_object_transfer_none (self);
5058 : 1 : *ref_count = object->ref_count;
5059 : 1 : *is_floating = g_object_is_floating (object);
5060 : :
5061 : : /* Attempt to sink and unref the returned object and avoid any potential leaks */
5062 : 1 : g_object_ref_sink (object);
5063 : 1 : g_object_unref (object);
5064 : 1 : }
5065 : :
5066 : : /**
5067 : : * gi_marshalling_tests_object_get_ref_info_for_vfunc_return_object_transfer_full:
5068 : : * @ref_count: (out): Ref count of the object returned from the vfunc directly after vfunc call.
5069 : : * @is_floating: (out): Floating state object returned from the vfunc directly after vfunc call.
5070 : : */
5071 : : void
5072 : 1 : gi_marshalling_tests_object_get_ref_info_for_vfunc_return_object_transfer_full
5073 : : (GIMarshallingTestsObject *self, guint *ref_count, gboolean *is_floating)
5074 : : {
5075 : 1 : GObject *object = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_object_transfer_full (self);
5076 : 1 : *ref_count = object->ref_count;
5077 : 1 : *is_floating = g_object_is_floating (object);
5078 : 1 : g_object_unref (object);
5079 : 1 : }
5080 : :
5081 : : /**
5082 : : * gi_marshalling_tests_object_get_ref_info_for_vfunc_out_object_transfer_none:
5083 : : * @ref_count: (out): Ref count of the object returned from the vfunc directly after vfunc call.
5084 : : * @is_floating: (out): Floating state object returned from the vfunc directly after vfunc call.
5085 : : */
5086 : : void
5087 : 1 : gi_marshalling_tests_object_get_ref_info_for_vfunc_out_object_transfer_none
5088 : : (GIMarshallingTestsObject *self, guint *ref_count, gboolean *is_floating)
5089 : : {
5090 : 1 : GObject *object = NULL;
5091 : 1 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_out_object_transfer_none (self, &object);
5092 : 1 : *ref_count = object->ref_count;
5093 : 1 : *is_floating = g_object_is_floating (object);
5094 : :
5095 : : /* Attempt to sink and unref the returned object and avoid any potential leaks */
5096 : 1 : g_object_ref_sink (object);
5097 : 1 : g_object_unref (object);
5098 : 1 : }
5099 : :
5100 : : /**
5101 : : * gi_marshalling_tests_object_get_ref_info_for_vfunc_out_object_transfer_full:
5102 : : * @ref_count: (out): Ref count of the object returned from the vfunc directly after vfunc call.
5103 : : * @is_floating: (out): Floating state object returned from the vfunc directly after vfunc call.
5104 : : */
5105 : : void
5106 : 1 : gi_marshalling_tests_object_get_ref_info_for_vfunc_out_object_transfer_full
5107 : : (GIMarshallingTestsObject *self, guint *ref_count, gboolean *is_floating)
5108 : : {
5109 : 1 : GObject *object = NULL;
5110 : 1 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_out_object_transfer_full (self, &object);
5111 : 1 : *ref_count = object->ref_count;
5112 : 1 : *is_floating = g_object_is_floating (object);
5113 : 1 : g_object_unref (object);
5114 : 1 : }
5115 : :
5116 : : static void
5117 : 1 : _vfunc_in_object_destroy_callback (gboolean *destroy_called,
5118 : : GObject *where_the_object_was G_GNUC_UNUSED)
5119 : : {
5120 : 1 : *destroy_called = TRUE;
5121 : 1 : }
5122 : :
5123 : : /**
5124 : : * gi_marshalling_tests_object_get_ref_info_for_vfunc_in_object_transfer_none:
5125 : : * @type: GType of object to create and pass as in argument to the vfunc
5126 : : * @ref_count: (out): Ref count of the in object directly after vfunc call.
5127 : : * @is_floating: (out): Floating state of in object directly after vfunc call.
5128 : : *
5129 : : * Calls vfunc_in_object_transfer_none with a new object of the given type.
5130 : : */
5131 : : void
5132 : 1 : gi_marshalling_tests_object_get_ref_info_for_vfunc_in_object_transfer_none
5133 : : (GIMarshallingTestsObject *self, GType type, guint *ref_count, gboolean *is_floating)
5134 : : {
5135 : : static gboolean destroy_called;
5136 : : GObject *object;
5137 : 1 : destroy_called = FALSE;
5138 : :
5139 : 1 : object = g_object_new (type, NULL);
5140 : 1 : g_object_weak_ref (object, (GWeakNotify) _vfunc_in_object_destroy_callback, &destroy_called);
5141 : :
5142 : 1 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_in_object_transfer_none (self, object);
5143 [ - + ]: 1 : if (destroy_called)
5144 : : {
5145 : 0 : *ref_count = 0;
5146 : 0 : *is_floating = FALSE;
5147 : : }
5148 : : else
5149 : : {
5150 : 1 : *ref_count = object->ref_count;
5151 : 1 : *is_floating = g_object_is_floating (object);
5152 : 1 : g_object_unref (object);
5153 : : }
5154 : 1 : }
5155 : :
5156 : :
5157 : : /**
5158 : : * gi_marshalling_tests_object_get_ref_info_for_vfunc_in_object_transfer_full:
5159 : : * @type: GType of object to create and pass as in argument to the vfunc
5160 : : * @ref_count: (out): Ref count of the in object directly after vfunc call.
5161 : : * @is_floating: (out): Floating state of in object directly after vfunc call.
5162 : : */
5163 : : void
5164 : 0 : gi_marshalling_tests_object_get_ref_info_for_vfunc_in_object_transfer_full
5165 : : (GIMarshallingTestsObject *self, GType type, guint *ref_count, gboolean *is_floating)
5166 : : {
5167 : : static gboolean destroy_called;
5168 : : GObject *object;
5169 : 0 : destroy_called = FALSE;
5170 : :
5171 : 0 : object = g_object_new (type, NULL);
5172 : 0 : g_object_weak_ref (object, (GWeakNotify) _vfunc_in_object_destroy_callback, &destroy_called);
5173 : :
5174 : : /* Calling the vfunc takes ownership of the object, so we use a weak_ref to determine
5175 : : * if the object gets destroyed after the call and appropriately return 0 as the ref count.
5176 : : */
5177 : 0 : GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_in_object_transfer_full (self, object);
5178 [ # # ]: 0 : if (destroy_called)
5179 : : {
5180 : 0 : *ref_count = 0;
5181 : 0 : *is_floating = FALSE;
5182 : : }
5183 : : else
5184 : : {
5185 : 0 : *ref_count = object->ref_count;
5186 : 0 : *is_floating = g_object_is_floating (object);
5187 : : }
5188 : 0 : }
5189 : :
5190 : :
5191 [ + + + - : 14 : G_DEFINE_TYPE (GIMarshallingTestsSubObject, gi_marshalling_tests_sub_object, GI_MARSHALLING_TESTS_TYPE_OBJECT);
+ + ]
5192 : :
5193 : : static void
5194 : 8 : gi_marshalling_tests_sub_object_init (GIMarshallingTestsSubObject *self G_GNUC_UNUSED)
5195 : : {
5196 : 8 : }
5197 : :
5198 : : static void
5199 : 8 : gi_marshalling_tests_sub_object_finalize (GObject *object)
5200 : : {
5201 : 8 : G_OBJECT_CLASS (gi_marshalling_tests_sub_object_parent_class)->finalize (object);
5202 : 8 : }
5203 : :
5204 : : static void
5205 : 0 : method_deep_hierarchy (GIMarshallingTestsObject *self, gint8 in)
5206 : : {
5207 : 0 : GValue val = { 0, };
5208 : 0 : g_value_init (&val, G_TYPE_INT);
5209 : 0 : g_value_set_int (&val, in);
5210 : 0 : g_object_set_property (G_OBJECT (self), "int", &val);
5211 : 0 : }
5212 : :
5213 : : static void
5214 : 2 : gi_marshalling_tests_sub_object_class_init (GIMarshallingTestsSubObjectClass *klass)
5215 : : {
5216 : 2 : G_OBJECT_CLASS (klass)->finalize = gi_marshalling_tests_sub_object_finalize;
5217 : 2 : GI_MARSHALLING_TESTS_OBJECT_CLASS (klass)->method_deep_hierarchy = method_deep_hierarchy;
5218 : 2 : }
5219 : :
5220 : : void
5221 : 2 : gi_marshalling_tests_sub_object_sub_method (GIMarshallingTestsSubObject *object)
5222 : : {
5223 : 2 : g_assert_cmpint (GI_MARSHALLING_TESTS_OBJECT (object)->int_, ==, 0);
5224 : 2 : }
5225 : :
5226 : 2 : void gi_marshalling_tests_sub_object_overwritten_method (GIMarshallingTestsSubObject *object)
5227 : : {
5228 : 2 : g_assert_cmpint (GI_MARSHALLING_TESTS_OBJECT (object)->int_, ==, 0);
5229 : 2 : }
5230 : :
5231 [ + + + - : 6 : G_DEFINE_TYPE (GIMarshallingTestsSubSubObject,
+ - ]
5232 : : gi_marshalling_tests_sub_sub_object, GI_MARSHALLING_TESTS_TYPE_SUB_OBJECT);
5233 : :
5234 : : static void
5235 : 4 : gi_marshalling_tests_sub_sub_object_init (GIMarshallingTestsSubSubObject *self G_GNUC_UNUSED)
5236 : : {
5237 : 4 : }
5238 : :
5239 : 2 : static void gi_marshalling_tests_sub_sub_object_class_init (GIMarshallingTestsSubSubObjectClass *klass G_GNUC_UNUSED)
5240 : : {
5241 : 2 : }
5242 : :
5243 : : /* Interfaces */
5244 : :
5245 : : static void
5246 : 3 : gi_marshalling_tests_interface_class_init (void *g_iface G_GNUC_UNUSED,
5247 : : void *data G_GNUC_UNUSED)
5248 : : {
5249 : 3 : }
5250 : :
5251 : : GType
5252 : 14 : gi_marshalling_tests_interface_get_type (void)
5253 : : {
5254 : : static GType type = 0;
5255 [ + + ]: 14 : if (type == 0)
5256 : : {
5257 : : /* Not adding prerequisite here for test purposes */
5258 : 3 : type = g_type_register_static_simple (G_TYPE_INTERFACE,
5259 : : "GIMarshallingTestsInterface",
5260 : : sizeof
5261 : : (GIMarshallingTestsInterfaceIface),
5262 : : (GClassInitFunc) gi_marshalling_tests_interface_class_init, 0, NULL, 0);
5263 : : }
5264 : :
5265 : 14 : return type;
5266 : : }
5267 : :
5268 : : /**
5269 : : * gi_marshalling_tests_interface_test_int8_in:
5270 : : * @in: (in):
5271 : : */
5272 : : void
5273 : 2 : gi_marshalling_tests_interface_test_int8_in (GIMarshallingTestsInterface *self, gint8 in)
5274 : : {
5275 : 2 : GI_MARSHALLING_TESTS_INTERFACE_GET_IFACE (self)->test_int8_in (self, in);
5276 : 2 : }
5277 : :
5278 : : /**
5279 : : * gi_marshalling_tests_test_interface_test_int8_in:
5280 : : * @in: (in):
5281 : : */
5282 : : void
5283 : 1 : gi_marshalling_tests_test_interface_test_int8_in (GIMarshallingTestsInterface *test_iface, gint8 in)
5284 : : {
5285 : 1 : gi_marshalling_tests_interface_test_int8_in (test_iface, in);
5286 : 1 : }
5287 : :
5288 : :
5289 : : static void test_interface_init (GIMarshallingTestsInterfaceIface *iface);
5290 : :
5291 [ + + + - : 9 : G_DEFINE_TYPE_WITH_CODE (GIMarshallingTestsInterfaceImpl, gi_marshalling_tests_interface_impl, G_TYPE_OBJECT,
+ + ]
5292 : : G_IMPLEMENT_INTERFACE(GI_MARSHALLING_TESTS_TYPE_INTERFACE, test_interface_init))
5293 : :
5294 : : static void
5295 : 2 : gi_marshalling_tests_interface_impl_test_int8_in (GIMarshallingTestsInterface *self G_GNUC_UNUSED,
5296 : : gint8 in G_GNUC_UNUSED)
5297 : : {
5298 : 2 : }
5299 : :
5300 : 2 : static void test_interface_init (GIMarshallingTestsInterfaceIface *iface)
5301 : : {
5302 : 2 : iface->test_int8_in = gi_marshalling_tests_interface_impl_test_int8_in;
5303 : 2 : }
5304 : :
5305 : : static void
5306 : 2 : gi_marshalling_tests_interface_impl_init (GIMarshallingTestsInterfaceImpl *self G_GNUC_UNUSED)
5307 : : {
5308 : 2 : }
5309 : :
5310 : : static void
5311 : 2 : gi_marshalling_tests_interface_impl_class_init (GIMarshallingTestsInterfaceImplClass *klass G_GNUC_UNUSED)
5312 : : {
5313 : 2 : }
5314 : :
5315 : : /**
5316 : : * gi_marshalling_tests_interface_impl_get_as_interface:
5317 : : *
5318 : : * Returns: (transfer none):
5319 : : */
5320 : : GIMarshallingTestsInterface *
5321 : 1 : gi_marshalling_tests_interface_impl_get_as_interface (GIMarshallingTestsInterfaceImpl *self)
5322 : : {
5323 : 1 : return (GIMarshallingTestsInterface *) self;
5324 : : }
5325 : :
5326 : : static void
5327 : 2 : gi_marshalling_tests_interface2_class_init (void *g_iface G_GNUC_UNUSED,
5328 : : void *data G_GNUC_UNUSED)
5329 : : {
5330 : 2 : }
5331 : :
5332 : : GType
5333 : 2 : gi_marshalling_tests_interface2_get_type (void)
5334 : : {
5335 : : static GType type = 0;
5336 [ + - ]: 2 : if (type == 0)
5337 : : {
5338 : 2 : type = g_type_register_static_simple (G_TYPE_INTERFACE,
5339 : : "GIMarshallingTestsInterface2",
5340 : : sizeof
5341 : : (GIMarshallingTestsInterface2Iface),
5342 : : (GClassInitFunc) gi_marshalling_tests_interface2_class_init, 0, NULL, 0);
5343 : : }
5344 : :
5345 : 2 : return type;
5346 : : }
5347 : :
5348 : : static void
5349 : 2 : gi_marshalling_tests_interface3_class_init (void *g_iface G_GNUC_UNUSED,
5350 : : void *data G_GNUC_UNUSED)
5351 : : {
5352 : 2 : }
5353 : :
5354 : : GType
5355 : 7 : gi_marshalling_tests_interface3_get_type (void)
5356 : : {
5357 : : static GType type = 0;
5358 [ + + ]: 7 : if (type == 0)
5359 : : {
5360 : 2 : type = g_type_register_static_simple (G_TYPE_INTERFACE,
5361 : : "GIMarshallingTestsInterface3",
5362 : : sizeof
5363 : : (GIMarshallingTestsInterface3Iface),
5364 : : (GClassInitFunc) gi_marshalling_tests_interface3_class_init, 0, NULL, 0);
5365 : : }
5366 : :
5367 : 7 : return type;
5368 : : }
5369 : :
5370 : : /**
5371 : : * gi_marshalling_tests_interface3_test_variant_array_in:
5372 : : * @in: (array length=n_in):
5373 : : * @n_in:
5374 : : */
5375 : : void
5376 : 2 : gi_marshalling_tests_interface3_test_variant_array_in
5377 : : (GIMarshallingTestsInterface3 *self, GVariant **in, gsize n_in)
5378 : : {
5379 : 2 : GI_MARSHALLING_TESTS_INTERFACE3_GET_IFACE (self)->test_variant_array_in (self, in, n_in);
5380 : 2 : }
5381 : :
5382 : : /**
5383 : : * gi_marshalling_tests_int_out_out:
5384 : : * @int0: (out):
5385 : : * @int1: (out):
5386 : : */
5387 : : void
5388 : 1 : gi_marshalling_tests_int_out_out (gint *int0, gint *int1)
5389 : : {
5390 : 1 : *int0 = 6;
5391 : 1 : *int1 = 7;
5392 : 1 : }
5393 : :
5394 : : /**
5395 : : * gi_marshalling_tests_int_three_in_three_out:
5396 : : * @a: (in):
5397 : : * @b: (in):
5398 : : * @c: (in):
5399 : : * @out0: (out):
5400 : : * @out1: (out):
5401 : : * @out2: (out):
5402 : : */
5403 : : void
5404 : 1 : gi_marshalling_tests_int_three_in_three_out (gint a, gint b, gint c, gint *out0, gint *out1, gint *out2)
5405 : : {
5406 : 1 : *out0 = a;
5407 : 1 : *out1 = b;
5408 : 1 : *out2 = c;
5409 : 1 : }
5410 : :
5411 : : /**
5412 : : * gi_marshalling_tests_int_return_out:
5413 : : * @int_: (out):
5414 : : */
5415 : : gint
5416 : 1 : gi_marshalling_tests_int_return_out (gint *int_)
5417 : : {
5418 : 1 : *int_ = 7;
5419 : 1 : return 6;
5420 : : }
5421 : :
5422 : : /**
5423 : : * gi_marshalling_tests_int_two_in_utf8_two_in_with_allow_none:
5424 : : * @a: (in): Must be 1
5425 : : * @b: (in): Must be 2
5426 : : * @c: (in) (allow-none): Must be "3" or NULL
5427 : : * @d: (in) (allow-none): Must be "4" or NULL
5428 : : */
5429 : : void
5430 : 4 : gi_marshalling_tests_int_two_in_utf8_two_in_with_allow_none (gint a, gint b, const gchar *c, const gchar *d)
5431 : : {
5432 : 4 : g_assert_cmpint (a, ==, 1);
5433 : 4 : g_assert_cmpint (b, ==, 2);
5434 [ + + ]: 4 : if (c != NULL)
5435 : 2 : g_assert_cmpstr (c, ==, "3");
5436 [ + + ]: 4 : if (d != NULL)
5437 : 2 : g_assert_cmpstr (d, ==, "4");
5438 : 4 : }
5439 : :
5440 : : /**
5441 : : * gi_marshalling_tests_int_one_in_utf8_two_in_one_allows_none:
5442 : : * @a: (in): Must be 1
5443 : : * @b: (in) (allow-none): Must be "2" or NULL
5444 : : * @c: (in): Must be "3"
5445 : : */
5446 : : void
5447 : 2 : gi_marshalling_tests_int_one_in_utf8_two_in_one_allows_none (gint a, const gchar *b, const gchar *c)
5448 : : {
5449 : 2 : g_assert_cmpint (a, ==, 1);
5450 [ + + ]: 2 : if (b != NULL)
5451 : 1 : g_assert_cmpstr (b, ==, "2");
5452 : 2 : g_assert_cmpstr (c, ==, "3");
5453 : 2 : }
5454 : :
5455 : : /**
5456 : : * gi_marshalling_tests_array_in_utf8_two_in:
5457 : : * @ints: (array length=length):
5458 : : * @length:
5459 : : * @a: (in) (allow-none): Must be "1" or NULL
5460 : : * @b: (in) (allow-none): Must be "2" or NULL
5461 : : */
5462 : : void
5463 : 4 : gi_marshalling_tests_array_in_utf8_two_in (const gint *ints, gint length, const gchar *a, const gchar *b)
5464 : : {
5465 : 4 : g_assert_cmpint (length, ==, 4);
5466 : 4 : g_assert_cmpint (ints[0], ==, -1);
5467 : 4 : g_assert_cmpint (ints[1], ==, 0);
5468 : 4 : g_assert_cmpint (ints[2], ==, 1);
5469 : 4 : g_assert_cmpint (ints[3], ==, 2);
5470 : :
5471 [ + + ]: 4 : if (a != NULL)
5472 : 2 : g_assert_cmpstr (a, ==, "1");
5473 [ + + ]: 4 : if (b != NULL)
5474 : 2 : g_assert_cmpstr (b, ==, "2");
5475 : 4 : }
5476 : :
5477 : : /**
5478 : : * gi_marshalling_tests_array_in_utf8_two_in_out_of_order:
5479 : : * @length:
5480 : : * @a: (in) (allow-none): Must be "1" or NULL
5481 : : * @ints: (array length=length):
5482 : : * @b: (in) (allow-none): Must be "2" or NULL
5483 : : */
5484 : : void
5485 : 4 : gi_marshalling_tests_array_in_utf8_two_in_out_of_order (gint length, const gchar *a, const gint *ints, const gchar *b)
5486 : : {
5487 : 4 : g_assert_cmpint (length, ==, 4);
5488 : 4 : g_assert_cmpint (ints[0], ==, -1);
5489 : 4 : g_assert_cmpint (ints[1], ==, 0);
5490 : 4 : g_assert_cmpint (ints[2], ==, 1);
5491 : 4 : g_assert_cmpint (ints[3], ==, 2);
5492 : :
5493 [ + + ]: 4 : if (a != NULL)
5494 : 2 : g_assert_cmpstr (a, ==, "1");
5495 [ + + ]: 4 : if (b != NULL)
5496 : 2 : g_assert_cmpstr (b, ==, "2");
5497 : 4 : }
5498 : :
5499 : : /* GError */
5500 : :
5501 : : void
5502 : 1 : gi_marshalling_tests_gerror (GError **error)
5503 : : {
5504 : 1 : GQuark quark = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
5505 : 1 : g_set_error_literal (error, quark,
5506 : : GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE, GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
5507 : 1 : }
5508 : :
5509 : : /**
5510 : : * gi_marshalling_tests_gerror_array_in:
5511 : : * @in_ints: (array zero-terminated):
5512 : : */
5513 : : void
5514 : 1 : gi_marshalling_tests_gerror_array_in (gint *in_ints G_GNUC_UNUSED,
5515 : : GError **error)
5516 : : {
5517 : 1 : GQuark quark = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
5518 : 1 : g_set_error_literal (error, quark,
5519 : : GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE, GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
5520 : 1 : }
5521 : :
5522 : : /**
5523 : : * gi_marshalling_tests_gerror_out:
5524 : : * @error: (out) (allow-none) (transfer full): location for the GError.
5525 : : * @debug: (out) (allow-none) (transfer full): location for the debug message
5526 : : *
5527 : : * Inspired by gst_message_parse_error.
5528 : : */
5529 : : void
5530 : 1 : gi_marshalling_tests_gerror_out (GError **error, gchar **debug)
5531 : : {
5532 : 1 : GQuark quark = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
5533 : 1 : g_set_error_literal (error, quark,
5534 : : GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE, GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
5535 : :
5536 [ + - ]: 1 : if (debug != NULL)
5537 : : {
5538 : 1 : *debug = g_strdup (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE);
5539 : : }
5540 : 1 : }
5541 : :
5542 : : /**
5543 : : * gi_marshalling_tests_gerror_out_transfer_none:
5544 : : * @err: (out) (allow-none) (transfer none): location for the GError.
5545 : : * @debug: (out) (allow-none) (transfer none): location for the debug message
5546 : : *
5547 : : * A variant of gi_marshalling_tests_gerror_out() which returns data the caller
5548 : : * must not free.
5549 : : */
5550 : : void
5551 : 1 : gi_marshalling_tests_gerror_out_transfer_none (GError **err, const gchar **debug)
5552 : : {
5553 : : static GError error = { 0,
5554 : : GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
5555 : : (gchar *) GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE
5556 : : };
5557 : 1 : error.domain = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
5558 : 1 : *err = &error;
5559 : 1 : *debug = GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE;
5560 : 1 : }
5561 : :
5562 : : /**
5563 : : * gi_marshalling_tests_gerror_return:
5564 : : *
5565 : : * Yet another variant of gi_marshalling_tests_gerror_out().
5566 : : *
5567 : : * Returns: (transfer full): a GError
5568 : : */
5569 : : GError *
5570 : 2 : gi_marshalling_tests_gerror_return (void)
5571 : : {
5572 : 2 : GQuark quark = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
5573 : :
5574 : 2 : return g_error_new_literal (quark, GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE, GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
5575 : : }
5576 : :
5577 : : static GIMarshallingTestsOverridesStruct *
5578 : 1 : gi_marshalling_tests_overrides_struct_copy (GIMarshallingTestsOverridesStruct *struct_)
5579 : : {
5580 : : GIMarshallingTestsOverridesStruct *new_struct;
5581 : :
5582 : 1 : new_struct = g_slice_new (GIMarshallingTestsOverridesStruct);
5583 : :
5584 : 1 : *new_struct = *struct_;
5585 : :
5586 : 1 : return new_struct;
5587 : : }
5588 : :
5589 : : static void
5590 : 3 : gi_marshalling_tests_overrides_struct_free (GIMarshallingTestsOverridesStruct *struct_)
5591 : : {
5592 : 3 : g_slice_free (GIMarshallingTestsOverridesStruct, struct_);
5593 : 3 : }
5594 : :
5595 : : GType
5596 : 6 : gi_marshalling_tests_overrides_struct_get_type (void)
5597 : : {
5598 : : static GType type = 0;
5599 : :
5600 [ + + ]: 6 : if (type == 0)
5601 : : {
5602 : 2 : type =
5603 : 2 : g_boxed_type_register_static ("GIMarshallingTestsOverridesStruct",
5604 : : (GBoxedCopyFunc)
5605 : : gi_marshalling_tests_overrides_struct_copy,
5606 : : (GBoxedFreeFunc) gi_marshalling_tests_overrides_struct_free);
5607 : : }
5608 : :
5609 : 6 : return type;
5610 : : }
5611 : :
5612 : : GIMarshallingTestsOverridesStruct *
5613 : 2 : gi_marshalling_tests_overrides_struct_new (void)
5614 : : {
5615 : 2 : return g_slice_new (GIMarshallingTestsOverridesStruct);
5616 : : }
5617 : :
5618 : 1 : glong gi_marshalling_tests_overrides_struct_method (GIMarshallingTestsOverridesStruct *self G_GNUC_UNUSED)
5619 : : {
5620 : 1 : return 42;
5621 : : }
5622 : :
5623 : :
5624 : : /**
5625 : : * gi_marshalling_tests_overrides_struct_returnv:
5626 : : *
5627 : : * Returns: (transfer full):
5628 : : */
5629 : : GIMarshallingTestsOverridesStruct *
5630 : 1 : gi_marshalling_tests_overrides_struct_returnv (void)
5631 : : {
5632 : 1 : return gi_marshalling_tests_overrides_struct_new ();
5633 : : }
5634 : :
5635 : :
5636 [ + + + - : 12 : G_DEFINE_TYPE (GIMarshallingTestsOverridesObject, gi_marshalling_tests_overrides_object, G_TYPE_OBJECT);
+ + ]
5637 : :
5638 : : static void
5639 : 3 : gi_marshalling_tests_overrides_object_init (GIMarshallingTestsOverridesObject *self G_GNUC_UNUSED)
5640 : : {
5641 : 3 : }
5642 : :
5643 : : static void
5644 : 3 : gi_marshalling_tests_overrides_object_finalize (GObject *object)
5645 : : {
5646 : 3 : G_OBJECT_CLASS (gi_marshalling_tests_overrides_object_parent_class)->finalize (object);
5647 : 3 : }
5648 : :
5649 : 2 : static void gi_marshalling_tests_overrides_object_class_init (GIMarshallingTestsOverridesObjectClass *klass)
5650 : : {
5651 : 2 : GObjectClass *object_class = G_OBJECT_CLASS (klass);
5652 : : #if 0
5653 : : GObjectClass *parent_class = G_OBJECT_CLASS (klass);
5654 : : #endif
5655 : :
5656 : 2 : object_class->finalize = gi_marshalling_tests_overrides_object_finalize;
5657 : 2 : }
5658 : :
5659 : : GIMarshallingTestsOverridesObject *
5660 : 0 : gi_marshalling_tests_overrides_object_new (void)
5661 : : {
5662 : 0 : return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
5663 : : }
5664 : :
5665 : 1 : glong gi_marshalling_tests_overrides_object_method (GIMarshallingTestsOverridesObject *self G_GNUC_UNUSED)
5666 : : {
5667 : 1 : return 42;
5668 : : }
5669 : :
5670 : : /**
5671 : : * gi_marshalling_tests_overrides_object_returnv:
5672 : : *
5673 : : * Returns: (transfer full):
5674 : : */
5675 : : GIMarshallingTestsOverridesObject *
5676 : 1 : gi_marshalling_tests_overrides_object_returnv (void)
5677 : : {
5678 : 1 : return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
5679 : : }
5680 : :
5681 : : /**
5682 : : * gi_marshalling_tests_filename_list_return:
5683 : : *
5684 : : * Returns: (transfer none) (element-type filename): List of filenames
5685 : : */
5686 : : GSList *
5687 : 1 : gi_marshalling_tests_filename_list_return (void)
5688 : : {
5689 : 1 : return NULL;
5690 : : }
5691 : :
5692 : : /**
5693 : : * gi_marshalling_tests_param_spec_in_bool:
5694 : : */
5695 : : void
5696 : 1 : gi_marshalling_tests_param_spec_in_bool (const GParamSpec *param)
5697 : : {
5698 : 1 : g_assert (G_IS_PARAM_SPEC (param));
5699 : 1 : g_assert_cmpint (G_PARAM_SPEC_VALUE_TYPE (param), ==, G_TYPE_BOOLEAN);
5700 : 1 : g_assert_cmpstr (g_param_spec_get_name ((GParamSpec *) param), ==, "mybool");
5701 : 1 : }
5702 : :
5703 : : /**
5704 : : * gi_marshalling_tests_param_spec_return:
5705 : : *
5706 : : * Returns: (transfer full): a #GParamSpec
5707 : : */
5708 : : GParamSpec *
5709 : 1 : gi_marshalling_tests_param_spec_return (void)
5710 : : {
5711 : 1 : return g_param_spec_string ("test-param", "test", "This is a test", "42", G_PARAM_READABLE);
5712 : : }
5713 : :
5714 : : /**
5715 : : * gi_marshalling_tests_param_spec_out:
5716 : : * @param: (out):
5717 : : */
5718 : : void
5719 : 1 : gi_marshalling_tests_param_spec_out (GParamSpec **param)
5720 : : {
5721 : 1 : *param = g_param_spec_string ("test-param", "test", "This is a test", "42", G_PARAM_READABLE);
5722 : 1 : }
5723 : :
5724 : :
5725 : : enum
5726 : : {
5727 : : DUMMY_PROPERTY,
5728 : : SOME_BOOLEAN_PROPERTY,
5729 : : SOME_CHAR_PROPERTY,
5730 : : SOME_UCHAR_PROPERTY,
5731 : : SOME_INT_PROPERTY,
5732 : : SOME_UINT_PROPERTY,
5733 : : SOME_LONG_PROPERTY,
5734 : : SOME_ULONG_PROPERTY,
5735 : : SOME_INT64_PROPERTY,
5736 : : SOME_UINT64_PROPERTY,
5737 : : SOME_FLOAT_PROPERTY,
5738 : : SOME_STRING_PROPERTY,
5739 : : SOME_DOUBLE_PROPERTY,
5740 : : SOME_STRV_PROPERTY,
5741 : : SOME_BOXED_STRUCT_PROPERTY,
5742 : : SOME_VARIANT_PROPERTY,
5743 : : SOME_BOXED_GLIST_PROPERTY,
5744 : : SOME_GVALUE_PROPERTY,
5745 : : SOME_OBJECT_PROPERTY,
5746 : : SOME_FLAGS_PROPERTY,
5747 : : SOME_ENUM_PROPERTY,
5748 : : SOME_BYTE_ARRAY_PROPERTY,
5749 : : SOME_READONLY_PROPERTY,
5750 : : };
5751 : :
5752 [ + + + - : 2142 : G_DEFINE_TYPE (GIMarshallingTestsPropertiesObject, gi_marshalling_tests_properties_object, G_TYPE_OBJECT);
+ + ]
5753 : :
5754 : 84 : static void gi_marshalling_tests_properties_object_init (GIMarshallingTestsPropertiesObject *self G_GNUC_UNUSED)
5755 : : {
5756 : 84 : }
5757 : :
5758 : : static void
5759 : 84 : gi_marshalling_tests_properties_object_finalize (GObject *obj)
5760 : : {
5761 : : GIMarshallingTestsPropertiesObject *self;
5762 : 84 : self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (obj);
5763 : :
5764 [ + + ]: 84 : if (self->some_gvalue) {
5765 : 14 : g_boxed_free (G_TYPE_VALUE, self->some_gvalue);
5766 : 14 : self->some_gvalue = NULL;
5767 : : }
5768 : :
5769 [ + + ]: 84 : g_clear_pointer (&self->some_string, g_free);
5770 [ + + ]: 84 : g_clear_pointer (&self->some_strv, g_strfreev);
5771 [ + + ]: 84 : g_clear_pointer (&self->some_boxed_struct, gi_marshalling_tests_boxed_struct_free);
5772 [ + + ]: 84 : g_clear_pointer (&self->some_variant, g_variant_unref);
5773 [ - + ]: 84 : g_clear_pointer (&self->some_boxed_glist, g_list_free);
5774 [ + + ]: 84 : g_clear_object (&self->some_object);
5775 : :
5776 : 84 : G_OBJECT_CLASS (gi_marshalling_tests_properties_object_parent_class)->finalize (obj);
5777 : 84 : }
5778 : :
5779 : : static void
5780 : 143 : gi_marshalling_tests_properties_object_get_property (GObject *object,
5781 : : guint property_id, GValue *value, GParamSpec *pspec)
5782 : : {
5783 : : GIMarshallingTestsPropertiesObject *self;
5784 : 143 : self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
5785 [ + + + + : 143 : switch (property_id)
+ + + + +
+ + + + +
+ + + + +
+ + + - ]
5786 : : {
5787 : 6 : case SOME_BOOLEAN_PROPERTY:
5788 : 6 : g_value_set_boolean (value, self->some_boolean);
5789 : 6 : break;
5790 : 6 : case SOME_CHAR_PROPERTY:
5791 : 6 : g_value_set_schar (value, self->some_char);
5792 : 6 : break;
5793 : 6 : case SOME_UCHAR_PROPERTY:
5794 : 6 : g_value_set_uchar (value, self->some_uchar);
5795 : 6 : break;
5796 : 6 : case SOME_INT_PROPERTY:
5797 : 6 : g_value_set_int (value, self->some_int);
5798 : 6 : break;
5799 : 6 : case SOME_UINT_PROPERTY:
5800 : 6 : g_value_set_uint (value, self->some_uint);
5801 : 6 : break;
5802 : 6 : case SOME_LONG_PROPERTY:
5803 : 6 : g_value_set_long (value, self->some_long);
5804 : 6 : break;
5805 : 6 : case SOME_ULONG_PROPERTY:
5806 : 6 : g_value_set_ulong (value, self->some_ulong);
5807 : 6 : break;
5808 : 14 : case SOME_INT64_PROPERTY:
5809 : 14 : g_value_set_int64 (value, self->some_int64);
5810 : 14 : break;
5811 : 8 : case SOME_UINT64_PROPERTY:
5812 : 8 : g_value_set_uint64 (value, self->some_uint64);
5813 : 8 : break;
5814 : 2 : case SOME_FLOAT_PROPERTY:
5815 : 2 : g_value_set_float (value, self->some_float);
5816 : 2 : break;
5817 : 2 : case SOME_DOUBLE_PROPERTY:
5818 : 2 : g_value_set_double (value, self->some_double);
5819 : 2 : break;
5820 : 6 : case SOME_STRING_PROPERTY:
5821 : 6 : g_value_set_string (value, self->some_string);
5822 : 6 : break;
5823 : 6 : case SOME_STRV_PROPERTY:
5824 : 6 : g_value_set_boxed (value, self->some_strv);
5825 : 6 : break;
5826 : 6 : case SOME_BOXED_STRUCT_PROPERTY:
5827 : 6 : g_value_set_boxed (value, self->some_boxed_struct);
5828 : 6 : break;
5829 : 6 : case SOME_BOXED_GLIST_PROPERTY:
5830 : 6 : g_value_set_boxed (value, self->some_boxed_glist);
5831 : 6 : break;
5832 : 8 : case SOME_GVALUE_PROPERTY:
5833 : 8 : g_value_set_boxed (value, self->some_gvalue);
5834 : 8 : break;
5835 : 18 : case SOME_VARIANT_PROPERTY:
5836 : 18 : g_value_set_variant (value, self->some_variant);
5837 : 18 : break;
5838 : 6 : case SOME_OBJECT_PROPERTY:
5839 : 6 : g_value_set_object (value, self->some_object);
5840 : 6 : break;
5841 : 6 : case SOME_FLAGS_PROPERTY:
5842 : 6 : g_value_set_flags (value, self->some_flags);
5843 : 6 : break;
5844 : 6 : case SOME_ENUM_PROPERTY:
5845 : 6 : g_value_set_enum (value, self->some_enum);
5846 : 6 : break;
5847 : 6 : case SOME_BYTE_ARRAY_PROPERTY:
5848 : 6 : g_value_set_boxed (value, self->some_byte_array);
5849 : 6 : break;
5850 : 1 : case SOME_READONLY_PROPERTY:
5851 : 1 : g_value_set_int (value, 42);
5852 : 1 : break;
5853 : 0 : default:
5854 : 0 : G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
5855 : 0 : break;
5856 : : }
5857 : 143 : }
5858 : :
5859 : : static void
5860 : 1906 : gi_marshalling_tests_properties_object_set_property (GObject *object,
5861 : : guint property_id, const GValue *value, GParamSpec *pspec)
5862 : : {
5863 : : GIMarshallingTestsPropertiesObject *self;
5864 : 1906 : self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
5865 [ + + + + : 1906 : switch (property_id)
+ + + + +
+ + + + +
+ + + + +
+ + - ]
5866 : : {
5867 : 90 : case SOME_BOOLEAN_PROPERTY:
5868 : 90 : self->some_boolean = g_value_get_boolean (value);
5869 : 90 : break;
5870 : 90 : case SOME_CHAR_PROPERTY:
5871 : 90 : self->some_char = g_value_get_schar (value);
5872 : 90 : break;
5873 : 90 : case SOME_UCHAR_PROPERTY:
5874 : 90 : self->some_uchar = g_value_get_uchar (value);
5875 : 90 : break;
5876 : 90 : case SOME_INT_PROPERTY:
5877 : 90 : self->some_int = g_value_get_int (value);
5878 : 90 : break;
5879 : 90 : case SOME_UINT_PROPERTY:
5880 : 90 : self->some_uint = g_value_get_uint (value);
5881 : 90 : break;
5882 : 90 : case SOME_LONG_PROPERTY:
5883 : 90 : self->some_long = g_value_get_long (value);
5884 : 90 : break;
5885 : 90 : case SOME_ULONG_PROPERTY:
5886 : 90 : self->some_ulong = g_value_get_ulong (value);
5887 : 90 : break;
5888 : 98 : case SOME_INT64_PROPERTY:
5889 : 98 : self->some_int64 = g_value_get_int64 (value);
5890 : 98 : break;
5891 : 92 : case SOME_UINT64_PROPERTY:
5892 : 92 : self->some_uint64 = g_value_get_uint64 (value);
5893 : 92 : break;
5894 : 86 : case SOME_FLOAT_PROPERTY:
5895 : 86 : self->some_float = g_value_get_float (value);
5896 : 86 : break;
5897 : 86 : case SOME_DOUBLE_PROPERTY:
5898 : 86 : self->some_double = g_value_get_double (value);
5899 : 86 : break;
5900 : 90 : case SOME_STRING_PROPERTY:
5901 [ + + ]: 90 : g_clear_pointer (&self->some_string, g_free);
5902 : 90 : self->some_string = g_value_dup_string (value);
5903 : 90 : break;
5904 : 90 : case SOME_STRV_PROPERTY:
5905 : 90 : g_strfreev (self->some_strv);
5906 : 90 : self->some_strv = g_strdupv (g_value_get_boxed (value));
5907 : 90 : break;
5908 : 90 : case SOME_BOXED_STRUCT_PROPERTY:
5909 : 90 : gi_marshalling_tests_boxed_struct_free (self->some_boxed_struct);
5910 : 90 : self->some_boxed_struct = gi_marshalling_tests_boxed_struct_copy (g_value_get_boxed (value));
5911 : 90 : break;
5912 : 90 : case SOME_BOXED_GLIST_PROPERTY:
5913 : 90 : g_list_free (self->some_boxed_glist);
5914 : 90 : self->some_boxed_glist = g_list_copy (g_value_get_boxed (value));
5915 : 90 : break;
5916 : 92 : case SOME_GVALUE_PROPERTY:
5917 [ + + ]: 92 : if (self->some_gvalue)
5918 : 4 : g_boxed_free (G_TYPE_VALUE, self->some_gvalue);
5919 : 92 : self->some_gvalue = g_value_dup_boxed (value);
5920 : 92 : break;
5921 : 102 : case SOME_VARIANT_PROPERTY:
5922 [ + + ]: 102 : if (self->some_variant != NULL)
5923 : 9 : g_variant_unref (self->some_variant);
5924 : 102 : self->some_variant = g_value_get_variant (value);
5925 [ + + ]: 102 : if (self->some_variant != NULL)
5926 : 28 : g_variant_ref (self->some_variant);
5927 : 102 : break;
5928 : 90 : case SOME_OBJECT_PROPERTY:
5929 [ + + ]: 90 : if (self->some_object != NULL)
5930 : 3 : g_object_unref (self->some_object);
5931 : 90 : self->some_object = g_value_dup_object (value);
5932 : 90 : break;
5933 : 90 : case SOME_FLAGS_PROPERTY:
5934 : 90 : self->some_flags = g_value_get_flags (value);
5935 : 90 : break;
5936 : 90 : case SOME_ENUM_PROPERTY:
5937 : 90 : self->some_enum = g_value_get_enum (value);
5938 : 90 : break;
5939 : 90 : case SOME_BYTE_ARRAY_PROPERTY:
5940 [ + + ]: 90 : if (self->some_byte_array != NULL)
5941 : 3 : g_byte_array_unref (self->some_byte_array);
5942 : 90 : self->some_byte_array = g_value_dup_boxed (value);
5943 : 90 : break;
5944 : 0 : default:
5945 : 0 : G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
5946 : 0 : break;
5947 : : }
5948 : 1906 : }
5949 : :
5950 : 3 : static void gi_marshalling_tests_properties_object_class_init (GIMarshallingTestsPropertiesObjectClass *klass)
5951 : : {
5952 : 3 : GObjectClass *object_class = G_OBJECT_CLASS (klass);
5953 : :
5954 : 3 : object_class->finalize = gi_marshalling_tests_properties_object_finalize;
5955 : 3 : object_class->get_property = gi_marshalling_tests_properties_object_get_property;
5956 : 3 : object_class->set_property = gi_marshalling_tests_properties_object_set_property;
5957 : :
5958 : 3 : g_object_class_install_property (object_class, SOME_BOOLEAN_PROPERTY,
5959 : : g_param_spec_boolean ("some-boolean",
5960 : : "some-boolean",
5961 : : "some-boolean",
5962 : : FALSE,
5963 : : G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5964 : :
5965 : 3 : g_object_class_install_property (object_class, SOME_CHAR_PROPERTY,
5966 : : g_param_spec_char ("some-char",
5967 : : "some-char",
5968 : : "some-char", G_MININT8,
5969 : : G_MAXINT8, 0,
5970 : : G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5971 : :
5972 : 3 : g_object_class_install_property (object_class, SOME_UCHAR_PROPERTY,
5973 : : g_param_spec_uchar ("some-uchar",
5974 : : "some-uchar",
5975 : : "some-uchar", 0,
5976 : : G_MAXUINT8, 0,
5977 : : G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5978 : :
5979 : 3 : g_object_class_install_property (object_class, SOME_INT_PROPERTY,
5980 : : g_param_spec_int ("some-int", "some-int",
5981 : : "some-int", G_MININT,
5982 : : G_MAXINT, 0,
5983 : : G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5984 : :
5985 : 3 : g_object_class_install_property (object_class, SOME_UINT_PROPERTY,
5986 : : g_param_spec_uint ("some-uint",
5987 : : "some-uint",
5988 : : "some-uint", 0,
5989 : : G_MAXUINT, 0,
5990 : : G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5991 : :
5992 : 3 : g_object_class_install_property (object_class, SOME_LONG_PROPERTY,
5993 : : g_param_spec_long ("some-long",
5994 : : "some-long",
5995 : : "some-long", G_MINLONG,
5996 : : G_MAXLONG, 0,
5997 : : G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
5998 : :
5999 : 3 : g_object_class_install_property (object_class, SOME_ULONG_PROPERTY,
6000 : : g_param_spec_ulong ("some-ulong",
6001 : : "some-ulong",
6002 : : "some-ulong", 0,
6003 : : G_MAXULONG, 0,
6004 : : G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
6005 : :
6006 : 3 : g_object_class_install_property (object_class, SOME_INT64_PROPERTY,
6007 : : g_param_spec_int64 ("some-int64",
6008 : : "some-int64",
6009 : : "some-int64",
6010 : : G_MININT64, G_MAXINT64,
6011 : : 0, G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
6012 : :
6013 : 3 : g_object_class_install_property (object_class, SOME_UINT64_PROPERTY,
6014 : : g_param_spec_uint64 ("some-uint64",
6015 : : "some-uint64",
6016 : : "some-uint64", 0,
6017 : : G_MAXUINT64, 0,
6018 : : G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
6019 : :
6020 : 3 : g_object_class_install_property (object_class, SOME_FLOAT_PROPERTY,
6021 : : g_param_spec_float ("some-float",
6022 : : "some-float",
6023 : : "some-float",
6024 : : -1 * G_MAXFLOAT,
6025 : : G_MAXFLOAT, 0,
6026 : : G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
6027 : :
6028 : 3 : g_object_class_install_property (object_class, SOME_DOUBLE_PROPERTY,
6029 : : g_param_spec_double ("some-double",
6030 : : "some-double",
6031 : : "some-double",
6032 : : -1 * G_MAXDOUBLE,
6033 : : G_MAXDOUBLE, 0,
6034 : : G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
6035 : :
6036 : 3 : g_object_class_install_property (object_class, SOME_STRING_PROPERTY,
6037 : : g_param_spec_string ("some-string",
6038 : : "some-string",
6039 : : "some-string",
6040 : : NULL,
6041 : : G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
6042 : :
6043 : 3 : g_object_class_install_property (object_class, SOME_STRV_PROPERTY,
6044 : : g_param_spec_boxed ("some-strv",
6045 : : "some-strv",
6046 : : "some-strv",
6047 : : G_TYPE_STRV,
6048 : : G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
6049 : :
6050 : 3 : g_object_class_install_property (object_class, SOME_BOXED_STRUCT_PROPERTY,
6051 : : g_param_spec_boxed ("some-boxed-struct",
6052 : : "some-boxed-struct",
6053 : : "some-boxed-struct",
6054 : : gi_marshalling_tests_boxed_struct_get_type
6055 : : (), G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
6056 : :
6057 : : /**
6058 : : * GIMarshallingTestsPropertiesObject:some-boxed-glist: (type GLib.List(gint)) (transfer none):
6059 : : */
6060 : 3 : g_object_class_install_property (object_class, SOME_BOXED_GLIST_PROPERTY,
6061 : : g_param_spec_boxed ("some-boxed-glist",
6062 : : "some-boxed-glist",
6063 : : "some-boxed-glist",
6064 : : gi_marshalling_tests_boxed_glist_get_type
6065 : : (), G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
6066 : :
6067 : 3 : g_object_class_install_property (object_class, SOME_GVALUE_PROPERTY,
6068 : : g_param_spec_boxed ("some-gvalue",
6069 : : "some-gvalue",
6070 : : "some-gvalue",
6071 : : G_TYPE_VALUE,
6072 : : G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
6073 : :
6074 : 3 : g_object_class_install_property (object_class, SOME_VARIANT_PROPERTY,
6075 : : g_param_spec_variant ("some-variant",
6076 : : "some-variant",
6077 : : "some-variant",
6078 : : G_VARIANT_TYPE_ANY,
6079 : : NULL,
6080 : : G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
6081 : :
6082 : 3 : g_object_class_install_property (object_class, SOME_OBJECT_PROPERTY,
6083 : : g_param_spec_object ("some-object",
6084 : : "some-object",
6085 : : "some-object",
6086 : : G_TYPE_OBJECT,
6087 : : G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
6088 : :
6089 : 3 : g_object_class_install_property (object_class, SOME_FLAGS_PROPERTY,
6090 : : g_param_spec_flags ("some-flags",
6091 : : "some-flags",
6092 : : "some-flags",
6093 : : GI_MARSHALLING_TESTS_TYPE_FLAGS,
6094 : : GI_MARSHALLING_TESTS_FLAGS_VALUE1,
6095 : : G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
6096 : :
6097 : 3 : g_object_class_install_property (object_class, SOME_ENUM_PROPERTY,
6098 : : g_param_spec_enum ("some-enum",
6099 : : "some-enum",
6100 : : "some-enum",
6101 : : GI_MARSHALLING_TESTS_TYPE_GENUM,
6102 : : GI_MARSHALLING_TESTS_GENUM_VALUE1,
6103 : : G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
6104 : :
6105 : 3 : g_object_class_install_property (object_class, SOME_BYTE_ARRAY_PROPERTY,
6106 : : g_param_spec_boxed ("some-byte-array",
6107 : : "some-byte-array",
6108 : : "some-byte-array",
6109 : : G_TYPE_BYTE_ARRAY,
6110 : : G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
6111 : :
6112 : 3 : g_object_class_install_property (object_class, SOME_READONLY_PROPERTY,
6113 : : g_param_spec_int ("some-readonly",
6114 : : "some-readonly",
6115 : : "some-readonly",
6116 : : G_MININT, G_MAXINT, 0,
6117 : : G_PARAM_READABLE));
6118 : 3 : }
6119 : :
6120 : : GIMarshallingTestsPropertiesObject *
6121 : 0 : gi_marshalling_tests_properties_object_new (void)
6122 : : {
6123 : 0 : return g_object_new (GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT, NULL);
6124 : : }
6125 : :
6126 [ + + + - : 12 : G_DEFINE_TYPE (GIMarshallingTestsSignalsObject, gi_marshalling_tests_signals_object, G_TYPE_OBJECT);
+ + ]
6127 : :
6128 : : static void
6129 : 3 : gi_marshalling_tests_signals_object_init (GIMarshallingTestsSignalsObject *object G_GNUC_UNUSED)
6130 : : {
6131 : 3 : }
6132 : :
6133 : : static void
6134 : 3 : gi_marshalling_tests_signals_object_finalize (GObject *object)
6135 : : {
6136 : 3 : G_OBJECT_CLASS (gi_marshalling_tests_signals_object_parent_class)->finalize (object);
6137 : 3 : }
6138 : :
6139 : : static void
6140 : 2 : gi_marshalling_tests_signals_object_class_init (GIMarshallingTestsSignalsObjectClass *klass)
6141 : : {
6142 : 2 : GObjectClass *object_class = G_OBJECT_CLASS (klass);
6143 : :
6144 : 2 : object_class->finalize = gi_marshalling_tests_signals_object_finalize;
6145 : :
6146 : : /**
6147 : : * GIMarshallingTestsSignalsObject::some-boxed-gptrarray-utf8:
6148 : : * @self:
6149 : : * @arg: (element-type utf8):
6150 : : */
6151 : 2 : g_signal_new ("some-boxed-gptrarray-utf8",
6152 : : G_TYPE_FROM_CLASS (klass),
6153 : : G_SIGNAL_RUN_LAST,
6154 : : 0, NULL, NULL, NULL,
6155 : : G_TYPE_NONE, 1,
6156 : : G_TYPE_PTR_ARRAY);
6157 : :
6158 : : /**
6159 : : * GIMarshallingTestsSignalsObject::some-boxed-gptrarray-boxed-struct:
6160 : : * @self:
6161 : : * @arg: (element-type GIMarshallingTestsBoxedStruct):
6162 : : */
6163 : 2 : g_signal_new ("some-boxed-gptrarray-boxed-struct",
6164 : : G_TYPE_FROM_CLASS (klass),
6165 : : G_SIGNAL_RUN_LAST,
6166 : : 0, NULL, NULL, NULL,
6167 : : G_TYPE_NONE, 1,
6168 : : G_TYPE_PTR_ARRAY);
6169 : 2 : }
6170 : :
6171 : : GIMarshallingTestsSignalsObject *
6172 : 0 : gi_marshalling_tests_signals_object_new (void)
6173 : : {
6174 : 0 : return g_object_new (GI_MARSHALLING_TESTS_TYPE_SIGNALS_OBJECT, NULL);
6175 : : }
6176 : :
6177 : : void
6178 : 1 : gi_marshalling_tests_signals_object_emit_boxed_gptrarray_utf8 (GIMarshallingTestsSignalsObject *object)
6179 : : {
6180 : : GPtrArray *ptrarray;
6181 : :
6182 : 1 : ptrarray = gi_marshalling_tests_gptrarray_utf8_full_return ();
6183 : 1 : g_signal_emit_by_name (object, "some-boxed-gptrarray-utf8",
6184 : : ptrarray);
6185 : 1 : g_ptr_array_unref (ptrarray);
6186 : 1 : }
6187 : :
6188 : : void
6189 : 1 : gi_marshalling_tests_signals_object_emit_boxed_gptrarray_boxed_struct (GIMarshallingTestsSignalsObject *object)
6190 : : {
6191 : : GPtrArray *ptrarray;
6192 : :
6193 : 1 : ptrarray = gi_marshalling_tests_gptrarray_boxed_struct_full_return ();
6194 : 1 : g_signal_emit_by_name (object, "some-boxed-gptrarray-boxed-struct",
6195 : : ptrarray);
6196 : 1 : g_ptr_array_unref (ptrarray);
6197 : 1 : }
|