#include <stdio.h>
#include <stdlib.h>
#include "CoreP.h"

static void
initialize_instance(CoreClassDescriptor *descriptor, Core p)
{
    if (descriptor->core.super_class != NULL) {
        initialize_instance(descriptor->core.super_class, p);
    }
    if (descriptor->core.initializer) {
        descriptor->core.initializer(p);
    }
}

Core
new_instance(CoreClassDescriptor *descriptor)
{
    Core            p;

    p = malloc(descriptor->core.size_of_instance);

    p->core.class_descriptor = descriptor;

    initialize_instance(descriptor, p);

    return p;
}