fx: update fx_iterator to return pointers to values
This commit is contained in:
+19
-27
@@ -41,16 +41,14 @@ fx_result fx_object_instantiate(
|
||||
out->obj_type = type;
|
||||
out->obj_ref = 1;
|
||||
|
||||
struct fx_queue_entry *entry = fx_queue_first(
|
||||
&type->ty_class_hierarchy);
|
||||
struct fx_queue_entry *entry
|
||||
= fx_queue_first(&type->ty_class_hierarchy);
|
||||
while (entry) {
|
||||
struct fx_type_component *comp = fx_unbox(
|
||||
struct fx_type_component,
|
||||
entry,
|
||||
c_entry);
|
||||
struct fx_type_component *comp
|
||||
= fx_unbox(struct fx_type_component, entry, c_entry);
|
||||
const struct fx_type_info *class_info = comp->c_type;
|
||||
void *private_data = (char *)out
|
||||
+ comp->c_instance_private_data_offset;
|
||||
void *private_data
|
||||
= (char *)out + comp->c_instance_private_data_offset;
|
||||
|
||||
if (class_info->ty_instance_init) {
|
||||
class_info->ty_instance_init(out, private_data);
|
||||
@@ -90,7 +88,7 @@ fx_status fx_object_to_string(
|
||||
fx_stream *out,
|
||||
const char *format)
|
||||
{
|
||||
fx_value value = FX_VALUE_OBJECT(p);
|
||||
fx_value value = FX_VALUE_OBJECT_REF(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);
|
||||
@@ -106,9 +104,8 @@ bool fx_object_is_type(const struct _fx_object *p, fx_type_id type)
|
||||
return true;
|
||||
}
|
||||
|
||||
struct fx_type_component *comp = fx_type_get_component(
|
||||
&p->obj_type->ty_components,
|
||||
type);
|
||||
struct fx_type_component *comp
|
||||
= fx_type_get_component(&p->obj_type->ty_components, type);
|
||||
|
||||
return comp != NULL;
|
||||
}
|
||||
@@ -125,9 +122,8 @@ void *fx_object_get_private(const struct _fx_object *object, fx_type_id type)
|
||||
return (char *)object + object->obj_main_priv_offset;
|
||||
}
|
||||
|
||||
struct fx_type_component *comp = fx_type_get_component(
|
||||
&object->obj_type->ty_components,
|
||||
type);
|
||||
struct fx_type_component *comp
|
||||
= fx_type_get_component(&object->obj_type->ty_components, type);
|
||||
if (!comp) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -143,9 +139,8 @@ void *fx_object_get_protected(const struct _fx_object *object, fx_type_id type)
|
||||
|
||||
assert(object->obj_magic == FX_OBJECT_MAGIC);
|
||||
|
||||
struct fx_type_component *comp = fx_type_get_component(
|
||||
&object->obj_type->ty_components,
|
||||
type);
|
||||
struct fx_type_component *comp
|
||||
= fx_type_get_component(&object->obj_type->ty_components, type);
|
||||
if (!comp) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -177,9 +172,8 @@ enum fx_status fx_object_get_data(
|
||||
|
||||
assert(object->obj_magic == FX_OBJECT_MAGIC);
|
||||
|
||||
struct fx_type_component *comp = fx_type_get_component(
|
||||
&object->obj_type->ty_components,
|
||||
type);
|
||||
struct fx_type_component *comp
|
||||
= fx_type_get_component(&object->obj_type->ty_components, type);
|
||||
if (!comp) {
|
||||
return FX_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
@@ -218,14 +212,12 @@ void fx_object_unref(struct _fx_object *p)
|
||||
|
||||
struct fx_queue_entry *cur = fx_queue_last(&type->ty_class_hierarchy);
|
||||
while (cur) {
|
||||
struct fx_type_component *comp = fx_unbox(
|
||||
struct fx_type_component,
|
||||
cur,
|
||||
c_entry);
|
||||
struct fx_type_component *comp
|
||||
= fx_unbox(struct fx_type_component, cur, c_entry);
|
||||
|
||||
const struct fx_type_info *class_info = comp->c_type;
|
||||
void *private_data = (char *)p
|
||||
+ comp->c_instance_private_data_offset;
|
||||
void *private_data
|
||||
= (char *)p + comp->c_instance_private_data_offset;
|
||||
|
||||
if (class_info->ty_instance_fini) {
|
||||
class_info->ty_instance_fini(p, private_data);
|
||||
|
||||
Reference in New Issue
Block a user