summaryrefslogtreecommitdiff
path: root/gir/everything.h
blob: 97b2c2e7900d0b96681b6585be78a756fedd4d45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
#ifndef __GITESTTYPES_H__
#define __GITESTTYPES_H__

#include <cairo/cairo.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <time.h>

void set_abort_on_error (gboolean abort_on_error);

/* basic types */
gboolean test_boolean (gboolean in);
gboolean test_boolean_true (gboolean in);
gboolean test_boolean_false (gboolean in);
gint8 test_int8 (gint8 in);
guint8 test_uint8 (guint8 in);
gint16 test_int16 (gint16 in);
guint16 test_uint16 (guint16 in);
gint32 test_int32 (gint32 in);
guint32 test_uint32 (guint32 in);
gint64 test_int64 (gint64 in);
guint64 test_uint64 (guint64 in);
gshort test_short (gshort in);
gushort test_ushort (gushort in);
gint test_int (gint in);
guint test_uint (guint in);
glong test_long (glong in);
gulong test_ulong (gulong in);
gssize test_ssize (gssize in);
gsize test_size (gsize in);
gfloat test_float (gfloat in);
gdouble test_double (gdouble in);
time_t test_timet (time_t in);
GType test_gtype (GType in);

/* utf8 */
G_CONST_RETURN char *test_utf8_const_return (void);
char *test_utf8_nonconst_return (void);
void test_utf8_nonconst_in (char *in);
void test_utf8_const_in (const char *in);
void test_utf8_out (char **out);
void test_utf8_inout (char **inout);
GSList *test_filename_return (void);
void test_utf8_null_in (char *in);
void test_utf8_null_out (char **char_out);

/* in arguments after out arguments */
void test_int_out_utf8 (int *length, const char *in);

/* multiple output arguments */
void test_multi_double_args (gdouble in, gdouble *one, gdouble *two);
void test_utf8_out_out (char **out0, char **out1);
char *test_utf8_out_nonconst_return (char **out);

/* non-basic-types */
/* array */
gboolean test_strv_in (char **arr);
int test_array_int_in (int n_ints, int *ints);
void test_array_int_out (int *n_ints, int **ints);
void test_array_int_inout (int *n_ints, int **ints);
int test_array_gint8_in (int n_ints, gint8 *ints);
int test_array_gint16_in (int n_ints, gint16 *ints);
gint32 test_array_gint32_in (int n_ints, gint32 *ints);
gint64 test_array_gint64_in (int n_ints, gint64 *ints);
char *test_array_gtype_in (int n_types, GType *types);
char **test_strv_out_container (void);
char **test_strv_out (void);
const char * const * test_strv_out_c (void);
void   test_strv_outarg (char ***retp);
int test_array_fixed_size_int_in (int *ints);
void test_array_fixed_size_int_out (int **ints);
int *test_array_fixed_size_int_return (void);

/* transfer tests */
int test_array_int_in_take (int n_ints, int *ints);
gboolean test_strv_in_container (char **arr);

int *test_array_int_full_out(int *len);
int *test_array_int_none_out(int *len);
void test_array_int_null_in (int *arr, int len);
void test_array_int_null_out (int **arr, int *len);

/* interface */
/* GList */
G_CONST_RETURN GList *test_glist_nothing_return (void);
GList *test_glist_nothing_return2 (void);
GList *test_glist_container_return (void);
GList *test_glist_everything_return (void);
void test_glist_nothing_in (const GList *in);
void test_glist_nothing_in2 (GList *in);
void test_glist_container_in (GList *in);
void test_glist_everything_in (GList *in);
void test_glist_null_in(GSList *in);
void test_glist_null_out(GSList **out_list);
void test_glist_free (GList *in);

/* GSList */
G_CONST_RETURN GSList *test_gslist_nothing_return (void);
GSList *test_gslist_nothing_return2 (void);
GSList *test_gslist_container_return (void);
GSList *test_gslist_everything_return (void);
void test_gslist_nothing_in (const GSList *in);
void test_gslist_nothing_in2 (GSList *in);
void test_gslist_container_in (GSList *in);
void test_gslist_everything_in (GSList *in);
void test_gslist_null_in(GSList *in);
void test_gslist_null_out(GSList **out_list);
void test_gslist_free (GSList *in);

/* GHashTable */
G_CONST_RETURN GHashTable *test_ghash_null_return (void);
G_CONST_RETURN GHashTable *test_ghash_nothing_return (void);
GHashTable *test_ghash_nothing_return2 (void);
GHashTable *test_ghash_container_return (void);
GHashTable *test_ghash_everything_return (void);
void test_ghash_null_in (const GHashTable *in);
void test_ghash_null_out (const GHashTable **out);
void test_ghash_nothing_in (const GHashTable *in);
void test_ghash_nothing_in2 (GHashTable *in);
void test_ghash_container_in (GHashTable *in);
void test_ghash_everything_in (GHashTable *in);
void test_ghash_free (GHashTable *in);
GHashTable *test_ghash_nested_everything_return (void);
GHashTable *test_ghash_nested_everything_return2 (void);

