]> git.draconx.ca Git - gob-dx.git/blob - src/test.gob
Release 1.99.1
[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 1.99.0
7
8 %at{
9 /* ALL TOP */
10 %}
11
12 %headertop{
13 /* this should go on the very top of the header */
14
15 %}
16 %ht{
17 /* this should go on the very top of the header as well */
18 %}
19 %ph{
20 /* this should go into the private header */
21 %}
22 %privateheader{
23 /* this should go into the private header as well*/
24 %}
25
26
27 %{
28 #include <stdio.h>
29 /* the next line is not mandatory, but if gob finds an include in one of
30    the %{ %} sections above the class definitions, it will not put it in
31    the file itself.  So you can this way select where the include file is
32    at */
33 #include "test-object.h"
34 #include "test-object-private.h"
35
36 /* this is to test if the lexer won't get confused by requires inside
37    some c code
38 requires 99.99.99
39 */
40
41 static void jjjj(void);
42
43 #define _(x) x
44 %}
45
46 %h{
47 enum _gob__enum_t {
48         BUDLIKY, BUDLIKY2
49 };
50
51 struct _gob__struct_t {
52         int i, x, y, z;
53 };
54 union _gob__union_t {
55         int i, x, y, z;
56 };
57 void bubu(void);
58 %}
59 %header{
60 /* this should be in the header, just under bubu prototype */
61 #define TEST_ARRAY 5
62 %}
63
64 class Test:Object from G:Object {
65
66         public int test_array[TEST_ARRAY];
67         public int i;
68         argument INT i set { self->i = ARG; } get { ARG = self->i; } ;
69
70         public int testing = 1;
71         argument INT testing link;
72
73         public char * testingstring = {g_strdup("test")}
74                 destroywith g_free;
75         argument POINTER testingstring stringlink;
76
77         public Test:Object * testingobj
78                 destroywith g_object_unref;
79         argument POINTER testingobj objectlink;
80
81         classwide int foo = 20;
82         argument INT foo link;
83
84         public G:Object * testingobj2
85                 destroy {
86                         if(VAR)
87                                 g_object_unref(G_OBJECT(VAR));
88                 };
89         argument POINTER (type G:Object *) testingobj2 objectlink;
90         
91         argument POINTER (type GObject *) some_object
92                 set { /* set some_object */ }
93                 get { /* get some_object */
94                         ARG=NULL; };
95         argument (CONSTRUCT) LONG (type long) write_only_long
96                 set { /* set write_only_long */ };
97         argument POINTER (type char *) read_only_string
98                 get { /* get readonly_long */
99                         ARG = g_strdup("BLAH"); };
100
101         private char a_property;
102         property CHAR a_property
103                 (nick = _("Nick"),
104                  blurb = _("Blurb"),
105                  minimum = 'a',
106                  maximum = 'Z',
107                  default_value = 'C',
108                  export)
109                 set { self->_priv->a_property = g_value_get_char (VAL); }
110                 get { g_value_set_char (VAL, self->_priv->a_property); };
111
112
113         private char *b_property;
114         property STRING b_property
115                 (nick = _("Nick b"),
116                  blurb = _("Blurb b"),
117                  default_value = "default",
118                  type = char *,
119                  flags = CONSTRUCT,
120                  export,
121                  link);
122
123
124         private int j;
125         public GObject * h;
126         public char *bleh;
127         public double array[23][18];
128         protected unsigned long int wagawaga;
129         public int wagawaga_should_be_after_this_in_the_header;
130
131         init(object) {
132                 object->i=0;
133         }
134         class_init(klass);
135
136         /**
137          * new:
138          * @j: foo
139          *
140          * budliky budliky
141          *
142          * Returns: new object
143          */
144         public GObject * new(int j (check > 0)) {
145                 GObject *ret;
146                 ret = G_OBJECT (GET_NEW);
147
148                 SELF(ret)->_priv->j = j;
149
150                 return ret;
151         }
152         private int blah(self, G:Object * wid (check null type),
153                          int h (check > 0)) onerror -1 {
154                 g_object_set (G_OBJECT (self),
155                               TEST_OBJECT_PROP_I (99),
156                               NULL);
157                 return h;
158         }
159         /**
160          * bleh:
161          * @self: foo
162          * @wid: foo
163          * @h: foo
164          *
165          * budliky budliky 2
166          *
167          * Returns: new object
168          **/
169         signal last STRING (POINTER, INT)
170         char * bleh(self, G:Object * wid (check null type),
171                         int h (check > 0)) {
172                 return self_blah(self,wid,h) > 0 ? g_strdup ("foo") : g_strdup ("bar");
173         }
174
175         private
176         int
177         test_handler (self, GObject *w, int h, gpointer data)
178         {
179                 return -1;
180         }
181
182         /**
183          * gtk_weird_button_bleh2:
184          * @self: foo
185          * @wid: foo
186          * @h: foo
187          *
188          * budliky budliky 3
189          *
190          * Returns: new object */
191         signal last INT (POINTER, INT)
192         int bleh2(self, const G:Object * wid (check null type),
193                         int h (check > 0)) {
194                 /*gtk_signal_connect (GTK_OBJECT (self),
195                                     GTK_WEIRD_BUTTON_SIGNAL_BLEH (test_handler),
196                                     NULL);*/
197
198                 /* testing multiple marshaller support */
199                 return 0;
200         }
201         /* this should not get documented as it's nonstandard */
202         /**
203          * bloh:
204
205          ******/
206
207         /* Here we are testing how the gtk-doc extraction code error handeling
208            it should just ingore these */
209         /**
210           */
211
212         /** */
213         /**
214          *
215          * bubu
216          *********/
217         /**
218          *
219          * bubu
220          **zblunk*******/
221         /**
222          *
223          * bubu
224          *zblunk*******//**//**/
225         signal first NONE (NONE)
226         void bloh(self);
227         virtual void * bah(self, int h (check > 0)) onerror NULL defreturn 0 {
228                 self_beh(self,h);
229                 return NULL;
230         }
231         virtual int beh(self, int h (check > 0));
232         /*override(G:Object) void add(Gtk:Container * self (check null type),
233                                          Gtk:Widget * wid (check null type)) {
234                 PARENT_HANDLER(self,wid);
235         }*/
236         public int consttest(self, const gchar *text, ...)
237         {
238                 return 25;
239         }
240         public int consttest2(self, gchar const *text, ...)
241         {
242                 return 25;
243         }
244         public int consttest3(self, G:Object const *wid (check null type))
245         {
246                 return 25;
247         }
248         public int consttest4(const self)
249         {
250                 return 25;
251         }
252         public int consttest5(self const)
253         {
254                 return 25;
255         }
256         virtual int consttest6(const self)
257         {
258                 return 25;
259         }
260         virtual int consttest7(self const)
261         {
262                 return 25;
263         }
264         public int consttest8(self)
265         {
266                 Self const *selfconst1, *selfconst2;
267                 selfconst1 = SELF_CONST(self);
268                 selfconst2 = TEST_OBJECT_CONST(self);
269                 return 25;
270         }
271         public int consttest9(const self, int i, double b)
272         {
273                 return 25;
274         }
275         public int consttest10(self const, int i, double b)
276         {
277                 return 25;
278         }
279         signal private first NONE (NONE)
280         void googlegoogle(self)
281         {
282                 puts("TEST1");
283                 self_googlegoogle2(self);
284         }
285         signal first private NONE (NONE)
286         void googlegoogle2(self)
287         {
288                 int array[5][8][9]={{{0}}};
289                 Self *foo = self;
290                 puts("TEST2");
291                 self_testprivvirtual(foo, array);
292         }
293         private signal first NONE (NONE)
294         void googlegoogle3(self)
295         {
296                 puts("TEST3");
297         }
298         protected signal first NONE (NONE)
299         void googlegoogle4(self)
300         {
301                 puts("TEST4");
302         }
303         protected signal first NONE (NONE)
304         void googlegoogle_const1(const self)
305         {
306                 puts("TEST4");
307         }
308         protected signal first NONE (NONE)
309         void googlegoogle_const2(self const)
310         {
311                 puts("TEST4");
312         }
313         virtual private
314         void testprivvirtual(self, int some_array[5][8][9])
315         {
316                 puts("TEST3");
317                 self_googlegoogle(self);
318         }
319         private virtual
320         void testprivvirtual2(self, const int some_array[5][8][9])
321         {
322                 /* nothing here */
323         }
324         public virtual
325         void testpublicvirtual(self, int const some_array[5][8][9])
326         {
327                 /* nothing here */
328         }
329         protected virtual
330         void testprotectedvirtual(self, int some_array[5][8][9])
331         {
332                 /* nothing here */
333         }
334         signal first NONE (POINTER)
335         void testarrsignal(self, long arr[8])
336         {
337                 /* foo */
338         }
339
340         /* testing empty func */
341         public void foofoofoo(self) {}
342         /* testing empty func 2 */
343         public void foofoofoo2(self);
344         /* testing empty func 3 */
345         public void foofoofoo3(self) {   }
346         /* testing empty func 4 */
347         public void foofoofoo4(self)
348         {
349         }
350
351 //      override (Gtk:Widget)
352 //      int event(Gtk:Widget *self (check null type),
353 //                GdkEvent *event (check null)) onerror FALSE
354 //      {
355 //              int ret;
356 //              /* some code */
357 //              ret = PARENT_HANDLER(self,event);
358 //              /* some code */
359 //              return ret;
360 //      }
361 //      override(Gtk:Container)
362 //      void
363 //      remove(Gtk:Container * self (check null type),
364 //             Gtk:Widget * wid (check null type));
365 //
366 //      override(Gtk:Object)
367 //      void
368 //      destroy(Gtk:Object * self (check null type))
369 //      {
370 //              /* foo bar */
371 //              PARENT_HANDLER(self);
372 //      }
373
374         protected
375         int foobar(self) {
376                 /* just an empty function */
377                 return 5;
378         }
379
380         signal last NONE(CHAR,UCHAR,BOOLEAN,INT,UINT,LONG,ULONG,FLOAT,DOUBLE,
381                          STRING,ENUM,FLAGS,BOXED,POINTER,OBJECT)
382         void
383         testargs(self, gchar a, guchar b, gboolean c, gint d, guint e, glong f,
384                  gulong g, gfloat h, gdouble i, gchar * j, gint k,
385                  guint l, gpointer m, gpointer o, GObject *p)
386         {
387                 /* ugh, testing casting */
388         }
389
390         public signal (NO_HOOKS) last INT (INT)
391         int testflags(self, int w (check > 0)) defreturn -99 {
392                 /*foo*/
393                 return w;
394         }
395
396         /* testing NONE */
397         signal BOOLEAN (NONE)
398         gboolean
399         test_none_thing (self)
400         {
401                 return FALSE;
402         }
403
404         /* testing types */
405         public int t1;
406         public long int t2;
407         public int long t3;
408         public int long const t4;
409         public const int long t5;
410         public const char * const t6;
411         public char const * const t7;
412         public enum _gob__enum_t const * const t8;
413         public union _gob__union_t t9;
414         public union _gob__union_t * const * const * t10;
415         public struct _gob__struct_t * const * const * t11;
416         public const struct _gob__struct_t * const * const * t13;
417         public const enum _gob__enum_t * const * const * t14;
418         public enum _gob__enum_t t15;
419         public gchar const t16;
420         public const gchar * const t17;
421         public const gchar t18;
422
423         /* testing method with no arguments */
424         public void method_with_no_arguments (void)
425         {
426                 /* FOO */
427         }
428
429         /* testing calling the above method */
430         public void foo (self) {
431                 self_method_with_no_arguments ();
432         }
433
434         /* this is to test custom get_type */
435         /*public GtkType
436         get_type (void)
437         {
438                 static guint type = 0;
439
440                 if ( ! type) {
441                         static const GtkTypeInfo info = {
442                                 "GtkWeirdButton",
443                                 sizeof (GtkWeirdButton),
444                                 sizeof (GtkWeirdButtonClass),
445                                 (GtkClassInitFunc) gtk_weird_button_class_init,
446                                 (GtkObjectInitFunc) gtk_weird_button_init,
447                                 NULL,
448                                 NULL,
449                                 (GtkClassInitFunc) NULL
450                         };
451
452                         type = gtk_type_unique (gtk_button_get_type(), &info);
453                 }
454
455                 return type;
456         }*/
457
458
459         /* testing empty statements */
460         ;
461         ;
462         ;
463 }
464
465 %{
466
467 static void
468 jjjj(void)
469 {
470 }
471
472 void
473 bubu(void)
474 {
475         jjjj();
476 }
477
478 %}