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