]> git.draconx.ca Git - gob-dx.git/blob - src/test.gob
Release 1.0.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 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         signal private first NONE (NONE)
208         void googlegoogle(self)
209         {
210                 puts("TEST1");
211                 googlegoogle2(self);
212         }
213         signal first private NONE (NONE)
214         void googlegoogle2(self)
215         {
216                 int array[5][8][9]={{{0}}};
217                 Self *foo = self;
218                 puts("TEST2");
219                 testprivvirtual(foo, array);
220         }
221         private signal first NONE (NONE)
222         void googlegoogle3(self)
223         {
224                 puts("TEST3");
225         }
226         protected signal first NONE (NONE)
227         void googlegoogle4(self)
228         {
229                 puts("TEST4");
230         }
231         virtual private
232         void testprivvirtual(self, int some_array[5][8][9])
233         {
234                 puts("TEST3");
235                 googlegoogle(self);
236         }
237         private virtual
238         void testprivvirtual2(self, const int some_array[5][8][9])
239         {
240                 /* nothing here */
241         }
242         public virtual
243         void testpublicvirtual(self, int const some_array[5][8][9])
244         {
245                 /* nothing here */
246         }
247         protected virtual
248         void testprotectedvirtual(self, int some_array[5][8][9])
249         {
250                 /* nothing here */
251         }
252         signal first NONE (POINTER)
253         void testarrsignal(self, long arr[8])
254         {
255                 /* foo */
256         }
257
258         /* testing empty func */
259         public void foofoofoo(self) {}
260         /* testing empty func 2 */
261         public void foofoofoo2(self);
262         /* testing empty func 3 */
263         public void foofoofoo3(self) {   }
264         /* testing empty func 4 */
265         public void foofoofoo4(self)
266         {
267         }
268
269         override (Gtk:Widget)
270         int event(Gtk:Widget *self (check null type),
271                   GdkEvent *event (check null)) onerror FALSE
272         {
273                 int ret;
274                 /* some code */
275                 ret = PARENT_HANDLER(self,event);
276                 /* some code */
277                 return ret;
278         }
279         override(Gtk:Container)
280         void
281         remove(Gtk:Container * self (check null type),
282                Gtk:Widget * wid (check null type));
283
284         override(Gtk:Object)
285         void
286         destroy(Gtk:Object * self (check null type))
287         {
288                 /* foo bar */
289                 PARENT_HANDLER(self);
290         }
291
292         protected
293         int foobar(self) {
294                 /* just an empty function */
295                 return 5;
296         }
297
298         signal last NONE(CHAR,UCHAR,BOOL,INT,UINT,LONG,ULONG,FLOAT,DOUBLE,
299                          STRING,ENUM,FLAGS,BOXED,POINTER,OBJECT)
300         void
301         testargs(self, gchar a, guchar b, gboolean c, gint d, guint e, glong f,
302                  gulong g, gfloat h, gdouble i, gchar * j, gint k,
303                  guint l, gpointer m, gpointer o, GtkObject *p)
304         {
305                 /* ugh, testing casting */
306         }
307
308         public signal (NO_HOOKS) last INT (INT)
309         int testflags(self, int w (check > 0)) defreturn -99 {
310                 /*foo*/
311                 return w;
312         }
313
314         /* testing NONE */
315         signal BOOL (NONE)
316         gboolean
317         test_none_thing (self)
318         {
319                 return FALSE;
320         }
321
322         /* testing types */
323         public int t1;
324         public long int t2;
325         public int long t3;
326         public int long const t4;
327         public const int long t5;
328         public const char * const t6;
329         public char const * const t7;
330         public enum _gob__enum_t const * const t8;
331         public union _gob__union_t t9;
332         public union _gob__union_t * const * const * t10;
333         public struct _gob__struct_t * const * const * t11;
334         public const struct _gob__struct_t * const * const * t13;
335         public const enum _gob__enum_t * const * const * t14;
336         public enum _gob__enum_t t15;
337         public gchar const t16;
338         public const gchar * const t17;
339         public const gchar t18;
340
341         /* testing empty statements */
342         ;
343         ;
344         ;
345 }
346
347 %{
348
349 static void
350 jjjj(void)
351 {
352 }
353
354 void
355 bubu(void)
356 {
357         jjjj();
358 }
359
360 %}