]> git.draconx.ca Git - gob-dx.git/blob - src/test.gob
Release 1.0.5
[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          * gtk_weird_button_bleh2:
151          * @self: foo
152          * @wid: foo
153          * @h: foo
154          *
155          * budliky budliky 3
156          *
157          * Returns: new object */
158         signal last INT (POINTER, INT)
159         int bleh2(self, const Gtk:Widget * wid (check null type),
160                         int h (check > 0)) {
161                 /* testing multiple marshaller support */
162                 return 0;
163         }
164         /* this should not get documented as it's nonstandard */
165         /**
166          * bloh:
167
168          ******/
169
170         /* Here we are testing how the gtk-doc extraction code error handeling
171            it should just ingore these */
172         /**
173           */
174
175         /** */
176         /**
177          *
178          * bubu
179          *********/
180         /**
181          *
182          * bubu
183          **zblunk*******/
184         /**
185          *
186          * bubu
187          *zblunk*******//**//**/
188         signal first NONE (NONE)
189         void bloh(self);
190         virtual void * bah(self, int h (check > 0)) onerror NULL defreturn 0 {
191                 beh(self,h);
192                 return NULL;
193         }
194         virtual int beh(self, int h (check > 0));
195         override(Gtk:Container) void add(Gtk:Container * self (check null type),
196                                          Gtk:Widget * wid (check null type)) {
197                 PARENT_HANDLER(self,wid);
198         }
199         public int consttest(self, const gchar *text, ...)
200         {
201                 return 25;
202         }
203         public int consttest2(self, gchar const *text, ...)
204         {
205                 return 25;
206         }
207         public int consttest3(self, Gtk:Widget const *wid (check null type))
208         {
209                 return 25;
210         }
211         public int consttest4(const self)
212         {
213                 return 25;
214         }
215         public int consttest5(self const)
216         {
217                 return 25;
218         }
219         virtual int consttest6(const self)
220         {
221                 return 25;
222         }
223         virtual int consttest7(self const)
224         {
225                 return 25;
226         }
227         public int consttest8(self)
228         {
229                 Self const *selfconst1, *selfconst2;
230                 selfconst1 = SELF_CONST(self);
231                 selfconst2 = GTK_WEIRD_BUTTON_CONST(self);
232                 return 25;
233         }
234         public int consttest9(const self, int i, double b)
235         {
236                 return 25;
237         }
238         public int consttest10(self const, int i, double b)
239         {
240                 return 25;
241         }
242         signal private first NONE (NONE)
243         void googlegoogle(self)
244         {
245                 puts("TEST1");
246                 googlegoogle2(self);
247         }
248         signal first private NONE (NONE)
249         void googlegoogle2(self)
250         {
251                 int array[5][8][9]={{{0}}};
252                 Self *foo = self;
253                 puts("TEST2");
254                 testprivvirtual(foo, array);
255         }
256         private signal first NONE (NONE)
257         void googlegoogle3(self)
258         {
259                 puts("TEST3");
260         }
261         protected signal first NONE (NONE)
262         void googlegoogle4(self)
263         {
264                 puts("TEST4");
265         }
266         protected signal first NONE (NONE)
267         void googlegoogle_const1(const self)
268         {
269                 puts("TEST4");
270         }
271         protected signal first NONE (NONE)
272         void googlegoogle_const2(self const)
273         {
274                 puts("TEST4");
275         }
276         virtual private
277         void testprivvirtual(self, int some_array[5][8][9])
278         {
279                 puts("TEST3");
280                 googlegoogle(self);
281         }
282         private virtual
283         void testprivvirtual2(self, const int some_array[5][8][9])
284         {
285                 /* nothing here */
286         }
287         public virtual
288         void testpublicvirtual(self, int const some_array[5][8][9])
289         {
290                 /* nothing here */
291         }
292         protected virtual
293         void testprotectedvirtual(self, int some_array[5][8][9])
294         {
295                 /* nothing here */
296         }
297         signal first NONE (POINTER)
298         void testarrsignal(self, long arr[8])
299         {
300                 /* foo */
301         }
302
303         /* testing empty func */
304         public void foofoofoo(self) {}
305         /* testing empty func 2 */
306         public void foofoofoo2(self);
307         /* testing empty func 3 */
308         public void foofoofoo3(self) {   }
309         /* testing empty func 4 */
310         public void foofoofoo4(self)
311         {
312         }
313
314         override (Gtk:Widget)
315         int event(Gtk:Widget *self (check null type),
316                   GdkEvent *event (check null)) onerror FALSE
317         {
318                 int ret;
319                 /* some code */
320                 ret = PARENT_HANDLER(self,event);
321                 /* some code */
322                 return ret;
323         }
324         override(Gtk:Container)
325         void
326         remove(Gtk:Container * self (check null type),
327                Gtk:Widget * wid (check null type));
328
329         override(Gtk:Object)
330         void
331         destroy(Gtk:Object * self (check null type))
332         {
333                 /* foo bar */
334                 PARENT_HANDLER(self);
335         }
336
337         protected
338         int foobar(self) {
339                 /* just an empty function */
340                 return 5;
341         }
342
343         signal last NONE(CHAR,UCHAR,BOOL,INT,UINT,LONG,ULONG,FLOAT,DOUBLE,
344                          STRING,ENUM,FLAGS,BOXED,POINTER,OBJECT)
345         void
346         testargs(self, gchar a, guchar b, gboolean c, gint d, guint e, glong f,
347                  gulong g, gfloat h, gdouble i, gchar * j, gint k,
348                  guint l, gpointer m, gpointer o, GtkObject *p)
349         {
350                 /* ugh, testing casting */
351         }
352
353         public signal (NO_HOOKS) last INT (INT)
354         int testflags(self, int w (check > 0)) defreturn -99 {
355                 /*foo*/
356                 return w;
357         }
358
359         /* testing NONE */
360         signal BOOL (NONE)
361         gboolean
362         test_none_thing (self)
363         {
364                 return FALSE;
365         }
366
367         /* testing types */
368         public int t1;
369         public long int t2;
370         public int long t3;
371         public int long const t4;
372         public const int long t5;
373         public const char * const t6;
374         public char const * const t7;
375         public enum _gob__enum_t const * const t8;
376         public union _gob__union_t t9;
377         public union _gob__union_t * const * const * t10;
378         public struct _gob__struct_t * const * const * t11;
379         public const struct _gob__struct_t * const * const * t13;
380         public const enum _gob__enum_t * const * const * t14;
381         public enum _gob__enum_t t15;
382         public gchar const t16;
383         public const gchar * const t17;
384         public const gchar t18;
385
386         /* testing method with no arguments */
387         public void method_with_no_arguments (void)
388         {
389                 /* FOO */
390         }
391
392         /* testing calling the above method */
393         public void foo (self) {
394                 method_with_no_arguments ();
395         }
396
397
398         /* testing empty statements */
399         ;
400         ;
401         ;
402 }
403
404 %{
405
406 static void
407 jjjj(void)
408 {
409 }
410
411 void
412 bubu(void)
413 {
414         jjjj();
415 }
416
417 %}