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 */
9 /* very very top of C file useful for "config.h" sort of like alltop
10 * but only for C file */
18 /* Just like ct above */
22 /* this should go on the very top of the header */
26 /* this should go on the very top of the header as well */
29 /* this should go into the private header */
32 /* this should go into the private header as well*/
36 /* between the declarations and the method implementations */
44 /* the next line is not mandatory, but if gob finds an include in one of
45 the %{ %} sections above the class definitions, it will not put it in
46 the file itself. So you can this way select where the include file is
48 #include "test-object.h"
49 #include "test-object-private.h"
51 /* this is to test if the lexer won't get confused by requires inside
56 static void jjjj(void);
66 struct _gob__struct_t {
75 #define PACKAGE_TYPE_BOXED 1
76 typedef void * PackageBoxed;
80 /* this should be in the header, just under bubu prototype */
96 error TEST_OBJECT_ERROR {
109 class Test:Object from /*G:Object*/ Gtk:Container
110 (interface Gtk:Tree:Model)
111 /* We can add more interfaces by adding more lines like the above */
112 /* Note that there must exist a GtkTreeModelIface structure */
115 /* function implemented for the Gtk:Tree:Model interface */
116 interface Gtk:Tree:Model
117 private GtkTreeModelFlags
118 get_flags (Gtk:Tree:Model *self (check null type))
121 return (GtkTreeModelFlags)0;
126 public int test_array[TEST_ARRAY];
128 argument INT i set { self->i = ARG; } get { ARG = self->i; } ;
130 public int testing = 1;
131 argument INT testing link;
133 public char * testingstring = {g_strdup("test")}
135 argument POINTER testingstring stringlink;
137 public Test:Object * testingobj
138 unrefwith g_object_unref;
139 argument POINTER testingobj objectlink;
141 public Test:Object * testingobjllll
142 unrefwith gtk_widget_destroy;
143 argument POINTER testingobjllll objectlink;
145 public Test:Object * testingobjfoo
146 unref { if (VAR) g_object_unref (VAR); };
147 argument POINTER testingobjfoo objectlink;
149 classwide int foo = 20;
150 argument INT foo link;
152 public G:Object * testingobj2
155 g_object_unref(G_OBJECT(VAR));
157 argument POINTER (type G:Object *) testingobj2 objectlink;
159 argument POINTER (type GObject *) some_object
160 set { /* set some_object */ }
161 get { /* get some_object */
163 argument (CONSTRUCT) LONG (type long) write_only_long
164 set { /* set write_only_long */ };
165 argument POINTER (type char *) read_only_string
166 get { /* get readonly_long */
167 ARG = g_strdup("BLAH"); };
169 private char a_property;
170 property CHAR a_property
179 set { self->_priv->a_property = g_value_get_char (VAL); }
180 get { g_value_set_char (VAL, self->_priv->a_property); };
182 property OBJECT foobarblahllll1
185 object_type = Gtk:Button)
187 property OBJECT foobarblahllll2
190 object_type = G:Object)
193 private double dblnum;
194 property DOUBLE dblnum
200 flags = CONSTRUCT|CONSTRUCT_ONLY,
204 private char *b_property;
205 property STRING b_property
207 blurb = _("Blurb b"),
208 default_value = "default",
214 private Test:Object *objectproperty;
215 property OBJECT objectproperty (nick = "object",
216 blurb = "obj property",
217 object_type = Test:Object,
220 private Test:Enum enum_property;
221 property ENUM enum_property (nick = "enumprop",
223 enum_type = Test:Enum,
226 private Some:Flags flags_property;
227 property FLAGS flags_property (nick = "flagsprop",
229 flags_type = Some:Flags,
232 private PackageBoxed prop;
233 property BOXED prop (nick="prop",
235 boxed_type=Package:Boxed,
237 /* testing old semantics */
238 private PackageBoxed prop2;
239 property BOXED prop2 (nick="prop2",
241 boxed_type=PACKAGE_TYPE_BOXED,
244 private char ov_prop;
245 property CHAR ov_prop
248 set { self->_priv->ov_prop = g_value_get_char (VAL); }
249 get { g_value_set_char (VAL, self->_priv->ov_prop); };
255 public double array[23][18];
256 protected unsigned long int wagawaga;
257 public int wagawaga_should_be_after_this_in_the_header;
272 * Returns: new object
274 public GObject * new(int j (check > 0)) {
276 ret = G_OBJECT (GET_NEW);
278 SELF(ret)->_priv->j = j;
282 private int blah(self, G:Object * wid (check null type),
283 int h (check > 0)) onerror -1 {
284 g_object_set (G_OBJECT (self),
285 TEST_OBJECT_PROP_I (99),
297 * Returns: new object
299 signal last STRING "bleh-signal" (POINTER, INT)
300 char * bleh(self, G:Object * wid (check null type),
302 return self_blah(self,wid,h) > 0 ? g_strdup ("foo") : g_strdup ("bar");
306 /* constructor stuff */
319 test_handler (self, GObject *w, int h, gpointer data)
328 * gtk_weird_button_bleh2:
335 * Returns: new object */
336 signal last INT (POINTER, INT)
337 int bleh2(self, const G:Object * wid (check null type),
340 test_object_connect__bleh (self, self_test_handler, NULL);
341 self_connect__bleh (self, self_test_handler, NULL);
342 test_object_connect_after__bleh (self, self_test_handler, NULL);
343 self_connect_after__bleh (self, self_test_handler, NULL);
344 test_object_connect_data__bleh (self, self_test_handler, NULL, NULL, 0);
345 self_connect_data__bleh (self, self_test_handler, NULL, NULL, 0);
350 /* testing multiple marshaller support */
353 /* this should not get documented as it's nonstandard */
359 /* Here we are testing how the gtk-doc extraction code error handeling
360 it should just ingore these */
376 *zblunk*******//**//**/
377 signal first NONE (NONE)
379 virtual void * bah(self, int h (check > 0)) onerror NULL defreturn 0 {
383 virtual int beh(self, int h (check > 0));
384 override(Gtk:Container)
385 void add(Gtk:Container * self (check null type),
386 Gtk:Widget * wid (check null type)) {
387 PARENT_HANDLER(self,wid);
391 void dispatch_properties_changed (G:Object *object,
401 public int consttest(self, const gchar *text, ...)
406 public int consttest2(self, gchar const *text, ...)
411 public int consttest3(self, G:Object const *wid (check null type))
416 public int consttest4(const self)
420 public int consttest5(self const)
424 virtual int consttest6(const self)
428 virtual int consttest7(self const)
432 public int consttest8(self)
434 Self const *selfconst1, *selfconst2;
435 selfconst1 = SELF_CONST(self);
436 selfconst2 = TEST_OBJECT_CONST(self);
439 public int consttest9(const self, int i, double b)
445 public int consttest10(self const, int i, double b)
451 public gchar *funcattrtest(self, const char *format (check null), ...)
452 attr {G_GNUC_PRINTF (2, 3)}
457 va_start(ap, format);
458 result = g_strdup_vprintf (format, ap);
462 private gchar *funcattrtest2(self, const char *format, ...)
463 attr {G_GNUC_SCANF(2,3)}
465 gchar *nonsense = NULL;
469 protected gchar *funcattrtest3(self, const char *format)
470 attr {G_GNUC_FORMAT (2)}
472 gchar *nonsense = NULL;
476 private char *funcattrtest4(self, const char *format, ...)
477 attr {G_GNUC_PRINTF(2,3)}
480 gchar *nonsense = NULL;
484 protected char * funcattrtest5(self, const char *format, ...)
486 attr {G_GNUC_PRINTF(2,3)}
488 gchar *nonsense = NULL;
492 public char * funcattrtest6(self, const char *format, ...)
493 attr {G_GNUC_PRINTF(2,3)}
496 gchar *nonsense = NULL;
500 // Note that the parser should accept defreturn with function
501 // attributes as well, but this may not be a good thing since
502 // it probably doesn't make sense, so we don't test it.
503 signal private first NONE (NONE)
504 void googlegoogle(self)
507 self_googlegoogle2(self);
509 signal first private NONE (NONE)
510 void googlegoogle2(self)
512 int array[5][8][9]={{{0}}};
515 self_testprivvirtual(foo, array);
517 private signal first NONE (NONE)
518 void googlegoogle3(self)
522 protected signal first NONE (NONE)
523 void googlegoogle4(self)
527 protected signal first NONE (NONE)
528 void googlegoogle_const1(const self)
532 protected signal first NONE (NONE)
533 void googlegoogle_const2(self const)
538 void testprivvirtual(self, int some_array[5][8][9])
541 self_googlegoogle(self);
542 if (some_array[0]) return;
545 void testprivvirtual2(self, const int some_array[5][8][9])
548 if (some_array[0]) return;
551 void testpublicvirtual(self, int const some_array[5][8][9])
554 if (some_array[0]) return;
557 void testprotectedvirtual(self, int some_array[5][8][9])
560 if (some_array[0]) return;
562 signal first NONE (POINTER, ENUM)
563 void testarrsignal(self, long arr[8], Buble:Enum foo)
570 /* testing empty func */
571 public void foofoofoo(self) {}
572 /* testing empty func 2 */
573 public void foofoofoo2(self);
574 /* testing empty func 3 */
575 public void foofoofoo3(self) { }
576 /* testing empty func 4 */
577 public void foofoofoo4(self)
581 // override (Gtk:Widget)
582 // int event(Gtk:Widget *self (check null type),
583 // GdkEvent *event (check null)) onerror FALSE
587 // ret = PARENT_HANDLER(self,event);
591 // override(Gtk:Container)
593 // remove(Gtk:Container * self (check null type),
594 // Gtk:Widget * wid (check null type));
596 // override(Gtk:Object)
598 // destroy(Gtk:Object * self (check null type))
601 // PARENT_HANDLER(self);
606 /* just an empty function */
610 signal last NONE(CHAR,UCHAR,BOOLEAN,INT,UINT,LONG,ULONG,FLOAT,DOUBLE,
611 STRING,ENUM,POINTER,OBJECT)
613 testargs(self, gchar a, guchar b, gboolean c, gint d, guint e, glong f,
614 gulong g, gfloat h, gdouble i, gchar * j, gint k,
615 gpointer o, GObject *p)
618 a = b = c = d = e = f = g = 0;
619 o = p = (GObject *)NULL;
621 /* ugh, testing casting */
624 public signal (NO_HOOKS) last INT (INT)
625 int testflags(self, int w (check > 0)) defreturn -99 {
631 signal BOOLEAN (NONE)
633 test_none_thing (self)
638 /* some more enum testing */
639 public BubleEnum buble;
643 enum_type = Buble:Enum,
644 default_value = BUBLE_STANDARD,
651 public int long const t4;
652 public const int long t5;
653 public const char * const t6;
654 public char const * const t7;
655 public enum _gob__enum_t const * const t8;
656 public union _gob__union_t t9;
657 public union _gob__union_t * const * const * t10;
658 public struct _gob__struct_t * const * const * t11;
659 public const struct _gob__struct_t * const * const * t13;
660 public const enum _gob__enum_t * const * const * t14;
661 public enum _gob__enum_t t15;
662 public gchar const t16;
663 public const gchar * const t17;
664 public const gchar t18;
666 /* testing method with no arguments */
667 public void method_with_no_arguments (void)
672 /* testing calling the above method */
673 public void foo (self) {
674 self_method_with_no_arguments ();
677 /* this is to test custom get_type */
681 static guint type = 0;
684 static const GtkTypeInfo info = {
686 sizeof (GtkWeirdButton),
687 sizeof (GtkWeirdButtonClass),
688 (GtkClassInitFunc) gtk_weird_button_class_init,
689 (GtkObjectInitFunc) gtk_weird_button_init,
692 (GtkClassInitFunc) NULL
695 type = gtk_type_unique (gtk_button_get_type(), &info);
702 /* testing empty statements */