fx.collections: update interface implementations
This commit is contained in:
+49
-37
@@ -41,8 +41,10 @@ static void *list_first_item(const struct fx_list_p *q)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct fx_list_entry *list_entry
|
||||
= fx_unbox(struct fx_list_entry, entry, e_entry);
|
||||
struct fx_list_entry *list_entry = fx_unbox(
|
||||
struct fx_list_entry,
|
||||
entry,
|
||||
e_entry);
|
||||
|
||||
return list_entry->e_data;
|
||||
}
|
||||
@@ -55,8 +57,10 @@ static void *list_last_item(const struct fx_list_p *q)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct fx_list_entry *list_entry
|
||||
= fx_unbox(struct fx_list_entry, entry, e_entry);
|
||||
struct fx_list_entry *list_entry = fx_unbox(
|
||||
struct fx_list_entry,
|
||||
entry,
|
||||
e_entry);
|
||||
|
||||
return list_entry->e_data;
|
||||
}
|
||||
@@ -69,8 +73,10 @@ static struct fx_list_entry *list_first_entry(const struct fx_list_p *q)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct fx_list_entry *list_entry
|
||||
= fx_unbox(struct fx_list_entry, entry, e_entry);
|
||||
struct fx_list_entry *list_entry = fx_unbox(
|
||||
struct fx_list_entry,
|
||||
entry,
|
||||
e_entry);
|
||||
|
||||
return list_entry;
|
||||
}
|
||||
@@ -83,8 +89,10 @@ static struct fx_list_entry *list_last_entry(const struct fx_list_p *q)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct fx_list_entry *list_entry
|
||||
= fx_unbox(struct fx_list_entry, entry, e_entry);
|
||||
struct fx_list_entry *list_entry = fx_unbox(
|
||||
struct fx_list_entry,
|
||||
entry,
|
||||
e_entry);
|
||||
|
||||
return list_entry;
|
||||
}
|
||||
@@ -169,8 +177,10 @@ static void *list_pop_front(struct fx_list_p *q)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct fx_list_entry *list_entry
|
||||
= fx_unbox(struct fx_list_entry, entry, e_entry);
|
||||
struct fx_list_entry *list_entry = fx_unbox(
|
||||
struct fx_list_entry,
|
||||
entry,
|
||||
e_entry);
|
||||
|
||||
void *item = list_entry->e_data;
|
||||
free(list_entry);
|
||||
@@ -187,8 +197,10 @@ static void *list_pop_back(struct fx_list_p *q)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct fx_list_entry *list_entry
|
||||
= fx_unbox(struct fx_list_entry, entry, e_entry);
|
||||
struct fx_list_entry *list_entry = fx_unbox(
|
||||
struct fx_list_entry,
|
||||
entry,
|
||||
e_entry);
|
||||
|
||||
void *item = list_entry->e_data;
|
||||
free(list_entry);
|
||||
@@ -202,8 +214,10 @@ static struct fx_list_entry *find_item(struct fx_list_p *list, void *item)
|
||||
{
|
||||
struct fx_queue_entry *entry = fx_queue_first(&list->l_queue);
|
||||
while (entry) {
|
||||
struct fx_list_entry *list_entry
|
||||
= fx_unbox(struct fx_list_entry, entry, e_entry);
|
||||
struct fx_list_entry *list_entry = fx_unbox(
|
||||
struct fx_list_entry,
|
||||
entry,
|
||||
e_entry);
|
||||
|
||||
if (list_entry->e_data == item) {
|
||||
return list_entry;
|
||||
@@ -246,8 +260,10 @@ static void list_delete_all(struct fx_list_p *q)
|
||||
{
|
||||
struct fx_queue_entry *entry = fx_queue_first(&q->l_queue);
|
||||
while (entry) {
|
||||
struct fx_list_entry *list_entry
|
||||
= fx_unbox(struct fx_list_entry, entry, e_entry);
|
||||
struct fx_list_entry *list_entry = fx_unbox(
|
||||
struct fx_list_entry,
|
||||
entry,
|
||||
e_entry);
|
||||
struct fx_queue_entry *next = fx_queue_next(entry);
|
||||
|
||||
free(list_entry);
|
||||
@@ -388,8 +404,9 @@ void *fx_list_entry_value(const struct fx_list_entry *entry)
|
||||
fx_iterator *fx_list_begin(fx_list *q)
|
||||
{
|
||||
fx_list_iterator *it_obj = fx_object_create(FX_TYPE_LIST_ITERATOR);
|
||||
struct fx_list_iterator_p *it
|
||||
= fx_object_get_private(it_obj, FX_TYPE_LIST_ITERATOR);
|
||||
struct fx_list_iterator_p *it = fx_object_get_private(
|
||||
it_obj,
|
||||
FX_TYPE_LIST_ITERATOR);
|
||||
|
||||
it->_q = q;
|
||||
it->_q_p = fx_object_get_private(q, FX_TYPE_LIST);
|
||||
@@ -407,8 +424,9 @@ fx_iterator *fx_list_begin(fx_list *q)
|
||||
const fx_iterator *fx_list_cbegin(const fx_list *q)
|
||||
{
|
||||
fx_list_iterator *it_obj = fx_object_create(FX_TYPE_LIST_ITERATOR);
|
||||
struct fx_list_iterator_p *it
|
||||
= fx_object_get_private(it_obj, FX_TYPE_LIST_ITERATOR);
|
||||
struct fx_list_iterator_p *it = fx_object_get_private(
|
||||
it_obj,
|
||||
FX_TYPE_LIST_ITERATOR);
|
||||
|
||||
it->_q = (fx_list *)q;
|
||||
it->_q_p = fx_object_get_private(q, FX_TYPE_LIST);
|
||||
@@ -440,8 +458,9 @@ static void list_fini(fx_object *obj, void *priv)
|
||||
|
||||
static enum fx_status iterator_move_next(const fx_iterator *obj)
|
||||
{
|
||||
struct fx_list_iterator_p *it
|
||||
= fx_object_get_private(obj, FX_TYPE_LIST_ITERATOR);
|
||||
struct fx_list_iterator_p *it = fx_object_get_private(
|
||||
obj,
|
||||
FX_TYPE_LIST_ITERATOR);
|
||||
|
||||
if (!it->_q_entry) {
|
||||
it->entry = NULL;
|
||||
@@ -467,8 +486,9 @@ static enum fx_status iterator_move_next(const fx_iterator *obj)
|
||||
|
||||
static enum fx_status iterator_erase(fx_iterator *obj)
|
||||
{
|
||||
struct fx_list_iterator_p *it
|
||||
= fx_object_get_private(obj, FX_TYPE_LIST_ITERATOR);
|
||||
struct fx_list_iterator_p *it = fx_object_get_private(
|
||||
obj,
|
||||
FX_TYPE_LIST_ITERATOR);
|
||||
|
||||
if (!it->entry || !it->_q_entry) {
|
||||
return FX_ERR_OUT_OF_BOUNDS;
|
||||
@@ -488,20 +508,13 @@ static enum fx_status iterator_erase(fx_iterator *obj)
|
||||
return FX_SUCCESS;
|
||||
}
|
||||
|
||||
static fx_iterator_value iterator_get_value(fx_iterator *obj)
|
||||
static fx_value iterator_get_value(const fx_iterator *obj)
|
||||
{
|
||||
struct fx_list_iterator_p *it
|
||||
= fx_object_get_private(obj, FX_TYPE_LIST_ITERATOR);
|
||||
struct fx_list_iterator_p *it = fx_object_get_private(
|
||||
obj,
|
||||
FX_TYPE_LIST_ITERATOR);
|
||||
|
||||
return FX_ITERATOR_VALUE_PTR(it->item);
|
||||
}
|
||||
|
||||
static const fx_iterator_value iterator_get_cvalue(const fx_iterator *obj)
|
||||
{
|
||||
struct fx_list_iterator_p *it
|
||||
= fx_object_get_private(obj, FX_TYPE_LIST_ITERATOR);
|
||||
|
||||
return FX_ITERATOR_VALUE_CPTR(it->item);
|
||||
return FX_POINTER(it->item);
|
||||
}
|
||||
|
||||
/*** CLASS DEFINITION *********************************************************/
|
||||
@@ -537,7 +550,6 @@ FX_TYPE_CLASS_BEGIN(fx_list_iterator)
|
||||
FX_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
||||
FX_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
||||
FX_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
||||
FX_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
||||
FX_TYPE_VTABLE_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
||||
FX_TYPE_CLASS_END(fx_list_iterator)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user