[everything] Add some "torture" test functions with baroque signatures
[gnome.gobject-introspection] / gir / everything.h
1 #ifndef __GITESTTYPES_H__
2 #define __GITESTTYPES_H__
3
4 #include <glib-object.h>
5 #include <time.h>
6
7 /* basic types */
8 gboolean test_boolean (gboolean in);
9 gint8 test_int8 (gint8 in);
10 guint8 test_uint8 (guint8 in);
11 gint16 test_int16 (gint16 in);
12 guint16 test_uint16 (guint16 in);
13 gint32 test_int32 (gint32 in);
14 guint32 test_uint32 (guint32 in);
15 gint64 test_int64 (gint64 in);
16 guint64 test_uint64 (guint64 in);
17 gshort test_short (gshort in);
18 gushort test_ushort (gushort in);
19 gint test_int (gint in);
20 guint test_uint (guint in);
21 glong test_long (glong in);
22 gulong test_ulong (gulong in);
23 gssize test_ssize (gssize in);
24 gsize test_size (gsize in);
25 gfloat test_float (gfloat in);
26 gdouble test_double (gdouble in);
27 time_t test_timet (time_t in);
28 GType test_gtype (GType in);
29
30 /* utf8 */
31 G_CONST_RETURN char *test_utf8_const_return (void);
32 char *test_utf8_nonconst_return (void);
33 void test_utf8_nonconst_in (char *in);
34 void test_utf8_const_in (const char *in);
35 void test_utf8_out (char **out);
36 void test_utf8_inout (char **inout);
37 GSList *test_filename_return (void);
38
39 /* in arguments after out arguments */
40 void test_int_out_utf8 (int *length, const char *in);
41
42 /* multiple output arguments */
43 void test_multi_double_args (gdouble in, gdouble *one, gdouble *two);
44 void test_utf8_out_out (char **out0, char **out1);
45 char *test_utf8_out_nonconst_return (char **out);
46
47 /* non-basic-types */
48 /* array */
49 gboolean test_strv_in (char **arr);
50 int test_array_int_in (int n_ints, int *ints);
51 void test_array_int_out (int *n_ints, int **ints);
52 void test_array_int_inout (int *n_ints, int **ints);
53 int test_array_gint8_in (int n_ints, gint8 *ints);
54 int test_array_gint16_in (int n_ints, gint16 *ints);
55 gint32 test_array_gint32_in (int n_ints, gint32 *ints);
56 gint64 test_array_gint64_in (int n_ints, gint64 *ints);
57 char *test_array_gtype_in (int n_types, GType *types);
58 char **test_strv_out_container (void);
59 char **test_strv_out (void);
60 const char * const * test_strv_out_c (void);
61 void   test_strv_outarg (char ***retp);
62 int test_array_fixed_size_int_in (int *ints);
63 void test_array_fixed_size_int_out (int **ints);
64 int *test_array_fixed_size_int_return (void);
65
66 /* transfer tests */
67 int test_array_int_in_take (int n_ints, int *ints);
68 gboolean test_strv_in_container (char **arr);
69
70 int *test_array_int_full_out(int *len);
71 int *test_array_int_none_out(int *len);
72
73 /* interface */
74 /* GList */
75 G_CONST_RETURN GList *test_glist_nothing_return (void);
76 GList *test_glist_nothing_return2 (void);
77 GList *test_glist_container_return (void);
78 GList *test_glist_everything_return (void);
79 void test_glist_nothing_in (const GList *in);
80 void test_glist_nothing_in2 (GList *in);
81 void test_glist_container_in (GList *in);
82 void test_glist_everything_in (GList *in);
83 void test_glist_free (GList *in);
84
85 /* GSList */
86 G_CONST_RETURN GSList *test_gslist_nothing_return (void);
87 GSList *test_gslist_nothing_return2 (void);
88 GSList *test_gslist_container_return (void);
89 GSList *test_gslist_everything_return (void);
90 void test_gslist_nothing_in (const GSList *in);
91 void test_gslist_nothing_in2 (GSList *in);
92 void test_gslist_container_in (GSList *in);
93 void test_gslist_everything_in (GSList *in);
94 void test_gslist_free (GSList *in);
95
96 /* GHashTable */
97 G_CONST_RETURN GHashTable *test_ghash_null_return (void);
98 G_CONST_RETURN GHashTable *test_ghash_nothing_return (void);
99 GHashTable *test_ghash_nothing_return2 (void);
100 GHashTable *test_ghash_container_return (void);
101 GHashTable *test_ghash_everything_return (void);
102 void test_ghash_null_in (const GHashTable *in);
103 void test_ghash_nothing_in (const GHashTable *in);
104 void test_ghash_nothing_in2 (GHashTable *in);
105 void test_ghash_container_in (GHashTable *in);
106 void test_ghash_everything_in (GHashTable *in);
107 void test_ghash_free (GHashTable *in);
108 GHashTable *test_ghash_nested_everything_return (void);
109 GHashTable *test_ghash_nested_everything_return2 (void);
110
111 /* error? */
112
113 /* closure */
114 int test_closure (GClosure *closure);
115 int test_closure_one_arg (GClosure *closure, int arg);
116
117 /* value */
118 int test_int_value_arg(const GValue *v);
119 const GValue *test_value_return(int i);
120
121 /* enums / flags */
122
123 typedef enum
124 {
125   TEST_VALUE1,
126   TEST_VALUE2,
127   TEST_VALUE3 = 42
128 } TestEnum;
129
130 typedef enum
131 {
132   TEST_FLAG1 = 1 << 0,
133   TEST_FLAG2 = 1 << 1,
134   TEST_FLAG3 = 1 << 2,
135 } TestFlags;
136
137 GType test_enum_get_type (void) G_GNUC_CONST;
138 #define TEST_TYPE_ENUM (test_enum_get_type ())
139 GType test_flags_get_type (void) G_GNUC_CONST;
140 #define TES_TYPE_FLAGS (test_flags_get_type ())
141
142 const gchar * test_enum_param(TestEnum e);
143
144 /* structures */
145 typedef struct _TestStructA TestStructA;
146 typedef struct _TestStructB TestStructB;
147
148 struct _TestStructA
149 {
150   gint some_int;
151   gint8 some_int8;
152   gdouble some_double;
153   TestEnum some_enum;
154 };
155
156 void test_struct_a_clone (TestStructA *a,
157                           TestStructA *a_out);
158
159 struct _TestStructB
160 {
161   gint8 some_int8;
162   TestStructA nested_a;
163 };
164
165 void test_struct_b_clone (TestStructB *b,
166                           TestStructB *b_out);
167
168 /* This one has a non-basic member */
169 struct _TestStructC
170 {
171   gint another_int;
172   GObject *obj;
173 };
174
175 /* plain-old-data boxed types */
176 typedef struct _TestSimpleBoxedA TestSimpleBoxedA;
177 typedef struct _TestSimpleBoxedB TestSimpleBoxedB;
178
179 struct _TestSimpleBoxedA
180 {
181   gint some_int;
182   gint8 some_int8;
183   gdouble some_double;
184   TestEnum some_enum;
185 };
186
187 GType                   test_simple_boxed_a_get_type     (void);
188 TestSimpleBoxedA *      test_simple_boxed_a_copy         (TestSimpleBoxedA *a);
189 gboolean                test_simple_boxed_a_equals       (TestSimpleBoxedA *a,
190                                                           TestSimpleBoxedA *other_a);
191 const TestSimpleBoxedA *test_simple_boxed_a_const_return (void);
192
193
194 struct _TestSimpleBoxedB
195 {
196   gint8 some_int8;
197   TestSimpleBoxedA nested_a;
198 };
199
200 GType             test_simple_boxed_b_get_type (void);
201 TestSimpleBoxedB *test_simple_boxed_b_copy     (TestSimpleBoxedB *b);
202
203 /* opaque boxed */
204 #define TEST_TYPE_BOXED (test_boxed_get_type())
205
206 typedef struct _TestBoxed TestBoxed;
207 typedef struct _TestBoxedPrivate TestBoxedPrivate;
208
209 struct _TestBoxed
210 {
211   gint8 some_int8;
212   TestSimpleBoxedA nested_a;
213
214   TestBoxedPrivate *priv;
215 };
216
217 GType      test_boxed_get_type (void);
218 TestBoxed *test_boxed_new      (void);
219 TestBoxed *test_boxed_copy     (TestBoxed *boxed);
220 gboolean   test_boxed_equals   (TestBoxed *boxed,
221                                 TestBoxed *other);
222
223 /* gobject */
224 #define TEST_TYPE_OBJ              (test_obj_get_type ())
225 #define TEST_OBJECT(object)        (G_TYPE_CHECK_INSTANCE_CAST ((object), TEST_TYPE_OBJ, TestObj))
226 #define TEST_IS_OBJECT(object)     (G_TYPE_CHECK_INSTANCE_TYPE ((object), TEST_TYPE_OBJ))
227 #define TEST_OBJ_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_OBJ, TestObjClass))
228
229 typedef struct _TestObj          TestObj;
230 typedef struct _TestObjClass     TestObjClass;
231
232 /**
233  * TestObj:
234  * @bare: (allow-none):
235  */
236 struct _TestObj
237 {
238   GObject parent_instance;
239
240   GObject *bare;
241   TestBoxed *boxed;
242 };
243
244 struct _TestObjClass
245 {
246   GObjectClass parent_class;
247
248   int (*matrix) (TestObj *obj, const char *somestr);
249
250   guint test_signal;
251   guint test_signal_with_static_scope_arg;
252 };
253
254 GType      test_obj_get_type (void);
255 TestObj*   test_obj_new_from_file (const char *x, GError **error);
256 void       test_obj_set_bare (TestObj *obj, GObject *bare);
257 int        test_obj_instance_method (TestObj *obj);
258 double     test_obj_static_method (int x);
259
260 void test_obj_torture_signature_0 (TestObj    *obj,
261                                    int        x,
262                                    double     *y,
263                                    int        *z,
264                                    const char *foo,
265                                    int        *q,
266                                    guint       m);
267 gboolean test_obj_torture_signature_1 (TestObj    *obj,
268                                        int        x,
269                                        double     *y,
270                                        int        *z,
271                                        const char *foo,
272                                        int        *q,
273                                        guint       m,
274                                        GError    **error);
275
276 /* virtual */
277 int        test_obj_do_matrix (TestObj *obj, const char *somestr);
278
279 /* inheritance */
280 #define TEST_TYPE_SUB_OBJ           (test_sub_obj_get_type ())
281 #define TEST_SUB_OBJECT(object)     (G_TYPE_CHECK_INSTANCE_CAST ((object), TEST_TYPE_SUB_OBJ, TestSubObj))
282 #define TEST_IS_SUB_OBJECT(object)  (G_TYPE_CHECK_INSTANCE_TYPE ((object), TEST_TYPE_SUB_OBJ))
283 #define TEST_SUB_OBJ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_SUB_OBJ, TestSubObjClass))
284
285 typedef struct _TestSubObj         TestSubObj;
286 typedef struct _TestSubObjClass    TestSubObjClass;
287
288 struct _TestSubObj
289 {
290   TestObj parent_instance;
291 };
292
293 struct _TestSubObjClass
294 {
295   TestObjClass parent_class;
296 };
297
298 GType       test_sub_obj_get_type (void);
299 TestSubObj* test_sub_obj_new (void);
300 void        test_sub_obj_unset_bare (TestSubObj *obj);
301 int         test_sub_obj_instance_method (TestSubObj *obj);
302
303 /* callback */
304 typedef int (*TestCallback) ();
305 typedef int (*TestCallbackUserData) (gpointer user_data);
306
307 int test_callback (TestCallback callback);
308 int test_callback_user_data (TestCallbackUserData callback,
309                              gpointer user_data);
310 int test_callback_destroy_notify (TestCallbackUserData callback,
311                                   gpointer user_data,
312                                   GDestroyNotify notify);
313 int test_callback_thaw_notifications (void);
314
315 void test_callback_async (TestCallbackUserData callback, gpointer user_data);
316 int test_callback_thaw_async (void);
317
318 int test_callback_infinite (TestCallbackUserData callback,
319                            gpointer user_data);
320
321 /* interface */
322 #define TEST_TYPE_INTERFACE              (test_interface_get_type ())
323 #define TEST_INTERFACE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), TEST_TYPE_INTERFACE, TestInterface))
324 #define TEST_IS_INTERFACE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), TEST_TYPE_INTERFACE))
325 #define TEST_INTERFACE_GET_IFACE(obj)    (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TEST_TYPE_INTERFACE, TestInterfaceIface))
326
327 typedef struct _TestInterfaceIface TestInterfaceIface;
328
329 struct _TestInterfaceIface {
330     GTypeInterface base_iface;
331 };
332
333 GType test_interface_get_type (void) G_GNUC_CONST;
334
335 /* gobject with non-standard prefix */
336 #define TEST_TYPE_WI_802_1X              (test_wi_802_1x_get_type ())
337 #define TEST_WI_802_1X(object)        (G_TYPE_CHECK_INSTANCE_CAST ((object), TEST_TYPE_WI_802_1X, TestWi8021x))
338 #define TEST_IS_WI_802_1X(object)     (G_TYPE_CHECK_INSTANCE_TYPE ((object), TEST_TYPE_WI_802_1X))
339 #define TEST_WI_802_1X_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_WI_802_1X, TestWi8021xClass))
340
341 typedef struct
342 {
343   GObject parent_instance;
344
345   gboolean testbool;
346 } TestWi8021x;
347
348 typedef struct
349 {
350   GObjectClass parent_class;
351 } TestWi8021xClass;
352
353 GType        test_wi_802_1x_get_type (void);
354 TestWi8021x* test_wi_802_1x_new (void);
355 gboolean     test_wi_802_1x_get_testbool (TestWi8021x *obj);
356 void         test_wi_802_1x_set_testbool (TestWi8021x *obj, gboolean v);
357 int          test_wi_802_1x_static_method (int x);
358
359 /* Function signature torture tests */
360 void test_torture_signature_0 (int        x,
361                                double     *y,
362                                int        *z,
363                                const char *foo,
364                                int        *q,
365                                guint       m);
366 gboolean test_torture_signature_1 (int        x,
367                                    double     *y,
368                                    int        *z,
369                                    const char *foo,
370                                    int        *q,
371                                    guint       m,
372                                    GError    **error);
373 void test_torture_signature_2 (int                  x,
374                                TestCallbackUserData  callback,
375                                gpointer              user_data,
376                                GDestroyNotify        notify,
377                                double               *y,
378                                int                  *z,
379                                const char           *foo,
380                                int                  *q,
381                                guint                 m);
382
383 #endif /* __GITESTTYPES_H__ */