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