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