core: object: remove legacy iterator interface usage
This commit is contained in:
@@ -47,16 +47,18 @@ b_result b_class_instantiate(
|
|||||||
out->c_magic = B_CLASS_MAGIC;
|
out->c_magic = B_CLASS_MAGIC;
|
||||||
out->c_type = type;
|
out->c_type = type;
|
||||||
|
|
||||||
b_queue_iterator q_it;
|
struct b_queue_entry *entry = b_queue_first(&type->r_class_hierarchy);
|
||||||
b_queue_foreach (&q_it, &type->r_class_hierarchy) {
|
while (entry) {
|
||||||
struct b_type_component *comp
|
struct b_type_component *comp
|
||||||
= b_unbox(struct b_type_component, q_it.entry, c_entry);
|
= b_unbox(struct b_type_component, entry, c_entry);
|
||||||
const struct b_type_info *class_info = comp->c_type->r_info;
|
const struct b_type_info *class_info = comp->c_type->r_info;
|
||||||
void *class_data = (char *)out + comp->c_class_data_offset;
|
void *class_data = (char *)out + comp->c_class_data_offset;
|
||||||
|
|
||||||
if (class_info->t_class_init) {
|
if (class_info->t_class_init) {
|
||||||
class_info->t_class_init(out, class_data);
|
class_info->t_class_init(out, class_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entry = b_queue_next(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
*out_class = out;
|
*out_class = out;
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ b_result b_object_instantiate(
|
|||||||
out->obj_type = type;
|
out->obj_type = type;
|
||||||
out->obj_ref = 1;
|
out->obj_ref = 1;
|
||||||
|
|
||||||
b_queue_iterator q_it;
|
struct b_queue_entry *entry = b_queue_first(&type->r_class_hierarchy);
|
||||||
b_queue_foreach (&q_it, &type->r_class_hierarchy) {
|
while (entry) {
|
||||||
struct b_type_component *comp
|
struct b_type_component *comp
|
||||||
= b_unbox(struct b_type_component, q_it.entry, c_entry);
|
= b_unbox(struct b_type_component, entry, c_entry);
|
||||||
const struct b_type_info *class_info = comp->c_type->r_info;
|
const struct b_type_info *class_info = comp->c_type->r_info;
|
||||||
void *private_data
|
void *private_data
|
||||||
= (char *)out + comp->c_instance_private_data_offset;
|
= (char *)out + comp->c_instance_private_data_offset;
|
||||||
@@ -49,6 +49,8 @@ b_result b_object_instantiate(
|
|||||||
out->obj_main_priv_offset
|
out->obj_main_priv_offset
|
||||||
= comp->c_instance_private_data_offset;
|
= comp->c_instance_private_data_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entry = b_queue_next(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
*out_object = out;
|
*out_object = out;
|
||||||
|
|||||||
14
core/type.c
14
core/type.c
@@ -233,21 +233,23 @@ static b_result find_type_components(struct b_type_registration *reg)
|
|||||||
current_id = &dep_class->r_info->t_parent_id;
|
current_id = &dep_class->r_info->t_parent_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
b_queue_iterator q_it;
|
b_queue_entry *entry = b_queue_first(®->r_class_hierarchy);
|
||||||
b_queue_foreach (&q_it, ®->r_class_hierarchy) {
|
while (entry) {
|
||||||
comp = b_unbox(struct b_type_component, q_it.entry, c_entry);
|
comp = b_unbox(struct b_type_component, entry, c_entry);
|
||||||
initialise_type_component(comp, comp->c_type->r_info, &init_ctx);
|
initialise_type_component(comp, comp->c_type->r_info, &init_ctx);
|
||||||
|
entry = b_queue_next(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
b_btree_iterator t_it;
|
b_btree_node *node = b_btree_first(®->r_components);
|
||||||
b_btree_foreach (&t_it, ®->r_components) {
|
while (node) {
|
||||||
comp = b_unbox(struct b_type_component, t_it.node, c_node);
|
comp = b_unbox(struct b_type_component, node, c_node);
|
||||||
if (comp->c_type->r_category == B_TYPE_CLASS) {
|
if (comp->c_type->r_category == B_TYPE_CLASS) {
|
||||||
/* this component was already initialised above */
|
/* this component was already initialised above */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
initialise_type_component(comp, comp->c_type->r_info, &init_ctx);
|
initialise_type_component(comp, comp->c_type->r_info, &init_ctx);
|
||||||
|
node = b_btree_next(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
skip_class_hierarchy:
|
skip_class_hierarchy:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define _TYPE_H_
|
#define _TYPE_H_
|
||||||
|
|
||||||
#include <blue/core/btree.h>
|
#include <blue/core/btree.h>
|
||||||
|
#include <blue/core/queue.h>
|
||||||
#include <blue/core/type.h>
|
#include <blue/core/type.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user