Update list (vtype_variable)

This commit is contained in:
2023-03-23 13:53:46 +03:00
parent b21ce2e799
commit 6fc4be2b75
3 changed files with 28 additions and 29 deletions
+5 -5
View File
@@ -43,7 +43,7 @@ int libcdsb_list_get(vtype_list* x, ssize_t i, void* _, list_access_callback cal
if (n || is_null(c)) return -1;
i = (callback) ? callback(vnode_peek(&c->node, c->type), i, c->type, _) : 0;
i = (callback) ? callback(libcdsb_variable_build(vnode_peek(&c->node, c->type), c->type), i, _) : 0;
if (cut) libcdsb_builtin_cut(x, c);
@@ -51,7 +51,7 @@ int libcdsb_list_get(vtype_list* x, ssize_t i, void* _, list_access_callback cal
}
int libcdsb_list_find(vtype_list* x, const void* v, vtype t, void* _, list_access_callback callback, bool r, bool cut) {
int libcdsb_list_find(vtype_list* x, vtype_variable value, void* _, list_access_callback callback, bool r, bool cut) {
ldir_t dir;
lnode_t* c;
ssize_t i;
@@ -62,10 +62,10 @@ int libcdsb_list_find(vtype_list* x, const void* v, vtype t, void* _, list_acces
i = 0;
while (!is_null(c)) {
cmp = vtype_compare(vnode_peek(&c->node, c->type), c->type, v, t);
cmp = vtype_compare(vnode_peek(&c->node, c->type), c->type, value.pointer, value.type);
if (cmp == 0) {
i = (callback) ? callback(vnode_peek(&c->node, c->type), (r)?~i:i, c->type, _) : 0;
i = (callback) ? callback(libcdsb_variable_build(vnode_peek(&c->node, c->type), c->type), (r)?~i:i, _) : 0;
if (cut) libcdsb_builtin_cut(x, c);
@@ -91,7 +91,7 @@ int libcdsb_list_foreach(vtype_list* x, void* data, list_access_callback callbac
i = 0;
while (!is_null(c)) {
if ((r = callback(vnode_peek(&c->node, c->type), i, c->type, data)) != 0)
if ((r = callback(libcdsb_variable_build(vnode_peek(&c->node, c->type), c->type), i, data)) != 0)
break;
n = c->next;
+6 -7
View File
@@ -3,7 +3,7 @@
#include "include.h"
bool libcdsb_list_insert(list_t* x, ssize_t i, const void* v, vtype t, int ins, void* dt, list_access_callback callback) {
bool libcdsb_list_insert(list_t* x, ssize_t i, vtype_variable value, int ins, void* dt, list_access_callback callback) {
ldir_t dir;
lnode_t* c;
@@ -42,18 +42,17 @@ bool libcdsb_list_insert(list_t* x, ssize_t i, const void* v, vtype t, int ins,
ldir_dir(ldir_inv(c, dir), dir) = c;
} else {
if (callback) callback(vnode_peek(&c->node, c->type), -1, c->type, dt);
if (callback) callback(libcdsb_variable_build(vnode_peek(&c->node, c->type), c->type), -1, dt);
vnode_free(&c->node, c->type);
}
c->node = vnode_create(v, t);
c->type = t;
c->node = vnode_create(value.pointer, c->type = value.type);
return true;
}
bool libcdsb_list_attach(list_t* x, ssize_t i, const void* v, vtype t, int ins, void* dt, list_access_callback callback) {
bool libcdsb_list_attach(list_t* x, ssize_t i, vtype_variable value, int ins, void* dt, list_access_callback callback) {
ldir_t dir;
lnode_t* c;
@@ -92,11 +91,11 @@ bool libcdsb_list_attach(list_t* x, ssize_t i, const void* v, vtype t, int ins,
ldir_dir(ldir_inv(c, dir), dir) = c;
} else {
if (callback) callback(vnode_peek(&c->node, c->type), -1, c->type, dt);
if (callback) callback(libcdsb_variable_build(vnode_peek(&c->node, c->type), c->type), -1, dt);
vnode_free(&c->node, c->type);
}
vnode_attach(&c->node, v, c->type = t);
vnode_attach(&c->node, value.pointer, c->type = value.type);
return true;
}