mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-07-02 23:50:47 +02:00
Use underlying vector implementation directly in array handles
* libguile/array-handle.c - scm_array_get_handle: if the object is an array, point impl to the underlying vector instead of array impl, then fix the axes. Avoid calling scm_i_array_implementation_for_obj twice. * libguile/arrays.c - array_handle_ref, array_handle_set, array_get_handle: remove. * libguile/bitvectors.c, libguile/bytevectors.c, libguile/strings.c, libguile/vectors.c: fix base = 0 in the array handle. * libguile/vectors.c: (vector_handle_set, vector_handle_ref): do not use h->dims.
This commit is contained in:
parent
ba7e018b61
commit
a70333d296
6 changed files with 33 additions and 61 deletions
|
@ -818,52 +818,7 @@ scm_i_print_array (SCM array, SCM port, scm_print_state *pstate)
|
|||
return scm_i_print_array_dimension (&h, 0, 0, port, pstate);
|
||||
}
|
||||
|
||||
static SCM
|
||||
array_handle_ref (scm_t_array_handle *hh, size_t pos)
|
||||
{
|
||||
scm_t_array_handle h;
|
||||
SCM ret;
|
||||
scm_array_get_handle (SCM_I_ARRAY_V (hh->array), &h);
|
||||
ret = h.impl->vref (&h, pos);
|
||||
scm_array_handle_release (&h);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
array_handle_set (scm_t_array_handle *hh, size_t pos, SCM val)
|
||||
{
|
||||
scm_t_array_handle h;
|
||||
scm_array_get_handle (SCM_I_ARRAY_V (hh->array), &h);
|
||||
h.impl->vset (&h, pos, val);
|
||||
scm_array_handle_release (&h);
|
||||
}
|
||||
|
||||
/* FIXME: should be handle for vect? maybe not, because of dims */
|
||||
static void
|
||||
array_get_handle (SCM array, scm_t_array_handle *h)
|
||||
{
|
||||
scm_t_array_handle vh;
|
||||
scm_array_get_handle (SCM_I_ARRAY_V (array), &vh);
|
||||
if (vh.dims[0].inc != 1 || vh.dims[0].lbnd != 0 || vh.base != 0)
|
||||
{
|
||||
fprintf(stderr, "INC %ld, %ld", vh.dims[0].inc, vh.dims[0].lbnd);
|
||||
fflush(stderr);
|
||||
abort();
|
||||
}
|
||||
h->element_type = vh.element_type;
|
||||
h->elements = vh.elements;
|
||||
h->writable_elements = vh.writable_elements;
|
||||
scm_array_handle_release (&vh);
|
||||
|
||||
h->dims = SCM_I_ARRAY_DIMS (array);
|
||||
h->ndims = SCM_I_ARRAY_NDIM (array);
|
||||
h->base = SCM_I_ARRAY_BASE (array);
|
||||
}
|
||||
|
||||
SCM_ARRAY_IMPLEMENTATION (scm_tc7_array,
|
||||
0x7f,
|
||||
array_handle_ref, array_handle_set,
|
||||
array_get_handle)
|
||||
SCM_ARRAY_IMPLEMENTATION (scm_tc7_array, 0x7f, NULL, NULL, NULL)
|
||||
|
||||
void
|
||||
scm_init_arrays ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue