3 * A simple SOD module for testing.
15 [nick = nml, link = SodObject]
16 class Animal: SodObject {
19 [combination = progn] void tickle();
20 [role = before] void nml.tickle() { me->nml.tickles++; }
24 void bite() { puts("Munch!"); }
25 void nml.tickle() { Lion_bite(me); }
29 void butt() { puts("Bonk!"); }
30 void nml.tickle() { Goat_butt(me); }
33 class Serpent: Animal {
36 void hiss() { puts("Sssss!"); }
37 void bite() { puts("Nom!"); }
39 if (SERPENT__CONV_NML(me)->nml.tickles <= me->serpent.limit)
46 [nick = sir, link = Animal]
47 class Chimaera: Lion, Goat, Serpent {
52 /*----- Main driver code --------------------------------------------------*/
54 static void tickle_animal(Animal *a)
58 for (i = 0; i < 3; i++) {
59 printf("tickle %s #%d...\n", a->_vt->_class->cls.name, i);
64 static void provoke_lion(Lion *l)
66 printf("provoking %s as a lion\n", l->_vt->_class->cls.name);
70 static void provoke_goat(Goat *g)
72 printf("provoking %s as a goat\n", g->_vt->_class->cls.name);
76 static void provoke_serpent(Serpent *s)
78 printf("provoking %s as a serpent\n", s->_vt->_class->cls.name);
85 SOD_DECL(Lion, l, NO_KWARGS);
87 tickle_animal(LION__CONV_NML(l));
91 SOD_DECL(Goat, g, NO_KWARGS);
93 tickle_animal(GOAT__CONV_NML(g));
97 SOD_DECL(Serpent, s, NO_KWARGS);
99 tickle_animal(SERPENT__CONV_NML(s));
103 SOD_DECL(Chimaera, c, NO_KWARGS);
104 provoke_lion(CHIMAERA__CONV_LION(c));
105 provoke_goat(CHIMAERA__CONV_GOAT(c));
106 provoke_serpent(CHIMAERA__CONV_SERPENT(c));
107 tickle_animal(CHIMAERA__CONV_NML(c));