]> git.draconx.ca Git - gob-dx.git/blob - src/test.gob
Release 1.99.2
[gob-dx.git] / src / test.gob
1 /* this is a TEST file, it's VERY VERY ugly, it's just supposed to test
2    the parser of gob and somewhat test some output as well, you can
3    look in here to see a whole array of different syntax options, but
4    don't expect this to be an easy to read file */
5
6 requires 1.99.0
7
8 %at{
9 /* ALL TOP */
10 %}
11
12 %headertop{
13 /* this should go on the very top of the header */
14
15 %}
16 %ht{
17 /* this should go on the very top of the header as well */
18 %}
19 %ph{
20 /* this should go into the private header */
21 %}
22 %privateheader{
23 /* this should go into the private header as well*/
24 %}
25
26
27 %{
28 #include <stdio.h>
29 #include <gtk/gtk.h>
30 /* the next line is not mandatory, but if gob finds an include in one of
31    the %{ %} sections above the class definitions, it will not put it in
32    the file itself.  So you can this way select where the include file is
33    at */
34 #include "test-object.h"
35 #include "test-object-private.h"
36
37 /* this is to test if the lexer won't get confused by requires inside
38    some c code
39 requires 99.99.99
40 */
41
42 static void jjjj(void);
43
44 #define _(x) x
45 %}
46
47 %h{
48 enum _gob__enum_t {
49         BUDLIKY, BUDLIKY2
50 };
51
52 struct _gob__struct_t {
53         int i, x, y, z;
54 };
55 union _gob__union_t {
56         int i, x, y, z;
57 };
58 void bubu(void);
59 %}
60 %header{
61 /* this should be in the header, just under bubu prototype */
62 #define TEST_ARRAY 5
63 %}
64
65 enum LAME_CLIENT {
66         IS_CONNECTED,
67         NONE = 9,
68         LAST
69 } Test:Enum;
70
71 flags BUGA_BUGA {
72         ONE,
73         TWO,
74         MANY,
75 } Some:Flags;
76
77 error TEST_OBJECT_ERROR {
78         BAD_THIS,
79         BAD_THAT
80 } Test:Object:Error;
81
82 class Test:Object from G:Object
83         (interface Gtk:Tree:Model)
84         /* We can add more interfaces by adding more lines like the above */
85         /* Note that there must exist a GtkTreeModelIface structure */
86 {
87
88         /* function implemented for the Gtk:Tree:Model interface */
89         interface Gtk:Tree:Model
90         private GtkTreeModelFlags
91         get_flags (Gtk:Tree:Model *self (check null type))
92         {
93                 /* FOO */
94                 return (GtkTreeModelFlags)0;
95         }
96
97
98
99         public int test_array[TEST_ARRAY];
100         public int i;
101         argument INT i set { self->i = ARG; } get { ARG = self->i; } ;
102
103         public int testing = 1;
104         argument INT testing link;
105
106         public char * testingstring = {g_strdup("test")}
107                 destroywith g_free;
108         argument POINTER testingstring stringlink;
109
110         public Test:Object * testingobj
111                 destroywith g_object_unref;
112         argument POINTER testingobj objectlink;
113
114         classwide int foo = 20;
115         argument INT foo link;
116
117         public G:Object * testingobj2
118                 destroy {
119                         if(VAR)
120                                 g_object_unref(G_OBJECT(VAR));
121                 };
122         argument POINTER (type G:Object *) testingobj2 objectlink;
123         
124         argument POINTER (type GObject *) some_object
125                 set { /* set some_object */ }
126                 get { /* get some_object */
127                         ARG=NULL; };
128         argument (CONSTRUCT) LONG (type long) write_only_long
129                 set { /* set write_only_long */ };
130         argument POINTER (type char *) read_only_string
131                 get { /* get readonly_long */
132                         ARG = g_strdup("BLAH"); };
133
134         private char a_property;
135         property CHAR a_property
136                 (nick = _("Nick"),
137                  blurb = _("Blurb"),
138                  minimum = 'a',
139                  maximum = 'Z',
140                  default_value = 'C',
141                  export)
142                 set { self->_priv->a_property = g_value_get_char (VAL); }
143                 get { g_value_set_char (VAL, self->_priv->a_property); };
144
145
146         private char *b_property;
147         property STRING b_property
148                 (nick = _("Nick b"),
149                  blurb = _("Blurb b"),
150                  default_value = "default",
151                  type = char *,
152                  flags = CONSTRUCT,
153                  export,
154                  link);
155
156
157         private int j;
158         public GObject * h;
159         public char *bleh;
160         public double array[23][18];
161         protected unsigned long int wagawaga;
162         public int wagawaga_should_be_after_this_in_the_header;
163
164         init(object) {
165                 object->i=0;
166         }
167         class_init(klass);
168
169         /**
170          * new:
171          * @j: foo
172          *
173          * budliky budliky
174          *
175          * Returns: new object
176          */
177         public GObject * new(int j (check > 0)) {
178                 GObject *ret;
179                 ret = G_OBJECT (GET_NEW);
180
181                 SELF(ret)->_priv->j = j;
182
183                 return ret;
184         }
185         private int blah(self, G:Object * wid (check null type),
186                          int h (check > 0)) onerror -1 {
187                 g_object_set (G_OBJECT (self),
188                               TEST_OBJECT_PROP_I (99),
189                               NULL);
190                 return h;
191         }
192         /**
193          * bleh:
194          * @self: foo
195          * @wid: foo
196          * @h: foo
197          *
198          * budliky budliky 2
199          *
200          * Returns: new object
201          **/
202         signal last STRING (POINTER, INT)
203         char * bleh(self, G:Object * wid (check null type),
204                         int h (check > 0)) {
205                 return self_blah(self,wid,h) > 0 ? g_strdup ("foo") : g_strdup ("bar");
206         }
207
208         private
209         char *
210         test_handler (self, GObject *w, int h, gpointer data)
211         {
212                 return NULL;
213         }
214
215         /**
216          * gtk_weird_button_bleh2:
217          * @self: foo
218          * @wid: foo
219          * @h: foo
220          *
221          * budliky budliky 3
222          *
223          * Returns: new object */
224         signal last INT (POINTER, INT)
225         int bleh2(self, const G:Object * wid (check null type),
226                         int h (check > 0)) {
227
228                 test_object_connect__bleh (self, self_test_handler, NULL);
229                 self_connect__bleh (self, self_test_handler, NULL);
230                 test_object_connect_after__bleh (self, self_test_handler, NULL);
231                 self_connect_after__bleh (self, self_test_handler, NULL);
232                 test_object_connect_data__bleh (self, self_test_handler, NULL, NULL, 0);
233                 self_connect_data__bleh (self, self_test_handler, NULL, NULL, 0);
234
235                 /* testing multiple marshaller support */
236                 return 0;
237         }
238         /* this should not get documented as it's nonstandard */
239         /**
240          * bloh:
241
242          ******/
243
244         /* Here we are testing how the gtk-doc extraction code error handeling
245            it should just ingore these */
246         /**
247           */
248
249         /** */
250         /**
251          *
252          * bubu
253          *********/
254         /**
255          *
256          * bubu
257          **zblunk*******/
258         /**
259          *
260          * bubu
261          *zblunk*******//**//**/
262         signal first NONE (NONE)
263         void bloh(self);
264         virtual void * bah(self, int h (check > 0)) onerror NULL defreturn 0 {
265                 self_beh(self,h);
266                 return NULL;
267         }
268         virtual int beh(self, int h (check > 0));
269         /*override(G:Object) void add(Gtk:Container * self (check null type),
270                                          Gtk:Widget * wid (check null type)) {
271                 PARENT_HANDLER(self,wid);
272         }*/
273         public int consttest(self, const gchar *text, ...)
274         {
275                 return 25;
276         }
277         public int consttest2(self, gchar const *text, ...)
278         {
279                 return 25;
280         }
281         public int consttest3(self, G:Object const *wid (check null type))
282         {
283                 return 25;
284         }
285         public int consttest4(const self)
286         {
287                 return 25;
288         }
289         public int consttest5(self const)
290         {
291                 return 25;
292         }
293         virtual int consttest6(const self)
294         {
295                 return 25;
296         }
297         virtual int consttest7(self const)
298         {
299                 return 25;
300         }
301         public int consttest8(self)
302         {
303                 Self const *selfconst1, *selfconst2;
304                 selfconst1 = SELF_CONST(self);
305                 selfconst2 = TEST_OBJECT_CONST(self);
306                 return 25;
307         }
308         public int consttest9(const self, int i, double b)
309         {
310                 return 25;
311         }
312         public int consttest10(self const, int i, double b)
313         {
314                 return 25;
315         }
316         signal private first NONE (NONE)
317         void googlegoogle(self)
318         {
319                 puts("TEST1");
320                 self_googlegoogle2(self);
321         }
322         signal first private NONE (NONE)
323         void googlegoogle2(self)
324         {
325                 int array[5][8][9]={{{0}}};
326                 Self *foo = self;
327                 puts("TEST2");
328                 self_testprivvirtual(foo, array);
329         }
330         private signal first NONE (NONE)
331         void googlegoogle3(self)
332         {
333                 puts("TEST3");
334         }
335         protected signal first NONE (NONE)
336         void googlegoogle4(self)
337         {
338                 puts("TEST4");
339         }
340         protected signal first NONE (NONE)
341         void googlegoogle_const1(const self)
342         {
343                 puts("TEST4");
344         }
345         protected signal first NONE (NONE)
346         void googlegoogle_const2(self const)
347         {
348                 puts("TEST4");
349         }
350         virtual private
351         void testprivvirtual(self, int some_array[5][8][9])
352         {
353                 puts("TEST3");
354                 self_googlegoogle(self);
355         }
356         private virtual
357         void testprivvirtual2(self, const int some_array[5][8][9])
358         {
359                 /* nothing here */
360         }
361         public virtual
362         void testpublicvirtual(self, int const some_array[5][8][9])
363         {
364                 /* nothing here */
365         }
366         protected virtual
367         void testprotectedvirtual(self, int some_array[5][8][9])
368         {
369                 /* nothing here */
370         }
371         signal first NONE (POINTER)
372         void testarrsignal(self, long arr[8])
373         {
374                 /* foo */
375         }
376
377         /* testing empty func */
378         public void foofoofoo(self) {}
379         /* testing empty func 2 */
380         public void foofoofoo2(self);
381         /* testing empty func 3 */
382         public void foofoofoo3(self) {   }
383         /* testing empty func 4 */
384         public void foofoofoo4(self)
385         {
386         }
387
388 //      override (Gtk:Widget)
389 //      int event(Gtk:Widget *self (check null type),
390 //                GdkEvent *event (check null)) onerror FALSE
391 //      {
392 //              int ret;
393 //              /* some code */
394 //              ret = PARENT_HANDLER(self,event);
395 //              /* some code */
396 //              return ret;
397 //      }
398 //      override(Gtk:Container)
399 //      void
400 //      remove(Gtk:Container * self (check null type),
401 //             Gtk:Widget * wid (check null type));
402 //
403 //      override(Gtk:Object)
404 //      void
405 //      destroy(Gtk:Object * self (check null type))
406 //      {
407 //              /* foo bar */
408 //              PARENT_HANDLER(self);
409 //      }
410
411         protected
412         int foobar(self) {
413                 /* just an empty function */
414                 return 5;
415         }
416
417         signal last NONE(CHAR,UCHAR,BOOLEAN,INT,UINT,LONG,ULONG,FLOAT,DOUBLE,
418                          STRING,ENUM,FLAGS,BOXED,POINTER,OBJECT)
419         void
420         testargs(self, gchar a, guchar b, gboolean c, gint d, guint e, glong f,
421                  gulong g, gfloat h, gdouble i, gchar * j, gint k,
422                  guint l, gpointer m, gpointer o, GObject *p)
423         {
424                 /* ugh, testing casting */
425         }
426
427         public signal (NO_HOOKS) last INT (INT)
428         int testflags(self, int w (check > 0)) defreturn -99 {
429                 /*foo*/
430                 return w;
431         }
432
433         /* testing NONE */
434         signal BOOLEAN (NONE)
435         gboolean
436         test_none_thing (self)
437         {
438                 return FALSE;
439         }
440
441         /* testing types */
442         public int t1;
443         public long int t2;
444         public int long t3;
445         public int long const t4;
446         public const int long t5;
447         public const char * const t6;
448         public char const * const t7;
449         public enum _gob__enum_t const * const t8;
450         public union _gob__union_t t9;
451         public union _gob__union_t * const * const * t10;
452         public struct _gob__struct_t * const * const * t11;
453         public const struct _gob__struct_t * const * const * t13;
454         public const enum _gob__enum_t * const * const * t14;
455         public enum _gob__enum_t t15;
456         public gchar const t16;
457         public const gchar * const t17;
458         public const gchar t18;
459
460         /* testing method with no arguments */
461         public void method_with_no_arguments (void)
462         {
463                 /* FOO */
464         }
465
466         /* testing calling the above method */
467         public void foo (self) {
468                 self_method_with_no_arguments ();
469         }
470
471         /* this is to test custom get_type */
472         /*public GtkType
473         get_type (void)
474         {
475                 static guint type = 0;
476
477                 if ( ! type) {
478                         static const GtkTypeInfo info = {
479                                 "GtkWeirdButton",
480                                 sizeof (GtkWeirdButton),
481                                 sizeof (GtkWeirdButtonClass),
482                                 (GtkClassInitFunc) gtk_weird_button_class_init,
483                                 (GtkObjectInitFunc) gtk_weird_button_init,
484                                 NULL,
485                                 NULL,
486                                 (GtkClassInitFunc) NULL
487                         };
488
489                         type = gtk_type_unique (gtk_button_get_type(), &info);
490                 }
491
492                 return type;
493         }*/
494
495
496         /* testing empty statements */
497         ;
498         ;
499         ;
500 }
501
502 %{
503
504 static void
505 jjjj(void)
506 {
507 }
508
509 void
510 bubu(void)
511 {
512         jjjj();
513 }
514
515 %}