diff options
author | Marius Vollmer <mvo@zagadka.de> | 2005-01-06 18:44:08 +0000 |
---|---|---|
committer | Marius Vollmer <mvo@zagadka.de> | 2005-01-06 18:44:08 +0000 |
commit | fea99690f2e31b08d4261d91509c6fed7d945125 (patch) | |
tree | 1e52f4e7dc4d7e5b9d9d8a8a8a3682993a4af1aa /libguile/srfi-4.c | |
parent | 996baf27e98447412d3751dd8343c9b8252ccfd4 (diff) | |
download | guile-fea99690f2e31b08d4261d91509c6fed7d945125.tar.gz |
(scm_c_uniform_vector_element_size,
scm_c_uniform_vector_size): Removed.
(scm_array_handle_uniform_element_size): New.
Diffstat (limited to 'libguile/srfi-4.c')
-rw-r--r-- | libguile/srfi-4.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/libguile/srfi-4.c b/libguile/srfi-4.c index 61995c662..eb61b31c2 100644 --- a/libguile/srfi-4.c +++ b/libguile/srfi-4.c @@ -482,15 +482,6 @@ scm_c_uniform_vector_length (SCM v) scm_wrong_type_arg_msg (NULL, 0, v, "uniform vector"); } -size_t -scm_c_uniform_vector_size (SCM v) -{ - if (scm_is_uniform_vector (v)) - return SCM_UVEC_LENGTH (v) * uvec_sizes[SCM_UVEC_TYPE (v)]; - else - scm_wrong_type_arg_msg (NULL, 0, v, "uniform vector"); -} - SCM_DEFINE (scm_uniform_vector_p, "uniform-vector?", 1, 0, 0, (SCM obj), "Return @code{#t} if @var{obj} is a uniform vector.") @@ -585,21 +576,23 @@ SCM_DEFINE (scm_uniform_vector_to_list, "uniform-vector->list", 1, 0, 0, #undef FUNC_NAME size_t -scm_uniform_vector_element_size (SCM uvec) +scm_array_handle_uniform_element_size (scm_t_array_handle *h) { - if (scm_is_uniform_vector (uvec)) - return uvec_sizes[SCM_UVEC_TYPE (uvec)]; - else - scm_wrong_type_arg_msg (NULL, 0, uvec, "uniform vector"); + SCM vec = h->array; + if (SCM_ARRAYP (vec)) + vec = SCM_ARRAY_V (vec); + if (scm_is_uniform_vector (vec)) + return uvec_sizes[SCM_UVEC_TYPE(vec)]; + scm_wrong_type_arg_msg (NULL, 0, h->array, "uniform array"); } - + /* return the size of an element in a uniform array or 0 if type not found. */ size_t scm_uniform_element_size (SCM obj) { if (scm_is_uniform_vector (obj)) - return scm_uniform_vector_element_size (obj); + return uvec_sizes[SCM_UVEC_TYPE(obj)]; else return 0; } @@ -638,7 +631,7 @@ scm_uniform_vector_writable_elements (SCM uvec, scm_t_array_handle *h, size_t *lenp, ssize_t *incp) { - scm_vector_get_handle (uvec, h); + scm_generalized_vector_get_handle (uvec, h); if (lenp) { scm_t_array_dim *dim = scm_array_handle_dims (h); @@ -696,7 +689,7 @@ SCM_DEFINE (scm_uniform_vector_read_x, "uniform-vector-read!", 1, 3, 0, scm_wrong_type_arg_msg (NULL, 0, uvec, "uniform vector"); base = scm_uniform_vector_writable_elements (uvec, &handle, &vlen, &inc); - sz = scm_uniform_vector_element_size (uvec); + sz = scm_array_handle_uniform_element_size (&handle); if (inc != 1) { @@ -765,6 +758,8 @@ SCM_DEFINE (scm_uniform_vector_read_x, "uniform-vector-read!", 1, 3, 0, ans = n / sz; } + scm_array_handle_release (&handle); + return scm_from_size_t (ans); } #undef FUNC_NAME @@ -806,7 +801,7 @@ SCM_DEFINE (scm_uniform_vector_write, "uniform-vector-write", 1, 3, 0, port_or_fd, SCM_ARG2, FUNC_NAME); base = scm_uniform_vector_elements (uvec, &handle, &vlen, &inc); - sz = scm_uniform_vector_element_size (uvec); + sz = scm_array_handle_uniform_element_size (&handle); if (inc != 1) { @@ -843,6 +838,8 @@ SCM_DEFINE (scm_uniform_vector_write, "uniform-vector-write", 1, 3, 0, ans = n / sz; } + scm_array_handle_release (&handle); + return scm_from_size_t (ans); } #undef FUNC_NAME |