]> git.draconx.ca Git - gob-dx.git/blob - src/test.gob
Release 0.92.2
[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 %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         argument POINTER (type GtkObject *) some_object
50                 set { /* set some_object */ }
51                 get { /* get some_object */
52                         ARG=NULL; };
53         argument (CONSTRUCT) LONG (type long) write_only_long
54                 set { /* set write_only_long */ };
55         argument POINTER (type char *) read_only_string
56                 get { /* get readonly_long */
57                         ARG = g_strdup("BLAH"); };
58         private int j;
59         public GtkWidget * h;
60         public char *bleh;
61         public double array[23][18];
62         protected unsigned long int wagawaga;
63         public int wagawaga_should_be_after_this_in_the_header;
64
65         init(object) {
66                 object->i=0;
67         }
68         class_init(klass);
69         public GtkWidget * new(int j (check > 0)) {
70                 GtkWidget *ret;
71                 ret = GTK_WIDGET (GET_NEW);
72
73                 GTK_WEIRD_BUTTON(ret)->_priv->j = j;
74
75                 return ret;
76         }
77         private int blah(self, Gtk:Widget * wid (check null type),
78                          int h (check > 0)) onerror -1 {
79                 gtk_container_add(GTK_CONTAINER(self),wid);
80
81                 gtk_object_set(GTK_OBJECT(self),
82                                GTK_WEIRD_BUTTON_ARG_I(99),
83                                NULL);
84                 return h;
85         }
86         signal last INT (POINTER, INT)
87         int bleh(self, Gtk:Widget * wid (check null type),
88                         int h (check > 0)) {
89                 return blah(self,wid,h);
90         }
91         signal last INT (POINTER, INT)
92         int bleh2(self, Gtk:Widget * wid (check null type),
93                         int h (check > 0)) {
94                 /* testing multiple marshaller support */
95                 return 0;
96         }
97         signal first NONE (NONE)
98         void bloh(self);
99         virtual void * bah(self, int h (check > 0)) onerror NULL {
100                 beh(self,h);
101                 return NULL;
102         }
103         virtual int beh(self, int h (check > 0));
104         override(Gtk:Container) void add(Gtk:Container * self (check null type),
105                                          Gtk:Widget * wid (check null type)) {
106                 PARENT_HANDLER(self,wid);
107         }
108         public int consttest(self, const gchar *text, ...)
109         {
110                 return 25;
111         }
112         signal private first NONE (NONE)
113         void googlegoogle(self)
114         {
115                 puts("TEST1");
116                 googlegoogle2(self);
117         }
118         signal first private NONE (NONE)
119         void googlegoogle2(self)
120         {
121                 int array[5][8][9]={{{0}}};
122                 puts("TEST2");
123                 testprivvirtual(self,array);
124         }
125         private signal first NONE (NONE)
126         void googlegoogle3(self)
127         {
128                 puts("TEST3");
129         }
130         protected signal first NONE (NONE)
131         void googlegoogle4(self)
132         {
133                 puts("TEST4");
134         }
135         virtual private
136         void testprivvirtual(self, int some_array[5][8][9])
137         {
138                 puts("TEST3");
139                 googlegoogle(self);
140         }
141         private virtual
142         void testprivvirtual2(self, int some_array[5][8][9])
143         {
144                 /* nothing here */
145         }
146         public virtual
147         void testpublicvirtual(self, int some_array[5][8][9])
148         {
149                 /* nothing here */
150         }
151         protected virtual
152         void testprotectedvirtual(self, int some_array[5][8][9])
153         {
154                 /* nothing here */
155         }
156         signal first NONE (POINTER)
157         void testarrsignal(self, long arr[8])
158         {
159                 /* foo */
160         }
161
162         /* testing empty func */
163         public void foofoofoo(self) {}
164         /* testing empty func 2 */
165         public void foofoofoo2(self);
166         /* testing empty func 3 */
167         public void foofoofoo3(self) {   }
168         /* testing empty func 4 */
169         public void foofoofoo4(self)
170         {
171         }
172
173         override (Gtk:Widget)
174         int event(Gtk:Widget *self (check null type),
175                   GdkEvent *event (check null)) onerror FALSE
176         {
177                 int ret;
178                 /* some code */
179                 ret = PARENT_HANDLER(self,event);
180                 /* some code */
181                 return ret;
182         }
183         override(Gtk:Container)
184         void
185         remove(Gtk:Container * self (check null type),
186                Gtk:Widget * wid (check null type));
187
188         protected
189         int foobar(self) {
190                 /* just an empty function */
191                 return 5;
192         }
193
194         signal last NONE(CHAR,UCHAR,BOOL,INT,UINT,LONG,ULONG,FLOAT,DOUBLE,
195                          STRING,ENUM,FLAGS,BOXED,POINTER,OBJECT)
196         void
197         testargs(self, gchar a, guchar b, gboolean c, gint d, guint e, glong f,
198                  gulong g, gfloat h, gdouble i, gchar * j, gint k,
199                  guint l, gpointer m, gpointer o, GtkObject *p)
200         {
201                 /* ugh, testing casting */
202         }
203 }
204
205 %{
206
207 static void
208 jjjj(void)
209 {
210 }
211
212 void
213 bubu(void)
214 {
215         jjjj();
216 }
217
218 %}