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