6c394e8280d55e97569c5b8bf59ed36fc4739dc6
[gnome.gobject-introspection] / gir / everything.c
1 #include <string.h>
2 #include "everything.h"
3
4 /* basic types */
5 gboolean test_boolean (gboolean in)
6 {
7   return in;
8 }
9
10 gint8 test_int8 (gint8 in)
11 {
12   return in;
13 }
14
15 guint8 test_uint8 (guint8 in)
16 {
17   return in;
18 }
19
20 gint16 test_int16 (gint16 in)
21 {
22   return in;
23 }
24
25 guint16 test_uint16 (guint16 in)
26 {
27   return in;
28 }
29
30 gint32 test_int32 (gint32 in)
31 {
32   return in;
33 }
34
35 guint32 test_uint32 (guint32 in)
36 {
37   return in;
38 }
39
40 gint64 test_int64 (gint64 in)
41 {
42   return in;
43 }
44
45 guint64 test_uint64 (guint64 in)
46 {
47   return in;
48 }
49
50 gshort test_short (gshort in)
51 {
52   return in;
53 }
54
55 gushort test_ushort (gushort in)
56 {
57   return in;
58 }
59
60 gint test_int (gint in)
61 {
62   return in;
63 }
64
65 guint test_uint (guint in)
66 {
67   return in;
68 }
69
70 glong test_long (glong in)
71 {
72   return in;
73 }
74
75 gulong test_ulong (gulong in)
76 {
77   return in;
78 }
79
80 gssize test_ssize (gssize in)
81 {
82   return in;
83 }
84
85 gsize test_size (gsize in)
86 {
87   return in;
88 }
89
90 gfloat test_float (gfloat in)
91 {
92   return in;
93 }
94
95 gdouble test_double (gdouble in)
96 {
97   return in;
98 }
99
100
101 time_t test_timet (time_t in)
102 {
103   return in;
104 }
105
106 GType test_gtype (GType in)
107 {
108   return in;
109 }
110
111 int test_closure (GClosure *closure)
112 {
113   GValue return_value = {0, };
114   int ret;
115
116   g_value_init (&return_value, G_TYPE_INT);
117
118   g_closure_invoke (closure,
119                     &return_value,
120                     0, NULL,
121                     NULL);
122
123   ret = g_value_get_int (&return_value);
124
125   g_value_unset(&return_value);
126
127   return ret;
128 }
129
130 int test_closure_one_arg (GClosure *closure, int arg)
131 {
132   GValue return_value = {0, };
133   GValue arguments[1];
134   int ret;
135
136   g_value_init (&return_value, G_TYPE_INT);
137
138   memset (&arguments[0], 0, sizeof (arguments));
139   g_value_init (&arguments[0], G_TYPE_INT);
140   g_value_set_int (&arguments[0], arg);
141
142   g_closure_invoke (closure,
143                     &return_value,
144                     1, arguments,
145                     NULL);
146
147   ret = g_value_get_int (&return_value);
148
149   g_value_unset(&return_value);
150   g_value_unset(&arguments[0]);
151
152   return ret;
153 }
154
155 /**
156  * test_value_arg:
157  * @v: (transfer none): a GValue expected to contain an int
158  *
159  * Return value: the int contained in the GValue.
160  */
161 int test_int_value_arg(const GValue *v) {
162   int i;
163
164   i = g_value_get_int (v);
165
166   return i;
167 }
168
169 static GValue value;
170 /**
171  * test_value_return:
172  * @i: an int
173  *
174  * Return value: (transfer none): the int wrapped in a GValue.
175  */
176 const GValue *test_value_return(int i) {
177   memset(&value, '\0', sizeof(GValue));
178
179   g_value_init (&value, G_TYPE_INT);
180   g_value_set_int (&value, i);
181
182   return &value;
183 }
184
185
186 /************************************************************************/
187 /* utf8 */
188 /* insert BLACK HEART SUIT to ensure UTF-8 doesn't get mangled */
189 static const char utf8_const[]    = "const \xe2\x99\xa5 utf8";
190 static const char utf8_nonconst[] = "nonconst \xe2\x99\xa5 utf8";
191
192 /**
193  * test_utf8_const_return:
194  * Return value: <const char*> UTF-8 string
195  */
196 G_CONST_RETURN char *test_utf8_const_return (void)
197 {
198   /* transfer mode none */
199   return utf8_const;
200 }
201
202 /**
203  * test_utf8_nonconst_return:
204  * Return value: <char*> UTF-8 string
205  */
206 char *test_utf8_nonconst_return (void)
207 {
208   /* transfer mode full */
209   return g_strdup (utf8_nonconst);
210 }
211
212 void test_utf8_nonconst_in (char *in)
213 {
214   /* transfer mode full */
215   g_assert (strcmp (in, utf8_nonconst) == 0);
216   g_free(in);
217 }
218
219 void test_utf8_const_in (const char *in)
220 {
221   /* transfer mode none */
222   g_assert (strcmp (in, utf8_const) == 0);
223 }
224
225 /**
226  * test_utf8_out:
227  * @out: (out) (transfer full):
228  */
229 void test_utf8_out (char **out)
230 {
231   /* out parameter, transfer mode full */
232   *out = g_strdup (utf8_nonconst);
233 }
234
235 /**
236  * test_utf8_inout:
237  * @inout: (inout):
238  */
239 void test_utf8_inout (char **inout)
240 {
241   /* inout parameter, transfer mode full */
242   g_assert (strcmp (*inout, utf8_const) == 0);
243   g_free(*inout);
244   *inout = g_strdup (utf8_nonconst);
245 }
246
247 /**
248  * test_filename_return:
249  *
250  * Return value: (element-type filename) (transfer full): list of strings
251  */
252 GSList *test_filename_return (void)
253 {
254   GSList *filenames = NULL;
255   filenames = g_slist_prepend (filenames, g_filename_from_utf8("/etc/fstab", -1, NULL, NULL, NULL));
256   filenames = g_slist_prepend (filenames, g_filename_from_utf8("åäö", -1, NULL, NULL, NULL));
257   return filenames;
258 }
259
260 /* in arguments after out arguments */
261
262 /**
263  * test_int_out_utf8:
264  * @out: (out):
265  * @in:
266  */
267 void
268 test_int_out_utf8 (int *length, const char *in)
269 {
270     *length = g_utf8_strlen(in, -1);
271 }
272
273
274 /* multiple output arguments */
275
276 /**
277  * test_multi_double_args:
278  * @in:
279  * @one: (out): 
280  * @two: (out): 
281  */
282 void
283 test_multi_double_args (gdouble in, gdouble *one, gdouble *two)
284 {
285   *one = in * 2;
286   *two = in * 3;
287 }
288
289 /**
290  * test_utf8_out_out:
291  * @out0: (out) (transfer full): a copy of "first"
292  * @out1: (out) (transfer full): a copy of "second"
293  */
294 void
295 test_utf8_out_out (char **out0, char **out1)
296 {
297   *out0 = g_strdup ("first");
298   *out1 = g_strdup ("second");
299 }
300
301 /**
302  * test_utf8_out_nonconst_return:
303  * @out: (out) (transfer full): a copy of "second"
304  *
305  * Returns: (transfer full): a copy of "first"
306  */
307 char *
308 test_utf8_out_nonconst_return (char **out)
309 {
310   *out = g_strdup ("second");
311   return g_strdup ("first");
312 }
313
314
315 /* non-basic-types */
316
317 static const char *test_sequence[] = {"1", "2", "3"};
318
319 /* array */
320
321 /**
322  * test_array_int_in:
323  * @n_ints:
324  * @ints: (array length=n_ints): List of ints
325  */
326 int
327 test_array_int_in (int n_ints, int *ints)
328 {
329   int i, sum = 0;
330   for (i = 0; i < n_ints; i++)
331     sum += ints[i];
332   return sum;
333 }
334
335 /**
336  * test_array_int_out:
337  * @n_ints: (out): the length of @ints
338  * @ints: (out) (array length=n_ints) (transfer full): a list of 5 integers, from 0 to 4 in consecutive order
339  */
340 void
341 test_array_int_out (int *n_ints, int **ints)
342 {
343   int i;
344   *n_ints = 5;
345   *ints = g_malloc0(sizeof(**ints) * *n_ints);
346   for (i = 1; i < *n_ints; i++)
347     (*ints)[i] = (*ints)[i-1] + 1;
348 }
349
350 /**
351  * test_array_int_inout:
352  * @n_ints: (inout): the length of @ints
353  * @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
354  */
355 void
356 test_array_int_inout (int *n_ints, int **ints)
357 {
358   int i;
359
360   for (i = 1; i < *n_ints; i++) {
361         (*ints)[i-1] = (*ints)[i] + 1;
362   }
363
364   if (0 < *n_ints) {
365     *n_ints -= 1;
366   }
367   *ints = g_realloc(*ints, sizeof(**ints) * *n_ints);
368 }
369
370 /**
371  * test_array_gint8_in:
372  * @n_ints:
373  * @ints: (array length=n_ints): List of ints
374  */
375 int
376 test_array_gint8_in (int n_ints, gint8 *ints)
377 {
378   int i, sum = 0;
379   for (i = 0; i < n_ints; i++)
380     sum += ints[i];
381   return sum;
382 }
383
384 /**
385  * test_array_gint16_in:
386  * @n_ints:
387  * @ints: (array length=n_ints): List of ints
388  */
389 int
390 test_array_gint16_in (int n_ints, gint16 *ints)
391 {
392   int i, sum = 0;
393   for (i = 0; i < n_ints; i++)
394     sum += ints[i];
395   return sum;
396 }
397
398 /**
399  * test_array_gint32_in:
400  * @n_ints:
401  * @ints: (array length=n_ints): List of ints
402  */
403 gint32
404 test_array_gint32_in (int n_ints, gint32 *ints)
405 {
406   int i;
407   gint32 sum = 0;
408   for (i = 0; i < n_ints; i++)
409     sum += ints[i];
410   return sum;
411 }
412
413 /**
414  * test_array_gint64_in:
415  * @n_ints:
416  * @ints: (array length=n_ints): List of ints
417  */
418 gint64
419 test_array_gint64_in (int n_ints, gint64 *ints)
420 {
421   int i;
422   gint64 sum = 0;
423   for (i = 0; i < n_ints; i++)
424     sum += ints[i];
425   return sum;
426 }
427
428 /**
429  * test_strv_in:
430  * @arr: (array zero-terminated=1) (transfer none):
431  */
432 gboolean
433 test_strv_in (char **arr)
434 {
435   if (g_strv_length (arr) != 3)
436     return FALSE;
437   if (strcmp (arr[0], "1") != 0)
438     return FALSE;
439   if (strcmp (arr[1], "2") != 0)
440     return FALSE;
441   if (strcmp (arr[2], "3") != 0)
442     return FALSE;
443   return TRUE;
444 }
445
446 /**
447  * test_strv_in_container:
448  * @arr: (array zero-terminated=1) (transfer container):
449  */
450 gboolean
451 test_strv_in_container (char **arr)
452 {
453   gboolean result = test_strv_in (arr);
454   g_free (arr);
455   return result;
456 }
457
458 /**
459  * test_array_gtype_in:
460  * @n_types:
461  * @types: (array length=n_types): List of types
462  * Return value: string representation of provided types
463  * */
464 char *
465 test_array_gtype_in (int n_types, GType *types)
466 {
467   GString *string;
468   int i;
469
470   string = g_string_new ("[");
471   for (i = 0; i < n_types; i++)
472     {
473       g_string_append (string, g_type_name (types[i]));
474       g_string_append_c (string, ',');
475     }
476   g_string_append_c (string, ']');
477   return g_string_free (string, FALSE);
478 }
479
480 /**
481  * test_strv_out:
482  *
483  * No annotations here.  We want the default to Do The Right Thing.
484  */
485 char **
486 test_strv_out (void)
487 {
488   int i = 0;
489   int n = 6;
490   char **ret = g_new (char *, n);
491   ret[i++] = g_strdup ("thanks");
492   ret[i++] = g_strdup ("for");
493   ret[i++] = g_strdup ("all");
494   ret[i++] = g_strdup ("the");
495   ret[i++] = g_strdup ("fish");
496   ret[i++] = NULL;
497   g_assert (i == n);
498   return ret;
499 }
500
501 /**
502  * test_strv_out_container:
503  *
504  * Return value: (array zero-terminated=1) (transfer container):
505  */
506 char **
507 test_strv_out_container (void)
508 {
509   char **ret = g_new (char *, 4);
510   ret[0] = "1";
511   ret[1] = "2";
512   ret[2] = "3";
513   ret[3] = NULL;
514   return ret;
515 }
516
517 /**
518  * test_strv_outarg:
519  * @retp: (array zero-terminated=1) (out) (transfer container):
520  */
521 void
522 test_strv_outarg (char ***retp)
523 {
524   char **ret = g_new (char *, 4);
525   ret[0] = "1";
526   ret[1] = "2";
527   ret[2] = "3";
528   ret[3] = NULL;
529   *retp = ret;
530 }
531
532 /**
533  * test_array_fixed_size_int_in:
534  * @ints: (array fixed-size=5): a list of 5 integers
535  *
536  * Returns: the sum of the items in @ints
537  */
538 int
539 test_array_fixed_size_int_in (int *ints)
540 {
541   int i, sum = 0;
542   for (i = 0; i < 5; i++)
543     sum += ints[i];
544   return sum;
545 }
546
547 /**
548  * test_array_fixed_size_int_out:
549  * @ints: (out) (array fixed-size=5) (transfer full): a list of 5 integers ranging from 0 to 4
550  */
551 void
552 test_array_fixed_size_int_out (int **ints)
553 {
554   int i;
555   *ints = g_malloc0(sizeof(**ints) * 5);
556   for (i = 1; i < 5; i++)
557     (*ints)[i] = (*ints)[i-1] + 1;
558 }
559
560 /**
561  * test_array_fixed_size_int_return:
562  * Returns: (array fixed-size=5) (transfer full): a list of 5 integers ranging from 0 to 4
563  */
564 int *
565 test_array_fixed_size_int_return (void)
566 {
567   int i, *ints;
568   ints = g_malloc0(sizeof(*ints) * 5);
569   for (i = 1; i < 5; i++)
570     ints[i] = ints[i-1] + 1;
571   return ints;
572 }
573
574 /**
575  * test_array_int_in_take:
576  * @n_ints:
577  * @ints: (array length=n_ints) (transfer full): List of ints
578  */
579 int test_array_int_in_take (int n_ints, int *ints)
580 {
581   int i, sum = 0;
582   for (i = 0; i < n_ints; i++)
583     sum += ints[i];
584   g_free (ints);
585   return sum;
586 }
587
588 /**
589  * test_strv_out_c:
590  *
591  * No annotations here.  We want the default to Do The Right Thing.
592  */
593 const char * const*
594 test_strv_out_c (void)
595 {
596   static char **ret = NULL;
597
598   if (ret == NULL)
599     ret = test_strv_out ();
600
601   return (const char * const *) ret;
602 }
603
604 /**
605  * test_array_int_full_out:
606  * @len: length of the returned array.
607  * Returns: (array length=len) (transfer full): a new array of integers.
608  */
609 int *
610 test_array_int_full_out(int *len) {
611   int *result, i;
612   *len = 5;
613   result = g_malloc0(sizeof(*result) * (*len));
614   for (i=1; i < (*len); i++)
615     result[i] = result[i-1] + 1;
616   return result;
617 }
618
619 /**
620  * test_array_int_none_out:
621  * @len: length of the returned array.
622  * Returns: (array length=len) (transfer none): a static array of integers.
623  */
624 int *
625 test_array_int_none_out(int *len) {
626   static int result[5] = { 1, 2, 3, 4, 5 };
627   *len = 5;
628   return result;
629 }
630
631 /* interface */
632
633 /************************************************************************/
634 /* GList */
635
636 static /*const*/ GList *test_sequence_list()
637 {
638     static GList *list = NULL;
639     if (!list) {
640         gsize i;
641         for (i = 0; i < G_N_ELEMENTS(test_sequence); ++i) {
642             list = g_list_prepend (list, (gpointer)test_sequence[i]);
643         }
644         list = g_list_reverse (list);
645     }
646     return list;
647 }
648
649 /**
650  * test_glist_free:
651  * @in: (element-type utf8) (transfer full):
652  */
653 void test_glist_free (GList *in)
654 {
655   g_list_foreach (in, (GFunc)g_free, NULL);
656   g_list_free (in);
657 }
658
659 /**
660  * test_glist_nothing_return:
661  *
662  * Return value: (element-type utf8) (transfer none):
663  */
664 G_CONST_RETURN GList *test_glist_nothing_return (void)
665 {
666   return test_sequence_list ();
667 }
668
669 /**
670  * test_glist_nothing_return2:
671  *
672  * Return value: (element-type utf8) (transfer none):
673  */
674 GList *test_glist_nothing_return2 (void)
675 {
676   return test_sequence_list ();
677 }
678
679 /**
680  * test_glist_container_return:
681  *
682  * Return value: (element-type utf8) (transfer container):
683  */
684 GList *test_glist_container_return (void)
685 {
686   return g_list_copy (test_sequence_list ());
687 }
688
689 /**
690  * test_glist_everything_return:
691  *
692  * Return value: (element-type utf8) (transfer full):
693  */
694 GList *test_glist_everything_return (void)
695 {
696   GList *list;
697   GList *l;
698
699   list = g_list_copy (test_sequence_list ());
700   for (l = list; l != NULL; l = l->next)
701       l->data = g_strdup (l->data);
702   return list;
703 }
704
705 static void assert_test_sequence_list (const GList *in)
706 {
707   const GList *l;
708   gsize i;
709
710   for (i = 0, l = in; l != NULL; ++i, l = l->next) {
711       g_assert (i < G_N_ELEMENTS(test_sequence));
712       g_assert (strcmp (l->data, test_sequence[i]) == 0);
713   }
714   g_assert (i == G_N_ELEMENTS(test_sequence));
715 }
716
717 /**
718  * test_glist_nothing_in:
719  * @in: (element-type utf8):
720  */
721 void test_glist_nothing_in (const GList *in)
722 {
723   assert_test_sequence_list (in);
724 }
725
726 /**
727  * test_glist_nothing_in2:
728  * @in: (element-type utf8):
729  */
730 void test_glist_nothing_in2 (GList *in)
731 {
732   assert_test_sequence_list (in);
733 }
734
735 /**
736  * test_glist_container_in:
737  * @in: (element-type utf8) (transfer container):
738  */
739 void test_glist_container_in (GList *in)
740 {
741   assert_test_sequence_list (in);
742   g_list_free (in);
743 }
744
745 /**
746  * test_glist_everything_in:
747  * @in: (element-type utf8) (transfer full):
748  */
749 void test_glist_everything_in (GList *in)
750 {
751   assert_test_sequence_list (in);
752   test_glist_free (in);
753 }
754
755 /************************************************************************/
756 /* GSList */
757
758 static /*const*/ GSList *test_sequence_slist()
759 {
760     static GSList *list = NULL;
761     if (!list) {
762         gsize i;
763         for (i = 0; i < G_N_ELEMENTS(test_sequence); ++i) {
764             list = g_slist_prepend (list, (gpointer)test_sequence[i]);
765         }
766         list = g_slist_reverse (list);
767     }
768     return list;
769 }
770
771 /**
772  * test_gslist_free:
773  * @in: (element-type utf8) (transfer full):
774  */
775 void test_gslist_free (GSList *in)
776 {
777   g_slist_foreach (in, (GFunc)g_free, NULL);
778   g_slist_free (in);
779 }
780
781 /**
782  * test_gslist_nothing_return:
783  *
784  * Return value: (element-type utf8) (transfer none):
785  */
786 G_CONST_RETURN GSList *test_gslist_nothing_return (void)
787 {
788   return test_sequence_slist ();
789 }
790
791 /**
792  * test_gslist_nothing_return2:
793  *
794  * Return value: (element-type utf8) (transfer none):
795  */
796 GSList *test_gslist_nothing_return2 (void)
797 {
798   return test_sequence_slist ();
799 }
800
801 /**
802  * test_gslist_container_return:
803  *
804  * Return value: (element-type utf8) (transfer container):
805  */
806 GSList *test_gslist_container_return (void)
807 {
808   return g_slist_copy (test_sequence_slist ());
809 }
810
811 /**
812  * test_gslist_everything_return:
813  *
814  * Return value: (element-type utf8) (transfer full):
815  */
816 GSList *test_gslist_everything_return (void)
817 {
818   GSList *list;
819   GSList *l;
820
821   list = g_slist_copy (test_sequence_slist ());
822   for (l = list; l != NULL; l = l->next)
823       l->data = g_strdup (l->data);
824   return list;
825 }
826
827 static void assert_test_sequence_slist (const GSList *in)
828 {
829   const GSList *l;
830   gsize i;
831
832   for (i = 0, l = in; l != NULL; ++i, l = l->next) {
833       g_assert (i < G_N_ELEMENTS(test_sequence));
834       g_assert (strcmp (l->data, test_sequence[i]) == 0);
835   }
836   g_assert (i == G_N_ELEMENTS(test_sequence));
837 }
838
839 /**
840  * test_gslist_nothing_in:
841  * @in: (element-type utf8):
842  */
843 void test_gslist_nothing_in (const GSList *in)
844 {
845   assert_test_sequence_slist (in);
846 }
847
848 /**
849  * test_gslist_nothing_in2:
850  * @in: (element-type utf8):
851  */
852 void test_gslist_nothing_in2 (GSList *in)
853 {
854   assert_test_sequence_slist (in);
855 }
856
857 /**
858  * test_gslist_container_in:
859  * @in: (element-type utf8) (transfer container):
860  */
861 void test_gslist_container_in (GSList *in)
862 {
863   assert_test_sequence_slist (in);
864   g_slist_free (in);
865 }
866
867 /**
868  * test_gslist_everything_in:
869  * @in: (element-type utf8) (transfer full):
870  */
871 void test_gslist_everything_in (GSList *in)
872 {
873   assert_test_sequence_slist (in);
874   test_gslist_free (in);
875 }
876
877 /************************************************************************/
878 /* GHash */
879
880 static char *table_data[3][2] = {
881   { "foo", "bar" }, { "baz", "bat" }, { "qux", "quux" }
882 };
883
884 static GHashTable *test_table_ghash_new_container()
885 {
886   GHashTable *hash;
887   int i;
888   hash = g_hash_table_new(g_str_hash, g_str_equal);
889   for (i=0; i<3; i++)
890     g_hash_table_insert(hash, table_data[i][0], table_data[i][1]);
891   return hash;
892 }
893
894 static GHashTable *test_table_ghash_new_full()
895 {
896   GHashTable *hash;
897   int i;
898   hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
899   for (i=0; i<3; i++)
900     g_hash_table_insert(hash,
901                         g_strdup(table_data[i][0]),
902                         g_strdup(table_data[i][1]));
903   return hash;
904 }
905
906 static /*const*/ GHashTable *test_table_ghash_const()
907 {
908   static GHashTable *hash = NULL;
909   if (!hash) {
910     hash = test_table_ghash_new_container();
911   }
912   return hash;
913 }
914
915 /**
916  * test_ghash_free:
917  * @in: (transfer full) (element-type utf8 utf8)
918  */
919 void test_ghash_free (GHashTable *in)
920 {
921   /* keys and values are deleted iff an appropriate element destroy function
922    * was registered */
923   g_hash_table_unref(in);
924 }
925
926 /**
927  * test_ghash_null_return:
928  *
929  * Return value: (element-type utf8 utf8) (transfer none) (allow-none):
930  */
931 G_CONST_RETURN GHashTable *test_ghash_null_return (void)
932 {
933   return NULL;
934 }
935
936 /**
937  * test_ghash_nothing_return:
938  *
939  * Return value: (element-type utf8 utf8) (transfer none):
940  */
941 G_CONST_RETURN GHashTable *test_ghash_nothing_return (void)
942 {
943   return test_table_ghash_const ();
944 }
945
946 /**
947  * test_ghash_nothing_return2:
948  *
949  * Return value: (element-type utf8 utf8) (transfer none):
950  */
951 GHashTable *test_ghash_nothing_return2 (void)
952 {
953   return test_table_ghash_const ();
954 }
955
956 /**
957  * test_ghash_container_return:
958  *
959  * Return value: (element-type utf8 utf8) (transfer container):
960  */
961 GHashTable *test_ghash_container_return (void)
962 {
963   return test_table_ghash_new_container ();
964 }
965
966 /**
967  * test_ghash_everything_return:
968  *
969  * Return value: (element-type utf8 utf8) (transfer full):
970  */
971 GHashTable *test_ghash_everything_return (void)
972 {
973   return test_table_ghash_new_full ();
974 }
975
976 static void assert_test_table_ghash (const GHashTable *in)
977 {
978   GHashTable *h = test_table_ghash_const();
979   GHashTableIter iter;
980   gpointer key, value;
981
982   g_assert(g_hash_table_size(h) ==
983            g_hash_table_size((GHashTable*)in));
984
985   g_hash_table_iter_init(&iter, (GHashTable*)in);
986   while (g_hash_table_iter_next (&iter, &key, &value))
987     g_assert( strcmp(g_hash_table_lookup(h, (char*)key), (char*)value) == 0);
988 }
989
990 /**
991  * test_ghash_null_in:
992  * @in: (element-type utf8 utf8) (allow-none):
993  */
994 void test_ghash_null_in (const GHashTable *in)
995 {
996   g_assert (in == NULL);
997 }
998
999 /**
1000  * test_ghash_nothing_in:
1001  * @in: (element-type utf8 utf8):
1002  */
1003 void test_ghash_nothing_in (const GHashTable *in)
1004 {
1005   assert_test_table_ghash (in);
1006 }
1007
1008 /**
1009  * test_ghash_nothing_in2:
1010  * @in: (element-type utf8 utf8):
1011  */
1012 void test_ghash_nothing_in2 (GHashTable *in)
1013 {
1014   assert_test_table_ghash (in);
1015 }
1016
1017 /**
1018  * test_ghash_container_in:
1019  * @in: (transfer container) (element-type utf8 utf8):
1020  */
1021 void test_ghash_container_in (GHashTable *in)
1022 {
1023   assert_test_table_ghash (in);
1024   /* be careful and explicitly steal all the elements from the ghash before
1025    * freeing it. */
1026   g_hash_table_steal_all (in);
1027   g_hash_table_destroy (in);
1028 }
1029
1030 static gboolean ghash_freer(gpointer key, gpointer value, gpointer user_data) {
1031   g_free(key);
1032   g_free(value);
1033   return TRUE;
1034 }
1035
1036 /**
1037  * test_ghash_everything_in:
1038  * @in: (transfer full) (element-type utf8 utf8):
1039  */
1040 void test_ghash_everything_in (GHashTable *in)
1041 {
1042   assert_test_table_ghash (in);
1043   /* free the elements, then free the container.  Don't rely on the
1044    * GHashTable's key/value destructor functions. */
1045   g_hash_table_foreach_steal (in, ghash_freer, NULL);
1046   /* okay, dealloc the hash table. */
1047   g_hash_table_destroy (in);
1048 }
1049
1050 /* Nested collection types */
1051
1052 /**
1053  * test_ghash_nested_everything_return:
1054  * Specify nested parameterized types directly with the (type ) annotation.
1055  *
1056  * Return value: (type GLib.HashTable<utf8,GLib.HashTable<utf8,utf8>>) (transfer full):
1057  */
1058 GHashTable *
1059 test_ghash_nested_everything_return (void)
1060 {
1061   GHashTable *hash;
1062   hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
1063                                (void (*) (gpointer)) g_hash_table_destroy);
1064   g_hash_table_insert(hash, g_strdup("wibble"), test_table_ghash_new_full());
1065   return hash;
1066 }
1067
1068 /**
1069  * test_ghash_nested_everything_return2:
1070  * Another way of specifying nested parameterized types: using the
1071  * element-type annotation.
1072  *
1073  * Return value: (element-type utf8 GLib.HashTable<utf8,utf8>) (transfer full):
1074  */
1075 GHashTable *
1076 test_ghash_nested_everything_return2 (void)
1077 {
1078   return test_ghash_nested_everything_return();
1079 }
1080
1081 /************************************************************************/
1082
1083 /* error? */
1084
1085 /* enums / flags */
1086
1087 GType
1088 test_enum_get_type (void)
1089 {
1090     static GType etype = 0;
1091     if (G_UNLIKELY(etype == 0)) {
1092         static const GEnumValue values[] = {
1093             { TEST_VALUE1, "TEST_VALUE1", "value1" },
1094             { TEST_VALUE2, "TEST_VALUE2", "value2" },
1095             { TEST_VALUE3, "TEST_VALUE3", "value3" },
1096             { 0, NULL, NULL }
1097         };
1098         etype = g_enum_register_static (g_intern_static_string ("TestEnum"), values);
1099     }
1100
1101     return etype;
1102 }
1103
1104 GType
1105 test_flags_get_type (void)
1106 {
1107     static GType etype = 0;
1108     if (G_UNLIKELY(etype == 0)) {
1109         static const GFlagsValue values[] = {
1110             { TEST_FLAG1, "TEST_FLAG1", "flag1" },
1111             { TEST_FLAG2, "TEST_FLAG2", "flag2" },
1112             { TEST_FLAG3, "TEST_FLAG3", "flag3" },
1113             { 0, NULL, NULL }
1114         };
1115         etype = g_flags_register_static (g_intern_static_string ("TestFlags"), values);
1116     }
1117
1118     return etype;
1119 }
1120
1121 const gchar *
1122 test_enum_param(TestEnum e)
1123 {
1124   GEnumValue *ev;
1125   GEnumClass *ec;
1126
1127   ec = g_type_class_ref (test_enum_get_type ());
1128   ev = g_enum_get_value (ec, e);
1129   g_type_class_unref (ec);
1130
1131   return ev->value_nick;
1132 }
1133
1134 /* structures */
1135
1136 /**
1137  * test_struct_a_clone:
1138  * @a: the structure
1139  * @a_out: the cloned structure
1140  *
1141  * Make a copy of a TestStructA
1142  */
1143 void
1144 test_struct_a_clone (TestStructA *a,
1145                      TestStructA *a_out)
1146 {
1147   *a_out = *a;
1148 }
1149
1150 /**
1151  * test_struct_b_clone:
1152  * @b: the structure
1153  * @b_out: the cloned structure
1154  *
1155  * Make a copy of a TestStructB
1156  */
1157 void
1158 test_struct_b_clone (TestStructB *b,
1159                      TestStructB *b_out)
1160 {
1161   *b_out = *b;
1162 }
1163
1164 /* plain-old-data boxed types */
1165
1166 TestSimpleBoxedA *
1167 test_simple_boxed_a_copy (TestSimpleBoxedA *a)
1168 {
1169   TestSimpleBoxedA *new_a = g_slice_new (TestSimpleBoxedA);
1170
1171   *new_a = *a;
1172
1173   return new_a;
1174 }
1175
1176 static void
1177 test_simple_boxed_a_free (TestSimpleBoxedA *a)
1178 {
1179   g_slice_free (TestSimpleBoxedA, a);
1180 }
1181
1182 GType
1183 test_simple_boxed_a_get_type (void)
1184 {
1185   static GType our_type = 0;
1186
1187   if (our_type == 0)
1188     our_type = g_boxed_type_register_static (g_intern_static_string ("TestSimpleBoxedA"),
1189                                              (GBoxedCopyFunc)test_simple_boxed_a_copy,
1190                                              (GBoxedFreeFunc)test_simple_boxed_a_free);
1191   return our_type;
1192 }
1193
1194 TestSimpleBoxedB *
1195 test_simple_boxed_b_copy (TestSimpleBoxedB *b)
1196 {
1197   TestSimpleBoxedB *new_b = g_slice_new (TestSimpleBoxedB);
1198
1199   *new_b = *b;
1200
1201   return new_b;
1202 }
1203
1204 gboolean
1205 test_simple_boxed_a_equals (TestSimpleBoxedA *a,
1206                             TestSimpleBoxedA *other_a)
1207 {
1208   return (a->some_int == other_a->some_int &&
1209           a->some_int8 == other_a->some_int8 &&
1210           a->some_double == other_a->some_double);
1211 }
1212
1213 const TestSimpleBoxedA*
1214 test_simple_boxed_a_const_return (void)
1215 {
1216   static TestSimpleBoxedA simple_a = {
1217     5, 6, 7.0
1218   };
1219
1220   return &simple_a;
1221 }
1222
1223 static void
1224 test_simple_boxed_b_free (TestSimpleBoxedB *a)
1225 {
1226   g_slice_free (TestSimpleBoxedB, a);
1227 }
1228
1229 GType
1230 test_simple_boxed_b_get_type (void)
1231 {
1232   static GType our_type = 0;
1233
1234   if (our_type == 0)
1235     our_type = g_boxed_type_register_static (g_intern_static_string ("TestSimpleBoxedB"),
1236                                              (GBoxedCopyFunc)test_simple_boxed_b_copy,
1237                                              (GBoxedFreeFunc)test_simple_boxed_b_free);
1238   return our_type;
1239 }
1240
1241 /* opaque boxed */
1242
1243 struct _TestBoxedPrivate
1244 {
1245   guint magic;
1246 };
1247
1248 TestBoxed *
1249 test_boxed_new (void)
1250 {
1251   TestBoxed *boxed = g_slice_new0(TestBoxed);
1252   boxed->priv = g_slice_new0(TestBoxedPrivate);
1253   boxed->priv->magic = 0xdeadbeef;
1254
1255   return boxed;
1256 }
1257
1258 TestBoxed *
1259 test_boxed_copy (TestBoxed *boxed)
1260 {
1261   TestBoxed *new_boxed = test_boxed_new();
1262   TestBoxedPrivate *save;
1263
1264   save = new_boxed->priv;
1265   *new_boxed = *boxed;
1266   new_boxed->priv = save;
1267
1268   return new_boxed;
1269 }
1270
1271 gboolean
1272 test_boxed_equals (TestBoxed *boxed,
1273                    TestBoxed *other)
1274 {
1275   return (other->some_int8 == boxed->some_int8 &&
1276           test_simple_boxed_a_equals(&other->nested_a, &boxed->nested_a));
1277 }
1278
1279 static void
1280 test_boxed_free (TestBoxed *boxed)
1281 {
1282   g_assert (boxed->priv->magic == 0xdeadbeef);
1283
1284   g_slice_free (TestBoxedPrivate, boxed->priv);
1285   g_slice_free (TestBoxed, boxed);
1286 }
1287
1288 GType
1289 test_boxed_get_type (void)
1290 {
1291   static GType our_type = 0;
1292
1293   if (our_type == 0)
1294     our_type = g_boxed_type_register_static (g_intern_static_string ("TestBoxed"),
1295                                              (GBoxedCopyFunc)test_boxed_copy,
1296                                              (GBoxedFreeFunc)test_boxed_free);
1297   return our_type;
1298 }
1299
1300 G_DEFINE_TYPE(TestObj, test_obj, G_TYPE_OBJECT);
1301
1302 enum
1303 {
1304   PROP_TEST_OBJ_BARE = 1,
1305   PROP_TEST_OBJ_BOXED
1306 };
1307
1308 static void
1309 test_obj_set_property (GObject      *object,
1310                        guint         property_id,
1311                        const GValue *value,
1312                        GParamSpec   *pspec)
1313 {
1314   TestObj *self = TEST_OBJECT (object);
1315
1316   switch (property_id)
1317     {
1318     case PROP_TEST_OBJ_BARE:
1319       test_obj_set_bare (self, g_value_get_object (value));
1320       break;
1321
1322     case PROP_TEST_OBJ_BOXED:
1323       if (self->boxed)
1324         test_boxed_free (self->boxed);
1325       self->boxed = g_value_dup_boxed (value);
1326       break;
1327       
1328     default:
1329       /* We don't have any other property... */
1330       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1331       break;
1332     }
1333 }
1334
1335 static void
1336 test_obj_get_property (GObject    *object,
1337                         guint       property_id,
1338                         GValue     *value,
1339                         GParamSpec *pspec)
1340 {
1341   TestObj *self = TEST_OBJECT (object);
1342
1343   switch (property_id)
1344     {
1345     case PROP_TEST_OBJ_BARE:
1346       g_value_set_object (value, self->bare);
1347       break;
1348
1349     case PROP_TEST_OBJ_BOXED:
1350       g_value_set_boxed (value, self->boxed);
1351       break;
1352       
1353     default:
1354       /* We don't have any other property... */
1355       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1356       break;
1357     }
1358 }
1359
1360 static void
1361 test_obj_dispose (GObject *gobject)
1362 {
1363   TestObj *self = TEST_OBJECT (gobject);
1364
1365   if (self->bare)
1366     {
1367       g_object_unref (self->bare);
1368
1369       self->bare = NULL;
1370     }
1371
1372   if (self->boxed)
1373     {
1374       test_boxed_free (self->boxed);
1375       self->boxed = NULL;
1376     }
1377   
1378   /* Chain up to the parent class */
1379   G_OBJECT_CLASS (test_obj_parent_class)->dispose (gobject);
1380 }
1381
1382 static int
1383 test_obj_default_matrix (TestObj *obj, const char *somestr)
1384 {
1385   return 42;
1386 }
1387
1388 static void
1389 test_obj_class_init (TestObjClass *klass)
1390 {
1391   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
1392   GParamSpec *pspec;
1393   GType param_types[1];
1394
1395   klass->test_signal =
1396     g_signal_newv ("test",
1397                    G_TYPE_FROM_CLASS (gobject_class),
1398                    G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
1399                    NULL /* closure */,
1400                    NULL /* accumulator */,
1401                    NULL /* accumulator data */,
1402                    g_cclosure_marshal_VOID__VOID,
1403                    G_TYPE_NONE /* return_type */,
1404                    0     /* n_params */,
1405                    NULL  /* param_types */);
1406
1407   param_types[0] = test_simple_boxed_a_get_type() | G_SIGNAL_TYPE_STATIC_SCOPE;
1408   klass->test_signal_with_static_scope_arg =
1409     g_signal_newv ("test-with-static-scope-arg",
1410                    G_TYPE_FROM_CLASS (gobject_class),
1411                    G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
1412                    NULL /* closure */,
1413                    NULL /* accumulator */,
1414                    NULL /* accumulator data */,
1415                    g_cclosure_marshal_VOID__BOXED,
1416                    G_TYPE_NONE /* return_type */,
1417                    1     /* n_params */,
1418                    param_types);
1419
1420   gobject_class->set_property = test_obj_set_property;
1421   gobject_class->get_property = test_obj_get_property;
1422   gobject_class->dispose = test_obj_dispose;
1423
1424   pspec = g_param_spec_object ("bare",
1425                                "Bare property",
1426                                "A contained object",
1427                                G_TYPE_OBJECT,
1428                                G_PARAM_READWRITE);
1429   g_object_class_install_property (gobject_class,
1430                                    PROP_TEST_OBJ_BARE,
1431                                    pspec);
1432
1433   pspec = g_param_spec_boxed ("boxed",
1434                               "Boxed property",
1435                               "A contained boxed struct",
1436                               TEST_TYPE_BOXED,
1437                               G_PARAM_READWRITE);
1438   g_object_class_install_property (gobject_class,
1439                                    PROP_TEST_OBJ_BOXED,
1440                                    pspec);
1441   
1442   klass->matrix = test_obj_default_matrix;
1443 }
1444
1445 static void
1446 test_obj_init (TestObj *obj)
1447 {
1448   obj->bare = NULL;
1449   obj->boxed = NULL;
1450 }
1451
1452 TestObj *
1453 test_obj_new_from_file (const char *x, GError **error)
1454 {
1455   return g_object_new (TEST_TYPE_OBJ, NULL);
1456 }
1457
1458 /**
1459  * test_obj_set_bare:
1460  * @bare: (allow-none):
1461  */
1462 void
1463 test_obj_set_bare (TestObj *obj, GObject *bare)
1464 {
1465   if (obj->bare)
1466     g_object_unref (obj->bare);
1467   obj->bare = bare;
1468   if (obj->bare)
1469     g_object_ref (obj->bare);
1470 }
1471
1472 int
1473 test_obj_instance_method (TestObj *obj)
1474 {
1475     return -1;
1476 }
1477
1478 double
1479 test_obj_static_method (int x)
1480 {
1481   return x;
1482 }
1483
1484 /**
1485  * test_obj_do_matrix:
1486  * @obj: A #TestObj
1487  * @somestr: Meaningless string
1488  *
1489  * This method is virtual.  Notably its name differs from the virtual
1490  * slot name, which makes it useful for testing bindings handle this
1491  * case.
1492  *
1493  * Virtual: matrix
1494  */
1495 int
1496 test_obj_do_matrix (TestObj *obj, const char *somestr)
1497 {
1498   return TEST_OBJ_GET_CLASS (obj)->matrix (obj, somestr);
1499 }
1500
1501 typedef struct _CallbackInfo CallbackInfo;
1502
1503 struct _CallbackInfo
1504 {
1505   TestCallbackUserData callback;
1506   GDestroyNotify notify;
1507   gpointer user_data;
1508 };
1509
1510
1511 G_DEFINE_TYPE(TestSubObj, test_sub_obj, TEST_TYPE_OBJ);
1512
1513 static void
1514 test_sub_obj_class_init (TestSubObjClass *klass)
1515 {
1516 }
1517
1518 static void
1519 test_sub_obj_init (TestSubObj *obj)
1520 {
1521 }
1522
1523 TestSubObj*
1524 test_sub_obj_new ()
1525 {
1526   return g_object_new (TEST_TYPE_SUB_OBJ, NULL);
1527 }
1528
1529 int
1530 test_sub_obj_instance_method (TestSubObj *obj)
1531 {
1532     return 0;
1533 }
1534
1535 void
1536 test_sub_obj_unset_bare (TestSubObj *obj)
1537 {
1538   test_obj_set_bare(TEST_OBJECT(obj), NULL);
1539 }
1540
1541
1542 /**
1543  * test_callback:
1544  * @callback: (scope call) (allow-none):
1545  *
1546  **/
1547 int
1548 test_callback (TestCallback callback)
1549 {
1550     if (callback != NULL)
1551         return callback();
1552     return 0;
1553 }
1554
1555 /**
1556  * test_callback_user_data:
1557  * @callback: (scope call):
1558  *
1559  * Call - callback parameter persists for the duration of the method
1560  * call and can be released on return.
1561  **/
1562 int
1563 test_callback_user_data (TestCallbackUserData callback,
1564                          gpointer user_data)
1565 {
1566   return callback(user_data);
1567 }
1568
1569 static GSList *notified_callbacks = NULL;
1570
1571 /**
1572  * test_callback_destroy_notify:
1573  * @callback: (scope notified):
1574  *
1575  * Notified - callback persists until a DestroyNotify delegate
1576  * is invoked.
1577  **/
1578 int
1579 test_callback_destroy_notify (TestCallbackUserData callback,
1580                               gpointer user_data,
1581                               GDestroyNotify notify)
1582 {
1583   int retval;
1584   CallbackInfo *info;
1585
1586   retval = callback(user_data);
1587
1588   info = g_slice_new(CallbackInfo);
1589   info->callback = callback;
1590   info->notify = notify;
1591   info->user_data = user_data;
1592
1593   notified_callbacks = g_slist_prepend(notified_callbacks, info);
1594
1595   return retval;
1596 }
1597
1598 /**
1599  * test_callback_thaw_notifications:
1600  *
1601  * Invokes all callbacks installed by #test_callback_destroy_notify(),
1602  * adding up their return values, and removes them, invoking the
1603  * corresponding destroy notfications.
1604  *
1605  * Return value: Sum of the return values of the invoked callbacks.
1606  */
1607 int
1608 test_callback_thaw_notifications (void)
1609 {
1610   int retval = 0;
1611   GSList *node;
1612
1613   for (node = notified_callbacks; node != NULL; node = node->next)
1614     {
1615       CallbackInfo *info = node->data;
1616       retval += info->callback (info->user_data);
1617       if (info->notify)
1618         info->notify (info->user_data);
1619       g_slice_free (CallbackInfo, info);
1620     }
1621
1622   g_slist_free (notified_callbacks);
1623   notified_callbacks = NULL;
1624
1625   return retval;
1626 }
1627
1628 static GSList *async_callbacks = NULL;
1629
1630 /**
1631  * test_callback_async:
1632  * @callback: (scope async):
1633  *
1634  **/
1635 void
1636 test_callback_async (TestCallbackUserData callback,
1637                      gpointer user_data)
1638 {
1639   CallbackInfo *info;
1640
1641   info = g_slice_new(CallbackInfo);
1642   info->callback = callback;
1643   info->user_data = user_data;
1644
1645   async_callbacks = g_slist_prepend(async_callbacks, info);
1646 }
1647
1648 /**
1649  * test_callback_thaw_async:
1650  */
1651 int
1652 test_callback_thaw_async (void)
1653 {
1654   int retval = 0;
1655   GSList *node;
1656
1657   for (node = async_callbacks; node != NULL; node = node->next)
1658     {
1659       CallbackInfo *info = node->data;
1660       retval = info->callback (info->user_data);
1661       g_slice_free (CallbackInfo, info);
1662     }
1663
1664   g_slist_free (async_callbacks);
1665   async_callbacks = NULL;
1666   return retval;
1667 }
1668
1669 /**
1670  * test_callback_infinite:
1671  * @callback: (scope infinite):
1672  *
1673  * Infinite - callback persists forever.
1674  **/
1675
1676 static GSList *infinite_callbacks = NULL;
1677
1678 int
1679 test_callback_infinite (TestCallbackUserData callback,
1680                        gpointer user_data)
1681 {
1682   infinite_callbacks = g_slist_prepend(infinite_callbacks, callback);
1683
1684   return callback(user_data);
1685 }
1686
1687 /* interface */
1688
1689 static void
1690 test_interface_class_init(void *g_iface)
1691 {
1692 }
1693
1694 GType
1695 test_interface_get_type(void)
1696 {
1697     static GType type = 0;
1698     if (type == 0) {
1699         type = g_type_register_static_simple (G_TYPE_INTERFACE,
1700                                               "EverythingTestInterface",
1701                                               sizeof (TestInterfaceIface),
1702                                               (GClassInitFunc) test_interface_class_init,
1703                                               0, NULL, 0);
1704     }
1705
1706     return type;
1707 }
1708
1709 /* gobject with non-standard prefix */
1710 G_DEFINE_TYPE(TestWi8021x, test_wi_802_1x, G_TYPE_OBJECT);
1711
1712 enum
1713 {
1714   PROP_TEST_WI_802_1X_TESTBOOL = 1
1715 };
1716
1717 static void
1718 test_wi_802_1x_set_property (GObject      *object,
1719                              guint         property_id,
1720                              const GValue *value,
1721                              GParamSpec   *pspec)
1722 {
1723   TestWi8021x *self = TEST_WI_802_1X (object);
1724
1725   switch (property_id)
1726     {
1727     case PROP_TEST_WI_802_1X_TESTBOOL:
1728       test_wi_802_1x_set_testbool (self, g_value_get_boolean (value));
1729       break;
1730
1731     default:
1732       /* We don't have any other property... */
1733       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1734       break;
1735     }
1736 }
1737
1738 static void
1739 test_wi_802_1x_get_property (GObject    *object,
1740                         guint       property_id,
1741                         GValue     *value,
1742                         GParamSpec *pspec)
1743 {
1744   TestWi8021x *self = TEST_WI_802_1X (object);
1745
1746   switch (property_id)
1747     {
1748     case PROP_TEST_WI_802_1X_TESTBOOL:
1749       g_value_set_boolean (value, test_wi_802_1x_get_testbool (self));
1750       break;
1751
1752     default:
1753       /* We don't have any other property... */
1754       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1755       break;
1756     }
1757 }
1758
1759 static void
1760 test_wi_802_1x_dispose (GObject *gobject)
1761 {
1762   /* Chain up to the parent class */
1763   G_OBJECT_CLASS (test_wi_802_1x_parent_class)->dispose (gobject);
1764 }
1765
1766 static void
1767 test_wi_802_1x_class_init (TestWi8021xClass *klass)
1768 {
1769   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
1770   GParamSpec *pspec;
1771
1772   gobject_class->set_property = test_wi_802_1x_set_property;
1773   gobject_class->get_property = test_wi_802_1x_get_property;
1774   gobject_class->dispose = test_wi_802_1x_dispose;
1775
1776   pspec = g_param_spec_boolean ("testbool",
1777                                 "Nick for testbool",
1778                                 "Blurb for testbool",
1779                                 TRUE,
1780                                 G_PARAM_READWRITE);
1781   g_object_class_install_property (gobject_class,
1782                                    PROP_TEST_WI_802_1X_TESTBOOL,
1783                                    pspec);
1784 }
1785
1786 static void
1787 test_wi_802_1x_init (TestWi8021x *obj)
1788 {
1789   obj->testbool = TRUE;
1790 }
1791
1792 TestWi8021x *
1793 test_wi_802_1x_new (void)
1794 {
1795   return g_object_new (TEST_TYPE_WI_802_1X, NULL);
1796 }
1797
1798 void
1799 test_wi_802_1x_set_testbool (TestWi8021x *obj, gboolean val)
1800 {
1801   obj->testbool = val;
1802 }
1803
1804 gboolean
1805 test_wi_802_1x_get_testbool (TestWi8021x *obj)
1806 {
1807   return obj->testbool;
1808 }
1809
1810 int
1811 test_wi_802_1x_static_method (int x)
1812 {
1813   return 2*x;
1814 }