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 */
13 /* this should go on the very top of the header */
17 /* this should go on the very top of the header as well */
20 /* this should go into the private header */
23 /* this should go into the private header as well*/
27 /* between the declarations and the method implementations */
35 /* the next line is not mandatory, but if gob finds an include in one of
36 the %{ %} sections above the class definitions, it will not put it in
37 the file itself. So you can this way select where the include file is
39 #include "test-object.h"
40 #include "test-object-private.h"
42 /* this is to test if the lexer won't get confused by requires inside
47 static void jjjj(void);
57 struct _gob__struct_t {
66 #define PACKAGE_TYPE_BOXED 1
67 typedef void * PackageBoxed;
71 /* this should be in the header, just under bubu prototype */
87 error TEST_OBJECT_ERROR {
100 class Test:Object from /*G:Object*/ Gtk:Container
101 (interface Gtk:Tree:Model)
102 /* We can add more interfaces by adding more lines like the above */
103 /* Note that there must exist a GtkTreeModelIface structure */
106 /* function implemented for the Gtk:Tree:Model interface */
107 interface Gtk:Tree:Model
108 private GtkTreeModelFlags
109 get_flags (Gtk:Tree:Model *self (check null type))
112 return (GtkTreeModelFlags)0;
117 public int test_array[TEST_ARRAY];
119 argument INT i set { self->i = ARG; } get { ARG = self->i; } ;
121 public int testing = 1;
122 argument INT testing link;
124 public char * testingstring = {g_strdup("test")}
126 argument POINTER testingstring stringlink;
128 public Test:Object * testingobj
129 unrefwith g_object_unref;
130 argument POINTER testingobj objectlink;
132 public Test:Object * testingobjllll
133 unrefwith gtk_widget_destroy;
134 argument POINTER testingobjllll objectlink;
136 public Test:Object * testingobjfoo
137 unref { if (VAR) g_object_unref (VAR); };
138 argument POINTER testingobjfoo objectlink;
140 classwide int foo = 20;
141 argument INT foo link;
143 public G:Object * testingobj2
146 g_object_unref(G_OBJECT(VAR));
148 argument POINTER (type G:Object *) testingobj2 objectlink;
150 argument POINTER (type GObject *) some_object
151 set { /* set some_object */ }
152 get { /* get some_object */
154 argument (CONSTRUCT) LONG (type long) write_only_long
155 set { /* set write_only_long */ };
156 argument POINTER (type char *) read_only_string
157 get { /* get readonly_long */
158 ARG = g_strdup("BLAH"); };
160 private char a_property;
161 property CHAR a_property
168 set { self->_priv->a_property = g_value_get_char (VAL); }
169 get { g_value_set_char (VAL, self->_priv->a_property); };
171 property OBJECT foobarblahllll1
174 object_type = Gtk:Button)
176 property OBJECT foobarblahllll2
179 object_type = G:Object)
182 private double dblnum;
183 property DOUBLE dblnum
189 flags = CONSTRUCT|CONSTRUCT_ONLY,
193 private char *b_property;
194 property STRING b_property
196 blurb = _("Blurb b"),
197 default_value = "default",
203 private Test:Object *objectproperty;
204 property OBJECT objectproperty (nick = "object",
205 blurb = "obj property",
206 object_type = Test:Object,
209 private Test:Enum enum_property;
210 property ENUM enum_property (nick = "enumprop",
212 enum_type = Test:Enum,
215 private Some:Flags flags_property;
216 property FLAGS flags_property (nick = "flagsprop",
218 flags_type = Some:Flags,
221 private PackageBoxed prop;
222 property BOXED prop (nick="prop",
224 boxed_type=Package:Boxed,
226 /* testing old semantics */
227 private PackageBoxed prop2;
228 property BOXED prop2 (nick="prop2",
230 boxed_type=PACKAGE_TYPE_BOXED,
233 private char ov_prop;
234 property CHAR ov_prop
237 set { self->_priv->ov_prop = g_value_get_char (VAL); }
238 get { g_value_set_char (VAL, self->_priv->ov_prop); };
244 public double array[23][18];
245 protected unsigned long int wagawaga;
246 public int wagawaga_should_be_after_this_in_the_header;
259 * Returns: new object
261 public GObject * new(int j (check > 0)) {
263 ret = G_OBJECT (GET_NEW);
265 SELF(ret)->_priv->j = j;
269 private int blah(self, G:Object * wid (check null type),
270 int h (check > 0)) onerror -1 {
271 g_object_set (G_OBJECT (self),
272 TEST_OBJECT_PROP_I (99),
284 * Returns: new object
286 signal last STRING (POINTER, INT)
287 char * bleh(self, G:Object * wid (check null type),
289 return self_blah(self,wid,h) > 0 ? g_strdup ("foo") : g_strdup ("bar");
293 /* constructor stuff */
306 test_handler (self, GObject *w, int h, gpointer data)
315 * gtk_weird_button_bleh2:
322 * Returns: new object */
323 signal last INT (POINTER, INT)
324 int bleh2(self, const G:Object * wid (check null type),
327 test_object_connect__bleh (self, self_test_handler, NULL);
328 self_connect__bleh (self, self_test_handler, NULL);
329 test_object_connect_after__bleh (self, self_test_handler, NULL);
330 self_connect_after__bleh (self, self_test_handler, NULL);
331 test_object_connect_data__bleh (self, self_test_handler, NULL, NULL, 0);
332 self_connect_data__bleh (self, self_test_handler, NULL, NULL, 0);
337 /* testing multiple marshaller support */
340 /* this should not get documented as it's nonstandard */
346 /* Here we are testing how the gtk-doc extraction code error handeling
347 it should just ingore these */
363 *zblunk*******//**//**/
364 signal first NONE (NONE)
366 virtual void * bah(self, int h (check > 0)) onerror NULL defreturn 0 {
370 virtual int beh(self, int h (check > 0));
371 override(Gtk:Container)
372 void add(Gtk:Container * self (check null type),
373 Gtk:Widget * wid (check null type)) {
374 PARENT_HANDLER(self,wid);
378 void dispatch_properties_changed (G:Object *object,
388 public int consttest(self, const gchar *text, ...)
393 public int consttest2(self, gchar const *text, ...)
398 public int consttest3(self, G:Object const *wid (check null type))
403 public int consttest4(const self)
407 public int consttest5(self const)
411 virtual int consttest6(const self)
415 virtual int consttest7(self const)
419 public int consttest8(self)
421 Self const *selfconst1, *selfconst2;
422 selfconst1 = SELF_CONST(self);
423 selfconst2 = TEST_OBJECT_CONST(self);
426 public int consttest9(const self, int i, double b)
432 public int consttest10(self const, int i, double b)
438 public gchar *funcattrtest(self, const char *format (check null), ...)
439 attr {G_GNUC_PRINTF (2, 3)}
444 va_start(ap, format);
445 result = g_strdup_vprintf (format, ap);
449 private gchar *funcattrtest2(self, const char *format, ...)
450 attr {G_GNUC_SCANF(2,3)}
452 gchar *nonsense = NULL;
456 protected gchar *funcattrtest3(self, const char *format)
457 attr {G_GNUC_FORMAT (2)}
459 gchar *nonsense = NULL;
463 private char *funcattrtest4(self, const char *format, ...)
464 attr {G_GNUC_PRINTF(2,3)}
467 gchar *nonsense = NULL;
471 protected char * funcattrtest5(self, const char *format, ...)
473 attr {G_GNUC_PRINTF(2,3)}
475 gchar *nonsense = NULL;
479 public char * funcattrtest6(self, const char *format, ...)
480 attr {G_GNUC_PRINTF(2,3)}
483 gchar *nonsense = NULL;
487 // Note that the parser should accept defreturn with function
488 // attributes as well, but this may not be a good thing since
489 // it probably doesn't make sense, so we don't test it.
490 signal private first NONE (NONE)
491 void googlegoogle(self)
494 self_googlegoogle2(self);
496 signal first private NONE (NONE)
497 void googlegoogle2(self)
499 int array[5][8][9]={{{0}}};
502 self_testprivvirtual(foo, array);
504 private signal first NONE (NONE)
505 void googlegoogle3(self)
509 protected signal first NONE (NONE)
510 void googlegoogle4(self)
514 protected signal first NONE (NONE)
515 void googlegoogle_const1(const self)
519 protected signal first NONE (NONE)
520 void googlegoogle_const2(self const)
525 void testprivvirtual(self, int some_array[5][8][9])
528 self_googlegoogle(self);
529 if (some_array[0]) return;
532 void testprivvirtual2(self, const int some_array[5][8][9])
535 if (some_array[0]) return;
538 void testpublicvirtual(self, int const some_array[5][8][9])
541 if (some_array[0]) return;
544 void testprotectedvirtual(self, int some_array[5][8][9])
547 if (some_array[0]) return;
549 signal first NONE (POINTER, ENUM)
550 void testarrsignal(self, long arr[8], Buble:Enum foo)
557 /* testing empty func */
558 public void foofoofoo(self) {}
559 /* testing empty func 2 */
560 public void foofoofoo2(self);
561 /* testing empty func 3 */
562 public void foofoofoo3(self) { }
563 /* testing empty func 4 */
564 public void foofoofoo4(self)
568 // override (Gtk:Widget)
569 // int event(Gtk:Widget *self (check null type),
570 // GdkEvent *event (check null)) onerror FALSE
574 // ret = PARENT_HANDLER(self,event);
578 // override(Gtk:Container)
580 // remove(Gtk:Container * self (check null type),
581 // Gtk:Widget * wid (check null type));
583 // override(Gtk:Object)
585 // destroy(Gtk:Object * self (check null type))
588 // PARENT_HANDLER(self);
593 /* just an empty function */
597 signal last NONE(CHAR,UCHAR,BOOLEAN,INT,UINT,LONG,ULONG,FLOAT,DOUBLE,
598 STRING,ENUM,POINTER,OBJECT)
600 testargs(self, gchar a, guchar b, gboolean c, gint d, guint e, glong f,
601 gulong g, gfloat h, gdouble i, gchar * j, gint k,
602 gpointer o, GObject *p)
605 a = b = c = d = e = f = g = 0;
606 o = p = (GObject *)NULL;
608 /* ugh, testing casting */
611 public signal (NO_HOOKS) last INT (INT)
612 int testflags(self, int w (check > 0)) defreturn -99 {
618 signal BOOLEAN (NONE)
620 test_none_thing (self)
625 /* some more enum testing */
626 public BubleEnum buble;
630 enum_type = Buble:Enum,
631 default_value = BUBLE_STANDARD,
638 public int long const t4;
639 public const int long t5;
640 public const char * const t6;
641 public char const * const t7;
642 public enum _gob__enum_t const * const t8;
643 public union _gob__union_t t9;
644 public union _gob__union_t * const * const * t10;
645 public struct _gob__struct_t * const * const * t11;
646 public const struct _gob__struct_t * const * const * t13;
647 public const enum _gob__enum_t * const * const * t14;
648 public enum _gob__enum_t t15;
649 public gchar const t16;
650 public const gchar * const t17;
651 public const gchar t18;
653 /* testing method with no arguments */
654 public void method_with_no_arguments (void)
659 /* testing calling the above method */
660 public void foo (self) {
661 self_method_with_no_arguments ();
664 /* this is to test custom get_type */
668 static guint type = 0;
671 static const GtkTypeInfo info = {
673 sizeof (GtkWeirdButton),
674 sizeof (GtkWeirdButtonClass),
675 (GtkClassInitFunc) gtk_weird_button_class_init,
676 (GtkObjectInitFunc) gtk_weird_button_init,
679 (GtkClassInitFunc) NULL
682 type = gtk_type_unique (gtk_button_get_type(), &info);
689 /* testing empty statements */