/* error? */

/* closure */
int test_closure (GClosure *closure);
int test_closure_one_arg (GClosure *closure, int arg);

/* value */
int test_int_value_arg(const GValue *v);
const GValue *test_value_return(int i);

/* foreign structs */
cairo_t *test_cairo_context_full_return (void);
void test_cairo_context_none_in (cairo_t *context);

cairo_surface_t *test_cairo_surface_none_return (void);
cairo_surface_t *test_cairo_surface_full_return (void);
void test_cairo_surface_none_in (cairo_surface_t *surface);
void test_cairo_surface_full_out (cairo_surface_t **surface);


/* enums / flags */

typedef enum
{
  TEST_VALUE1,
  TEST_VALUE2,
  TEST_VALUE3 = 42
} TestEnum;

typedef enum
{
  TEST_FLAG1 = 1 << 0,
  TEST_FLAG2 = 1 << 1,
  TEST_FLAG3 = 1 << 2,
} TestFlags;

GType test_enum_get_type (void) G_GNUC_CONST;
#define TEST_TYPE_ENUM (test_enum_get_type ())
GType test_flags_get_type (void) G_GNUC_CONST;
#define TES_TYPE_FLAGS (test_flags_get_type ())

const gchar * test_enum_param(TestEnum e);

/* structures */
typedef struct _TestStructA TestStructA;
typedef struct _TestStructB TestStructB;

struct _TestStructA
{
  gint some_int;
  gint8 some_int8;
  gdouble some_double;
  TestEnum some_enum;
};

void test_struct_a_clone (TestStructA *a,
			  TestStructA *a_out);

struct _TestStructB
{
  gint8 some_int8;
  TestStructA nested_a;
};

void test_struct_b_clone (TestStructB *b,
			  TestStructB *b_out);

/* This one has a non-basic member */
struct _TestStructC
{
  gint another_int;
  GObject *obj;
};

/* plain-old-data boxed types */
typedef struct _TestSimpleBoxedA TestSimpleBoxedA;
typedef struct _TestSimpleBoxedB TestSimpleBoxedB;

struct _TestSimpleBoxedA
{
  gint some_int;
  gint8 some_int8;
  gdouble some_double;
  TestEnum some_enum;
};

GType                   test_simple_boxed_a_get_type     (void);
TestSimpleBoxedA *      test_simple_boxed_a_copy         (TestSimpleBoxedA *a);
gboolean                test_simple_boxed_a_equals       (TestSimpleBoxedA *a,
                                                          TestSimpleBoxedA *other_a);
const TestSimpleBoxedA *test_simple_boxed_a_const_return (void);


struct _TestSimpleBoxedB
{
  gint8 some_int8;
  TestSimpleBoxedA nested_a;
};

GType             test_simple_boxed_b_get_type (void);
TestSimpleBoxedB *test_simple_boxed_b_copy     (TestSimpleBoxedB *b);

/* opaque boxed */
#define TEST_TYPE_BOXED (test_boxed_get_type())

typedef struct _TestBoxed TestBoxed;
typedef struct _TestBoxedPrivate TestBoxedPrivate;

struct _TestBoxed
{
  gint8 some_int8;
  TestSimpleBoxedA nested_a;

  TestBoxedPrivate *priv;
};

GType      test_boxed_get_type (void);
TestBoxed *test_boxed_new      (void);
TestBoxed *test_boxed_new_alternative_constructor1  (int i);
TestBoxed *test_boxed_new_alternative_constructor2  (int i, int j);
TestBoxed *test_boxed_new_alternative_constructor3  (char *s);

TestBoxed *test_boxed_copy     (TestBoxed *boxed);
gboolean   test_boxed_equals   (TestBoxed *boxed,
				TestBoxed *other);

/* gobject */
#define TEST_TYPE_OBJ              (test_obj_get_type ())
#define TEST_OBJECT(object)        (G_TYPE_CHECK_INSTANCE_CAST ((object), TEST_TYPE_OBJ, TestObj))
#define TEST_IS_OBJECT(object)     (G_TYPE_CHECK_INSTANCE_TYPE ((object), TEST_TYPE_OBJ))
#define TEST_OBJ_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_OBJ, TestObjClass))

typedef struct _TestObj          TestObj;
typedef struct _TestObjClass     TestObjClass;

