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