/* This is a generated file; do not edit */ #include #include "classes.h" /* The Object class */ /* --- Object --- */ /* Class methods */ static struct Object_i* _Object___create__(struct Object_c* self) { struct Object_i* o = self->__alloc__(self); o->__class__ = self; self->__init__(o, self); return o; } static struct Object_i* _Object___alloc__(struct Object_c* self) { return malloc(self->instance_size); } /* Instance methods */ static void _Object___init__(struct Object_i* self, struct Object_c* cls) { /* Chain to super and then init self */ if (cls->super) cls->super->__init__(self, cls->super); } static void _Object___del__(struct Object_i* self, struct Object_c* cls) { /* Delete self and then chain to super */ if (cls->super) cls->super->__init__(self, cls->super); else free(self); } /* Class object */ struct Object_c _Object_class = { /* --- Object --- */ /* Class variables */ 0, sizeof(struct Object_i), sizeof(struct Object_c), "Object", NULL, /* Class methods */ (struct Object_i*(*)(struct Object_c*))_Object___create__, (struct Object_i*(*)(struct Object_c*))_Object___alloc__, /* Instance methods */ (void(*)(struct Object_i*, struct Object_c*))_Object___init__, (void(*)(struct Object_i*, struct Object_c*))_Object___del__ }; /* The Animal class */ /* --- Animal --- */ /* Instance methods */ static void _Animal_noise(struct Animal_i* self) { printf("Generic animal noise.\n"); } /* Class object */ struct Animal_c _Animal_class = { /* --- Object --- */ /* Class variables */ 1, sizeof(struct Animal_i), sizeof(struct Animal_c), "Animal", (struct Object_c*)&_Object_class, /* Class methods */ (struct Animal_i*(*)(struct Animal_c*))_Object___create__, (struct Animal_i*(*)(struct Animal_c*))_Object___alloc__, /* Instance methods */ (void(*)(struct Animal_i*, struct Animal_c*))_Object___init__, (void(*)(struct Animal_i*, struct Animal_c*))_Object___del__, /* --- Animal --- */ /* Instance methods */ (void(*)(struct Animal_i*))_Animal_noise }; /* The Doggy class */ /* --- Object --- */ /* Class methods */ static void _Doggy___init__(struct Doggy_i* self, struct Doggy_c* cls) { /* Chain to super and then init self */ cls->super->__init__((struct Object_i*)self, cls->super); printf("Hi.\n"); } /* --- Animal --- */ /* Instance methods */ static void _Doggy_noise(struct Doggy_i* self) { printf("Bow wow.\n"); } /* Class object */ struct Doggy_c _Doggy_class = { /* --- Object --- */ /* Class variables */ 2, sizeof(struct Doggy_i), sizeof(struct Doggy_c), "Doggy", (struct Object_c*)&_Animal_class, /* Class methods */ (struct Doggy_i*(*)(struct Doggy_c*))_Object___create__, (struct Doggy_i*(*)(struct Doggy_c*))_Object___alloc__, /* Instance methods */ (void(*)(struct Doggy_i*, struct Doggy_c*))_Doggy___init__, (void(*)(struct Doggy_i*, struct Doggy_c*))_Object___del__, /* --- Animal --- */ /* Instance methods */ (void(*)(struct Doggy_i*))_Doggy_noise }; /* The Kitty class */ /* --- Object --- */ /* Class methods */ static struct Kitty_i* _Kitty___create__(struct Kitty_c* self) { self->count++; return ((struct Kitty_i*(*)(struct Kitty_c*)) self->super->__create__)(self); } /* Instance methods */ static void _Kitty___init__(struct Kitty_i* self, struct Kitty_c* cls) { /* Chain to super and then init self */ cls->super->__init__((struct Object_i*)self, cls->super); self->num = self->__class__->count; } static void _Kitty___del__(struct Kitty_i* self, struct Kitty_c* cls) { /* Delete self and then chain to super */ printf("Bye!\n"); cls->super->__init__((struct Object_i*)self, cls->super); } /* --- Animal --- */ /* Instance methods */ static void _Kitty_noise(struct Kitty_i* self) { printf("Meow, I say. I'm #%i.\n", self->num); } /* Class object */ struct Kitty_c _Kitty_class = { /* --- Object --- */ /* Class variables */ 3, sizeof(struct Kitty_i), sizeof(struct Kitty_c), "Kitty", (struct Object_c*)&_Animal_class, /* Class methods */ (struct Kitty_i*(*)(struct Kitty_c*))_Kitty___create__, (struct Kitty_i*(*)(struct Kitty_c*))_Object___alloc__, /* Instance methods */ (void(*)(struct Kitty_i*, struct Kitty_c*))_Kitty___init__, (void(*)(struct Kitty_i*, struct Kitty_c*))_Kitty___del__, /* --- Animal --- */ /* Instance methods */ (void(*)(struct Kitty_i*))_Kitty_noise, /* --- Kitty --- */ /* Class variables */ 0 };