Initial packaging for Tizen
[profile/ivi/gobject-introspection.git] / tests / scanner / foo.h
1 #ifndef __FOO_OBJECT_H__
2 #define __FOO_OBJECT_H__
3
4 #include <glib-object.h>
5 #include <gio/gio.h> /* GAsyncReadyCallback */
6 #include "utility.h"
7
8 #define FOO_SUCCESS_INT 0x1138
9
10 #define FOO_DEFINE_SHOULD_BE_EXPOSED "should be exposed"
11
12 #define FOO_PIE_IS_TASTY 3.14159
13
14 #define FOO_TYPE_INTERFACE           (foo_interface_get_type ())
15 #define FOO_INTERFACE(object)        (G_TYPE_CHECK_INSTANCE_CAST ((object), FOO_TYPE_INTERFACE, FooInterface))
16 #define FOO_IS_INTERFACE(object)     (G_TYPE_CHECK_INSTANCE_TYPE ((object), FOO_TYPE_INTERFACE))
17 #define FOO_INTERFACE_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), FOO_TYPE_INTERFACE, FooInterfaceIface))
18
19 #define FOO_TYPE_SUBINTERFACE           (foo_sub_interface_get_type ())
20 #define FOO_SUBINTERFACE(object)        (G_TYPE_CHECK_INSTANCE_CAST ((object), FOO_TYPE_SUBINTERFACE, FooSubInterface))
21 #define FOO_IS_SUBINTERFACE(object)     (G_TYPE_CHECK_INSTANCE_TYPE ((object), FOO_TYPE_SUBINTERFACE))
22 #define FOO_SUBINTERFACE_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), FOO_TYPE_SUBINTERFACE, FooSubInterfaceIface))
23
24
25 #define FOO_TYPE_OBJECT              (foo_object_get_type ())
26 #define FOO_OBJECT(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), FOO_TYPE_OBJECT, FooObject))
27 #define FOO_IS_OBJECT(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), FOO_TYPE_OBJECT))
28
29 #define FOO_TYPE_SUBOBJECT           (foo_subobject_get_type ())
30 #define FOO_SUBOBJECT(subobject)     (G_TYPE_CHECK_INSTANCE_CAST ((subobject), FOO_TYPE_SUBOBJECT, FooSubobject))
31 #define FOO_IS_SUBOBJECT(subobject)  (G_TYPE_CHECK_INSTANCE_TYPE ((subobject), FOO_TYPE_SUBOBJECT))
32
33 #define FOO_TYPE_BUFFER        (foo_buffer_get_type ())
34 #define FOO_BUFFER(object)     (G_TYPE_CHECK_INSTANCE_CAST ((object), FOO_TYPE_BUFFER, FooBuffer))
35 #define FOO_IS_BUFFER(object)  (G_TYPE_CHECK_INSTANCE_TYPE ((object), FOO_TYPE_BUFFER))
36
37 #define FOO_TYPE_OTHER_OBJECT  (foo_other_object_get_type ())
38 #define FOO_OTHER_OBJECT(object)     (G_TYPE_CHECK_INSTANCE_CAST ((object), FOO_TYPE_OTHER_OBJECT, FooOtherObject))
39 #define FOO_IS_OTHER_OBJECT(object)  (G_TYPE_CHECK_INSTANCE_TYPE ((object), FOO_TYPE_OTHER_OBJECT))
40
41 typedef struct _FooInterface       FooInterface;
42 typedef struct _FooInterfaceIface  FooInterfaceIface;
43 typedef struct _FooSubInterface       FooSubInterface;
44 typedef struct _FooSubInterfaceIface  FooSubInterfaceIface;
45 typedef struct _FooObject          FooObject;
46 typedef struct _FooObjectClass     FooObjectClass;
47 typedef struct _FooSubobject       FooSubobject;
48 typedef struct _FooSubobjectClass  FooSubobjectClass;
49 typedef struct _FooBuffer          FooBuffer;
50 typedef struct _FooBufferClass     FooBufferClass;
51 typedef struct _FooOtherObject          FooOtherObject;
52 typedef struct _FooOtherObjectClass     FooOtherObjectClass;
53
54 struct _FooInterfaceIface
55 {
56   GTypeInterface parent_iface;
57
58   void (*do_foo) (FooInterface *self, int x);
59 };
60
61 GType                 foo_interface_get_type       (void) G_GNUC_CONST;
62
63 void foo_interface_do_foo (FooInterface *iface, int x);
64
65 void foo_interface_static_method (int x);
66
67 struct _FooSubInterfaceIface
68 {
69   GTypeInterface parent_iface;
70
71   /* signals */
72
73   void (*destroy_event) (FooSubInterface *self);
74
75   /* virtual table */
76
77   void (*do_bar) (FooSubInterface *self);
78
79   /* explicitly test un-named parameters */
80   void (*do_moo) (FooSubInterface *self, int, gpointer);
81
82   void (*do_baz) (FooSubInterface *self, GCallback callback, gpointer data);
83 };
84
85 GType                 foo_sub_interface_get_type       (void) G_GNUC_CONST;
86
87 void foo_sub_interface_do_bar (FooSubInterface *self);
88 void foo_sub_interface_do_moo (FooSubInterface *self, int, gpointer);
89 void foo_sub_interface_do_baz (FooSubInterface *self,
90                                GCallback callback,
91                                gpointer data);
92
93 struct _FooObject
94 {
95   GObject parent_instance;
96
97   int some_int;
98 };
99
100 struct _FooObjectClass
101 {
102   GObjectClass parent_class;
103
104   gboolean (* virtual_method) (FooObject *object, int first_param);
105
106   /* Intended to match GFile */
107   void (*read_fn) (FooObject *object, int offset, int length);
108   
109   /* Test reserved stuff */
110   GCallback _reserved[4];
111 };
112
113 gint                  foo_init                     (void);
114
115 GType                 foo_object_get_type          (void) G_GNUC_CONST;
116 FooObject*            foo_object_new               (void);
117 UtilityObject*        foo_object_external_type     (FooObject *object);
118 GObject*              foo_object_new_as_super      (void);
119
120 void                  foo_object_various           (FooObject *object, void *data, GType some_type);
121
122 void                  foo_object_take_all          (FooObject *object, int x, ...);
123
124 typedef gpointer FooObjectCookie;
125
126 FooObjectCookie       foo_object_new_cookie        (FooObject *object, const char *target);
127
128 void                  foo_object_is_it_time_yet    (FooObject *object, time_t time);
129
130 const char *          foo_object_get_name          (FooObject *object);
131
132 char *                foo_object_dup_name          (FooObject *object);
133
134 void                  foo_object_handle_glyph      (FooObject *object, UtilityGlyph glyph);
135
136 gboolean              foo_object_virtual_method    (FooObject *object, int first_param);
137
138 void                  foo_object_read              (FooObject *object, int offset, int length);
139
140 int                   foo_object_static_meth       (void);
141
142 void                  foo_object_skipped_method    (FooObject *object);
143
144 struct _FooSubobject
145 {
146   FooObject parent_instance;
147 };
148
149 struct _FooSubobjectClass
150 {
151   FooObjectClass parent_class;
152 };
153
154 GType                 foo_subobject_get_type       (void) G_GNUC_CONST;
155 FooSubobject*         foo_subobject_new            (void);
156
157 FooObject *           foo_object_get_default       (void);
158
159 GType                 foo_buffer_get_type          (void);
160
161 void                  foo_buffer_some_method       (FooBuffer *buffer);
162
163 GType                 foo_other_object_get_type    (void) G_GNUC_CONST;
164
165 typedef enum
166 {
167   FOO_ENUM_ALPHA,
168   FOO_ENUM_BETA,
169   FOO_ENUM_DELTA
170 } FooEnumType;
171
172 GType foo_enum_type_get_type (void);
173
174 int                   foo_enum_type_method         (FooEnumType foo_enum);
175
176 FooEnumType           foo_enum_type_returnv        (int x);
177
178 typedef enum
179 {
180   FOO_FLAGS_FIRST  = 1 << 0,
181   FOO_FLAGS_SECOND = 1 << 1,
182   FOO_FLAGS_THIRD  = 1 << 2
183 } FooFlagsType;
184
185 GType foo_flags_type_get_type (void);
186
187 typedef enum
188 {
189   FOO_ENUM_UN = 1,
190   FOO_ENUM_DEUX = 2,
191   FOO_ENUM_TROIS = 3,
192   FOO_ENUM_NEUF = 9
193 } FooEnumNoType;
194
195 typedef enum
196 {
197   FOO_FLAGS_ETT  = 1 << 0,
198   FOO_FLAGS_TVA = 1 << 1,
199   FOO_FLAGS_FYRA  = 1 << 2
200 } FooFlagsNoType;
201
202 typedef enum
203 {
204   FOO_ENUM_FULLNAME_ONE = 1,
205   FOO_ENUM_FULLNAME_TWO,
206   FOO_ENUM_FULLNAME_THREE
207 } FooEnumFullname;
208
209 typedef enum
210 {
211   FOO_ADDRESS_INVALID,
212   FOO_ADDRESS_IPV4,
213   FOO_ADDRESS_IPV6
214 } FooAddressType;
215
216 typedef struct _FooBoxed FooBoxed;
217
218 GType                 foo_boxed_get_type       (void) G_GNUC_CONST;
219 FooBoxed*             foo_boxed_new            (void);
220 void                  foo_boxed_method         (FooBoxed* boxed);
221
222 /* This one tests capitalization handling with respect to DBus */
223 typedef struct _FooDBusData FooDBusData;
224 GType                 foo_dbus_data_get_type       (void) G_GNUC_CONST;
225 void                  foo_dbus_data_method         (FooDBusData* dbusdata);
226
227 /* FIXME: Scanner does not support this yet
228 const char *FOO_CONSTANT_STR = "foo-constant-str";
229 const int FOO_CONSTANT_INT = 10;
230 const float FOO_CONSTANT_FLOAT = 10;
231 */
232
233 /* Callback */
234 typedef gboolean (* FooCallback) (FooObject *foo, gboolean b, gpointer data);
235
236 /* Invalid comments, should be ignored */
237
238 /* @ */
239 /* @: */
240
241 typedef struct _FooStruct           FooStruct; 
242 typedef struct _FooStructPrivate    FooStructPrivate; 
243
244 struct _FooStruct
245 {
246   FooStructPrivate *priv;
247   int member;
248 };
249
250 typedef struct _FooRectangle          FooRectangle;
251
252 struct _FooRectangle
253 {
254   gint x;
255   gint y;
256   gint width;
257   gint height;
258 };
259
260 void
261 foo_method_external_references (UtilityObject *object,
262                                 UtilityEnumType e,
263                                 UtilityFlagType f,
264                                 UtilityStruct s);
265
266 void foo_rectangle_add(FooRectangle *r1, const FooRectangle *r2);
267
268 FooRectangle * foo_rectangle_new (int x, int y, int width, int height);
269
270
271 typedef struct _FooEventAny FooEventAny;
272 typedef struct _FooEventExpose FooEventExpose;
273
274 typedef union  _FooEvent FooEvent;
275
276 struct _FooEventAny
277 {
278   gint8 send_event;
279 };
280
281 struct _FooEventExpose
282 {
283   gint8 send_event;
284   gint count;
285 };
286   
287 union _FooEvent
288 {
289   int type;
290   FooEventAny any;
291   FooEventExpose expose;
292 };
293
294 typedef void FooXEvent;
295
296 /* And now some boxed variants */
297
298 typedef struct _FooBRect          FooBRect;
299
300 struct _FooBRect
301 {
302   double x;
303   double y;
304 };
305
306 GType foo_brect_get_type (void);
307
308 FooBRect *foo_brect_new (double x, double y);
309
310 void foo_brect_add (FooBRect *b1, FooBRect *b2);
311
312 typedef union _FooBUnion FooBUnion;
313
314 union _FooBUnion
315 {
316   int type;
317   double v;
318   FooBRect *rect;
319 };
320
321 typedef union _FooUnion FooUnion;
322
323 union _FooUnion
324 {
325   int foo;
326 };
327
328 typedef struct _FooUtilityStruct FooUtilityStruct;
329 struct _FooUtilityStruct
330 {
331   UtilityStruct bar;
332 };
333
334 typedef struct _FooThingWithArray FooThingWithArray;
335 struct _FooThingWithArray
336 {
337   int x;
338   int y;
339   char lines[80];
340   guchar *data;
341 } ;
342
343 FooBUnion *foo_bunion_new (void);
344
345 GType foo_bunion_get_type (void);
346
347 int foo_bunion_get_contained_type (FooBUnion *bunion);
348
349 void foo_test_unsigned_qualifier (unsigned int unsigned_param);
350 void foo_test_unsigned_type (unsigned unsigned_param);
351
352 void foo_test_string_array (char **array);
353
354 void foo_test_string_array_with_g (gchar **array);
355
356 GArray *foo_test_array (void);
357
358 const char * foo_test_const_char_retval (void);
359 const FooStruct * foo_test_const_struct_retval (void);
360 void foo_test_const_char_param (const char * param);
361 void foo_test_const_struct_param (const FooStruct * param);
362
363 typedef void (*FooVarargsCallback) (const char * param, ...);
364 void foo_test_varargs_callback (gint i, FooVarargsCallback callback);
365 void foo_test_varargs_callback2 (FooVarargsCallback callback);
366 void foo_test_varargs_callback3 (FooVarargsCallback callback,
367                                  FooVarargsCallback callback2);
368
369 /* Make sure callbacks get the right scope by default */
370 void foo_async_ready_callback(GCancellable *cancellable,
371                               GAsyncReadyCallback callback,
372                               gpointer user_data);
373 void foo_destroy_notify_callback(FooCallback callback,
374                                  gpointer data,
375                                  GDestroyNotify destroy);
376
377 typedef enum {
378   FOO_ERROR_GOOD,
379   FOO_ERROR_BAD,
380   FOO_ERROR_UGLY
381 } FooError;
382 GType foo_error_get_type (void);
383
384 GQuark foo_error_quark (void);
385
386 typedef enum
387 {
388   FOO_LAYER_DESKTOP        = 0,
389   FOO_LAYER_BOTTOM        = 1,
390   FOO_LAYER_NORMAL        = 2,
391   FOO_LAYER_TOP        = 4, /* Same as DOCK; see EWMH and bug 330717 */
392   FOO_LAYER_DOCK        = 4,
393   FOO_LAYER_FULLSCREEN        = 5,
394   FOO_LAYER_FOCUSED_WINDOW    = 6,
395   FOO_LAYER_OVERRIDE_REDIRECT = 7,
396   FOO_LAYER_LAST        = 8
397 } FooStackLayer;
398
399 typedef enum
400 {
401   FOO_SOME_SINGLE_ENUM
402 } FooASingle;
403
404 /* Should be skipped */
405 void foo_some_variant (guint x, va_list args);
406 void foo_some_variant_ptr (guint x, va_list *args);
407
408 /**
409  * FooSkippable: (skip)
410  * @FOO_SKIPPABLE_ONE: a skippable enum value
411  * @FOO_SKIPPABLE_TWO: another skippable enum value
412  *
413  * Some type that is only interesting from C and should not be
414  * exposed to language bindings.
415  */
416 typedef enum {
417   FOO_SKIPPABLE_ONE,
418   FOO_SKIPPABLE_TWO
419 } FooSkippable;
420 void foo_skip_me (FooSkippable fs);
421
422 typedef struct _FooForeignStruct           FooForeignStruct;
423
424 struct _FooForeignStruct
425 {
426   int foo;
427 };
428
429 FooForeignStruct* foo_foreign_struct_new (void);
430 FooForeignStruct* foo_foreign_struct_copy (FooForeignStruct *original);
431
432 /* This one should be a global, not a method on UtilityObject since
433  * it's a separate namespace.
434  */
435 void foo_object_a_global_method (UtilityObject *obj);
436
437 FooOtherObject * foo_object_append_new_stack_layer (FooObject *obj, int x);
438
439 #endif /* __FOO_OBJECT_H__ */