diff --git a/core/class.c b/core/class.c index 7d305dd..0967330 100644 --- a/core/class.c +++ b/core/class.c @@ -47,16 +47,18 @@ b_result b_class_instantiate( out->c_magic = B_CLASS_MAGIC; out->c_type = type; - b_queue_iterator q_it; - b_queue_foreach (&q_it, &type->r_class_hierarchy) { + struct b_queue_entry *entry = b_queue_first(&type->r_class_hierarchy); + while (entry) { 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; void *class_data = (char *)out + comp->c_class_data_offset; if (class_info->t_class_init) { class_info->t_class_init(out, class_data); } + + entry = b_queue_next(entry); } *out_class = out; diff --git a/core/object.c b/core/object.c index 513242a..20e5cca 100644 --- a/core/object.c +++ b/core/object.c @@ -33,10 +33,10 @@ b_result b_object_instantiate( out->obj_type = type; out->obj_ref = 1; - b_queue_iterator q_it; - b_queue_foreach (&q_it, &type->r_class_hierarchy) { + struct b_queue_entry *entry = b_queue_first(&type->r_class_hierarchy); + while (entry) { 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; void *private_data = (char *)out + comp->c_instance_private_data_offset; @@ -49,6 +49,8 @@ b_result b_object_instantiate( out->obj_main_priv_offset = comp->c_instance_private_data_offset; } + + entry = b_queue_next(entry); } *out_object = out; diff --git a/core/type.c b/core/type.c index 23e594a..818080c 100644 --- a/core/type.c +++ b/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; } - b_queue_iterator q_it; - b_queue_foreach (&q_it, ®->r_class_hierarchy) { - comp = b_unbox(struct b_type_component, q_it.entry, c_entry); + b_queue_entry *entry = b_queue_first(®->r_class_hierarchy); + while (entry) { + comp = b_unbox(struct b_type_component, entry, c_entry); initialise_type_component(comp, comp->c_type->r_info, &init_ctx); + entry = b_queue_next(entry); } - b_btree_iterator t_it; - b_btree_foreach (&t_it, ®->r_components) { - comp = b_unbox(struct b_type_component, t_it.node, c_node); + b_btree_node *node = b_btree_first(®->r_components); + while (node) { + comp = b_unbox(struct b_type_component, node, c_node); if (comp->c_type->r_category == B_TYPE_CLASS) { /* this component was already initialised above */ continue; } initialise_type_component(comp, comp->c_type->r_info, &init_ctx); + node = b_btree_next(node); } skip_class_hierarchy: diff --git a/core/type.h b/core/type.h index c5b46b8..c728bdb 100644 --- a/core/type.h +++ b/core/type.h @@ -2,6 +2,7 @@ #define _TYPE_H_ #include +#include #include #include