OOC: Object

Object

rep/object.r
struct Object {
        unsigned long magic;
        const struct Class *class; // object's description
};
inc/object.h
extern const void *const Object(void);

Class

rep/object.r
struct Class {
        const struct Object _;
        const char *name;
        const struct Class *super;
        size_t size;
        void *(*ctor)(void *self, va_list *app);
        void *(*dtor)(void *self);
        int (*diag)(const void *self, FILE *fp);
};
inc/object.h
extern const void *const Class(void);

ctor

inc/object.h
void *ctor(void *self, va_list *app);

dtor

inc/object.h
void *dtor(void *self);

diag

inc/object.h
int diag(const void *self, FILE *fp);

create

inc/object.h
void *create(const void *ooc_class, ...);

destroy

inc/object.h
void destroy(const void *self);

get_class

inc/object.h
const void *get_class(const void *self);

get_super

inc/object.h
const void *get_super(const void *self);

get_size

inc/object.h
size_t get_size(const void *self);

cast

inc/object.h
void *cast(const void *ooc_class, const void *self);

is_object

inc/object.h
bool is_object(const void *self);