fx: implement updated interfaces in builtin classes

This commit is contained in:
2026-05-25 17:27:14 +01:00
parent 5d0aa577d6
commit 6efe473c11
13 changed files with 691 additions and 293 deletions
+12 -8
View File
@@ -85,15 +85,19 @@ struct _fx_object *fx_object_create(fx_type_id type)
return out;
}
void fx_object_to_string(const struct _fx_object *p, fx_stream *out)
fx_status fx_object_to_string(
const struct _fx_object *p,
fx_stream *out,
const char *format)
{
FX_CLASS_DISPATCH_VIRTUAL_V(
fx_object,
FX_TYPE_OBJECT,
to_string,
p,
out);
fx_stream_write_fmt(out, NULL, "<%s@%p>", p->obj_type->ty_name, p);
fx_value value = FX_VALUE_OBJECT(p);
fx_object_class *iface = fx_object_get_interface(p, FX_TYPE_OBJECT);
if (iface && iface->to_string) {
return iface->to_string(&value, out, format);
}
fx_stream_write_fmt(out, NULL, "%s", p->obj_type->ty_name);
return FX_SUCCESS;
}
bool fx_object_is_type(const struct _fx_object *p, fx_type_id type)