/**
 * TestObj:
 * @bare: (allow-none):
 */
struct _TestObj
{
  GObject parent_instance;

  GObject *bare;
  TestBoxed *boxed;
  GHashTable *hash_table;
  GList *list;
  gint8 some_int8;
  float some_float;
  double some_double;
  char* string;
};

struct _TestObjClass
{
  GObjectClass parent_class;

  int (*matrix) (TestObj *obj, const char *somestr);

  guint test_signal;
  guint test_signal_with_static_scope_arg;
};

GType      test_obj_get_type (void);
TestObj*   test_obj_new_from_file (const char *x, GError **error);
void       test_obj_set_bare (TestObj *obj, GObject *bare);
int        test_obj_instance_method (TestObj *obj);
double     test_obj_static_method (int x);

void test_obj_torture_signature_0 (TestObj    *obj,
                                   int        x,
                                   double     *y,
                                   int        *z,
                                   const char *foo,
                                   int        *q,
                                   guint       m);
gboolean test_obj_torture_signature_1 (TestObj    *obj,
                                       int        x,
                                       double     *y,
                                       int        *z,
                                       const char *foo,
                                       int        *q,
                                       guint       m,
                                       GError    **error);

/* virtual */
int        test_obj_do_matrix (TestObj *obj, const char *somestr);

void test_object_null_in (TestObj *obj);
void test_object_null_out (TestObj **obj);

/* inheritance */
#define TEST_TYPE_SUB_OBJ           (test_sub_obj_get_type ())
#define TEST_SUB_OBJECT(object)     (G_TYPE_CHECK_INSTANCE_CAST ((object), TEST_TYPE_SUB_OBJ, TestSubObj))
#define TEST_IS_SUB_OBJECT(object)  (G_TYPE_CHECK_INSTANCE_TYPE ((object), TEST_TYPE_SUB_OBJ))
#define TEST_SUB_OBJ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_SUB_OBJ, TestSubObjClass))

typedef struct _TestSubObj         TestSubObj;
typedef struct _TestSubObjClass    TestSubObjClass;

struct _TestSubObj
{
  TestObj parent_instance;
};

struct _TestSubObjClass
{
  TestObjClass parent_class;
};

GType       test_sub_obj_get_type (void);
TestSubObj* test_sub_obj_new (void);
void        test_sub_obj_unset_bare (TestSubObj *obj);
int         test_sub_obj_instance_method (TestSubObj *obj);

/* fundamental object */
#define TEST_TYPE_FUNDAMENTAL_OBJECT            (test_fundamental_object_get_type())
#define TEST_IS_FUNDAMENTAL_OBJECT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_FUNDAMENTAL_OBJECT))
#define TEST_IS_FUNDAMENTAL_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TEST_TYPE_FUNDAMENTAL_OBJECT))
#define TEST_FUNDAMENTAL_OBJECT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_FUNDAMENTAL_OBJECT, TestFundamentalObjectClass))
#define TEST_FUNDAMENTAL_OBJECT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_FUNDAMENTAL_OBJECT, TestFundamentalObject))
#define TEST_FUNDAMENTAL_OBJECT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), TEST_TYPE_FUNDAMENTAL_OBJECT, TestFundamentalObjectClass))
#define TEST_FUNDAMENTAL_OBJECT_CAST(obj)       ((TestFundamentalObject*)(obj))

typedef struct _TestFundamentalObject TestFundamentalObject;
typedef struct _TestFundamentalObjectClass TestFundamentalObjectClass;
typedef TestFundamentalObject * (*TestFundamentalObjectCopyFunction) (const TestFundamentalObject *obj);
typedef void (*TestFundamentalObjectFinalizeFunction) (TestFundamentalObject *obj);


struct _TestFundamentalObject {
  GTypeInstance instance;
  gint refcount;
  guint flags;
};

struct _TestFundamentalObjectClass {
  GTypeClass type_class;

  TestFundamentalObjectCopyFunction copy;
  TestFundamentalObjectFinalizeFunction finalize;
};

GType 		       test_fundamental_object_get_type (void);
TestFundamentalObject* test_fundamental_object_ref      (TestFundamentalObject *fundamental_object);
void 		       test_fundamental_object_unref 	(TestFundamentalObject *fundamental_object);

#define TEST_VALUE_HOLDS_FUNDAMENTAL_OBJECT(value)  (G_VALUE_HOLDS(value, TEST_TYPE_FUNDAMENTAL_OBJECT))

void 		       test_value_set_fundamental_object (GValue *value, TestFundamentalObject *fundamental_object);
TestFundamentalObject* test_value_get_fundamental_object (const GValue *value);

