fx: implement updated interfaces in builtin classes
This commit is contained in:
+12
-8
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user