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
177 set { self->_priv->a_property = g_value_get_char (VAL); }
178 get { g_value_set_char (VAL, self->_priv->a_property); };
180 property OBJECT foobarblahllll1
183 object_type = Gtk:Button)
185 property OBJECT foobarblahllll2
188 object_type = G:Object)
191 private double dblnum;
192 property DOUBLE dblnum
198 flags = CONSTRUCT|CONSTRUCT_ONLY,
202 private char *b_property;
203 property STRING b_property
205 blurb = _("Blurb b"),
206 default_value = "default",
212 private Test:Object *objectproperty;
213 property OBJECT objectproperty (nick = "object",
214 blurb = "obj property",
215 object_type = Test:Object,
218 private Test:Enum enum_property;
219 property ENUM enum_property (nick = "enumprop",
221 enum_type = Test:Enum,
224 private Some:Flags flags_property;
225 property FLAGS flags_property (nick = "flagsprop",
227 flags_type = Some:Flags,
230 private PackageBoxed prop;
231 property BOXED prop (nick="prop",
233 boxed_type=Package:Boxed,
235 /* testing old semantics */
236 private PackageBoxed prop2;
237 property BOXED prop2 (nick="prop2",
239 boxed_type=PACKAGE_TYPE_BOXED,
242 private char ov_prop;
243 property CHAR ov_prop
246 set { self->_priv->ov_prop = g_value_get_char (VAL); }
247 get { g_value_set_char (VAL, self->_priv->ov_prop); };
253 public double array[23][18];
254 protected unsigned long int wagawaga;
255 public int wagawaga_should_be_after_this_in_the_header;
268 * Returns: new object
270 public GObject * new(int j (check > 0)) {
272 ret = G_OBJECT (GET_NEW);
274 SELF(ret)->_priv->j = j;
278 private int blah(self, G:Object * wid (check null type),
279 int h (check > 0)) onerror -1 {
280 g_object_set (G_OBJECT (self),
281 TEST_OBJECT_PROP_I (99),
293 * Returns: new object
295 signal last STRING (POINTER, INT)
296 char * bleh(self, G:Object * wid (check null type),
298 return self_blah(self,wid,h) > 0 ? g_strdup ("foo") : g_strdup ("bar");
302 /* constructor stuff */
315 test_handler (self, GObject *w, int h, gpointer data)
324 * gtk_weird_button_bleh2:
331 * Returns: new object */
332 signal last INT (POINTER, INT)
333 int bleh2(self, const G:Object * wid (check null type),
336 test_object_connect__bleh (self, self_test_handler, NULL);
337 self_connect__bleh (self, self_test_handler, NULL);
338 test_object_connect_after__bleh (self, self_test_handler, NULL);
339 self_connect_after__bleh (self, self_test_handler, NULL);
340 test_object_connect_data__bleh (self, self_test_handler, NULL, NULL, 0);
341 self_connect_data__bleh (self, self_test_handler, NULL, NULL, 0);
346 /* testing multiple marshaller support */
349 /* this should not get documented as it's nonstandard */
355 /* Here we are testing how the gtk-doc extraction code error handeling
356 it should just ingore these */
372 *zblunk*******//**//**/
373 signal first NONE (NONE)
375 virtual void * bah(self, int h (check > 0)) onerror NULL defreturn 0 {
379 virtual int beh(self, int h (check > 0));
380 override(Gtk:Container)
381 void add(Gtk:Container * self (check null type),
382 Gtk:Widget * wid (check null type)) {
383 PARENT_HANDLER(self,wid);
387 void dispatch_properties_changed (G:Object *object,
397 public int consttest(self, const gchar *text, ...)
402 public int consttest2(self, gchar const *text, ...)
407 public int consttest3(self, G:Object const *wid (check null type))
412 public int consttest4(const self)
416 public int consttest5(self const)
420 virtual int consttest6(const self)
424 virtual int consttest7(self const)
428 public int consttest8(self)
430 Self const *selfconst1, *selfconst2;
431 selfconst1 = SELF_CONST(self);
432 selfconst2 = TEST_OBJECT_CONST(self);
435 public int consttest9(const self, int i, double b)
441 public int consttest10(self const, int i, double b)
447 public gchar *funcattrtest(self, const char *format (check null), ...)
448 attr {G_GNUC_PRINTF (2, 3)}
453 va_start(ap, format);
454 result = g_strdup_vprintf (format, ap);
458 private gchar *funcattrtest2(self, const char *format, ...)
459 attr {G_GNUC_SCANF(2,3)}
461 gchar *nonsense = NULL;
465 protected gchar *funcattrtest3(self, const char *format)
466 attr {G_GNUC_FORMAT (2)}
468 gchar *nonsense = NULL;
472 private char *funcattrtest4(self, const char *format, ...)
473 attr {G_GNUC_PRINTF(2,3)}
476 gchar *nonsense = NULL;
480 protected char * funcattrtest5(self, const char *format, ...)
482 attr {G_GNUC_PRINTF(2,3)}
484 gchar *nonsense = NULL;
488 public char * funcattrtest6(self, const char *format, ...)
489 attr {G_GNUC_PRINTF(2,3)}
492 gchar *nonsense = NULL;
496 // Note that the parser should accept defreturn with function
497 // attributes as well, but this may not be a good thing since
498 // it probably doesn't make sense, so we don't test it.
499 signal private first NONE (NONE)
500 void googlegoogle(self)
503 self_googlegoogle2(self);
505 signal first private NONE (NONE)
506 void googlegoogle2(self)
508 int array[5][8][9]={{{0}}};
511 self_testprivvirtual(foo, array);
513 private signal first NONE (NONE)
514 void googlegoogle3(self)
518 protected signal first NONE (NONE)
519 void googlegoogle4(self)
523 protected signal first NONE (NONE)
524 void googlegoogle_const1(const self)
528 protected signal first NONE (NONE)
529 void googlegoogle_const2(self const)
534 void testprivvirtual(self, int some_array[5][8][9])
537 self_googlegoogle(self);
538 if (some_array[0]) return;
541 void testprivvirtual2(self, const int some_array[5][8][9])
544 if (some_array[0]) return;
547 void testpublicvirtual(self, int const some_array[5][8][9])
550 if (some_array[0]) return;
553 void testprotectedvirtual(self, int some_array[5][8][9])
556 if (some_array[0]) return;
558 signal first NONE (POINTER, ENUM)
559 void testarrsignal(self, long arr[8], Buble:Enum foo)
566 /* testing empty func */
567 public void foofoofoo(self) {}
568 /* testing empty func 2 */
569 public void foofoofoo2(self);
570 /* testing empty func 3 */
571 public void foofoofoo3(self) { }
572 /* testing empty func 4 */
573 public void foofoofoo4(self)
577 // override (Gtk:Widget)
578 // int event(Gtk:Widget *self (check null type),
579 // GdkEvent *event (check null)) onerror FALSE
583 // ret = PARENT_HANDLER(self,event);
587 // override(Gtk:Container)
589 // remove(Gtk:Container * self (check null type),
590 // Gtk:Widget * wid (check null type));
592 // override(Gtk:Object)
594 // destroy(Gtk:Object * self (check null type))
597 // PARENT_HANDLER(self);
602 /* just an empty function */
606 signal last NONE(CHAR,UCHAR,BOOLEAN,INT,UINT,LONG,ULONG,FLOAT,DOUBLE,
607 STRING,ENUM,POINTER,OBJECT)
609 testargs(self, gchar a, guchar b, gboolean c, gint d, guint e, glong f,
610 gulong g, gfloat h, gdouble i, gchar * j, gint k,
611 gpointer o, GObject *p)
614 a = b = c = d = e = f = g = 0;
615 o = p = (GObject *)NULL;
617 /* ugh, testing casting */
620 public signal (NO_HOOKS) last INT (INT)
621 int testflags(self, int w (check > 0)) defreturn -99 {
627 signal BOOLEAN (NONE)
629 test_none_thing (self)
634 /* some more enum testing */
635 public BubleEnum buble;
639 enum_type = Buble:Enum,
640 default_value = BUBLE_STANDARD,
647 public int long const t4;
648 public const int long t5;
649 public const char * const t6;
650 public char const * const t7;
651 public enum _gob__enum_t const * const t8;
652 public union _gob__union_t t9;
653 public union _gob__union_t * const * const * t10;
654 public struct _gob__struct_t * const * const * t11;
655 public const struct _gob__struct_t * const * const * t13;
656 public const enum _gob__enum_t * const * const * t14;
657 public enum _gob__enum_t t15;
658 public gchar const t16;
659 public const gchar * const t17;
660 public const gchar t18;
662 /* testing method with no arguments */
663 public void method_with_no_arguments (void)
668 /* testing calling the above method */
669 public void foo (self) {
670 self_method_with_no_arguments ();
673 /* this is to test custom get_type */
677 static guint type = 0;
680 static const GtkTypeInfo info = {
682 sizeof (GtkWeirdButton),
683 sizeof (GtkWeirdButtonClass),
684 (GtkClassInitFunc) gtk_weird_button_class_init,
685 (GtkObjectInitFunc) gtk_weird_button_init,
688 (GtkClassInitFunc) NULL
691 type = gtk_type_unique (gtk_button_get_type(), &info);
698 /* testing empty statements */