Update array symbols
This commit is contained in:
parent
350e6187ca
commit
9fe446383f
@ -18,14 +18,14 @@ extern void array_reverse(vtype_array* x) LIBCDSB_nt__ LIBCDSB_nn1__;
|
||||
#define array_push(x, value) _LIBCDSB_Generic(libcdsb_array, push, value)(x, value)
|
||||
#define array_indexof(x, value) _LIBCDSB_Generic(libcdsb_array, indexof, value)(x, value)
|
||||
|
||||
#define array_get_by_index(s, x, index) array_get(s, x, index, 0)
|
||||
#define array_pop_by_index(s, x, index) array_get(s, x, index, 1)
|
||||
#define array_remove_by_index(s, index) array_pop_by_index(s, 0, index)
|
||||
#define array_get(x, s, index) libcdsb_array_get(x, s, index, 0)
|
||||
#define array_pop(x, s, index) libcdsb_array_get(x, s, index, 1)
|
||||
#define array_remove(s, index) libcdsb_array_get(0, s, index, 1)
|
||||
|
||||
#define in_array(x, value) (array_indexof(x, value) >= 0)
|
||||
|
||||
extern void* array_at (const vtype_array* s, ssize_t index);
|
||||
extern ssize_t array_get(vtype_array* s, vtype_value* x, ssize_t index, _Bool cut);
|
||||
extern void* libcdsb_array_at (const vtype_array* s, ssize_t index);
|
||||
extern ssize_t libcdsb_array_get(vtype_value* x, vtype_array* s, ssize_t index, _Bool cut);
|
||||
|
||||
/*#####################################################################################################################*/
|
||||
|
||||
|
@ -5,29 +5,29 @@
|
||||
#include "../__internal/assert.h"
|
||||
#include "../__internal/vnode.h"
|
||||
|
||||
void* array_at(const arr_t* x, ssize_t i) {
|
||||
void* libcdsb_array_at(const arr_t* x, ssize_t i) {
|
||||
if (i < 0 && (i += x->size) < 0) i = 0;
|
||||
return x->mem + i*vtype_size(x->type);
|
||||
}
|
||||
|
||||
ssize_t array_get(arr_t* x, val_t* d, ssize_t i, _Bool cut) {
|
||||
ssize_t libcdsb_array_get(val_t* x, arr_t* s, ssize_t i, _Bool cut) {
|
||||
|
||||
if (i < 0 && (i += x->size) < 0) i = 0;
|
||||
if (i < 0 && (i += s->size) < 0) i = 0;
|
||||
|
||||
if (i < x->size) {
|
||||
assert(!is_null(x->mem));
|
||||
if (i < s->size) {
|
||||
assert(!is_null(s->mem));
|
||||
|
||||
if (cut) {
|
||||
if (!is_null(d)) {
|
||||
vnode_t n = vnode_create(array_internal_at(x, i), x->type);
|
||||
value_set(d, n, x->type, VF_WRITEABLE|VF_REMOVABLE);
|
||||
if (!is_null(x)) {
|
||||
vnode_t n = vnode_create(array_internal_at(s, i), s->type);
|
||||
value_set(x, n, s->type, VF_WRITEABLE|VF_REMOVABLE);
|
||||
}
|
||||
|
||||
array_cut(x, i, 1);
|
||||
} else value_set(d, array_internal_at(x, i), x->type, VF_WRITEABLE);
|
||||
array_cut(s, i, 1);
|
||||
} else value_set(x, array_internal_at(s, i), s->type, VF_WRITEABLE);
|
||||
} else {
|
||||
i = -1;
|
||||
memset(d, 0, sizeof(*d));
|
||||
memset(x, 0, sizeof(*x));
|
||||
}
|
||||
|
||||
return i;
|
||||
|
Loading…
Reference in New Issue
Block a user