diff --git a/core/object.c b/core/object.c index 72b82fa..bc7ded0 100644 --- a/core/object.c +++ b/core/object.c @@ -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) {