]> git.draconx.ca Git - gob-dx.git/blob - src/test.gob
Release 0.93.4
[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                 puts("TEST2");
197                 testprivvirtual(self,array);
198         }
199         private signal first NONE (NONE)
200         void googlegoogle3(self)
201         {
202                 puts("TEST3");
203         }
204         protected signal first NONE (NONE)
205         void googlegoogle4(self)
206         {
207                 puts("TEST4");
208         }
209         virtual private
210         void testprivvirtual(self, int some_array[5][8][9])
211         {
212                 puts("TEST3");
213                 googlegoogle(self);
214         }
215         private virtual
216         void testprivvirtual2(self, int some_array[5][8][9])
217         {
218                 /* nothing here */
219         }
220         public virtual
221         void testpublicvirtual(self, int some_array[5][8][9])
222         {
223                 /* nothing here */
224         }
225         protected virtual
226         void testprotectedvirtual(self, int some_array[5][8][9])
227         {
228                 /* nothing here */
229         }
230         signal first NONE (POINTER)
231         void testarrsignal(self, long arr[8])
232         {
233                 /* foo */
234         }
235
236         /* testing empty func */
237         public void foofoofoo(self) {}
238         /* testing empty func 2 */
239         public void foofoofoo2(self);
240         /* testing empty func 3 */
241         public void foofoofoo3(self) {   }
242         /* testing empty func 4 */
243         public void foofoofoo4(self)
244         {
245         }
246
247         override (Gtk:Widget)
248         int event(Gtk:Widget *self (check null type),
249                   GdkEvent *event (check null)) onerror FALSE
250         {
251                 int ret;
252                 /* some code */
253                 ret = PARENT_HANDLER(self,event);
254                 /* some code */
255                 return ret;
256         }
257         override(Gtk:Container)
258         void
259         remove(Gtk:Container * self (check null type),
260                Gtk:Widget * wid (check null type));
261
262         protected
263         int foobar(self) {
264                 /* just an empty function */
265                 return 5;
266         }
267
268         signal last NONE(CHAR,UCHAR,BOOL,INT,UINT,LONG,ULONG,FLOAT,DOUBLE,
269                          STRING,ENUM,FLAGS,BOXED,POINTER,OBJECT)
270         void
271         testargs(self, gchar a, guchar b, gboolean c, gint d, guint e, glong f,
272                  gulong g, gfloat h, gdouble i, gchar * j, gint k,
273                  guint l, gpointer m, gpointer o, GtkObject *p)
274         {
275                 /* ugh, testing casting */
276         }
277
278         public signal (NO_HOOKS) last INT (INT)
279         int testflags(self, int w (check > 0)) defreturn -99 {
280                 /*foo*/
281                 return w;
282         }
283
284         /* testing NONE */
285         signal BOOL (NONE)
286         gboolean
287         test_none_thing (self)
288         {
289                 return FALSE;
290         }
291         /* testing empty statements */
292         ;
293         ;
294         ;
295 }
296
297 %{
298
299 static void
300 jjjj(void)
301 {
302 }
303
304 void
305 bubu(void)
306 {
307         jjjj();
308 }
309
310 %}