typedef struct _TestFundamentalSubObject TestFundamentalSubObject;
typedef struct _TestFundamentalSubObjectClass TestFundamentalSubObjectClass;

struct _TestFundamentalSubObject
{
  TestFundamentalObject fundamental_object;
  char *data;
};

struct _TestFundamentalSubObjectClass {
  TestFundamentalObjectClass fundamental_object_class;
};

GType test_fundamental_sub_object_get_type(void);

TestFundamentalSubObject *
test_fundamental_sub_object_new (const char *data);

/* callback */
typedef void (*TestSimpleCallback) (void);
typedef int (*TestCallback) (void);
typedef int (*TestCallbackUserData) (gpointer user_data);

void test_simple_callback (TestSimpleCallback callback);
int test_callback (TestCallback callback);
int test_multi_callback (TestCallback callback);
int test_callback_user_data (TestCallbackUserData callback,
                             gpointer user_data);
int test_callback_destroy_notify (TestCallbackUserData callback,
                                  gpointer user_data,
                                  GDestroyNotify notify);
int test_callback_thaw_notifications (void);

void test_callback_async (TestCallbackUserData callback, gpointer user_data);
int test_callback_thaw_async (void);

void test_async_ready_callback (GAsyncReadyCallback callback);

void test_obj_instance_method_callback (TestObj *obj, TestCallback callback);
void test_obj_static_method_callback (TestCallback callback);
TestObj *test_obj_new_callback (TestCallbackUserData callback,
                                gpointer user_data,
                                GDestroyNotify notify);

/* interface */
#define TEST_TYPE_INTERFACE              (test_interface_get_type ())
#define TEST_INTERFACE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), TEST_TYPE_INTERFACE, TestInterface))
#define TEST_IS_INTERFACE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), TEST_TYPE_INTERFACE))
#define TEST_INTERFACE_GET_IFACE(obj)    (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TEST_TYPE_INTERFACE, TestInterfaceIface))

typedef struct _TestInterfaceIface TestInterfaceIface;

struct _TestInterfaceIface {
    GTypeInterface base_iface;
};

GType test_interface_get_type (void) G_GNUC_CONST;

/* gobject with non-standard prefix */
#define TEST_TYPE_WI_802_1X              (test_wi_802_1x_get_type ())
#define TEST_WI_802_1X(object)        (G_TYPE_CHECK_INSTANCE_CAST ((object), TEST_TYPE_WI_802_1X, TestWi8021x))
#define TEST_IS_WI_802_1X(object)     (G_TYPE_CHECK_INSTANCE_TYPE ((object), TEST_TYPE_WI_802_1X))
#define TEST_WI_802_1X_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_WI_802_1X, TestWi8021xClass))

typedef struct
{
  GObject parent_instance;

  gboolean testbool;
} TestWi8021x;

typedef struct
{
  GObjectClass parent_class;
} TestWi8021xClass;

GType        test_wi_802_1x_get_type (void);
TestWi8021x* test_wi_802_1x_new (void);
gboolean     test_wi_802_1x_get_testbool (TestWi8021x *obj);
void         test_wi_802_1x_set_testbool (TestWi8021x *obj, gboolean v);
int          test_wi_802_1x_static_method (int x);

/* floating gobject */
#define TEST_TYPE_FLOATING           (test_floating_get_type ())
#define TEST_FLOATING(object)        (G_TYPE_CHECK_INSTANCE_CAST ((object), TEST_TYPE_FLOATING, TestFloating))
#define TEST_IS_FLOATING(object)     (G_TYPE_CHECK_INSTANCE_TYPE ((object), TEST_TYPE_FLOATING))
#define TEST_FLOATING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_FLOATING, TestFloatingClass))

typedef struct
{
  GInitiallyUnowned parent_instance;
} TestFloating;

typedef struct
{
  GInitiallyUnownedClass parent_class;
} TestFloatingClass;

GType        test_floating_get_type (void);
TestFloating* test_floating_new (void);

/* Function signature torture tests */
void test_torture_signature_0 (int        x,
                               double     *y,
                               int        *z,
                               const char *foo,
                               int        *q,
                               guint       m);
gboolean test_torture_signature_1 (int        x,
                                   double     *y,
                                   int        *z,
                                   const char *foo,
                                   int        *q,
                                   guint       m,
                                   GError    **error);
void test_torture_signature_2 (int                  x,
                               TestCallbackUserData  callback,
                               gpointer              user_data,
                               GDestroyNotify        notify,
                               double               *y,
                               int                  *z,
                               const char           *foo,
                               int                  *q,
                               guint                 m);

GValue *test_date_in_gvalue (void);
GValue *test_strv_in_gvalue (void);

#endif /* __GITESTTYPES_H__ */