WarnLib: New library for testing API that emits warnings
[platform/upstream/gobject-introspection.git] / tests / scanner / regress.c
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 #include <string.h>
3 #include <stdlib.h>
4 #include <glib-object.h>
5 #include <gobject/gvaluecollector.h>
6 #include <cairo-gobject.h>
7
8 #include "regress.h"
9
10 static gboolean abort_on_error = TRUE;
11
12 #define ASSERT_VALUE(condition)  \
13   if (abort_on_error)             \
14     g_assert (condition);         \
15   else                            \
16     g_warn_if_fail (condition);   \
17
18 void
19 regress_set_abort_on_error (gboolean in)
20 {
21   abort_on_error = in;
22 }
23
24 /* basic types */
25 gboolean
26 regress_test_boolean (gboolean in)
27 {
28   return in;
29 }
30
31 gboolean
32 regress_test_boolean_true (gboolean in)
33 {
34   ASSERT_VALUE (in == TRUE);
35   return in;
36 }
37
38 gboolean
39 regress_test_boolean_false (gboolean in)
40 {
41   ASSERT_VALUE (in == FALSE);
42   return in;
43 }
44
45 gint8
46 regress_test_int8 (gint8 in)
47 {
48   return in;
49 }
50
51 guint8
52 regress_test_uint8 (guint8 in)
53 {
54   return in;
55 }
56
57 gint16
58 regress_test_int16 (gint16 in)
59 {
60   return in;
61 }
62
63 guint16
64 regress_test_uint16 (guint16 in)
65 {
66   return in;
67 }
68
69 gint32
70 regress_test_int32 (gint32 in)
71 {
72   return in;
73 }
74
75 guint32
76 regress_test_uint32 (guint32 in)
77 {
78   return in;
79 }
80
81 gint64
82 regress_test_int64 (gint64 in)
83 {
84   return in;
85 }
86
87 guint64
88 regress_test_uint64 (guint64 in)
89 {
90   return in;
91 }
92
93 gshort
94 regress_test_short (gshort in)
95 {
96   return in;
97 }
98
99 gushort
100 regress_test_ushort (gushort in)
101 {
102   return in;
103 }
104
105 gint
106 regress_test_int (gint in)
107 {
108   return in;
109 }
110
111 guint
112 regress_test_uint (guint in)
113 {
114   return in;
115 }
116
117 glong
118 regress_test_long (glong in)
119 {
120   return in;
121 }
122
123 gulong
124 regress_test_ulong (gulong in)
125 {
126   return in;
127 }
128
129 gssize
130 regress_test_ssize (gssize in)
131 {
132   return in;
133 }
134
135 gsize
136 regress_test_size (gsize in)
137 {
138   return in;
139 }
140
141 gfloat
142 regress_test_float (gfloat in)
143 {
144   return in;
145 }
146
147 gdouble
148 regress_test_double (gdouble in)
149 {
150   return in;
151 }
152
153 gunichar
154 regress_test_unichar (gunichar in)
155 {
156   return in;
157 }
158
159 time_t
160 regress_test_timet (time_t in)
161 {
162   return in;
163 }
164
165 GType
166 regress_test_gtype (GType in)
167 {
168   return in;
169 }
170
171 int
172 regress_test_closure (GClosure *closure)
173 {
174   GValue return_value = {0, };
175   int ret;
176
177   g_value_init (&return_value, G_TYPE_INT);
178
179   g_closure_invoke (closure,
180                     &return_value,
181                     0, NULL,
182                     NULL);
183
184   ret = g_value_get_int (&return_value);
185
186   g_value_unset(&return_value);
187
188   return ret;
189 }
190
191 int
192 regress_test_closure_one_arg (GClosure *closure, int arg)
193 {
194   GValue return_value = {0, };
195   GValue arguments[1];
196   int ret;
197
198   g_value_init (&return_value, G_TYPE_INT);
199
200   memset (&arguments[0], 0, sizeof (arguments));
201   g_value_init (&arguments[0], G_TYPE_INT);
202   g_value_set_int (&arguments[0], arg);
203
204   g_closure_invoke (closure,
205                     &return_value,
206                     1, arguments,
207                     NULL);
208
209   ret = g_value_get_int (&return_value);
210
211   g_value_unset(&return_value);
212   g_value_unset(&arguments[0]);
213
214   return ret;
215 }
216
217 /**
218  * regress_test_closure_variant:
219  * @closure: GClosure which takes one GVariant and returns a GVariant
220  * @arg: (allow-none) (transfer none): a GVariant passed as argument to @closure
221  *
222  * Return value: (transfer full): the return value of @closure
223  */
224 GVariant*
225 regress_test_closure_variant (GClosure *closure, GVariant* arg)
226 {
227   GValue return_value = {0, };
228   GValue arguments[1] = {{0,} };
229   GVariant *ret;
230
231   g_value_init (&return_value, G_TYPE_VARIANT);
232
233   g_value_init (&arguments[0], G_TYPE_VARIANT);
234   g_value_set_variant (&arguments[0], arg);
235
236   g_closure_invoke (closure,
237                     &return_value,
238                     1, arguments,
239                     NULL);
240
241   ret = g_value_get_variant (&return_value);
242   if (ret != NULL)
243     g_variant_ref (ret);
244
245   g_value_unset (&return_value);
246   g_value_unset (&arguments[0]);
247
248   return ret;
249 }
250
251 /**
252  * regress_test_value_arg:
253  * @v: (transfer none): a GValue expected to contain an int
254  *
255  * Return value: the int contained in the GValue.
256  */
257 int
258 regress_test_int_value_arg(const GValue *v)
259 {
260   int i;
261
262   i = g_value_get_int (v);
263
264   return i;
265 }
266
267 static GValue value;
268 /**
269  * regress_test_value_return:
270  * @i: an int
271  *
272  * Return value: (transfer none): the int wrapped in a GValue.
273  */
274 const GValue *
275 regress_test_value_return(int i)
276 {
277   memset(&value, '\0', sizeof(GValue));
278
279   g_value_init (&value, G_TYPE_INT);
280   g_value_set_int (&value, i);
281
282   return &value;
283 }
284
285 /************************************************************************/
286 /* foreign structs */
287
288 /**
289  * regress_test_cairo_context_full_return:
290  *
291  * Returns: (transfer full):
292  */
293 cairo_t *
294 regress_test_cairo_context_full_return (void)
295 {
296   cairo_surface_t *surface;
297   cairo_t *cr;
298   surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 10, 10);
299   cr = cairo_create (surface);
300   cairo_surface_destroy (surface);
301   return cr;
302 }
303
304 /**
305  * regress_test_cairo_context_none_in:
306  * @context: (transfer none):
307  */
308 void
309 regress_test_cairo_context_none_in (cairo_t *context)
310 {
311   cairo_surface_t *surface = cairo_get_target (context);
312
313   g_assert (cairo_image_surface_get_format (surface) == CAIRO_FORMAT_ARGB32);
314   g_assert (cairo_image_surface_get_width (surface) == 10);
315   g_assert (cairo_image_surface_get_height (surface) == 10);
316 }
317
318
319 /**
320  * regress_test_cairo_surface_none_return:
321  *
322  * Returns: (transfer none):
323  */
324 cairo_surface_t *
325 regress_test_cairo_surface_none_return (void)
326 {
327   static cairo_surface_t *surface;
328
329   if (surface == NULL) {
330     surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 10, 10);
331   }
332
333   return surface;
334 }
335
336 /**
337  * regress_test_cairo_surface_full_return:
338  *
339  * Returns: (transfer full):
340  */
341 cairo_surface_t *
342 regress_test_cairo_surface_full_return (void)
343 {
344   return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 10, 10);
345 }
346
347 /**
348  * regress_test_cairo_surface_none_in:
349  * @surface: (transfer none):
350  */
351 void
352 regress_test_cairo_surface_none_in (cairo_surface_t *surface)
353 {
354   g_assert (cairo_image_surface_get_format (surface) == CAIRO_FORMAT_ARGB32);
355   g_assert (cairo_image_surface_get_width (surface) == 10);
356   g_assert (cairo_image_surface_get_height (surface) == 10);
357 }
358
359 /**
360  * regress_test_cairo_surface_full_out:
361  * @surface: (out) (transfer full):
362  */
363 void
364 regress_test_cairo_surface_full_out (cairo_surface_t **surface)
365 {
366   *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 10, 10);
367 }
368
369 /**
370  * regress_test_gvariant_i:
371  *
372  * Returns: (transfer none): New variant
373  */
374 GVariant *
375 regress_test_gvariant_i (void)
376 {
377   return g_variant_new_int32 (1);
378 }
379
380 /**
381  * regress_test_gvariant_s:
382  *
383  * Returns: (transfer none): New variant
384  */
385 GVariant *
386 regress_test_gvariant_s (void)
387 {
388   return g_variant_new_string ("one");
389 }
390
391 /**
392  * regress_test_gvariant_asv:
393  *
394  * Returns: (transfer none): New variant
395  */
396 GVariant *
397 regress_test_gvariant_asv (void)
398 {
399   GVariantBuilder b;
400
401   g_variant_builder_init (&b, G_VARIANT_TYPE ("a{sv}"));
402
403   g_variant_builder_add (&b, "{sv}", "name", g_variant_new_string ("foo"));
404   g_variant_builder_add (&b, "{sv}", "timeout", g_variant_new_int32 (10));
405
406   return g_variant_builder_end (&b);
407 }
408
409 /**
410  * regress_test_gvariant_v:
411  *
412  * Returns: (transfer none): New variant
413  */
414 GVariant *
415 regress_test_gvariant_v (void)
416 {
417   return g_variant_new_variant (g_variant_new_string ("contents"));
418 }
419
420 /**
421  * regress_test_gvariant_as:
422  *
423  * Returns: (transfer none): New variant
424  */
425 GVariant *
426 regress_test_gvariant_as (void)
427 {
428   const char *as[] = { "one", "two", "three", NULL };
429
430   return g_variant_new_strv (as, -1);
431 }
432
433 /************************************************************************/
434 /* utf8 */
435 /* insert BLACK HEART SUIT to ensure UTF-8 doesn't get mangled */
436 static const char utf8_const[]    = "const \xe2\x99\xa5 utf8";
437 static const char utf8_nonconst[] = "nonconst \xe2\x99\xa5 utf8";
438
439 /**
440  * regress_test_utf8_const_return:
441  *
442  * Return value: UTF-8 string
443  */
444 const char *
445 regress_test_utf8_const_return (void)
446 {
447   /* transfer mode none */
448   return utf8_const;
449 }
450
451 /**
452  * regress_test_utf8_nonconst_return:
453  *
454  * Return value: (transfer full): UTF-8 string
455  */
456 char *
457 regress_test_utf8_nonconst_return (void)
458 {
459   return g_strdup (utf8_nonconst);
460 }
461
462 /**
463  * regress_test_utf8_const_in:
464  *
465  */
466 void
467 regress_test_utf8_const_in (const char *in)
468 {
469   /* transfer mode none */
470   g_assert (strcmp (in, utf8_const) == 0);
471 }
472
473 /**
474  * regress_test_utf8_out:
475  * @out: (out) (transfer full):
476  */
477 void
478 regress_test_utf8_out (char **out)
479 {
480   /* out parameter, transfer mode full */
481   *out = g_strdup (utf8_nonconst);
482 }
483
484 /**
485  * regress_test_utf8_inout:
486  * @inout: (inout) (transfer full):
487  */
488 void
489 regress_test_utf8_inout (char **inout)
490 {
491   /* inout parameter, transfer mode full */
492   g_assert (strcmp (*inout, utf8_const) == 0);
493   *inout = g_strdup (utf8_nonconst);
494 }
495
496 /**
497  * regress_test_filename_return:
498  *
499  * Return value: (element-type filename) (transfer full): list of strings
500  */
501 GSList *
502 regress_test_filename_return (void)
503 {
504   GSList *filenames = NULL;
505   filenames = g_slist_prepend (filenames, g_filename_from_utf8("/etc/fstab", -1, NULL, NULL, NULL));
506   filenames = g_slist_prepend (filenames, g_filename_from_utf8("åäö", -1, NULL, NULL, NULL));
507   return filenames;
508 }
509
510 /* in arguments after out arguments */
511
512 /**
513  * regress_test_int_out_utf8:
514  * @length: (out):
515  * @in:
516  */
517 void
518 regress_test_int_out_utf8 (int *length, const char *in)
519 {
520     *length = g_utf8_strlen(in, -1);
521 }
522
523
524 /* multiple output arguments */
525
526 /**
527  * regress_test_multi_double_args:
528  * @in:
529  * @one: (out):
530  * @two: (out):
531  */
532 void
533 regress_test_multi_double_args (gdouble in, gdouble *one, gdouble *two)
534 {
535   *one = in * 2;
536   *two = in * 3;
537 }
538
539 /**
540  * regress_test_utf8_out_out:
541  * @out0: (out) (transfer full): a copy of "first"
542  * @out1: (out) (transfer full): a copy of "second"
543  */
544 void
545 regress_test_utf8_out_out (char **out0, char **out1)
546 {
547   *out0 = g_strdup ("first");
548   *out1 = g_strdup ("second");
549 }
550
551 /**
552  * regress_test_utf8_out_nonconst_return:
553  * @out: (out) (transfer full): a copy of "second"
554  *
555  * Returns: (transfer full): a copy of "first"
556  */
557 char *
558 regress_test_utf8_out_nonconst_return (char **out)
559 {
560   *out = g_strdup ("second");
561   return g_strdup ("first");
562 }
563
564 /**
565  * regress_test_utf8_null_in:
566  * @in: (allow-none):
567  */
568 void
569 regress_test_utf8_null_in (char *in)
570 {
571   g_assert (in == NULL);
572 }
573
574 /**
575  * regress_test_utf8_null_out:
576  * @char_out: (allow-none) (out):
577  */
578 void regress_test_utf8_null_out (char **char_out)
579 {
580   *char_out = NULL;
581 }
582
583
584 /* non-basic-types */
585
586 static const char *test_sequence[] = {"1", "2", "3"};
587
588 /* array */
589
590 /**
591  * regress_test_array_int_in:
592  * @n_ints:
593  * @ints: (array length=n_ints): List of ints
594  */
595 int
596 regress_test_array_int_in (int n_ints, int *ints)
597 {
598   int i, sum = 0;
599   for (i = 0; i < n_ints; i++)
600     sum += ints[i];
601   return sum;
602 }
603
604 /**
605  * regress_test_array_int_out:
606  * @n_ints: (out): the length of @ints
607  * @ints: (out) (array length=n_ints) (transfer full): a list of 5 integers, from 0 to 4 in consecutive order
608  */
609 void
610 regress_test_array_int_out (int *n_ints, int **ints)
611 {
612   int i;
613   *n_ints = 5;
614   *ints = g_malloc0(sizeof(**ints) * *n_ints);
615   for (i = 1; i < *n_ints; i++)
616     (*ints)[i] = (*ints)[i-1] + 1;
617 }
618
619 /**
620  * regress_test_array_int_inout:
621  * @n_ints: (inout): the length of @ints
622  * @ints: (inout) (array length=n_ints) (transfer full): a list of integers whose items will be increased by 1, except the first that will be dropped
623  */
624 void
625 regress_test_array_int_inout (int *n_ints, int **ints)
626 {
627   int i;
628   int *new_ints;
629
630   if (0 < *n_ints)
631     {
632       *n_ints -= 1;
633       new_ints = g_malloc(sizeof(**ints) * *n_ints);
634       for (i = 0; i < *n_ints; i++)
635         new_ints[i] = (*ints)[i + 1] + 1;
636       *ints = new_ints;
637     }
638 }
639
640 /**
641  * regress_test_array_gint8_in:
642  * @n_ints:
643  * @ints: (array length=n_ints): List of ints
644  */
645 int
646 regress_test_array_gint8_in (int n_ints, gint8 *ints)
647 {
648   int i, sum = 0;
649   for (i = 0; i < n_ints; i++)
650     sum += ints[i];
651   return sum;
652 }
653
654 /**
655  * regress_test_array_gint16_in:
656  * @n_ints:
657  * @ints: (array length=n_ints): List of ints
658  */
659 int
660 regress_test_array_gint16_in (int n_ints, gint16 *ints)
661 {
662   int i, sum = 0;
663   for (i = 0; i < n_ints; i++)
664     sum += ints[i];
665   return sum;
666 }
667
668 /**
669  * regress_test_array_gint32_in:
670  * @n_ints:
671  * @ints: (array length=n_ints): List of ints
672  */
673 gint32
674 regress_test_array_gint32_in (int n_ints, gint32 *ints)
675 {
676   int i;
677   gint32 sum = 0;
678   for (i = 0; i < n_ints; i++)
679     sum += ints[i];
680   return sum;
681 }
682
683 /**
684  * regress_test_array_gint64_in:
685  * @n_ints:
686  * @ints: (array length=n_ints): List of ints
687  */
688 gint64
689 regress_test_array_gint64_in (int n_ints, gint64 *ints)
690 {
691   int i;
692   gint64 sum = 0;
693   for (i = 0; i < n_ints; i++)
694     sum += ints[i];
695   return sum;
696 }
697
698 /**
699  * regress_test_strv_in:
700  * @arr: (array zero-terminated=1) (transfer none):
701  */
702 gboolean
703 regress_test_strv_in (char **arr)
704 {
705   if (g_strv_length (arr) != 3)
706     return FALSE;
707   if (strcmp (arr[0], "1") != 0)
708     return FALSE;
709   if (strcmp (arr[1], "2") != 0)
710     return FALSE;
711   if (strcmp (arr[2], "3") != 0)
712     return FALSE;
713   return TRUE;
714 }
715
716 /**
717  * regress_test_array_gtype_in:
718  * @n_types:
719  * @types: (array length=n_types): List of types
720  *
721  * Return value: (transfer full): string representation of provided types
722  */
723 char *
724 regress_test_array_gtype_in (int n_types, GType *types)
725 {
726   GString *string;
727   int i;
728
729   string = g_string_new ("[");
730   for (i = 0; i < n_types; i++)
731     {
732       g_string_append (string, g_type_name (types[i]));
733       g_string_append_c (string, ',');
734     }
735   g_string_append_c (string, ']');
736   return g_string_free (string, FALSE);
737 }
738
739 /**
740  * regress_test_strv_out:
741  *
742  * Returns: (transfer full):
743  */
744 char **
745 regress_test_strv_out (void)
746 {
747   int i = 0;
748   int n = 6;
749   char **ret = g_new (char *, n);
750   ret[i++] = g_strdup ("thanks");
751   ret[i++] = g_strdup ("for");
752   ret[i++] = g_strdup ("all");
753   ret[i++] = g_strdup ("the");
754   ret[i++] = g_strdup ("fish");
755   ret[i++] = NULL;
756   g_assert (i == n);
757   return ret;
758 }
759
760 /**
761  * regress_test_strv_out_container:
762  *
763  * Return value: (array zero-terminated=1) (transfer container):
764  */
765 char **
766 regress_test_strv_out_container (void)
767 {
768   char **ret = g_new (char *, 4);
769   ret[0] = "1";
770   ret[1] = "2";
771   ret[2] = "3";
772   ret[3] = NULL;
773   return ret;
774 }
775
776 /**
777  * regress_test_strv_outarg:
778  * @retp: (array zero-terminated=1) (out) (transfer container):
779  */
780 void
781 regress_test_strv_outarg (char ***retp)
782 {
783   char **ret = g_new (char *, 4);
784   ret[0] = "1";
785   ret[1] = "2";
786   ret[2] = "3";
787   ret[3] = NULL;
788   *retp = ret;
789 }
790
791 /**
792  * regress_test_array_fixed_size_int_in:
793  * @ints: (array fixed-size=5): a list of 5 integers
794  *
795  * Returns: the sum of the items in @ints
796  */
797 int
798 regress_test_array_fixed_size_int_in (int *ints)
799 {
800   int i, sum = 0;
801   for (i = 0; i < 5; i++)
802     sum += ints[i];
803   return sum;
804 }
805
806 /**
807  * regress_test_array_fixed_size_int_out:
808  * @ints: (out) (array fixed-size=5) (transfer full): a list of 5 integers ranging from 0 to 4
809  */
810 void
811 regress_test_array_fixed_size_int_out (int **ints)
812 {
813   int i;
814   *ints = g_malloc0(sizeof(**ints) * 5);
815   for (i = 1; i < 5; i++)
816     (*ints)[i] = (*ints)[i-1] + 1;
817 }
818
819 /**
820  * regress_test_array_fixed_size_int_return:
821  *
822  * Returns: (array fixed-size=5) (transfer full): a list of 5 integers ranging from 0 to 4
823  */
824 int *
825 regress_test_array_fixed_size_int_return (void)
826 {
827   int i, *ints;
828   ints = g_malloc0(sizeof(*ints) * 5);
829   for (i = 1; i < 5; i++)
830     ints[i] = ints[i-1] + 1;
831   return ints;
832 }
833
834 /**
835  * regress_test_strv_out_c:
836  *
837  * Returns: (transfer none):
838  */
839 const char * const*
840 regress_test_strv_out_c (void)
841 {
842   static char **ret = NULL;
843
844   if (ret == NULL)
845     ret = regress_test_strv_out ();
846
847   return (const char * const *) ret;
848 }
849
850 /**
851  * regress_test_array_int_full_out:
852  * @len: length of the returned array.
853  *
854  * Returns: (array length=len) (transfer full): a new array of integers.
855  */
856 int *
857 regress_test_array_int_full_out(int *len)
858 {
859   int *result, i;
860   *len = 5;
861   result = g_malloc0(sizeof(*result) * (*len));
862   for (i=1; i < (*len); i++)
863     result[i] = result[i-1] + 1;
864   return result;
865 }
866
867 /**
868  * regress_test_array_int_none_out:
869  * @len: length of the returned array.
870  *
871  * Returns: (array length=len) (transfer none): a static array of integers.
872  */
873 int *
874 regress_test_array_int_none_out(int *len)
875 {
876   static int result[5] = { 1, 2, 3, 4, 5 };
877   *len = 5;
878   return result;
879 }
880
881 /**
882  * regress_test_array_int_null_in:
883  * @arr: (array length=len) (allow-none):
884  * @len: length
885  */
886 void
887 regress_test_array_int_null_in (int *arr, int len)
888 {
889   g_assert (arr == NULL);
890 }
891
892 /**
893  * regress_test_array_int_null_out:
894  * @arr: (out) (array length=len) (allow-none):
895  * @len: (out) : length
896  */
897 void
898 regress_test_array_int_null_out (int **arr, int *len)
899 {
900   *arr = NULL;
901   *len = 0;
902 }
903
904 /* interface */
905
906 /************************************************************************/
907 /* GList */
908
909 static /*const*/ GList *
910 regress_test_sequence_list()
911 {
912     static GList *list = NULL;
913     if (!list) {
914         gsize i;
915         for (i = 0; i < G_N_ELEMENTS(test_sequence); ++i) {
916             list = g_list_prepend (list, (gpointer)test_sequence[i]);
917         }
918         list = g_list_reverse (list);
919     }
920     return list;
921 }
922
923 /**
924  * regress_test_glist_nothing_return:
925  *
926  * Return value: (element-type utf8) (transfer none):
927  */
928 const GList *
929 regress_test_glist_nothing_return (void)
930 {
931   return regress_test_sequence_list ();
932 }
933
934 /**
935  * regress_test_glist_nothing_return2:
936  *
937  * Return value: (element-type utf8) (transfer none):
938  */
939 GList *
940 regress_test_glist_nothing_return2 (void)
941 {
942   return regress_test_sequence_list ();
943 }
944
945 /**
946  * regress_test_glist_container_return:
947  *
948  * Return value: (element-type utf8) (transfer container):
949  */
950 GList *
951 regress_test_glist_container_return (void)
952 {
953   return g_list_copy (regress_test_sequence_list ());
954 }
955
956 /**
957  * regress_test_glist_everything_return:
958  *
959  * Return value: (element-type utf8) (transfer full):
960  */
961 GList *
962 regress_test_glist_everything_return (void)
963 {
964   GList *list;
965   GList *l;
966
967   list = g_list_copy (regress_test_sequence_list ());
968   for (l = list; l != NULL; l = l->next)
969       l->data = g_strdup (l->data);
970   return list;
971 }
972
973 static void
974 regress_assert_test_sequence_list (const GList *in)
975 {
976   const GList *l;
977   gsize i;
978
979   for (i = 0, l = in; l != NULL; ++i, l = l->next) {
980       g_assert (i < G_N_ELEMENTS(test_sequence));
981       g_assert (strcmp (l->data, test_sequence[i]) == 0);
982   }
983   g_assert (i == G_N_ELEMENTS(test_sequence));
984 }
985
986 /**
987  * regress_test_glist_nothing_in:
988  * @in: (element-type utf8):
989  */
990 void
991 regress_test_glist_nothing_in (const GList *in)
992 {
993   regress_assert_test_sequence_list (in);
994 }
995
996 /**
997  * regress_test_glist_nothing_in2:
998  * @in: (element-type utf8):
999  */
1000 void
1001 regress_test_glist_nothing_in2 (GList *in)
1002 {
1003   regress_assert_test_sequence_list (in);
1004 }
1005
1006 /**
1007  * regress_test_glist_null_in:
1008  * @in: (element-type utf8) (allow-none):
1009  */
1010 void
1011 regress_test_glist_null_in (GSList *in)
1012 {
1013   g_assert (in == NULL);
1014 }
1015
1016 /**
1017  * regress_test_glist_null_out:
1018  * @out_list: (out) (element-type utf8) (allow-none):
1019  */
1020 void
1021 regress_test_glist_null_out (GSList **out_list)
1022 {
1023   *out_list = NULL;
1024 }
1025
1026
1027 /************************************************************************/
1028 /* GSList */
1029
1030 static /*const*/ GSList *
1031 regress_test_sequence_slist()
1032 {
1033     static GSList *list = NULL;
1034     if (!list) {
1035         gsize i;
1036         for (i = 0; i < G_N_ELEMENTS(test_sequence); ++i) {
1037             list = g_slist_prepend (list, (gpointer)test_sequence[i]);
1038         }
1039         list = g_slist_reverse (list);
1040     }
1041     return list;
1042 }
1043
1044 /**
1045  * regress_test_gslist_nothing_return:
1046  *
1047  * Return value: (element-type utf8) (transfer none):
1048  */
1049 const GSList *
1050 regress_test_gslist_nothing_return (void)
1051 {
1052   return regress_test_sequence_slist ();
1053 }
1054
1055 /**
1056  * regress_test_gslist_nothing_return2:
1057  *
1058  * Return value: (element-type utf8) (transfer none):
1059  */
1060 GSList *
1061 regress_test_gslist_nothing_return2 (void)
1062 {
1063   return regress_test_sequence_slist ();
1064 }
1065
1066 /**
1067  * regress_test_gslist_container_return:
1068  *
1069  * Return value: (element-type utf8) (transfer container):
1070  */
1071 GSList *
1072 regress_test_gslist_container_return (void)
1073 {
1074   return g_slist_copy (regress_test_sequence_slist ());
1075 }
1076
1077 /**
1078  * regress_test_gslist_everything_return:
1079  *
1080  * Return value: (element-type utf8) (transfer full):
1081  */
1082 GSList *
1083 regress_test_gslist_everything_return (void)
1084 {
1085   GSList *list;
1086   GSList *l;
1087
1088   list = g_slist_copy (regress_test_sequence_slist ());
1089   for (l = list; l != NULL; l = l->next)
1090       l->data = g_strdup (l->data);
1091   return list;
1092 }
1093
1094 static void
1095 regress_assert_test_sequence_slist (const GSList *in)
1096 {
1097   const GSList *l;
1098   gsize i;
1099
1100   for (i = 0, l = in; l != NULL; ++i, l = l->next) {
1101       g_assert (i < G_N_ELEMENTS(test_sequence));
1102       g_assert (strcmp (l->data, test_sequence[i]) == 0);
1103   }
1104   g_assert (i == G_N_ELEMENTS(test_sequence));
1105 }
1106
1107 /**
1108  * regress_test_gslist_nothing_in:
1109  * @in: (element-type utf8):
1110  */
1111 void
1112 regress_test_gslist_nothing_in (const GSList *in)
1113 {
1114   regress_assert_test_sequence_slist (in);
1115 }
1116
1117 /**
1118  * regress_test_gslist_nothing_in2:
1119  * @in: (element-type utf8):
1120  */
1121 void
1122 regress_test_gslist_nothing_in2 (GSList *in)
1123 {
1124   regress_assert_test_sequence_slist (in);
1125 }
1126
1127 /**
1128  * regress_test_gslist_null_in:
1129  * @in: (element-type utf8) (allow-none):
1130  */
1131 void
1132 regress_test_gslist_null_in (GSList *in)
1133 {
1134   g_assert (in == NULL);
1135 }
1136
1137 /**
1138  * regress_test_gslist_null_out:
1139  * @out_list: (out) (element-type utf8) (allow-none):
1140  */
1141 void
1142 regress_test_gslist_null_out (GSList **out_list)
1143 {
1144   *out_list = NULL;
1145 }
1146
1147 /************************************************************************/
1148 /* GHash */
1149
1150 static char *table_data[3][2] = {
1151   { "foo", "bar" }, { "baz", "bat" }, { "qux", "quux" }
1152 };
1153
1154 static GHashTable *
1155 regress_test_table_ghash_new_container()
1156 {
1157   GHashTable *hash;
1158   int i;
1159   hash = g_hash_table_new(g_str_hash, g_str_equal);
1160   for (i=0; i<3; i++)
1161     g_hash_table_insert(hash, table_data[i][0], table_data[i][1]);
1162   return hash;
1163 }
1164
1165 static GHashTable *
1166 regress_test_table_ghash_new_full()
1167 {
1168   GHashTable *hash;
1169   int i;
1170   hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
1171   for (i=0; i<3; i++)
1172     g_hash_table_insert(hash,
1173                         g_strdup(table_data[i][0]),
1174                         g_strdup(table_data[i][1]));
1175   return hash;
1176 }
1177
1178 static /*const*/ GHashTable *
1179 regress_test_table_ghash_const()
1180 {
1181   static GHashTable *hash = NULL;
1182   if (!hash) {
1183     hash = regress_test_table_ghash_new_container();
1184   }
1185   return hash;
1186 }
1187
1188 /**
1189  * regress_test_ghash_null_return:
1190  *
1191  * Return value: (element-type utf8 utf8) (transfer none) (allow-none):
1192  */
1193 const GHashTable *
1194 regress_test_ghash_null_return (void)
1195 {
1196   return NULL;
1197 }
1198
1199 /**
1200  * regress_test_ghash_nothing_return:
1201  *
1202  * Return value: (element-type utf8 utf8) (transfer none):
1203  */
1204 const GHashTable *
1205 regress_test_ghash_nothing_return (void)
1206 {
1207   return regress_test_table_ghash_const ();
1208 }
1209
1210 /**
1211  * regress_test_ghash_nothing_return2:
1212  *
1213  * Return value: (element-type utf8 utf8) (transfer none):
1214  */
1215 GHashTable *
1216 regress_test_ghash_nothing_return2 (void)
1217 {
1218   return regress_test_table_ghash_const ();
1219 }
1220
1221 static GValue *
1222 g_value_new (GType type)
1223 {
1224   GValue *value = g_slice_new0(GValue);
1225   g_value_init(value, type);
1226   return value;
1227 }
1228
1229 static void
1230 g_value_free (GValue *value)
1231 {
1232   g_value_unset(value);
1233   g_slice_free(GValue, value);
1234 }
1235
1236 static const gchar *string_array[] = {
1237   "first",
1238   "second",
1239   "third",
1240   NULL
1241 };
1242
1243 /**
1244  * regress_test_ghash_gvalue_return:
1245  *
1246  * Return value: (element-type utf8 GValue) (transfer none):
1247  */
1248 GHashTable *
1249 regress_test_ghash_gvalue_return (void)
1250 {
1251   GHashTable *hash;
1252   GValue *value;
1253   hash = g_hash_table_new_full(g_str_hash, g_str_equal,
1254                                g_free, (GDestroyNotify)g_value_free);
1255
1256   value = g_value_new(G_TYPE_INT);
1257   g_value_set_int(value, 12);
1258   g_hash_table_insert(hash, g_strdup("integer"), value);
1259
1260   value = g_value_new(G_TYPE_BOOLEAN);
1261   g_value_set_boolean(value, TRUE);
1262   g_hash_table_insert(hash, g_strdup("boolean"), value);
1263
1264   value = g_value_new(G_TYPE_STRING);
1265   g_value_set_string(value, "some text");
1266   g_hash_table_insert(hash, g_strdup("string"), value);
1267
1268   value = g_value_new(G_TYPE_STRV);
1269   g_value_set_boxed(value, string_array);
1270   g_hash_table_insert(hash, g_strdup("strings"), value);
1271
1272   value = g_value_new(REGRESS_TEST_TYPE_FLAGS);
1273   g_value_set_flags(value, REGRESS_TEST_FLAG1 | REGRESS_TEST_FLAG3);
1274   g_hash_table_insert(hash, g_strdup("flags"), value);
1275
1276   value = g_value_new(regress_test_enum_get_type());
1277   g_value_set_enum(value, REGRESS_TEST_VALUE2);
1278   g_hash_table_insert(hash, g_strdup("enum"), value);
1279
1280   return hash;
1281 }
1282
1283 /**
1284  * regress_test_ghash_gvalue_in:
1285  * @hash: (element-type utf8 GValue): the hash table returned by
1286  * regress_test_ghash_gvalue_return().
1287  */
1288 void
1289 regress_test_ghash_gvalue_in (GHashTable *hash)
1290 {
1291   GValue *value;
1292   const gchar **strings;
1293   int i;
1294
1295   g_assert(hash != NULL);
1296
1297   value = g_hash_table_lookup(hash, "integer");
1298   g_assert(value != NULL);
1299   g_assert(G_VALUE_HOLDS_INT(value));
1300   g_assert(g_value_get_int(value) == 12);
1301
1302   value = g_hash_table_lookup(hash, "boolean");
1303   g_assert(value != NULL);
1304   g_assert(G_VALUE_HOLDS_BOOLEAN(value));
1305   g_assert(g_value_get_boolean(value) == TRUE);
1306
1307   value = g_hash_table_lookup(hash, "string");
1308   g_assert(value != NULL);
1309   g_assert(G_VALUE_HOLDS_STRING(value));
1310   g_assert(strcmp(g_value_get_string(value), "some text") == 0);
1311
1312   value = g_hash_table_lookup(hash, "strings");
1313   g_assert(value != NULL);
1314   g_assert(G_VALUE_HOLDS(value, G_TYPE_STRV));
1315   strings = g_value_get_boxed(value);
1316   g_assert(strings != NULL);
1317   for (i = 0; string_array[i] != NULL; i++)
1318     g_assert(strcmp(strings[i], string_array[i]) == 0);
1319
1320   value = g_hash_table_lookup(hash, "flags");
1321   g_assert(value != NULL);
1322   g_assert(G_VALUE_HOLDS_FLAGS(value));
1323   g_assert(g_value_get_flags(value) == (REGRESS_TEST_FLAG1 | REGRESS_TEST_FLAG3));
1324
1325   value = g_hash_table_lookup(hash, "enum");
1326   g_assert(value != NULL);
1327   g_assert(G_VALUE_HOLDS_ENUM(value));
1328   g_assert(g_value_get_enum(value) == REGRESS_TEST_VALUE2);
1329 }
1330
1331 /**
1332  * regress_test_ghash_container_return:
1333  *
1334  * Return value: (element-type utf8 utf8) (transfer container):
1335  */
1336 GHashTable *
1337 regress_test_ghash_container_return (void)
1338 {
1339   return regress_test_table_ghash_new_container ();
1340 }
1341
1342 /**
1343  * regress_test_ghash_everything_return:
1344  *
1345  * Return value: (element-type utf8 utf8) (transfer full):
1346  */
1347 GHashTable *
1348 regress_test_ghash_everything_return (void)
1349 {
1350   return regress_test_table_ghash_new_full ();
1351 }
1352
1353 static void
1354 assert_test_table_ghash (const GHashTable *in)
1355 {
1356   GHashTable *h = regress_test_table_ghash_const();
1357   GHashTableIter iter;
1358   gpointer key, value;
1359
1360   g_assert(g_hash_table_size(h) ==
1361            g_hash_table_size((GHashTable*)in));
1362
1363   g_hash_table_iter_init(&iter, (GHashTable*)in);
1364   while (g_hash_table_iter_next (&iter, &key, &value))
1365     g_assert( strcmp(g_hash_table_lookup(h, (char*)key), (char*)value) == 0);
1366 }
1367
1368 /**
1369  * regress_test_ghash_null_in:
1370  * @in: (element-type utf8 utf8) (allow-none):
1371  */
1372 void
1373 regress_test_ghash_null_in (const GHashTable *in)
1374 {
1375   g_assert (in == NULL);
1376 }
1377
1378 /**
1379  * regress_test_ghash_null_out:
1380  * @out: (element-type utf8 utf8) (allow-none) (out):
1381  */
1382 void
1383 regress_test_ghash_null_out (const GHashTable **out)
1384 {
1385   *out = NULL;
1386 }
1387
1388 /**
1389  * regress_test_ghash_nothing_in:
1390  * @in: (element-type utf8 utf8):
1391  */
1392 void
1393 regress_test_ghash_nothing_in (const GHashTable *in)
1394 {
1395   assert_test_table_ghash (in);
1396 }
1397
1398 /**
1399  * regress_test_ghash_nothing_in2:
1400  * @in: (element-type utf8 utf8):
1401  */
1402 void
1403 regress_test_ghash_nothing_in2 (GHashTable *in)
1404 {
1405   assert_test_table_ghash (in);
1406 }
1407
1408 /* Nested collection types */
1409
1410 /**
1411  * regress_test_ghash_nested_everything_return:
1412  *
1413  * Specify nested parameterized types directly with the (type ) annotation.
1414  *
1415  * Return value: (type GLib.HashTable<utf8,GLib.HashTable<utf8,utf8>>) (transfer full):
1416  */
1417 GHashTable *
1418 regress_test_ghash_nested_everything_return (void)
1419 {
1420   GHashTable *hash;
1421   hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
1422                                (void (*) (gpointer)) g_hash_table_destroy);
1423   g_hash_table_insert(hash, g_strdup("wibble"), regress_test_table_ghash_new_full());
1424   return hash;
1425 }
1426
1427 /**
1428  * regress_test_ghash_nested_everything_return2:
1429  *
1430  * Another way of specifying nested parameterized types: using the
1431  * element-type annotation.
1432  *
1433  * Return value: (element-type utf8 GLib.HashTable<utf8,utf8>) (transfer full):
1434  */
1435 GHashTable *
1436 regress_test_ghash_nested_everything_return2 (void)
1437 {
1438   return regress_test_ghash_nested_everything_return();
1439 }
1440
1441 /************************************************************************/
1442
1443 /**
1444  * regress_test_garray_container_return:
1445  *
1446  * Returns: (transfer container) (type GLib.PtrArray) (element-type utf8):
1447  */
1448 GPtrArray *
1449 regress_test_garray_container_return (void)
1450 {
1451   GPtrArray *array;
1452
1453   array = g_ptr_array_new_with_free_func (g_free);
1454   g_ptr_array_add (array, g_strdup ("regress"));
1455
1456   return array;
1457 }
1458
1459 /**
1460  * regress_test_garray_full_return:
1461  *
1462  * Returns: (transfer full) (type GLib.PtrArray) (element-type utf8):
1463  */
1464 GPtrArray *
1465 regress_test_garray_full_return (void)
1466 {
1467   GPtrArray *array;
1468
1469   array = g_ptr_array_new ();
1470   g_ptr_array_add (array, g_strdup ("regress"));
1471
1472   return array;
1473 }
1474
1475 /************************************************************************/
1476
1477 /* error? */
1478
1479 /* enums / flags */
1480
1481 /**
1482  * NUM_REGRESS_FOO: (skip)
1483  *
1484  * num of elements in RegressFoo
1485  */
1486
1487 GType
1488 regress_test_enum_get_type (void)
1489 {
1490     static GType etype = 0;
1491     if (G_UNLIKELY(etype == 0)) {
1492         static const GEnumValue values[] = {
1493             { REGRESS_TEST_VALUE1, "REGRESS_TEST_VALUE1", "value1" },
1494             { REGRESS_TEST_VALUE2, "REGRESS_TEST_VALUE2", "value2" },
1495             { REGRESS_TEST_VALUE3, "REGRESS_TEST_VALUE3", "value3" },
1496             { REGRESS_TEST_VALUE4, "REGRESS_TEST_VALUE4", "value4" },
1497             { 0, NULL, NULL }
1498         };
1499         etype = g_enum_register_static (g_intern_static_string ("RegressTestEnum"), values);
1500     }
1501
1502     return etype;
1503 }
1504
1505 GType
1506 regress_test_enum_unsigned_get_type (void)
1507 {
1508     static GType etype = 0;
1509     if (G_UNLIKELY(etype == 0)) {
1510         static const GEnumValue values[] = {
1511             { REGRESS_TEST_UNSIGNED_VALUE1, "REGRESS_TEST_UNSIGNED_VALUE1", "value1" },
1512             { REGRESS_TEST_UNSIGNED_VALUE2, "REGRESS_TEST_UNSIGNED_VALUE2", "value2" },
1513             { 0, NULL, NULL }
1514         };
1515         etype = g_enum_register_static (g_intern_static_string ("RegressTestEnumUnsigned"), values);
1516     }
1517
1518     return etype;
1519 }
1520
1521 GType
1522 regress_test_flags_get_type (void)
1523 {
1524     static GType etype = 0;
1525     if (G_UNLIKELY(etype == 0)) {
1526         static const GFlagsValue values[] = {
1527             { REGRESS_TEST_FLAG1, "TEST_FLAG1", "flag1" },
1528             { REGRESS_TEST_FLAG2, "TEST_FLAG2", "flag2" },
1529             { REGRESS_TEST_FLAG3, "TEST_FLAG3", "flag3" },
1530             { 0, NULL, NULL }
1531         };
1532         etype = g_flags_register_static (g_intern_static_string ("RegressTestFlags"), values);
1533     }
1534
1535     return etype;
1536 }
1537
1538 const gchar *
1539 regress_test_enum_param(RegressTestEnum e)
1540 {
1541   GEnumValue *ev;
1542   GEnumClass *ec;
1543
1544   ec = g_type_class_ref (regress_test_enum_get_type ());
1545   ev = g_enum_get_value (ec, e);
1546   g_type_class_unref (ec);
1547
1548   return ev->value_nick;
1549 }
1550
1551 const gchar *
1552 regress_test_unsigned_enum_param(RegressTestEnumUnsigned e)
1553 {
1554   GEnumValue *ev;
1555   GEnumClass *ec;
1556
1557   ec = g_type_class_ref (regress_test_enum_unsigned_get_type ());
1558   ev = g_enum_get_value (ec, e);
1559   g_type_class_unref (ec);
1560
1561   return ev->value_nick;
1562 }
1563
1564 /**
1565  * regress_global_get_flags_out:
1566  * @v: (out): A flags value
1567  *
1568  */
1569 void
1570 regress_global_get_flags_out (RegressTestFlags *v)
1571 {
1572   *v = REGRESS_TEST_FLAG1 | REGRESS_TEST_FLAG3;
1573 }
1574
1575 /* error domains */
1576
1577 GType
1578 regress_test_error_get_type (void)
1579 {
1580     static GType etype = 0;
1581     if (G_UNLIKELY(etype == 0)) {
1582         static const GEnumValue values[] = {
1583             { REGRESS_TEST_ERROR_CODE1, "REGRESS_TEST_ERROR_CODE1", "code1" },
1584             { REGRESS_TEST_ERROR_CODE2, "REGRESS_TEST_ERROR_CODE2", "code2" },
1585             { REGRESS_TEST_ERROR_CODE3, "REGRESS_TEST_ERROR_CODE3", "code3" },
1586             { 0, NULL, NULL }
1587         };
1588         etype = g_enum_register_static (g_intern_static_string ("RegressTestError"), values);
1589     }
1590
1591     return etype;
1592 }
1593
1594 GQuark
1595 regress_test_error_quark (void)
1596 {
1597   return g_quark_from_static_string ("regress-test-error");
1598 }
1599
1600 GType
1601 regress_test_abc_error_get_type (void)
1602 {
1603     static GType etype = 0;
1604     if (G_UNLIKELY(etype == 0)) {
1605         static const GEnumValue values[] = {
1606             { REGRESS_TEST_ABC_ERROR_CODE1, "REGRESS_TEST_ABC_ERROR_CODE1", "code1" },
1607             { REGRESS_TEST_ABC_ERROR_CODE2, "REGRESS_TEST_ABC_ERROR_CODE2", "code2" },
1608             { REGRESS_TEST_ABC_ERROR_CODE3, "REGRESS_TEST_ABC_ERROR_CODE3", "code3" },
1609             { 0, NULL, NULL }
1610         };
1611         etype = g_enum_register_static (g_intern_static_string ("RegressTestABCError"), values);
1612     }
1613
1614     return etype;
1615 }
1616
1617 GQuark
1618 regress_test_abc_error_quark (void)
1619 {
1620   return g_quark_from_static_string ("regress-test-abc-error");
1621 }
1622
1623 GType
1624 regress_test_unconventional_error_get_type (void)
1625 {
1626     static GType etype = 0;
1627     if (G_UNLIKELY(etype == 0)) {
1628         static const GEnumValue values[] = {
1629             { REGRESS_TEST_OTHER_ERROR_CODE1, "REGRESS_TEST_OTHER_ERROR_CODE1", "code1" },
1630             { REGRESS_TEST_OTHER_ERROR_CODE2, "REGRESS_TEST_OTHER_ERROR_CODE2", "code2" },
1631             { REGRESS_TEST_OTHER_ERROR_CODE3, "REGRESS_TEST_OTHER_ERROR_CODE3", "code3" },
1632             { 0, NULL, NULL }
1633         };
1634         etype = g_enum_register_static (g_intern_static_string ("RegressTestOtherError"), values);
1635     }
1636
1637     return etype;
1638 }
1639
1640 GQuark
1641 regress_test_unconventional_error_quark (void)
1642 {
1643   return g_quark_from_static_string ("regress-test-other-error");
1644 }
1645
1646
1647 GQuark
1648 regress_test_def_error_quark (void)
1649 {
1650   return g_quark_from_static_string ("regress-test-def-error");
1651 }
1652
1653 GQuark
1654 regress_atest_error_quark (void)
1655 {
1656   return g_quark_from_static_string ("regress-atest-error");
1657 }
1658
1659 GQuark
1660 regress_unpaired_error_quark (void)
1661 {
1662   return g_quark_from_static_string ("regress-unpaired-error");
1663 }
1664
1665 gboolean
1666 regress_throw_unpaired (GError **error)
1667 {
1668   g_set_error_literal (error, regress_unpaired_error_quark (), 0,
1669                        "Unpaired error");
1670   return FALSE;
1671 }
1672
1673 /* structures */
1674
1675 /**
1676  * regress_test_struct_a_clone:
1677  * @a: the structure
1678  * @a_out: (out caller-allocates): the cloned structure
1679  *
1680  * Make a copy of a RegressTestStructA
1681  */
1682 void
1683 regress_test_struct_a_clone (RegressTestStructA *a,
1684                      RegressTestStructA *a_out)
1685 {
1686   *a_out = *a;
1687 }
1688
1689 /**
1690  * regress_test_struct_a_parse:
1691  * @a_out: (out caller-allocates): the structure that is to be filled
1692  * @string: ignored
1693  */
1694 void
1695 regress_test_struct_a_parse (RegressTestStructA *a_out,
1696                              const gchar *string)
1697 {
1698         a_out->some_int = 23;
1699 }
1700
1701 /**
1702  * regress_test_struct_b_clone:
1703  * @b: the structure
1704  * @b_out: (out): the cloned structure
1705  *
1706  * Make a copy of a RegressTestStructB
1707  */
1708 void
1709 regress_test_struct_b_clone (RegressTestStructB *b,
1710                      RegressTestStructB *b_out)
1711 {
1712   *b_out = *b;
1713 }
1714
1715 /* plain-old-data boxed types */
1716
1717 RegressTestSimpleBoxedA *
1718 regress_test_simple_boxed_a_copy (RegressTestSimpleBoxedA *a)
1719 {
1720   RegressTestSimpleBoxedA *new_a = g_slice_new (RegressTestSimpleBoxedA);
1721
1722   *new_a = *a;
1723
1724   return new_a;
1725 }
1726
1727 static void
1728 regress_test_simple_boxed_a_free (RegressTestSimpleBoxedA *a)
1729 {
1730   g_slice_free (RegressTestSimpleBoxedA, a);
1731 }
1732
1733 GType
1734 regress_test_simple_boxed_a_get_gtype (void)
1735 {
1736   static GType our_type = 0;
1737
1738   if (our_type == 0)
1739     our_type = g_boxed_type_register_static (g_intern_static_string ("RegressTestSimpleBoxedA"),
1740                                              (GBoxedCopyFunc)regress_test_simple_boxed_a_copy,
1741                                              (GBoxedFreeFunc)regress_test_simple_boxed_a_free);
1742   return our_type;
1743 }
1744
1745 RegressTestSimpleBoxedB *
1746 regress_test_simple_boxed_b_copy (RegressTestSimpleBoxedB *b)
1747 {
1748   RegressTestSimpleBoxedB *new_b = g_slice_new (RegressTestSimpleBoxedB);
1749
1750   *new_b = *b;
1751
1752   return new_b;
1753 }
1754
1755 gboolean
1756 regress_test_simple_boxed_a_equals (RegressTestSimpleBoxedA *a,
1757                             RegressTestSimpleBoxedA *other_a)
1758 {
1759   return (a->some_int == other_a->some_int &&
1760           a->some_int8 == other_a->some_int8 &&
1761           a->some_double == other_a->some_double);
1762 }
1763
1764 const RegressTestSimpleBoxedA*
1765 regress_test_simple_boxed_a_const_return (void)
1766 {
1767   static RegressTestSimpleBoxedA simple_a = {
1768     5, 6, 7.0
1769   };
1770
1771   return &simple_a;
1772 }
1773
1774 static void
1775 regress_test_simple_boxed_b_free (RegressTestSimpleBoxedB *a)
1776 {
1777   g_slice_free (RegressTestSimpleBoxedB, a);
1778 }
1779
1780 GType
1781 regress_test_simple_boxed_b_get_type (void)
1782 {
1783   static GType our_type = 0;
1784
1785   if (our_type == 0)
1786     our_type = g_boxed_type_register_static (g_intern_static_string ("RegressTestSimpleBoxedB"),
1787                                              (GBoxedCopyFunc)regress_test_simple_boxed_b_copy,
1788                                              (GBoxedFreeFunc)regress_test_simple_boxed_b_free);
1789   return our_type;
1790 }
1791
1792 /* opaque boxed */
1793
1794 struct _RegressTestBoxedPrivate
1795 {
1796   guint magic;
1797 };
1798
1799 /**
1800  * regress_test_boxed_new:
1801  *
1802  * Returns: (transfer full):
1803  */
1804 RegressTestBoxed *
1805 regress_test_boxed_new (void)
1806 {
1807   RegressTestBoxed *boxed = g_slice_new0(RegressTestBoxed);
1808   boxed->priv = g_slice_new0(RegressTestBoxedPrivate);
1809   boxed->priv->magic = 0xdeadbeef;
1810
1811   return boxed;
1812 }
1813
1814 /**
1815  * regress_test_boxed_new_alternative_constructor1:
1816  *
1817  * Returns: (transfer full):
1818  */
1819 RegressTestBoxed *
1820 regress_test_boxed_new_alternative_constructor1 (int i)
1821 {
1822   RegressTestBoxed *boxed = g_slice_new0(RegressTestBoxed);
1823   boxed->priv = g_slice_new0(RegressTestBoxedPrivate);
1824   boxed->priv->magic = 0xdeadbeef;
1825   boxed->some_int8 = i;
1826
1827   return boxed;
1828 }
1829
1830 /**
1831  * regress_test_boxed_new_alternative_constructor2:
1832  *
1833  * Returns: (transfer full):
1834  */
1835 RegressTestBoxed *
1836 regress_test_boxed_new_alternative_constructor2 (int i, int j)
1837 {
1838   RegressTestBoxed *boxed = g_slice_new0(RegressTestBoxed);
1839   boxed->priv = g_slice_new0(RegressTestBoxedPrivate);
1840   boxed->priv->magic = 0xdeadbeef;
1841   boxed->some_int8 = i + j;
1842
1843   return boxed;
1844 }
1845
1846 /**
1847  * regress_test_boxed_new_alternative_constructor3:
1848  *
1849  * Returns: (transfer full):
1850  */
1851 RegressTestBoxed *
1852 regress_test_boxed_new_alternative_constructor3 (char *s)
1853 {
1854   RegressTestBoxed *boxed = g_slice_new0(RegressTestBoxed);
1855   boxed->priv = g_slice_new0(RegressTestBoxedPrivate);
1856   boxed->priv->magic = 0xdeadbeef;
1857   boxed->some_int8 = atoi(s);
1858
1859   return boxed;
1860 }
1861
1862 /**
1863  * regress_test_boxed_copy:
1864  *
1865  * Returns: (transfer full):
1866  */
1867 RegressTestBoxed *
1868 regress_test_boxed_copy (RegressTestBoxed *boxed)
1869 {
1870   RegressTestBoxed *new_boxed = regress_test_boxed_new();
1871   RegressTestBoxedPrivate *save;
1872
1873   save = new_boxed->priv;
1874   *new_boxed = *boxed;
1875   new_boxed->priv = save;
1876
1877   return new_boxed;
1878 }
1879
1880 gboolean
1881 regress_test_boxed_equals (RegressTestBoxed *boxed,
1882                    RegressTestBoxed *other)
1883 {
1884   return (other->some_int8 == boxed->some_int8 &&
1885           regress_test_simple_boxed_a_equals(&other->nested_a, &boxed->nested_a));
1886 }
1887
1888 static void
1889 regress_test_boxed_free (RegressTestBoxed *boxed)
1890 {
1891   g_assert (boxed->priv->magic == 0xdeadbeef);
1892
1893   g_slice_free (RegressTestBoxedPrivate, boxed->priv);
1894   g_slice_free (RegressTestBoxed, boxed);
1895 }
1896
1897 GType
1898 regress_test_boxed_get_type (void)
1899 {
1900   static GType our_type = 0;
1901
1902   if (our_type == 0)
1903     our_type = g_boxed_type_register_static (g_intern_static_string ("RegressTestBoxed"),
1904                                              (GBoxedCopyFunc)regress_test_boxed_copy,
1905                                              (GBoxedFreeFunc)regress_test_boxed_free);
1906   return our_type;
1907 }
1908
1909 RegressTestBoxedB *
1910 regress_test_boxed_b_new (gint8 some_int8, glong some_long)
1911 {
1912   RegressTestBoxedB *boxed;
1913
1914   boxed = g_slice_new (RegressTestBoxedB);
1915   boxed->some_int8 = some_int8;
1916   boxed->some_long = some_long;
1917
1918   return boxed;
1919 }
1920
1921 RegressTestBoxedB *
1922 regress_test_boxed_b_copy (RegressTestBoxedB *boxed)
1923 {
1924   return regress_test_boxed_b_new (boxed->some_int8, boxed->some_long);
1925 }
1926
1927 static void
1928 regress_test_boxed_b_free (RegressTestBoxedB *boxed)
1929 {
1930   g_slice_free (RegressTestBoxedB, boxed);
1931 }
1932
1933 G_DEFINE_BOXED_TYPE(RegressTestBoxedB,
1934                     regress_test_boxed_b,
1935                     regress_test_boxed_b_copy,
1936                     regress_test_boxed_b_free);
1937
1938 RegressTestBoxedC *
1939 regress_test_boxed_c_new (void)
1940 {
1941   RegressTestBoxedC *boxed;
1942
1943   boxed = g_slice_new (RegressTestBoxedC);
1944   boxed->refcount = 1;
1945   boxed->another_thing = 42; /* what else */
1946
1947   return boxed;
1948 }
1949
1950 static RegressTestBoxedC *
1951 regress_test_boxed_c_ref (RegressTestBoxedC *boxed)
1952 {
1953   g_atomic_int_inc (&boxed->refcount);
1954   return boxed;
1955 }
1956
1957 static void
1958 regress_test_boxed_c_unref (RegressTestBoxedC *boxed)
1959 {
1960   if (g_atomic_int_dec_and_test (&boxed->refcount)) {
1961     g_slice_free (RegressTestBoxedC, boxed);
1962   }
1963 }
1964
1965 G_DEFINE_BOXED_TYPE(RegressTestBoxedC,
1966                     regress_test_boxed_c,
1967                     regress_test_boxed_c_ref,
1968                     regress_test_boxed_c_unref);
1969
1970 struct _RegressTestBoxedD {
1971   char *a_string;
1972   gint a_int;
1973 };
1974
1975 RegressTestBoxedD *
1976 regress_test_boxed_d_new (const char *a_string, int a_int)
1977 {
1978   RegressTestBoxedD *boxed;
1979
1980   boxed = g_slice_new (RegressTestBoxedD);
1981   boxed->a_string = g_strdup (a_string);
1982   boxed->a_int = a_int;
1983
1984   return boxed;
1985 }
1986
1987 RegressTestBoxedD *
1988 regress_test_boxed_d_copy (RegressTestBoxedD *boxed)
1989 {
1990   RegressTestBoxedD *ret;
1991
1992   ret = g_slice_new (RegressTestBoxedD);
1993   ret->a_string = g_strdup (boxed->a_string);
1994   ret->a_int = boxed->a_int;
1995
1996   return ret;
1997 }
1998
1999 void
2000 regress_test_boxed_d_free (RegressTestBoxedD *boxed)
2001 {
2002   g_free (boxed->a_string);
2003   g_slice_free (RegressTestBoxedD, boxed);
2004 }
2005
2006 int
2007 regress_test_boxed_d_get_magic (RegressTestBoxedD *boxed)
2008 {
2009   return strlen (boxed->a_string) + boxed->a_int;
2010 }
2011
2012 G_DEFINE_BOXED_TYPE(RegressTestBoxedD,
2013                     regress_test_boxed_d,
2014                     regress_test_boxed_d_copy,
2015                     regress_test_boxed_d_free);
2016
2017 G_DEFINE_TYPE(RegressTestObj, regress_test_obj, G_TYPE_OBJECT);
2018
2019 enum
2020 {
2021   PROP_TEST_OBJ_BARE = 1,
2022   PROP_TEST_OBJ_BOXED,
2023   PROP_TEST_OBJ_HASH_TABLE,
2024   PROP_TEST_OBJ_LIST,
2025   PROP_TEST_OBJ_HASH_TABLE_OLD,
2026   PROP_TEST_OBJ_LIST_OLD,
2027   PROP_TEST_OBJ_INT,
2028   PROP_TEST_OBJ_FLOAT,
2029   PROP_TEST_OBJ_DOUBLE,
2030   PROP_TEST_OBJ_STRING,
2031   PROP_TEST_OBJ_GTYPE
2032 };
2033
2034 static void
2035 regress_test_obj_set_property (GObject      *object,
2036                        guint         property_id,
2037                        const GValue *value,
2038                        GParamSpec   *pspec)
2039 {
2040   RegressTestObj *self = REGRESS_TEST_OBJECT (object);
2041   GList *list;
2042
2043   switch (property_id)
2044     {
2045     case PROP_TEST_OBJ_BARE:
2046       regress_test_obj_set_bare (self, g_value_get_object (value));
2047       break;
2048
2049     case PROP_TEST_OBJ_BOXED:
2050       if (self->boxed)
2051         regress_test_boxed_free (self->boxed);
2052       self->boxed = g_value_dup_boxed (value);
2053       break;
2054
2055     case PROP_TEST_OBJ_HASH_TABLE:
2056     case PROP_TEST_OBJ_HASH_TABLE_OLD:
2057       if (self->hash_table)
2058         g_hash_table_unref (self->hash_table);
2059       self->hash_table = g_hash_table_ref (g_value_get_boxed (value));
2060       break;
2061
2062     case PROP_TEST_OBJ_LIST:
2063     case PROP_TEST_OBJ_LIST_OLD:
2064       if (self->list != NULL)
2065         {
2066           for (list = self->list; list != NULL; list = g_list_next (list))
2067             g_free (list->data);
2068           g_list_free (self->list);
2069         }
2070       self->list = NULL;
2071       for (list = g_value_get_pointer (value); list != NULL; list = g_list_next (list))
2072         self->list = g_list_append (self->list, g_strdup (list->data));
2073       break;
2074
2075     case PROP_TEST_OBJ_INT:
2076       self->some_int8 = g_value_get_int (value);
2077       break;
2078
2079     case PROP_TEST_OBJ_FLOAT:
2080       self->some_float = g_value_get_float (value);
2081       break;
2082
2083     case PROP_TEST_OBJ_DOUBLE:
2084       self->some_double = g_value_get_double (value);
2085       break;
2086
2087     case PROP_TEST_OBJ_STRING:
2088       self->string = g_value_dup_string (value);
2089       break;
2090
2091     case PROP_TEST_OBJ_GTYPE:
2092       self->gtype = g_value_get_gtype (value);
2093       break;
2094
2095     default:
2096       /* We don't have any other property... */
2097       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
2098       break;
2099     }
2100 }
2101
2102 static void
2103 regress_test_obj_get_property (GObject    *object,
2104                         guint       property_id,
2105                         GValue     *value,
2106                         GParamSpec *pspec)
2107 {
2108   RegressTestObj *self = REGRESS_TEST_OBJECT (object);
2109
2110   switch (property_id)
2111     {
2112     case PROP_TEST_OBJ_BARE:
2113       g_value_set_object (value, self->bare);
2114       break;
2115
2116     case PROP_TEST_OBJ_BOXED:
2117       g_value_set_boxed (value, self->boxed);
2118       break;
2119
2120     case PROP_TEST_OBJ_HASH_TABLE:
2121     case PROP_TEST_OBJ_HASH_TABLE_OLD:
2122       if (self->hash_table != NULL)
2123         g_hash_table_ref (self->hash_table);
2124       g_value_set_boxed (value, self->hash_table);
2125       break;
2126
2127     case PROP_TEST_OBJ_LIST:
2128     case PROP_TEST_OBJ_LIST_OLD:
2129       g_value_set_pointer (value, self->list);
2130       break;
2131
2132     case PROP_TEST_OBJ_INT:
2133       g_value_set_int (value, self->some_int8);
2134       break;
2135
2136     case PROP_TEST_OBJ_FLOAT:
2137       g_value_set_float (value, self->some_float);
2138       break;
2139
2140     case PROP_TEST_OBJ_DOUBLE:
2141       g_value_set_double (value, self->some_double);
2142       break;
2143
2144     case PROP_TEST_OBJ_STRING:
2145       g_value_set_string (value, self->string);
2146       break;
2147
2148     case PROP_TEST_OBJ_GTYPE:
2149       g_value_set_gtype (value, self->gtype);
2150       break;
2151
2152     default:
2153       /* We don't have any other property... */
2154       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
2155       break;
2156     }
2157 }
2158
2159 static void
2160 regress_test_obj_dispose (GObject *gobject)
2161 {
2162   RegressTestObj *self = REGRESS_TEST_OBJECT (gobject);
2163
2164   if (self->bare)
2165     {
2166       g_object_unref (self->bare);
2167
2168       self->bare = NULL;
2169     }
2170
2171   if (self->boxed)
2172     {
2173       regress_test_boxed_free (self->boxed);
2174       self->boxed = NULL;
2175     }
2176
2177   /* Chain up to the parent class */
2178   G_OBJECT_CLASS (regress_test_obj_parent_class)->dispose (gobject);
2179 }
2180
2181 static int
2182 regress_test_obj_default_matrix (RegressTestObj *obj, const char *somestr)
2183 {
2184   return 42;
2185 }
2186
2187 enum {
2188   REGRESS_TEST_OBJ_SIGNAL_SIG_NEW_WITH_ARRAY_PROP,
2189   REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_HASH_PROP,
2190   REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_STRV,
2191   REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_OBJ,
2192   REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_FOREIGN_STRUCT,
2193   REGRESS_TEST_OBJ_SIGNAL_FIRST,
2194   REGRESS_TEST_OBJ_SIGNAL_CLEANUP,
2195   REGRESS_TEST_OBJ_SIGNAL_ALL,
2196   REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INT64_PROP,
2197   REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_UINT64_PROP,
2198   N_REGRESS_TEST_OBJ_SIGNALS
2199 };
2200
2201 static guint regress_test_obj_signals[N_REGRESS_TEST_OBJ_SIGNALS] = { 0 };
2202
2203 static void
2204 regress_test_obj_class_init (RegressTestObjClass *klass)
2205 {
2206   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
2207   GParamSpec *pspec;
2208   GType param_types[1];
2209
2210   klass->test_signal =
2211     g_signal_newv ("test",
2212                    G_TYPE_FROM_CLASS (gobject_class),
2213                    G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
2214                    NULL /* closure */,
2215                    NULL /* accumulator */,
2216                    NULL /* accumulator data */,
2217                    g_cclosure_marshal_VOID__VOID,
2218                    G_TYPE_NONE /* return_type */,
2219                    0     /* n_params */,
2220                    NULL  /* param_types */);
2221
2222   param_types[0] = regress_test_simple_boxed_a_get_gtype() | G_SIGNAL_TYPE_STATIC_SCOPE;
2223   klass->test_signal_with_static_scope_arg =
2224     g_signal_newv ("test-with-static-scope-arg",
2225                    G_TYPE_FROM_CLASS (gobject_class),
2226                    G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
2227                    NULL /* closure */,
2228                    NULL /* accumulator */,
2229                    NULL /* accumulator data */,
2230                    g_cclosure_marshal_VOID__BOXED,
2231                    G_TYPE_NONE /* return_type */,
2232                    1     /* n_params */,
2233                    param_types);
2234
2235   /**
2236    * RegressTestObj::sig-with-array-prop:
2237    * @self: an object
2238    * @arr: (type GArray) (element-type uint): numbers
2239    *
2240    * This test signal is like TelepathyGlib's
2241    *  TpChannel:: group-members-changed-detailed:
2242    */
2243   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_NEW_WITH_ARRAY_PROP] =
2244     g_signal_new ("sig-with-array-prop",
2245                   G_TYPE_FROM_CLASS (gobject_class),
2246                   G_SIGNAL_RUN_LAST,
2247                   0,
2248                   NULL,
2249                   NULL,
2250                   g_cclosure_marshal_VOID__BOXED,
2251                   G_TYPE_NONE,
2252                   1,
2253                   G_TYPE_ARRAY);
2254
2255   /**
2256    * RegressTestObj::sig-with-hash-prop:
2257    * @self: an object
2258    * @hash: (element-type utf8 GObject.Value):
2259    *
2260    * This test signal is like TelepathyGlib's
2261    *  TpAccount::status-changed
2262    */
2263   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_HASH_PROP] =
2264     g_signal_new ("sig-with-hash-prop",
2265                   G_TYPE_FROM_CLASS (gobject_class),
2266                   G_SIGNAL_RUN_LAST,
2267                   0,
2268                   NULL,
2269                   NULL,
2270                   g_cclosure_marshal_VOID__BOXED,
2271                   G_TYPE_NONE,
2272                   1,
2273                   G_TYPE_HASH_TABLE);
2274
2275   /**
2276    * RegressTestObj::sig-with-strv:
2277    * @self: an object
2278    * @strs: strings
2279    *
2280    * Test GStrv as a param.
2281    */
2282   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_STRV] =
2283     g_signal_new ("sig-with-strv",
2284                   G_TYPE_FROM_CLASS (gobject_class),
2285                   G_SIGNAL_RUN_LAST,
2286                   0,
2287                   NULL,
2288                   NULL,
2289                   g_cclosure_marshal_VOID__BOXED,
2290                   G_TYPE_NONE,
2291                   1,
2292                   G_TYPE_STRV);
2293
2294    /**
2295    * RegressTestObj::sig-with-obj:
2296    * @self: an object
2297    * @obj: (transfer none): A newly created RegressTestObj
2298    *
2299    * Test transfer none GObject as a param (tests refcounting).
2300    * Use with regress_test_obj_emit_sig_with_obj
2301    */
2302   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_OBJ] =
2303     g_signal_new ("sig-with-obj",
2304                   G_TYPE_FROM_CLASS (gobject_class),
2305                   G_SIGNAL_RUN_LAST,
2306                   0,
2307                   NULL,
2308                   NULL,
2309                   g_cclosure_marshal_VOID__OBJECT,
2310                   G_TYPE_NONE,
2311                   1,
2312                   G_TYPE_OBJECT);
2313
2314    /**
2315    * RegressTestObj::sig-with-foreign-struct:
2316    * @self: an object
2317    * @cr: (transfer none): A cairo context.
2318    */
2319   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_FOREIGN_STRUCT] =
2320     g_signal_new ("sig-with-foreign-struct",
2321                   G_TYPE_FROM_CLASS (gobject_class),
2322                   G_SIGNAL_RUN_LAST,
2323                   0,
2324                   NULL,
2325                   NULL,
2326                   NULL,
2327                   G_TYPE_NONE,
2328                   1,
2329                   CAIRO_GOBJECT_TYPE_CONTEXT);
2330
2331   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_FIRST] =
2332     g_signal_new ("first",
2333                   G_TYPE_FROM_CLASS (gobject_class),
2334                   G_SIGNAL_RUN_FIRST,
2335                   0,
2336                   NULL,
2337                   NULL,
2338                   g_cclosure_marshal_VOID__VOID,
2339                   G_TYPE_NONE,
2340                   0);
2341
2342     regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_CLEANUP] =
2343     g_signal_new ("cleanup",
2344                   G_TYPE_FROM_CLASS (gobject_class),
2345                   G_SIGNAL_RUN_CLEANUP,
2346                   0,
2347                   NULL,
2348                   NULL,
2349                   g_cclosure_marshal_VOID__VOID,
2350                   G_TYPE_NONE,
2351                   0);
2352
2353     regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_ALL] =
2354     g_signal_new ("all",
2355                   G_TYPE_FROM_CLASS (gobject_class),
2356                   G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_ACTION | G_SIGNAL_NO_HOOKS,
2357                   0,
2358                   NULL,
2359                   NULL,
2360                   g_cclosure_marshal_VOID__VOID,
2361                   G_TYPE_NONE,
2362                   0);
2363
2364   /**
2365    * RegressTestObj::sig-with-int64-prop:
2366    * @self: an object
2367    * @i: an integer
2368    *
2369    * You can use this with regress_test_obj_emit_sig_with_int64, or raise from
2370    * the introspection client langage.
2371    */
2372   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INT64_PROP] =
2373     g_signal_new ("sig-with-int64-prop",
2374                   G_TYPE_FROM_CLASS (gobject_class),
2375                   G_SIGNAL_RUN_LAST,
2376                   0,
2377                   NULL,
2378                   NULL,
2379                   g_cclosure_marshal_VOID__BOXED,
2380                   G_TYPE_INT64,
2381                   1,
2382                   G_TYPE_INT64);
2383
2384   /**
2385    * RegressTestObj::sig-with-uint64-prop:
2386    * @self: an object
2387    * @i: an integer
2388    *
2389    * You can use this with regress_test_obj_emit_sig_with_uint64, or raise from
2390    * the introspection client langage.
2391    */
2392   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_UINT64_PROP] =
2393     g_signal_new ("sig-with-uint64-prop",
2394                   G_TYPE_FROM_CLASS (gobject_class),
2395                   G_SIGNAL_RUN_LAST,
2396                   0,
2397                   NULL,
2398                   NULL,
2399                   g_cclosure_marshal_VOID__BOXED,
2400                   G_TYPE_UINT64,
2401                   1,
2402                   G_TYPE_UINT64);
2403
2404   gobject_class->set_property = regress_test_obj_set_property;
2405   gobject_class->get_property = regress_test_obj_get_property;
2406   gobject_class->dispose = regress_test_obj_dispose;
2407
2408   pspec = g_param_spec_object ("bare",
2409                                "Bare property",
2410                                "A contained object",
2411                                G_TYPE_OBJECT,
2412                                G_PARAM_READWRITE);
2413   g_object_class_install_property (gobject_class,
2414                                    PROP_TEST_OBJ_BARE,
2415                                    pspec);
2416
2417   pspec = g_param_spec_boxed ("boxed",
2418                               "Boxed property",
2419                               "A contained boxed struct",
2420                               REGRESS_TEST_TYPE_BOXED,
2421                               G_PARAM_READWRITE);
2422   g_object_class_install_property (gobject_class,
2423                                    PROP_TEST_OBJ_BOXED,
2424                                    pspec);
2425
2426   /**
2427    * RegressTestObj:hash-table:
2428    *
2429    * Type: GLib.HashTable(utf8,gint8)
2430    * Transfer: container
2431    */
2432   pspec = g_param_spec_boxed ("hash-table",
2433                               "GHashTable property",
2434                               "A contained GHashTable",
2435                               G_TYPE_HASH_TABLE,
2436                               G_PARAM_READWRITE);
2437   g_object_class_install_property (gobject_class,
2438                                    PROP_TEST_OBJ_HASH_TABLE,
2439                                    pspec);
2440
2441   /**
2442    * RegressTestObj:list:
2443    *
2444    * Type: GLib.List(utf8)
2445    * Transfer: none
2446    */
2447   pspec = g_param_spec_pointer ("list",
2448                                 "GList property",
2449                                 "A contained GList",
2450                                 G_PARAM_READWRITE);
2451   g_object_class_install_property (gobject_class,
2452                                    PROP_TEST_OBJ_LIST,
2453                                    pspec);
2454
2455   /**
2456    * RegressTestObj:hash-table-old:
2457    *
2458    * Type: GLib.HashTable<utf8,gint8>
2459    * Transfer: container
2460    */
2461   pspec = g_param_spec_boxed ("hash-table-old",
2462                               "GHashTable property with <>",
2463                               "A contained GHashTable with <>",
2464                               G_TYPE_HASH_TABLE,
2465                               G_PARAM_READWRITE);
2466   g_object_class_install_property (gobject_class,
2467                                    PROP_TEST_OBJ_HASH_TABLE_OLD,
2468                                    pspec);
2469
2470   /**
2471    * RegressTestObj:list-old:
2472    *
2473    * Type: GLib.List<utf8>
2474    * Transfer: none
2475    */
2476   pspec = g_param_spec_pointer ("list-old",
2477                                 "GList property with ()",
2478                                 "A contained GList with <>",
2479                                 G_PARAM_READWRITE);
2480   g_object_class_install_property (gobject_class,
2481                                    PROP_TEST_OBJ_LIST_OLD,
2482                                    pspec);
2483
2484
2485
2486   /**
2487    * TestObj:int:
2488    */
2489   pspec = g_param_spec_int ("int",
2490                             "int property",
2491                             "A contained int",
2492                             G_MININT,
2493                             G_MAXINT,
2494                             0,
2495                             G_PARAM_READWRITE);
2496   g_object_class_install_property (gobject_class,
2497                                    PROP_TEST_OBJ_INT,
2498                                    pspec);
2499
2500   /**
2501    * TestObj:float:
2502    */
2503   pspec = g_param_spec_float ("float",
2504                               "float property",
2505                               "A contained float",
2506                               G_MINFLOAT,
2507                               G_MAXFLOAT,
2508                               1.0f,
2509                               G_PARAM_READWRITE);
2510   g_object_class_install_property (gobject_class,
2511                                    PROP_TEST_OBJ_FLOAT,
2512                                    pspec);
2513
2514   /**
2515    * TestObj:double:
2516    */
2517   pspec = g_param_spec_double ("double",
2518                                "double property",
2519                                "A contained double",
2520                                G_MINDOUBLE,
2521                                G_MAXDOUBLE,
2522                                1.0f,
2523                                G_PARAM_READWRITE);
2524   g_object_class_install_property (gobject_class,
2525                                    PROP_TEST_OBJ_DOUBLE,
2526                                    pspec);
2527
2528   /**
2529    * TestObj:string:
2530    */
2531   pspec = g_param_spec_string ("string",
2532                                "string property",
2533                                "A contained string",
2534                                NULL,
2535                                G_PARAM_READWRITE);
2536   g_object_class_install_property (gobject_class,
2537                                    PROP_TEST_OBJ_STRING,
2538                                    pspec);
2539
2540
2541   /**
2542    * TestObj:gtype:
2543    */
2544   pspec = g_param_spec_gtype ("gtype",
2545                               "GType property",
2546                               "A GType property",
2547                               G_TYPE_NONE,
2548                               G_PARAM_READWRITE);
2549   g_object_class_install_property (gobject_class,
2550                                    PROP_TEST_OBJ_GTYPE,
2551                                    pspec);
2552
2553   klass->matrix = regress_test_obj_default_matrix;
2554 }
2555
2556 static void
2557 regress_test_obj_init (RegressTestObj *obj)
2558 {
2559   obj->bare = NULL;
2560   obj->boxed = NULL;
2561   obj->hash_table = NULL;
2562   obj->gtype = G_TYPE_INVALID;
2563 }
2564
2565 /**
2566  * regress_test_obj_new: (constructor)
2567  * @obj: A #RegressTestObj
2568  */
2569 RegressTestObj *
2570 regress_test_obj_new (RegressTestObj *obj)
2571 {
2572   return g_object_new (REGRESS_TEST_TYPE_OBJ, NULL);
2573 }
2574
2575 /**
2576  * regress_constructor: (constructor)
2577  *
2578  */
2579 RegressTestObj *
2580 regress_constructor (void)
2581 {
2582   return g_object_new (REGRESS_TEST_TYPE_OBJ, NULL);
2583 }
2584
2585 /**
2586  * regress_test_obj_new_from_file:
2587  */
2588 RegressTestObj *
2589 regress_test_obj_new_from_file (const char *x, GError **error)
2590 {
2591   return g_object_new (REGRESS_TEST_TYPE_OBJ, NULL);
2592 }
2593
2594 /**
2595  * regress_test_obj_set_bare:
2596  * @bare: (allow-none):
2597  */
2598 void
2599 regress_test_obj_set_bare (RegressTestObj *obj, GObject *bare)
2600 {
2601   if (obj->bare)
2602     g_object_unref (obj->bare);
2603   obj->bare = bare;
2604   if (obj->bare)
2605     g_object_ref (obj->bare);
2606 }
2607
2608 void
2609 regress_test_obj_emit_sig_with_obj (RegressTestObj *obj)
2610 {
2611     RegressTestObj *obj_param = regress_constructor ();
2612     g_object_set (obj_param, "int", 3, NULL);
2613     g_signal_emit_by_name (obj, "sig-with-obj", obj_param);
2614     g_object_unref (obj_param);
2615 }
2616
2617 void
2618 regress_test_obj_emit_sig_with_foreign_struct (RegressTestObj *obj)
2619 {
2620   cairo_t *cr = regress_test_cairo_context_full_return ();
2621   g_signal_emit_by_name (obj, "sig-with-foreign-struct", cr);
2622   cairo_destroy (cr);
2623 }
2624
2625 void
2626 regress_test_obj_emit_sig_with_int64 (RegressTestObj *obj)
2627 {
2628   gint64 ret = 0;
2629   RegressTestObj *obj_param = regress_constructor ();
2630   g_signal_emit_by_name (obj, "sig-with-int64-prop", G_MAXINT64, &ret);
2631   g_object_unref (obj_param);
2632   g_assert (ret == G_MAXINT64);
2633 }
2634
2635 void
2636 regress_test_obj_emit_sig_with_uint64 (RegressTestObj *obj)
2637 {
2638   guint64 ret = 0;
2639   RegressTestObj *obj_param = regress_constructor ();
2640   g_signal_emit_by_name (obj, "sig-with-uint64-prop", G_MAXUINT64, &ret);
2641   g_object_unref (obj_param);
2642   g_assert (ret == G_MAXUINT64);
2643 }
2644
2645 int
2646 regress_test_obj_instance_method (RegressTestObj *obj)
2647 {
2648     return -1;
2649 }
2650
2651 double
2652 regress_test_obj_static_method (int x)
2653 {
2654   return x;
2655 }
2656
2657 /**
2658  * regress_forced_method: (method)
2659  * @obj: A #RegressTestObj
2660  *
2661  */
2662 void
2663 regress_forced_method (RegressTestObj *obj)
2664 {
2665 }
2666
2667 /**
2668  * regress_test_obj_torture_signature_0:
2669  * @obj: A #RegressTestObj
2670  * @x:
2671  * @y: (out):
2672  * @z: (out):
2673  * @foo:
2674  * @q: (out):
2675  * @m:
2676  *
2677  */
2678 void
2679 regress_test_obj_torture_signature_0 (RegressTestObj    *obj,
2680                               int         x,
2681                               double     *y,
2682                               int        *z,
2683                               const char *foo,
2684                               int        *q,
2685                               guint       m)
2686 {
2687   *y = x;
2688   *z = x * 2;
2689   *q = g_utf8_strlen (foo, -1) + m;
2690 }
2691
2692 /**
2693  * regress_test_obj_torture_signature_1:
2694  * @obj: A #RegressTestObj
2695  * @x:
2696  * @y: (out):
2697  * @z: (out):
2698  * @foo:
2699  * @q: (out):
2700  * @m:
2701  * @error: A #GError
2702  *
2703  * This function throws an error if m is odd.
2704  */
2705 gboolean
2706 regress_test_obj_torture_signature_1 (RegressTestObj   *obj,
2707                               int        x,
2708                               double     *y,
2709                               int        *z,
2710                               const char *foo,
2711                               int        *q,
2712                               guint       m,
2713                               GError    **error)
2714 {
2715   *y = x;
2716   *z = x * 2;
2717   *q = g_utf8_strlen (foo, -1) + m;
2718   if (m % 2 == 0)
2719       return TRUE;
2720   g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "m is odd");
2721   return FALSE;
2722 }
2723
2724 /**
2725  * regress_test_obj_skip_return_val:
2726  * @obj: a #RegressTestObj
2727  * @a: Parameter.
2728  * @out_b: (out): A return value.
2729  * @c: Other parameter.
2730  * @inout_d: (inout): Will be incremented.
2731  * @out_sum: (out): Return value.
2732  * @num1: Number.
2733  * @num2: Number.
2734  * @error: Return location for error.
2735  *
2736  * Check that the return value is skipped
2737  *
2738  * Returns: (skip): %TRUE if the call succeeds, %FALSE if @error is set.
2739  */
2740 gboolean
2741 regress_test_obj_skip_return_val (RegressTestObj *obj,
2742                                   gint            a,
2743                                   gint           *out_b,
2744                                   gdouble         c,
2745                                   gint           *inout_d,
2746                                   gint           *out_sum,
2747                                   gint            num1,
2748                                   gint            num2,
2749                                   GError        **error)
2750 {
2751   if (out_b != NULL)
2752     *out_b = a + 1;
2753   if (inout_d != NULL)
2754     *inout_d = *inout_d + 1;
2755   if (out_sum != NULL)
2756     *out_sum = num1 + 10*num2;
2757   return TRUE;
2758 }
2759
2760 /**
2761  * regress_test_obj_skip_return_val_no_out:
2762  * @obj: a #RegressTestObj
2763  * @a: Parameter.
2764  * @error: Return location for error.
2765  *
2766  * Check that the return value is skipped. Succeed if a is nonzero, otherwise
2767  * raise an error.
2768  *
2769  * Returns: (skip): %TRUE if the call succeeds, %FALSE if @error is set.
2770  */
2771 gboolean
2772 regress_test_obj_skip_return_val_no_out (RegressTestObj *obj,
2773                                          gint            a,
2774                                          GError        **error)
2775 {
2776   if (a == 0) {
2777     g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "a is zero");
2778     return FALSE;
2779   } else {
2780     return TRUE;
2781   }
2782 }
2783
2784 /**
2785  * regress_test_obj_skip_param:
2786  * @obj: A #RegressTestObj.
2787  * @a: Parameter.
2788  * @out_b: (out): Return value.
2789  * @c: (skip): Other parameter.
2790  * @inout_d: (inout): Will be incremented.
2791  * @out_sum: (out): Return value.
2792  * @num1: Number.
2793  * @num2: Number.
2794  * @error: Return location for error.
2795  *
2796  * Check that a parameter is skipped
2797  *
2798  * Returns: %TRUE if the call succeeds, %FALSE if @error is set.
2799  */
2800 gboolean
2801 regress_test_obj_skip_param (RegressTestObj *obj,
2802                              gint            a,
2803                              gint           *out_b,
2804                              gdouble         c,
2805                              gint           *inout_d,
2806                              gint           *out_sum,
2807                              gint            num1,
2808                              gint            num2,
2809                              GError        **error)
2810 {
2811   if (out_b != NULL)
2812     *out_b = a + 1;
2813   if (inout_d != NULL)
2814     *inout_d = *inout_d + 1;
2815   if (out_sum != NULL)
2816     *out_sum = num1 + 10*num2;
2817   return TRUE;
2818 }
2819
2820 /**
2821  * regress_test_obj_skip_out_param:
2822  * @obj: A #RegressTestObj.
2823  * @a: Parameter.
2824  * @out_b: (out) (skip): Return value.
2825  * @c: Other parameter.
2826  * @inout_d: (inout): Will be incremented.
2827  * @out_sum: (out): Return value.
2828  * @num1: Number.
2829  * @num2: Number.
2830  * @error: Return location for error.
2831  *
2832  * Check that the out value is skipped
2833  *
2834  * Returns: %TRUE if the call succeeds, %FALSE if @error is set.
2835  */
2836 gboolean
2837 regress_test_obj_skip_out_param (RegressTestObj *obj,
2838                                  gint            a,
2839                                  gint           *out_b,
2840                                  gdouble         c,
2841                                  gint           *inout_d,
2842                                  gint           *out_sum,
2843                                  gint            num1,
2844                                  gint            num2,
2845                                  GError        **error)
2846 {
2847   if (out_b != NULL)
2848     *out_b = a + 1;
2849   if (inout_d != NULL)
2850     *inout_d = *inout_d + 1;
2851   if (out_sum != NULL)
2852     *out_sum = num1 + 10*num2;
2853   return TRUE;
2854 }
2855
2856 /**
2857  * regress_test_obj_skip_inout_param:
2858  * @obj: A #RegressTestObj.
2859  * @a: Parameter.
2860  * @out_b: (out): Return value.
2861  * @c: Other parameter.
2862  * @inout_d: (inout) (skip): Will be incremented.
2863  * @out_sum: (out): Return value.
2864  * @num1: Number.
2865  * @num2: Number.
2866  * @error: Return location for error.
2867  *
2868  * Check that the out value is skipped
2869  *
2870  * Returns: %TRUE if the call succeeds, %FALSE if @error is set.
2871  */
2872 gboolean
2873 regress_test_obj_skip_inout_param (RegressTestObj *obj,
2874                                    gint            a,
2875                                    gint           *out_b,
2876                                    gdouble         c,
2877                                    gint           *inout_d,
2878                                    gint           *out_sum,
2879                                    gint            num1,
2880                                    gint            num2,
2881                                    GError        **error)
2882 {
2883   if (out_b != NULL)
2884     *out_b = a + 1;
2885   if (inout_d != NULL)
2886     *inout_d = *inout_d + 1;
2887   if (out_sum != NULL)
2888     *out_sum = num1 + 10*num2;
2889   return TRUE;
2890 }
2891
2892 /**
2893  * regress_test_obj_do_matrix:
2894  * @obj: A #RegressTestObj
2895  * @somestr: Meaningless string
2896  *
2897  * This method is virtual.  Notably its name differs from the virtual
2898  * slot name, which makes it useful for testing bindings handle this
2899  * case.
2900  *
2901  * Virtual: matrix
2902  */
2903 int
2904 regress_test_obj_do_matrix (RegressTestObj *obj, const char *somestr)
2905 {
2906   return REGRESS_TEST_OBJ_GET_CLASS (obj)->matrix (obj, somestr);
2907 }
2908
2909 /**
2910  * regress_func_obj_null_in:
2911  * @obj: (allow-none): A #RegressTestObj
2912  */
2913 void
2914 regress_func_obj_null_in (RegressTestObj *obj)
2915 {
2916 }
2917
2918 /**
2919  * regress_test_obj_null_out:
2920  * @obj: (allow-none) (out): A #RegressTestObj
2921  */
2922 void
2923 regress_test_obj_null_out (RegressTestObj **obj)
2924 {
2925   if (obj)
2926     *obj = NULL;
2927 }
2928
2929 /**
2930  * regress_test_array_fixed_out_objects:
2931  * @objs: (out) (array fixed-size=2) (transfer full): An array of #RegressTestObj
2932  */
2933 void
2934 regress_test_array_fixed_out_objects (RegressTestObj ***objs)
2935 {
2936     RegressTestObj **values = (RegressTestObj**)g_new(gpointer, 2);
2937
2938     values[0] = regress_constructor();
2939     values[1] = regress_constructor();
2940
2941     *objs = values;
2942 }
2943
2944 typedef struct _CallbackInfo CallbackInfo;
2945
2946 struct _CallbackInfo
2947 {
2948   RegressTestCallbackUserData callback;
2949   GDestroyNotify notify;
2950   gpointer user_data;
2951 };
2952
2953
2954 G_DEFINE_TYPE(RegressTestSubObj, regress_test_sub_obj, REGRESS_TEST_TYPE_OBJ);
2955
2956 static void
2957 regress_test_sub_obj_class_init (RegressTestSubObjClass *klass)
2958 {
2959 }
2960
2961 static void
2962 regress_test_sub_obj_init (RegressTestSubObj *obj)
2963 {
2964 }
2965
2966 RegressTestObj*
2967 regress_test_sub_obj_new ()
2968 {
2969   return g_object_new (REGRESS_TEST_TYPE_SUB_OBJ, NULL);
2970 }
2971
2972 int
2973 regress_test_sub_obj_instance_method (RegressTestSubObj *obj)
2974 {
2975     return 0;
2976 }
2977
2978 void
2979 regress_test_sub_obj_unset_bare (RegressTestSubObj *obj)
2980 {
2981   regress_test_obj_set_bare(REGRESS_TEST_OBJECT(obj), NULL);
2982 }
2983
2984 /* RegressTestFundamental */
2985
2986 /**
2987  * regress_test_fundamental_object_ref:
2988  *
2989  * Returns: (transfer full): A new #RegressTestFundamentalObject
2990  */
2991 RegressTestFundamentalObject *
2992 regress_test_fundamental_object_ref (RegressTestFundamentalObject * fundamental_object)
2993 {
2994   g_return_val_if_fail (fundamental_object != NULL, NULL);
2995   g_atomic_int_inc (&fundamental_object->refcount);
2996
2997   return fundamental_object;
2998 }
2999
3000 static void
3001 regress_test_fundamental_object_free (RegressTestFundamentalObject * fundamental_object)
3002 {
3003   RegressTestFundamentalObjectClass *mo_class;
3004   regress_test_fundamental_object_ref (fundamental_object);
3005
3006   mo_class = REGRESS_TEST_FUNDAMENTAL_OBJECT_GET_CLASS (fundamental_object);
3007   mo_class->finalize (fundamental_object);
3008
3009   if (G_LIKELY (g_atomic_int_dec_and_test (&fundamental_object->refcount))) {
3010     g_type_free_instance ((GTypeInstance *) fundamental_object);
3011   }
3012 }
3013
3014 void
3015 regress_test_fundamental_object_unref (RegressTestFundamentalObject * fundamental_object)
3016 {
3017   g_return_if_fail (fundamental_object != NULL);
3018   g_return_if_fail (fundamental_object->refcount > 0);
3019
3020   if (G_UNLIKELY (g_atomic_int_dec_and_test (&fundamental_object->refcount))) {
3021     regress_test_fundamental_object_free (fundamental_object);
3022   }
3023 }
3024
3025 static void
3026 regress_test_fundamental_object_replace (RegressTestFundamentalObject ** olddata, RegressTestFundamentalObject * newdata)
3027 {
3028   RegressTestFundamentalObject *olddata_val;
3029
3030   g_return_if_fail (olddata != NULL);
3031
3032   olddata_val = g_atomic_pointer_get ((gpointer *) olddata);
3033
3034   if (olddata_val == newdata)
3035     return;
3036
3037   if (newdata)
3038     regress_test_fundamental_object_ref (newdata);
3039
3040   while (!g_atomic_pointer_compare_and_exchange ((gpointer *) olddata,
3041           olddata_val, newdata)) {
3042     olddata_val = g_atomic_pointer_get ((gpointer *) olddata);
3043   }
3044
3045   if (olddata_val)
3046     regress_test_fundamental_object_unref (olddata_val);
3047 }
3048
3049 static void
3050 regress_test_value_fundamental_object_init (GValue * value)
3051 {
3052   value->data[0].v_pointer = NULL;
3053 }
3054
3055 static void
3056 regress_test_value_fundamental_object_free (GValue * value)
3057 {
3058   if (value->data[0].v_pointer) {
3059     regress_test_fundamental_object_unref (REGRESS_TEST_FUNDAMENTAL_OBJECT_CAST (value->data[0].v_pointer));
3060   }
3061 }
3062
3063 static void
3064 regress_test_value_fundamental_object_copy (const GValue * src_value, GValue * dest_value)
3065 {
3066   if (src_value->data[0].v_pointer) {
3067     dest_value->data[0].v_pointer =
3068         regress_test_fundamental_object_ref (REGRESS_TEST_FUNDAMENTAL_OBJECT_CAST (src_value->data[0].
3069             v_pointer));
3070   } else {
3071     dest_value->data[0].v_pointer = NULL;
3072   }
3073 }
3074
3075 static gpointer
3076 regress_test_value_fundamental_object_peek_pointer (const GValue * value)
3077 {
3078   return value->data[0].v_pointer;
3079 }
3080
3081 static gchar *
3082 regress_test_value_fundamental_object_collect (GValue * value,
3083                                        guint n_collect_values,
3084                                        GTypeCValue * collect_values,
3085                                        guint collect_flags)
3086 {
3087   if (collect_values[0].v_pointer) {
3088     value->data[0].v_pointer =
3089         regress_test_fundamental_object_ref (collect_values[0].v_pointer);
3090   } else {
3091     value->data[0].v_pointer = NULL;
3092   }
3093
3094   return NULL;
3095 }
3096
3097 static gchar *
3098 regress_test_value_fundamental_object_lcopy (const GValue * value,
3099                                      guint n_collect_values,
3100                                      GTypeCValue * collect_values,
3101                                      guint collect_flags)
3102 {
3103   gpointer *fundamental_object_p = collect_values[0].v_pointer;
3104
3105   if (!fundamental_object_p) {
3106     return g_strdup_printf ("value location for '%s' passed as NULL",
3107         G_VALUE_TYPE_NAME (value));
3108   }
3109
3110   if (!value->data[0].v_pointer)
3111     *fundamental_object_p = NULL;
3112   else if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
3113     *fundamental_object_p = value->data[0].v_pointer;
3114   else
3115     *fundamental_object_p = regress_test_fundamental_object_ref (value->data[0].v_pointer);
3116
3117   return NULL;
3118 }
3119
3120 static void
3121 regress_test_fundamental_object_finalize (RegressTestFundamentalObject * obj)
3122 {
3123
3124 }
3125
3126 static RegressTestFundamentalObject *
3127 regress_test_fundamental_object_copy_default (const RegressTestFundamentalObject * obj)
3128 {
3129   g_warning ("RegressTestFundamentalObject classes must implement RegressTestFundamentalObject::copy");
3130   return NULL;
3131 }
3132
3133 static void
3134 regress_test_fundamental_object_class_init (gpointer g_class, gpointer class_data)
3135 {
3136   RegressTestFundamentalObjectClass *mo_class = REGRESS_TEST_FUNDAMENTAL_OBJECT_CLASS (g_class);
3137
3138   mo_class->copy = regress_test_fundamental_object_copy_default;
3139   mo_class->finalize = regress_test_fundamental_object_finalize;
3140 }
3141
3142 static void
3143 regress_test_fundamental_object_init (GTypeInstance * instance, gpointer klass)
3144 {
3145   RegressTestFundamentalObject *fundamental_object = REGRESS_TEST_FUNDAMENTAL_OBJECT_CAST (instance);
3146
3147   fundamental_object->refcount = 1;
3148 }
3149
3150 /**
3151  * RegressTestFundamentalObject:
3152  *
3153  * Ref Func: regress_test_fundamental_object_ref
3154  * Unref Func: regress_test_fundamental_object_unref
3155  * Set Value Func: regress_test_value_set_fundamental_object
3156  * Get Value Func: regress_test_value_get_fundamental_object
3157  */
3158
3159 GType
3160 regress_test_fundamental_object_get_type (void)
3161 {
3162   static GType _test_fundamental_object_type = 0;
3163
3164   if (G_UNLIKELY (_test_fundamental_object_type == 0)) {
3165     static const GTypeValueTable value_table = {
3166       regress_test_value_fundamental_object_init,
3167       regress_test_value_fundamental_object_free,
3168       regress_test_value_fundamental_object_copy,
3169       regress_test_value_fundamental_object_peek_pointer,
3170       (char *) "p",
3171       regress_test_value_fundamental_object_collect,
3172       (char *) "p",
3173       regress_test_value_fundamental_object_lcopy
3174     };
3175     static const GTypeInfo fundamental_object_info = {
3176       sizeof (RegressTestFundamentalObjectClass),
3177       NULL, NULL,
3178       regress_test_fundamental_object_class_init,
3179       NULL,
3180       NULL,
3181       sizeof (RegressTestFundamentalObject),
3182       0,
3183       (GInstanceInitFunc) regress_test_fundamental_object_init,
3184       &value_table
3185     };
3186     static const GTypeFundamentalInfo fundamental_object_fundamental_info = {
3187       (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE |
3188           G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE)
3189     };
3190
3191     _test_fundamental_object_type = g_type_fundamental_next ();
3192     g_type_register_fundamental (_test_fundamental_object_type, "RegressTestFundamentalObject",
3193         &fundamental_object_info, &fundamental_object_fundamental_info, G_TYPE_FLAG_ABSTRACT);
3194
3195   }
3196
3197   return _test_fundamental_object_type;
3198 }
3199
3200 /**
3201  * regress_test_value_set_fundamental_object: (skip)
3202  * @value:
3203  * @fundamental_object:
3204  */
3205 void
3206 regress_test_value_set_fundamental_object (GValue * value, RegressTestFundamentalObject * fundamental_object)
3207 {
3208   gpointer *pointer_p;
3209
3210   g_return_if_fail (REGRESS_TEST_VALUE_HOLDS_FUNDAMENTAL_OBJECT (value));
3211   g_return_if_fail (fundamental_object == NULL || REGRESS_TEST_IS_FUNDAMENTAL_OBJECT (fundamental_object));
3212
3213   pointer_p = &value->data[0].v_pointer;
3214
3215   regress_test_fundamental_object_replace ((RegressTestFundamentalObject **) pointer_p, fundamental_object);
3216 }
3217
3218 /**
3219  * regress_test_value_get_fundamental_object: (skip)
3220  * @value:
3221  */
3222 RegressTestFundamentalObject *
3223 regress_test_value_get_fundamental_object (const GValue * value)
3224 {
3225   g_return_val_if_fail (REGRESS_TEST_VALUE_HOLDS_FUNDAMENTAL_OBJECT (value), NULL);
3226
3227   return value->data[0].v_pointer;
3228 }
3229
3230 static RegressTestFundamentalObjectClass *parent_class = NULL;
3231
3232 G_DEFINE_TYPE (RegressTestFundamentalSubObject, regress_test_fundamental_sub_object, REGRESS_TEST_TYPE_FUNDAMENTAL_OBJECT);
3233
3234 static RegressTestFundamentalSubObject *
3235 _regress_test_fundamental_sub_object_copy (RegressTestFundamentalSubObject * fundamental_sub_object)
3236 {
3237   RegressTestFundamentalSubObject *copy;
3238
3239   copy = regress_test_fundamental_sub_object_new(NULL);
3240   copy->data = g_strdup(fundamental_sub_object->data);
3241   return copy;
3242 }
3243
3244 static void
3245 regress_test_fundamental_sub_object_finalize (RegressTestFundamentalSubObject * fundamental_sub_object)
3246 {
3247   g_return_if_fail (fundamental_sub_object != NULL);
3248
3249   g_free(fundamental_sub_object->data);
3250   regress_test_fundamental_object_finalize (REGRESS_TEST_FUNDAMENTAL_OBJECT (fundamental_sub_object));
3251 }
3252
3253 static void
3254 regress_test_fundamental_sub_object_class_init (RegressTestFundamentalSubObjectClass * klass)
3255 {
3256   parent_class = g_type_class_peek_parent (klass);
3257
3258   klass->fundamental_object_class.copy = (RegressTestFundamentalObjectCopyFunction) _regress_test_fundamental_sub_object_copy;
3259   klass->fundamental_object_class.finalize =
3260       (RegressTestFundamentalObjectFinalizeFunction) regress_test_fundamental_sub_object_finalize;
3261 }
3262
3263 static void
3264 regress_test_fundamental_sub_object_init(RegressTestFundamentalSubObject *object)
3265 {
3266
3267 }
3268
3269 /**
3270  * regress_test_fundamental_sub_object_new:
3271  */
3272 RegressTestFundamentalSubObject *
3273 regress_test_fundamental_sub_object_new (const char * data)
3274 {
3275   RegressTestFundamentalSubObject *object;
3276
3277   object = (RegressTestFundamentalSubObject *) g_type_create_instance (regress_test_fundamental_sub_object_get_type());
3278   object->data = g_strdup(data);
3279   return object;
3280 }
3281
3282
3283 /**
3284  * regress_test_callback:
3285  * @callback: (scope call) (allow-none):
3286  *
3287  **/
3288 int
3289 regress_test_callback (RegressTestCallback callback)
3290 {
3291     if (callback != NULL)
3292         return callback();
3293     return 0;
3294 }
3295
3296 /**
3297  * regress_test_multi_callback:
3298  * @callback: (scope call) (allow-none):
3299  *
3300  **/
3301 int
3302 regress_test_multi_callback (RegressTestCallback callback)
3303 {
3304     int sum = 0;
3305     if (callback != NULL) {
3306         sum += callback();
3307         sum += callback();
3308     }
3309
3310     return sum;
3311 }
3312
3313 /**
3314  * regress_test_array_callback:
3315  * @callback: (scope call):
3316  *
3317  **/
3318 int regress_test_array_callback (RegressTestCallbackArray callback)
3319 {
3320   static const char *strings[] = { "one", "two", "three" };
3321   static int ints[] = { -1, 0, 1, 2 };
3322   int sum = 0;
3323
3324   sum += callback(ints, 4, strings, 3);
3325   sum += callback(ints, 4, strings, 3);
3326
3327   return sum;
3328 }
3329
3330 /**
3331  * regress_test_simple_callback:
3332  * @callback: (scope call) (allow-none):
3333  *
3334  **/
3335 void
3336 regress_test_simple_callback (RegressTestSimpleCallback callback)
3337 {
3338     if (callback != NULL)
3339         callback();
3340
3341     return;
3342 }
3343
3344 /**
3345  * regress_test_callback_user_data:
3346  * @callback: (scope call):
3347  *
3348  * Call - callback parameter persists for the duration of the method
3349  * call and can be released on return.
3350  **/
3351 int
3352 regress_test_callback_user_data (RegressTestCallbackUserData callback,
3353                          gpointer user_data)
3354 {
3355   return callback(user_data);
3356 }
3357
3358 static GSList *notified_callbacks = NULL;
3359
3360 /**
3361  * regress_test_callback_destroy_notify:
3362  * @callback: (scope notified):
3363  *
3364  * Notified - callback persists until a DestroyNotify delegate
3365  * is invoked.
3366  **/
3367 int
3368 regress_test_callback_destroy_notify (RegressTestCallbackUserData callback,
3369                               gpointer user_data,
3370                               GDestroyNotify notify)
3371 {
3372   int retval;
3373   CallbackInfo *info;
3374
3375   retval = callback(user_data);
3376
3377   info = g_slice_new(CallbackInfo);
3378   info->callback = callback;
3379   info->notify = notify;
3380   info->user_data = user_data;
3381
3382   notified_callbacks = g_slist_prepend(notified_callbacks, info);
3383
3384   return retval;
3385 }
3386
3387 /**
3388  * regress_test_callback_destroy_notify_no_user_data:
3389  * @callback: (scope notified):
3390  *
3391  * Adds a scope notified callback with no user data. This can invoke an error
3392  * condition in bindings which needs to be tested.
3393  **/
3394 int
3395 regress_test_callback_destroy_notify_no_user_data (RegressTestCallbackUserData callback,
3396                               GDestroyNotify notify)
3397 {
3398   return regress_test_callback_destroy_notify(callback, NULL, notify);
3399 }
3400
3401 /**
3402  * regress_test_callback_thaw_notifications:
3403  *
3404  * Invokes all callbacks installed by #test_callback_destroy_notify(),
3405  * adding up their return values, and removes them, invoking the
3406  * corresponding destroy notfications.
3407  *
3408  * Return value: Sum of the return values of the invoked callbacks.
3409  */
3410 int
3411 regress_test_callback_thaw_notifications (void)
3412 {
3413   int retval = 0;
3414   GSList *node;
3415
3416   for (node = notified_callbacks; node != NULL; node = node->next)
3417     {
3418       CallbackInfo *info = node->data;
3419       retval += info->callback (info->user_data);
3420       if (info->notify)
3421         info->notify (info->user_data);
3422       g_slice_free (CallbackInfo, info);
3423     }
3424
3425   g_slist_free (notified_callbacks);
3426   notified_callbacks = NULL;
3427
3428   return retval;
3429 }
3430
3431 static GSList *async_callbacks = NULL;
3432
3433 /**
3434  * regress_test_callback_async:
3435  * @callback: (scope async):
3436  *
3437  **/
3438 void
3439 regress_test_callback_async (RegressTestCallbackUserData callback,
3440                      gpointer user_data)
3441 {
3442   CallbackInfo *info;
3443
3444   info = g_slice_new(CallbackInfo);
3445   info->callback = callback;
3446   info->user_data = user_data;
3447
3448   async_callbacks = g_slist_prepend(async_callbacks, info);
3449 }
3450
3451 /**
3452  * regress_test_callback_thaw_async:
3453  */
3454 int
3455 regress_test_callback_thaw_async (void)
3456 {
3457   int retval = 0;
3458   GSList *node;
3459
3460   for (node = async_callbacks; node != NULL; node = node->next)
3461     {
3462       CallbackInfo *info = node->data;
3463       retval = info->callback (info->user_data);
3464       g_slice_free (CallbackInfo, info);
3465     }
3466
3467   g_slist_free (async_callbacks);
3468   async_callbacks = NULL;
3469   return retval;
3470 }
3471
3472 void
3473 regress_test_async_ready_callback (GAsyncReadyCallback callback)
3474 {
3475   GSimpleAsyncResult *result = g_simple_async_result_new (NULL, callback, NULL,
3476     regress_test_async_ready_callback);
3477   g_simple_async_result_complete_in_idle (result);
3478 }
3479
3480 /**
3481  * regress_test_obj_instance_method_callback:
3482  * @callback: (scope call) (allow-none):
3483  *
3484  **/
3485 void
3486 regress_test_obj_instance_method_callback (RegressTestObj *obj, RegressTestCallback callback)
3487 {
3488     if (callback != NULL)
3489         callback();
3490 }
3491
3492 /**
3493  * regress_test_obj_static_method_callback:
3494  * @callback: (scope call) (allow-none):
3495  *
3496  **/
3497 void
3498 regress_test_obj_static_method_callback (RegressTestCallback callback)
3499 {
3500     if (callback != NULL)
3501         callback();
3502 }
3503
3504 /**
3505  * regress_test_obj_new_callback:
3506  * @callback: (scope notified):
3507  **/
3508 RegressTestObj *
3509 regress_test_obj_new_callback (RegressTestCallbackUserData callback, gpointer user_data,
3510                        GDestroyNotify notify)
3511 {
3512   CallbackInfo *info;
3513
3514   callback(user_data);
3515
3516   info = g_slice_new(CallbackInfo);
3517   info->callback = callback;
3518   info->notify = notify;
3519   info->user_data = user_data;
3520
3521   notified_callbacks = g_slist_prepend(notified_callbacks, info);
3522
3523   return g_object_new (REGRESS_TEST_TYPE_OBJ, NULL);
3524 }
3525
3526 /**
3527  * regress_test_hash_table_callback:
3528  * @data: (element-type utf8 gint): GHashTable that gets passed to callback
3529  * @callback: (scope call):
3530  **/
3531 void
3532 regress_test_hash_table_callback (GHashTable *data, RegressTestCallbackHashtable callback)
3533 {
3534   callback (data);
3535 }
3536
3537 /**
3538  * regress_test_gerror_callback:
3539  * @callback: (scope call):
3540  **/
3541 void
3542 regress_test_gerror_callback (RegressTestCallbackGError callback)
3543 {
3544   GError *error;
3545
3546   error = g_error_new_literal (G_IO_ERROR,
3547                                G_IO_ERROR_NOT_SUPPORTED,
3548                                "regression test error");
3549   callback (error);
3550   g_error_free (error);
3551 }
3552
3553 /**
3554  * regress_test_null_gerror_callback:
3555  * @callback: (scope call):
3556  **/
3557 void
3558 regress_test_null_gerror_callback (RegressTestCallbackGError callback)
3559 {
3560   callback (NULL);
3561 }
3562
3563 /**
3564  * regress_test_owned_gerror_callback:
3565  * @callback: (scope call):
3566  **/
3567 void
3568 regress_test_owned_gerror_callback (RegressTestCallbackOwnedGError callback)
3569 {
3570   GError *error;
3571
3572   error = g_error_new_literal (G_IO_ERROR,
3573                                G_IO_ERROR_PERMISSION_DENIED,
3574                                "regression test owned error");
3575   callback (error);
3576 }
3577
3578 /**
3579  * regress_test_skip_unannotated_callback: (skip)
3580  * @callback: No annotation here
3581  *
3582  * Should not emit a warning:
3583  * https://bugzilla.gnome.org/show_bug.cgi?id=685399
3584  */
3585 void
3586 regress_test_skip_unannotated_callback (RegressTestCallback callback)
3587 {
3588 }
3589
3590 /* interface */
3591
3592 static void
3593 regress_test_interface_default_init(RegressTestInterfaceIface *iface)
3594 {
3595 }
3596
3597 typedef RegressTestInterfaceIface RegressTestInterfaceInterface;
3598 G_DEFINE_INTERFACE (RegressTestInterface, regress_test_interface, G_TYPE_OBJECT)
3599
3600
3601 /* gobject with non-standard prefix */
3602 G_DEFINE_TYPE(RegressTestWi8021x, regress_test_wi_802_1x, G_TYPE_OBJECT);
3603
3604 enum
3605 {
3606   PROP_TEST_WI_802_1X_TESTBOOL = 1
3607 };
3608
3609 static void
3610 regress_test_wi_802_1x_set_property (GObject      *object,
3611                              guint         property_id,
3612                              const GValue *value,
3613                              GParamSpec   *pspec)
3614 {
3615   RegressTestWi8021x *self = REGRESS_TEST_WI_802_1X (object);
3616
3617   switch (property_id)
3618     {
3619     case PROP_TEST_WI_802_1X_TESTBOOL:
3620       regress_test_wi_802_1x_set_testbool (self, g_value_get_boolean (value));
3621       break;
3622
3623     default:
3624       /* We don't have any other property... */
3625       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
3626       break;
3627     }
3628 }
3629
3630 static void
3631 regress_test_wi_802_1x_get_property (GObject    *object,
3632                         guint       property_id,
3633                         GValue     *value,
3634                         GParamSpec *pspec)
3635 {
3636   RegressTestWi8021x *self = REGRESS_TEST_WI_802_1X (object);
3637
3638   switch (property_id)
3639     {
3640     case PROP_TEST_WI_802_1X_TESTBOOL:
3641       g_value_set_boolean (value, regress_test_wi_802_1x_get_testbool (self));
3642       break;
3643
3644     default:
3645       /* We don't have any other property... */
3646       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
3647       break;
3648     }
3649 }
3650
3651 static void
3652 regress_test_wi_802_1x_dispose (GObject *gobject)
3653 {
3654   /* Chain up to the parent class */
3655   G_OBJECT_CLASS (regress_test_wi_802_1x_parent_class)->dispose (gobject);
3656 }
3657
3658 static void
3659 regress_test_wi_802_1x_class_init (RegressTestWi8021xClass *klass)
3660 {
3661   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
3662   GParamSpec *pspec;
3663
3664   gobject_class->set_property = regress_test_wi_802_1x_set_property;
3665   gobject_class->get_property = regress_test_wi_802_1x_get_property;
3666   gobject_class->dispose = regress_test_wi_802_1x_dispose;
3667
3668   pspec = g_param_spec_boolean ("testbool",
3669                                 "Nick for testbool",
3670                                 "Blurb for testbool",
3671                                 TRUE,
3672                                 G_PARAM_READWRITE);
3673   g_object_class_install_property (gobject_class,
3674                                    PROP_TEST_WI_802_1X_TESTBOOL,
3675                                    pspec);
3676 }
3677
3678 static void
3679 regress_test_wi_802_1x_init (RegressTestWi8021x *obj)
3680 {
3681   obj->testbool = TRUE;
3682 }
3683
3684 RegressTestWi8021x *
3685 regress_test_wi_802_1x_new (void)
3686 {
3687   return g_object_new (REGRESS_TEST_TYPE_WI_802_1X, NULL);
3688 }
3689
3690 void
3691 regress_test_wi_802_1x_set_testbool (RegressTestWi8021x *obj, gboolean val)
3692 {
3693   obj->testbool = val;
3694 }
3695
3696 gboolean
3697 regress_test_wi_802_1x_get_testbool (RegressTestWi8021x *obj)
3698 {
3699   return obj->testbool;
3700 }
3701
3702 int
3703 regress_test_wi_802_1x_static_method (int x)
3704 {
3705   return 2*x;
3706 }
3707
3708 /* floating gobject */
3709 G_DEFINE_TYPE(RegressTestFloating, regress_test_floating, G_TYPE_INITIALLY_UNOWNED);
3710
3711 static void
3712 regress_test_floating_finalize(GObject *object)
3713 {
3714   g_assert(!g_object_is_floating (object));
3715
3716   G_OBJECT_CLASS(regress_test_floating_parent_class)->finalize(object);
3717 }
3718
3719 static void
3720 regress_test_floating_class_init (RegressTestFloatingClass *klass)
3721 {
3722   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
3723   gobject_class->finalize = regress_test_floating_finalize;
3724 }
3725
3726 static void
3727 regress_test_floating_init (RegressTestFloating *obj)
3728 {
3729 }
3730
3731 /**
3732  * regress_test_floating_new:
3733  *
3734  * Returns:: A new floating #RegressTestFloating
3735  */
3736 RegressTestFloating *
3737 regress_test_floating_new (void)
3738 {
3739   return g_object_new (REGRESS_TEST_TYPE_FLOATING, NULL);
3740 }
3741
3742
3743 /**
3744  * regress_test_torture_signature_0:
3745  * @x:
3746  * @y: (out):
3747  * @z: (out):
3748  * @foo:
3749  * @q: (out):
3750  * @m:
3751  *
3752  */
3753 void
3754 regress_test_torture_signature_0 (int         x,
3755                           double     *y,
3756                           int        *z,
3757                           const char *foo,
3758                           int        *q,
3759                           guint       m)
3760 {
3761   *y = x;
3762   *z = x * 2;
3763   *q = g_utf8_strlen (foo, -1) + m;
3764 }
3765
3766 /**
3767  * regress_test_torture_signature_1:
3768  * @x:
3769  * @y: (out):
3770  * @z: (out):
3771  * @foo:
3772  * @q: (out):
3773  * @m:
3774  * @error: A #GError
3775  *
3776  * This function throws an error if m is odd.
3777  */
3778 gboolean
3779 regress_test_torture_signature_1 (int         x,
3780                           double     *y,
3781                           int        *z,
3782                           const char *foo,
3783                           int        *q,
3784                           guint       m,
3785                           GError    **error)
3786 {
3787   *y = x;
3788   *z = x * 2;
3789   *q = g_utf8_strlen (foo, -1) + m;
3790   if (m % 2 == 0)
3791       return TRUE;
3792   g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "m is odd");
3793   return FALSE;
3794 }
3795
3796 /**
3797  * regress_test_torture_signature_2:
3798  * @x:
3799  * @callback:
3800  * @user_data:
3801  * @notify:
3802  * @y: (out):
3803  * @z: (out):
3804  * @foo:
3805  * @q: (out):
3806  * @m:
3807  *
3808  */
3809 void
3810 regress_test_torture_signature_2 (int                   x,
3811                           RegressTestCallbackUserData  callback,
3812                           gpointer              user_data,
3813                           GDestroyNotify        notify,
3814                           double               *y,
3815                           int                  *z,
3816                           const char           *foo,
3817                           int                  *q,
3818                           guint                 m)
3819 {
3820   *y = x;
3821   *z = x * 2;
3822   *q = g_utf8_strlen (foo, -1) + m;
3823   notify (user_data);
3824 }
3825
3826 /**
3827  * regress_test_date_in_gvalue:
3828  *
3829  * Returns: (transfer full):
3830  */
3831 GValue *
3832 regress_test_date_in_gvalue (void)
3833 {
3834   GValue *value = g_new0 (GValue, 1);
3835   GDate *date = g_date_new_dmy (5, 12, 1984);
3836
3837   g_value_init (value, G_TYPE_DATE);
3838   g_value_take_boxed (value, date);
3839
3840   return value;
3841 }
3842
3843 /**
3844  * regress_test_strv_in_gvalue:
3845  *
3846  * Returns: (transfer full):
3847  */
3848 GValue *
3849 regress_test_strv_in_gvalue (void)
3850 {
3851   GValue *value = g_new0 (GValue, 1);
3852   const char *strv[] = { "one", "two", "three", NULL };
3853
3854   g_value_init (value, G_TYPE_STRV);
3855   g_value_set_boxed (value, strv);
3856
3857   return value;
3858 }
3859
3860 /**
3861  * regress_test_multiline_doc_comments:
3862  *
3863  * This is a function.
3864  *
3865  * It has multiple lines in the documentation.
3866  *
3867  * The sky is blue.
3868  *
3869  * You will give me your credit card number.
3870  */
3871 void
3872 regress_test_multiline_doc_comments (void)
3873 {
3874 }
3875
3876 /**
3877  * regress_test_nested_parameter:
3878  * @a: An integer
3879  *
3880  * <informaltable>
3881  *   <tgroup cols="3">
3882  *     <thead>
3883  *       <row>
3884  *         <entry>Syntax</entry>
3885  *         <entry>Explanation</entry>
3886  *         <entry>Examples</entry>
3887  *       </row>
3888  *     </thead>
3889  *     <tbody>
3890  *       <row>
3891  *         <entry>rgb(@r, @g, @b)</entry>
3892  *         <entry>An opaque color; @r, @g, @b can be either integers between
3893  *                0 and 255 or percentages</entry>
3894  *         <entry><literallayout>rgb(128, 10, 54)
3895  * rgb(20%, 30%, 0%)</literallayout></entry>
3896  *       </row>
3897  *       <row>
3898  *         <entry>rgba(@r, @g, @b, @a)</entry>
3899  *         <entry>A translucent color; @r, @g, @b are as in the previous row,
3900  *                @a is a floating point number between 0 and 1</entry>
3901  *         <entry><literallayout>rgba(255, 255, 0, 0.5)</literallayout></entry>
3902  *       </row>
3903  *    </tbody>
3904  *  </tgroup>
3905  * </informaltable>
3906  *
3907  * What we're testing here is that the scanner ignores the @a nested inside XML.
3908  */
3909 void
3910 regress_test_nested_parameter (int a)
3911 {
3912 }
3913
3914 /**
3915  * regress_introspectable_via_alias:
3916  *
3917  */
3918 void
3919 regress_introspectable_via_alias (RegressPtrArrayAlias *data)
3920 {
3921 }
3922
3923 /**
3924  * regress_not_introspectable_via_alias:
3925  *
3926  */
3927 void
3928 regress_not_introspectable_via_alias (RegressVaListAlias ok)
3929 {
3930 }
3931
3932 /**
3933  * regress_aliased_caller_alloc:
3934  * @boxed: (out):
3935  */
3936 void regress_aliased_caller_alloc (RegressAliasedTestBoxed *boxed)
3937 {
3938   boxed->priv = g_slice_new0 (RegressTestBoxedPrivate);
3939   boxed->priv->magic = 0xdeadbeef;
3940 }
3941
3942 void
3943 regress_test_struct_fixed_array_frob (RegressTestStructFixedArray *str)
3944 {
3945   guint i;
3946   str->just_int = 7;
3947
3948   for (i = 0; i < G_N_ELEMENTS(str->array); i++)
3949     str->array[i] = 42 + i;
3950 }
3951
3952 /**
3953  * regress_has_parameter_named_attrs:
3954  * @foo: some int
3955  * @attributes: (type guint32) (array fixed-size=32): list of attributes
3956  *
3957  * This test case mirrors GnomeKeyringPasswordSchema from
3958  * libgnome-keyring.
3959  */
3960 void
3961 regress_has_parameter_named_attrs (int        foo,
3962                                    gpointer   attributes)
3963 {
3964 }
3965
3966 /**
3967  * regress_test_versioning:
3968  *
3969  * Since: 1.32.1
3970  * Deprecated: 1.33.3: Use foobar instead
3971  * Stability: Unstable
3972  */
3973 void
3974 regress_test_versioning (void)
3975 {
3976 }