mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-07-09 19:00:27 +02:00
Arrays are not an array implementation
* libguile/bitvectors.c: match other uses of SCM_ARRAY_IMPLEMENTATION. * libguile/generalized-arrays.c (scm_is_array): don't use scm_i_array_implementation_for_obj on arrays. (scm_is_typed_array): idem. Use impl->get_handle instead of scm_array_get_handle to avoid calling scm_i_array_implementation_for_obj twice. * libguile/arrays.c: remove SCM_ARRAY_IMPLEMENTATION on scm_tc7_array type.
This commit is contained in:
parent
96f7332263
commit
257e163c75
3 changed files with 11 additions and 13 deletions
|
@ -817,8 +817,6 @@ scm_i_print_array (SCM array, SCM port, scm_print_state *pstate)
|
||||||
return scm_i_print_array_dimension (&h, 0, 0, port, pstate);
|
return scm_i_print_array_dimension (&h, 0, 0, port, pstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM_ARRAY_IMPLEMENTATION (scm_tc7_array, 0x7f, NULL, NULL, NULL)
|
|
||||||
|
|
||||||
void
|
void
|
||||||
scm_init_arrays ()
|
scm_init_arrays ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -879,8 +879,7 @@ bitvector_get_handle (SCM bv, scm_t_array_handle *h)
|
||||||
h->elements = h->writable_elements = BITVECTOR_BITS (bv);
|
h->elements = h->writable_elements = BITVECTOR_BITS (bv);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM_ARRAY_IMPLEMENTATION (scm_tc7_bitvector,
|
SCM_ARRAY_IMPLEMENTATION (scm_tc7_bitvector, 0x7f,
|
||||||
0x7f,
|
|
||||||
bitvector_handle_ref, bitvector_handle_set,
|
bitvector_handle_ref, bitvector_handle_set,
|
||||||
bitvector_get_handle)
|
bitvector_get_handle)
|
||||||
SCM_VECTOR_IMPLEMENTATION (SCM_ARRAY_ELEMENT_TYPE_BIT, scm_make_bitvector)
|
SCM_VECTOR_IMPLEMENTATION (SCM_ARRAY_ELEMENT_TYPE_BIT, scm_make_bitvector)
|
||||||
|
|
|
@ -42,7 +42,7 @@ SCM_INTERNAL SCM scm_i_array_set_x (SCM v, SCM obj,
|
||||||
int
|
int
|
||||||
scm_is_array (SCM obj)
|
scm_is_array (SCM obj)
|
||||||
{
|
{
|
||||||
return scm_i_array_implementation_for_obj (obj) ? 1 : 0;
|
return SCM_I_ARRAYP (obj) || scm_i_array_implementation_for_obj (obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM_DEFINE (scm_array_p_2, "array?", 1, 0, 0,
|
SCM_DEFINE (scm_array_p_2, "array?", 1, 0, 0,
|
||||||
|
@ -68,17 +68,18 @@ scm_array_p (SCM obj, SCM unused)
|
||||||
int
|
int
|
||||||
scm_is_typed_array (SCM obj, SCM type)
|
scm_is_typed_array (SCM obj, SCM type)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
scm_t_array_implementation *impl;
|
||||||
if (scm_i_array_implementation_for_obj (obj))
|
if (SCM_I_ARRAYP (obj))
|
||||||
|
obj = SCM_I_ARRAY_V (obj);
|
||||||
|
impl = scm_i_array_implementation_for_obj (obj);
|
||||||
|
if (impl)
|
||||||
{
|
{
|
||||||
scm_t_array_handle h;
|
scm_t_array_handle h;
|
||||||
|
impl->get_handle (obj, &h);
|
||||||
scm_array_get_handle (obj, &h);
|
return scm_is_eq (scm_array_handle_element_type (&h), type);
|
||||||
ret = scm_is_eq (scm_array_handle_element_type (&h), type);
|
|
||||||
scm_array_handle_release (&h);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM_DEFINE (scm_typed_array_p, "typed-array?", 2, 0, 0,
|
SCM_DEFINE (scm_typed_array_p, "typed-array?", 2, 0, 0,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue