core: object: implement b_object_is_type()

This commit is contained in:
2025-10-19 13:46:44 +01:00
parent 838835e6e1
commit 2cc1a541c2

View File

@@ -71,12 +71,24 @@ struct _b_object *b_object_create(b_type type)
return out;
}
void b_object_to_string(struct _b_object *p, struct b_stream *out)
void b_object_to_string(const struct _b_object *p, struct b_stream *out)
{
B_CLASS_DISPATCH_VIRTUAL_V(b_object, B_TYPE_OBJECT, p, to_string, p, out);
b_stream_write_fmt(out, NULL, "<%s@%p>", p->obj_type->r_info->t_name, p);
}
bool b_object_is_type(const struct _b_object *p, b_type type)
{
if (b_type_id_compare(&p->obj_type->r_info->t_id, type) == 0) {
return true;
}
struct b_type_component *comp
= b_type_get_component(&p->obj_type->r_components, type);
return comp != NULL;
}
void *b_object_get_private(const struct _b_object *object, b_type type)
{
if (b_type_id_compare(&object->obj_type->r_info->t_id, type) == 0) {