add object module from corelib

This commit is contained in:
2024-10-24 19:24:54 +01:00
parent 7eb0fc5581
commit fa6ebe6a84
38 changed files with 5606 additions and 24 deletions

29
object/type.c Normal file
View File

@@ -0,0 +1,29 @@
#include "object.h"
#include <blue/core/queue.h>
#include <blue/object/type.h>
#include <stdlib.h>
#include <string.h>
struct b_object *b_object_type_instantiate(const b_object_type *type)
{
if (!type || type->t_instance_size < sizeof(struct b_object)) {
return NULL;
}
struct b_object *out = malloc(type->t_instance_size);
if (!out) {
return NULL;
}
memset(out, 0x0, type->t_instance_size);
out->ob_ref = 1;
out->ob_type = type;
if (type->t_init) {
type->t_init(out);
}
return out;
}