]> git.draconx.ca Git - gob-dx.git/blob - src/test.gob
181b92d3d2ea73d08c393a6eee022c1807694505
[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.92.1
7
8 %{
9 #include <stdio.h>
10 /* the next line is not mandatory, but if gob finds an include in one of
11    the %{ %} sections above the class definitions, it will not put it in
12    the file itself.  So you can this way select where the include file is
13    at */
14 #include "gtk-weird-button.h"
15 #include "gtk-weird-button-private.h"
16
17 /* this is to test if the lexer won't get confused by requires inside
18    some c code
19 requires 99.99.99
20 */
21
22 static void jjjj(void);
23 %}
24
25 %h{
26 void bubu(void);
27 %}
28
29 class Gtk:Weird:Button from Gtk:Button {
30         public int i;
31         argument INT i set { self->i = ARG; } get { ARG = self->i; } ;
32         argument POINTER (type GtkObject *) some_object
33                 set { /* set some_object */ }
34                 get { /* get some_object */
35                         ARG=NULL; };
36         argument (CONSTRUCT) LONG (type long) write_only_long
37                 set { /* set write_only_long */ };
38         argument POINTER (type char *) read_only_string
39                 get { /* get readonly_long */
40                         ARG = g_strdup("BLAH"); };
41         private int j;
42         public GtkWidget * h;
43         public char *bleh;
44         public double array[23][18];
45         protected unsigned long int wagawaga;
46         public int wagawaga_should_be_after_this_in_the_header;
47
48         init(object) {
49                 object->i=0;
50         }
51         class_init(klass);
52         public GtkWidget * new(int j (check > 0)) {
53                 GtkWidget *ret;
54                 ret = GTK_WIDGET (GET_NEW);
55
56                 GTK_WEIRD_BUTTON(ret)->_priv->j = j;
57
58                 return ret;
59         }
60         private int blah(self, Gtk:Widget * wid (check null type),
61                          int h (check > 0)) onerror -1 {
62                 gtk_container_add(GTK_CONTAINER(self),wid);
63
64                 gtk_object_set(GTK_OBJECT(self),
65                                GTK_WEIRD_BUTTON_ARG_I(99),
66                                NULL);
67                 return h;
68         }
69         signal last INT (POINTER, INT)
70         int bleh(self, Gtk:Widget * wid (check null type),
71                         int h (check > 0)) {
72                 return blah(self,wid,h);
73         }
74         signal last INT (POINTER, INT)
75         int bleh2(self, Gtk:Widget * wid (check null type),
76                         int h (check > 0)) {
77                 /* testing multiple marshaller support */
78                 return 0;
79         }
80         signal first NONE (NONE)
81         void bloh(self);
82         virtual void * bah(self, int h (check > 0)) onerror NULL {
83                 beh(self,h);
84                 return NULL;
85         }
86         virtual int beh(self, int h (check > 0));
87         override(Gtk:Container) void add(Gtk:Container * self (check null type),
88                                          Gtk:Widget * wid (check null type)) {
89                 PARENT_HANDLER(self,wid);
90         }
91         public int consttest(self, const gchar *text, ...)
92         {
93                 return 25;
94         }
95         signal private first NONE (NONE)
96         void googlegoogle(self)
97         {
98                 puts("TEST1");
99                 googlegoogle2(self);
100         }
101         signal first private NONE (NONE)
102         void googlegoogle2(self)
103         {
104                 int array[5][8][9]={{{0}}};
105                 puts("TEST2");
106                 testprivvirtual(self,array);
107         }
108         private signal first NONE (NONE)
109         void googlegoogle3(self)
110         {
111                 puts("TEST3");
112         }
113         protected signal first NONE (NONE)
114         void googlegoogle4(self)
115         {
116                 puts("TEST4");
117         }
118         virtual private
119         void testprivvirtual(self, int some_array[5][8][9])
120         {
121                 puts("TEST3");
122                 googlegoogle(self);
123         }
124         private virtual
125         void testprivvirtual2(self, int some_array[5][8][9])
126         {
127                 /* nothing here */
128         }
129         public virtual
130         void testpublicvirtual(self, int some_array[5][8][9])
131         {
132                 /* nothing here */
133         }
134         protected virtual
135         void testprotectedvirtual(self, int some_array[5][8][9])
136         {
137                 /* nothing here */
138         }
139         signal first NONE (POINTER)
140         void testarrsignal(self, long arr[8])
141         {
142                 /* foo */
143         }
144
145         /* testing empty func */
146         public void foofoofoo(self) {}
147         /* testing empty func 2 */
148         public void foofoofoo2(self);
149         /* testing empty func 3 */
150         public void foofoofoo3(self) {   }
151         /* testing empty func 4 */
152         public void foofoofoo4(self)
153         {
154         }
155
156         override (Gtk:Widget)
157         int event(Gtk:Widget *self (check null type),
158                   GdkEvent *event (check null)) onerror FALSE
159         {
160                 int ret;
161                 /* some code */
162                 ret = PARENT_HANDLER(self,event);
163                 /* some code */
164                 return ret;
165         }
166         override(Gtk:Container)
167         void
168         remove(Gtk:Container * self (check null type),
169                Gtk:Widget * wid (check null type));
170
171         protected
172         int foobar(self) {
173                 /* just an empty function */
174                 return 5;
175         }
176
177         signal last NONE(CHAR,UCHAR,BOOL,INT,UINT,LONG,ULONG,FLOAT,DOUBLE,
178                          STRING,ENUM,FLAGS,BOXED,POINTER,OBJECT)
179         void
180         testargs(self, gchar a, guchar b, gboolean c, gint d, guint e, glong f,
181                  gulong g, gfloat h, gdouble i, gchar * j, gint k,
182                  guint l, gpointer m, gpointer o, GtkObject *p)
183         {
184                 /* ugh, testing casting */
185         }
186 }
187
188 %{
189
190 static void
191 jjjj(void)
192 {
193 }
194
195 void
196 bubu(void)
197 {
198         jjjj();
199 }
200
201 %}