]> git.draconx.ca Git - gob-dx.git/blob - src/test.gob
Release 1.0.7
[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 0.93.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 /* the next line is not mandatory, but if gob finds an include in one of
30    the %{ %} sections above the class definitions, it will not put it in
31    the file itself.  So you can this way select where the include file is
32    at */
33 #include "gtk-weird-button.h"
34 #include "gtk-weird-button-private.h"
35
36 /* this is to test if the lexer won't get confused by requires inside
37    some c code
38 requires 99.99.99
39 */
40
41 static void jjjj(void);
42 %}
43
44 %h{
45 enum _gob__enum_t {
46         BUDLIKY, BUDLIKY2
47 };
48
49 struct _gob__struct_t {
50         int i, x, y, z;
51 };
52 union _gob__union_t {
53         int i, x, y, z;
54 };
55 void bubu(void);
56 %}
57 %header{
58 /* this should be in the header, just under bubu prototype */
59 #define TEST_ARRAY 5
60 %}
61
62 class Gtk:Weird:Button from Gtk:Button {
63
64         public int test_array[TEST_ARRAY];
65         public int i;
66         argument INT i set { self->i = ARG; } get { ARG = self->i; } ;
67
68         public int testing = 1;
69         argument INT testing link;
70
71         public char * testingstring = {g_strdup("test")}
72                 destroywith g_free;
73         argument POINTER testingstring stringlink;
74
75         public Gtk:Weird:Button * testingobj
76                 destroywith gtk_object_unref;
77         argument POINTER testingobj objectlink;
78
79         classwide int foo = 20;
80         argument INT foo link;
81
82         public Gtk:Object * testingobj2
83                 destroy {
84                         if(VAR)
85                                 gtk_object_unref(GTK_OBJECT(VAR));
86                 };
87         argument POINTER (type Gtk:Object *) testingobj2 objectlink;
88         
89         argument POINTER (type GtkObject *) some_object
90                 set { /* set some_object */ }
91                 get { /* get some_object */
92                         ARG=NULL; };
93         argument (CONSTRUCT) LONG (type long) write_only_long
94                 set { /* set write_only_long */ };
95         argument POINTER (type char *) read_only_string
96                 get { /* get readonly_long */
97                         ARG = g_strdup("BLAH"); };
98         private int j;
99         public GtkWidget * h;
100         public char *bleh;
101         public double array[23][18];
102         protected unsigned long int wagawaga;
103         public int wagawaga_should_be_after_this_in_the_header;
104
105         init(object) {
106                 object->i=0;
107         }
108         class_init(klass);
109
110         /**
111          * new:
112          * @j: foo
113          *
114          * budliky budliky
115          *
116          * Returns: new object
117          */
118         public GtkWidget * new(int j (check > 0)) {
119                 GtkWidget *ret;
120                 ret = GTK_WIDGET (GET_NEW);
121
122                 SELF(ret)->_priv->j = j;
123
124                 return ret;
125         }
126         private int _blah(self, Gtk:Widget * wid (check null type),
127                          int h (check > 0)) onerror -1 {
128                 gtk_container_add(GTK_CONTAINER(self),wid);
129
130                 gtk_object_set(GTK_OBJECT(self),
131                                GTK_WEIRD_BUTTON_ARG_I(99),
132                                NULL);
133                 return h;
134         }
135         /**
136          * bleh:
137          * @self: foo
138          * @wid: foo
139          * @h: foo
140          *
141          * budliky budliky 2
142          *
143          * Returns: new object
144          **/
145         signal last INT (POINTER, INT)
146         int bleh(self, Gtk:Widget * wid (check null type),
147                         int h (check > 0)) {
148                 return _blah(self,wid,h);
149         }
150
151         private
152         int
153         test_handler (self, GtkWidget *w, int h, gpointer data)
154         {
155                 return -1;
156         }
157
158         /**
159          * gtk_weird_button_bleh2:
160          * @self: foo
161          * @wid: foo
162          * @h: foo
163          *
164          * budliky budliky 3
165          *
166          * Returns: new object */
167         signal last INT (POINTER, INT)
168         int bleh2(self, const Gtk:Widget * wid (check null type),
169                         int h (check > 0)) {
170                 gtk_signal_connect (GTK_OBJECT (self),
171                                     GTK_WEIRD_BUTTON_SIGNAL_BLEH (test_handler),
172                                     NULL);
173
174                 /* testing multiple marshaller support */
175                 return 0;
176         }
177         /* this should not get documented as it's nonstandard */
178         /**
179          * bloh:
180
181          ******/
182
183         /* Here we are testing how the gtk-doc extraction code error handeling
184            it should just ingore these */
185         /**
186           */
187
188         /** */
189         /**
190          *
191          * bubu
192          *********/
193         /**
194          *
195          * bubu
196          **zblunk*******/
197         /**
198          *
199          * bubu
200          *zblunk*******//**//**/
201         signal first NONE (NONE)
202         void bloh(self);
203         virtual void * bah(self, int h (check > 0)) onerror NULL defreturn 0 {
204                 beh(self,h);
205                 return NULL;
206         }
207         virtual int beh(self, int h (check > 0));
208         override(Gtk:Container) void add(Gtk:Container * self (check null type),
209                                          Gtk:Widget * wid (check null type)) {
210                 PARENT_HANDLER(self,wid);
211         }
212         public int consttest(self, const gchar *text, ...)
213         {
214                 return 25;
215         }
216         public int consttest2(self, gchar const *text, ...)
217         {
218                 return 25;
219         }
220         public int consttest3(self, Gtk:Widget const *wid (check null type))
221         {
222                 return 25;
223         }
224         public int consttest4(const self)
225         {
226                 return 25;
227         }
228         public int consttest5(self const)
229         {
230                 return 25;
231         }
232         virtual int consttest6(const self)
233         {
234                 return 25;
235         }
236         virtual int consttest7(self const)
237         {
238                 return 25;
239         }
240         public int consttest8(self)
241         {
242                 Self const *selfconst1, *selfconst2;
243                 selfconst1 = SELF_CONST(self);
244                 selfconst2 = GTK_WEIRD_BUTTON_CONST(self);
245                 return 25;
246         }
247         public int consttest9(const self, int i, double b)
248         {
249                 return 25;
250         }
251         public int consttest10(self const, int i, double b)
252         {
253                 return 25;
254         }
255         signal private first NONE (NONE)
256         void googlegoogle(self)
257         {
258                 puts("TEST1");
259                 googlegoogle2(self);
260         }
261         signal first private NONE (NONE)
262         void googlegoogle2(self)
263         {
264                 int array[5][8][9]={{{0}}};
265                 Self *foo = self;
266                 puts("TEST2");
267                 testprivvirtual(foo, array);
268         }
269         private signal first NONE (NONE)
270         void googlegoogle3(self)
271         {
272                 puts("TEST3");
273         }
274         protected signal first NONE (NONE)
275         void googlegoogle4(self)
276         {
277                 puts("TEST4");
278         }
279         protected signal first NONE (NONE)
280         void googlegoogle_const1(const self)
281         {
282                 puts("TEST4");
283         }
284         protected signal first NONE (NONE)
285         void googlegoogle_const2(self const)
286         {
287                 puts("TEST4");
288         }
289         virtual private
290         void testprivvirtual(self, int some_array[5][8][9])
291         {
292                 puts("TEST3");
293                 googlegoogle(self);
294         }
295         private virtual
296         void testprivvirtual2(self, const int some_array[5][8][9])
297         {
298                 /* nothing here */
299         }
300         public virtual
301         void testpublicvirtual(self, int const some_array[5][8][9])
302         {
303                 /* nothing here */
304         }
305         protected virtual
306         void testprotectedvirtual(self, int some_array[5][8][9])
307         {
308                 /* nothing here */
309         }
310         signal first NONE (POINTER)
311         void testarrsignal(self, long arr[8])
312         {
313                 /* foo */
314         }
315
316         /* testing empty func */
317         public void foofoofoo(self) {}
318         /* testing empty func 2 */
319         public void foofoofoo2(self);
320         /* testing empty func 3 */
321         public void foofoofoo3(self) {   }
322         /* testing empty func 4 */
323         public void foofoofoo4(self)
324         {
325         }
326
327         override (Gtk:Widget)
328         int event(Gtk:Widget *self (check null type),
329                   GdkEvent *event (check null)) onerror FALSE
330         {
331                 int ret;
332                 /* some code */
333                 ret = PARENT_HANDLER(self,event);
334                 /* some code */
335                 return ret;
336         }
337         override(Gtk:Container)
338         void
339         remove(Gtk:Container * self (check null type),
340                Gtk:Widget * wid (check null type));
341
342         override(Gtk:Object)
343         void
344         destroy(Gtk:Object * self (check null type))
345         {
346                 /* foo bar */
347                 PARENT_HANDLER(self);
348         }
349
350         protected
351         int foobar(self) {
352                 /* just an empty function */
353                 return 5;
354         }
355
356         signal last NONE(CHAR,UCHAR,BOOL,INT,UINT,LONG,ULONG,FLOAT,DOUBLE,
357                          STRING,ENUM,FLAGS,BOXED,POINTER,OBJECT)
358         void
359         testargs(self, gchar a, guchar b, gboolean c, gint d, guint e, glong f,
360                  gulong g, gfloat h, gdouble i, gchar * j, gint k,
361                  guint l, gpointer m, gpointer o, GtkObject *p)
362         {
363                 /* ugh, testing casting */
364         }
365
366         public signal (NO_HOOKS) last INT (INT)
367         int testflags(self, int w (check > 0)) defreturn -99 {
368                 /*foo*/
369                 return w;
370         }
371
372         /* testing NONE */
373         signal BOOL (NONE)
374         gboolean
375         test_none_thing (self)
376         {
377                 return FALSE;
378         }
379
380         /* testing types */
381         public int t1;
382         public long int t2;
383         public int long t3;
384         public int long const t4;
385         public const int long t5;
386         public const char * const t6;
387         public char const * const t7;
388         public enum _gob__enum_t const * const t8;
389         public union _gob__union_t t9;
390         public union _gob__union_t * const * const * t10;
391         public struct _gob__struct_t * const * const * t11;
392         public const struct _gob__struct_t * const * const * t13;
393         public const enum _gob__enum_t * const * const * t14;
394         public enum _gob__enum_t t15;
395         public gchar const t16;
396         public const gchar * const t17;
397         public const gchar t18;
398
399         /* testing method with no arguments */
400         public void method_with_no_arguments (void)
401         {
402                 /* FOO */
403         }
404
405         /* testing calling the above method */
406         public void foo (self) {
407                 method_with_no_arguments ();
408         }
409
410         /* this is to test custom get_type */
411         /*public GtkType
412         get_type (void)
413         {
414                 static guint type = 0;
415
416                 if ( ! type) {
417                         static const GtkTypeInfo info = {
418                                 "GtkWeirdButton",
419                                 sizeof (GtkWeirdButton),
420                                 sizeof (GtkWeirdButtonClass),
421                                 (GtkClassInitFunc) gtk_weird_button_class_init,
422                                 (GtkObjectInitFunc) gtk_weird_button_init,
423                                 NULL,
424                                 NULL,
425                                 (GtkClassInitFunc) NULL
426                         };
427
428                         type = gtk_type_unique (gtk_button_get_type(), &info);
429                 }
430
431                 return type;
432         }*/
433
434
435         /* testing empty statements */
436         ;
437         ;
438         ;
439 }
440
441 %{
442
443 static void
444 jjjj(void)
445 {
446 }
447
448 void
449 bubu(void)
450 {
451         jjjj();
452 }
453
454 %}