diff options
author | Daniel Llorens <daniel.llorens@bluewin.ch> | 2013-05-22 13:36:24 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2014-02-07 15:46:04 +0100 |
commit | a5340d7288407c6c6cf5c842ae3925d184bf95eb (patch) | |
tree | 452075c17cf19f9e55451a04d6c4ee1e7296e5ea | |
parent | c361f6b17705fdadc4da436d3ec291713c2d7113 (diff) | |
download | guile-ra0.tar.gz |
Arrays are not an array implementationra0
* 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.
-rw-r--r-- | libguile/arrays.c | 2 | ||||
-rw-r--r-- | libguile/bitvectors.c | 3 | ||||
-rw-r--r-- | libguile/generalized-arrays.c | 19 |
3 files changed, 11 insertions, 13 deletions
diff --git a/libguile/arrays.c b/libguile/arrays.c index 93112e214..702faacbe 100644 --- a/libguile/arrays.c +++ b/libguile/arrays.c @@ -818,8 +818,6 @@ scm_i_print_array (SCM array, SCM port, scm_print_state *pstate) return scm_i_print_array_dimension (&h, 0, 0, port, pstate); } -SCM_ARRAY_IMPLEMENTATION (scm_tc7_array, 0x7f, NULL, NULL, NULL) - void scm_init_arrays () { diff --git a/libguile/bitvectors.c b/libguile/bitvectors.c index dd4a12e3f..354895c5a 100644 --- a/libguile/bitvectors.c +++ b/libguile/bitvectors.c @@ -879,8 +879,7 @@ bitvector_get_handle (SCM bv, scm_t_array_handle *h) h->elements = h->writable_elements = BITVECTOR_BITS (bv); } -SCM_ARRAY_IMPLEMENTATION (scm_tc7_bitvector, - 0x7f, +SCM_ARRAY_IMPLEMENTATION (scm_tc7_bitvector, 0x7f, bitvector_handle_ref, bitvector_handle_set, bitvector_get_handle) SCM_VECTOR_IMPLEMENTATION (SCM_ARRAY_ELEMENT_TYPE_BIT, scm_make_bitvector) diff --git a/libguile/generalized-arrays.c b/libguile/generalized-arrays.c index 6d2106714..ac5572858 100644 --- a/libguile/generalized-arrays.c +++ b/libguile/generalized-arrays.c @@ -42,7 +42,7 @@ SCM_INTERNAL SCM scm_i_array_set_x (SCM v, SCM obj, int 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, @@ -68,17 +68,18 @@ scm_array_p (SCM obj, SCM unused) int scm_is_typed_array (SCM obj, SCM type) { - int ret = 0; - if (scm_i_array_implementation_for_obj (obj)) + scm_t_array_implementation *impl; + 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_array_get_handle (obj, &h); - ret = scm_is_eq (scm_array_handle_element_type (&h), type); - scm_array_handle_release (&h); + impl->get_handle (obj, &h); + return scm_is_eq (scm_array_handle_element_type (&h), type); } - - return ret; + else + return 0; } SCM_DEFINE (scm_typed_array_p, "typed-array?", 2, 0, 0, |