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