diff options
author | Daniel Llorens <daniel.llorens@bluewin.ch> | 2013-05-08 01:54:29 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2014-01-27 21:45:17 +0100 |
commit | b370eedc5edcc88386ffda3d78e9351e783a75a0 (patch) | |
tree | 23b92c60eeea53b06e4873243d708660b8880f78 | |
parent | ad93aa0195db29e30d21e4b6143b3a5be0234a37 (diff) | |
download | guile-b370eedc5edcc88386ffda3d78e9351e783a75a0.tar.gz |
Don't use generalized-vector in array-map.c (II)
* libguile/array-map.c
- replace scm_is_generalized_vector by scm_is_array && !SCM_I_ARRAY_P.
- replace scm_c_generalized_vector_length by scm_c_array_length.
- remove header.
-rw-r--r-- | libguile/array-map.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/libguile/array-map.c b/libguile/array-map.c index 660d04453..4d7d3e38e 100644 --- a/libguile/array-map.c +++ b/libguile/array-map.c @@ -39,7 +39,6 @@ #include "libguile/bitvectors.h" #include "libguile/srfi-4.h" #include "libguile/generalized-arrays.h" -#include "libguile/generalized-vectors.h" #include "libguile/validate.h" #include "libguile/array-map.h" @@ -104,34 +103,34 @@ scm_ra_matchp (SCM ra0, SCM ras) int i, ndim = 1; int exact = 2 /* 4 */ ; /* Don't care about values >2 (yet?) */ - if (scm_is_generalized_vector (ra0)) + if (!scm_is_array (ra0)) + return 0; + else if (!SCM_I_ARRAYP (ra0)) { s0->lbnd = 0; s0->inc = 1; - s0->ubnd = scm_c_generalized_vector_length (ra0) - 1; + s0->ubnd = scm_c_array_length (ra0) - 1; } - else if (SCM_I_ARRAYP (ra0)) + else { ndim = SCM_I_ARRAY_NDIM (ra0); s0 = SCM_I_ARRAY_DIMS (ra0); bas0 = SCM_I_ARRAY_BASE (ra0); } - else - return 0; while (scm_is_pair (ras)) { ra1 = SCM_CAR (ras); - - if (scm_is_generalized_vector (ra1)) + + if (!SCM_I_ARRAYP (ra1)) { size_t length; - + if (1 != ndim) return 0; - - length = scm_c_generalized_vector_length (ra1); - + + length = scm_c_array_length (ra1); + switch (exact) { case 4: @@ -149,7 +148,7 @@ scm_ra_matchp (SCM ra0, SCM ras) return 0; } } - else if (SCM_I_ARRAYP (ra1) && ndim == SCM_I_ARRAY_NDIM (ra1)) + else if (ndim == SCM_I_ARRAY_NDIM (ra1)) { s1 = SCM_I_ARRAY_DIMS (ra1); if (bas0 != SCM_I_ARRAY_BASE (ra1)) @@ -213,7 +212,7 @@ scm_ramapc (void *cproc_ptr, SCM data, SCM ra0, SCM lra, const char *what) if (SCM_IMP (vra0)) goto gencase; if (!SCM_I_ARRAYP (vra0)) { - size_t length = scm_c_generalized_vector_length (vra0); + size_t length = scm_c_array_length (vra0); vra1 = scm_i_make_array (1); SCM_I_ARRAY_BASE (vra1) = 0; SCM_I_ARRAY_DIMS (vra1)->lbnd = 0; @@ -271,7 +270,7 @@ scm_ramapc (void *cproc_ptr, SCM data, SCM ra0, SCM lra, const char *what) } else { - size_t length = scm_c_generalized_vector_length (ra0); + size_t length = scm_c_array_length (ra0); kmax = 0; SCM_I_ARRAY_DIMS (vra0)->lbnd = 0; SCM_I_ARRAY_DIMS (vra0)->ubnd = length - 1; @@ -814,7 +813,16 @@ SCM_DEFINE (scm_array_index_map_x, "array-index-map!", 2, 0, 0, unsigned long i; SCM_VALIDATE_PROC (2, proc); - if (SCM_I_ARRAYP (ra)) + if (!scm_is_array (ra)) + scm_wrong_type_arg_msg (NULL, 0, ra, "array"); + else if (!SCM_I_ARRAYP (ra)) + { + size_t length = scm_c_array_length (ra); + for (i = 0; i < length; ++i) + ASET (ra, i, scm_call_1 (proc, scm_from_ulong (i))); + return SCM_UNSPECIFIED; + } + else { SCM args = SCM_EOL; int j, k, kmax = SCM_I_ARRAY_NDIM (ra) - 1; @@ -858,15 +866,6 @@ SCM_DEFINE (scm_array_index_map_x, "array-index-map!", 2, 0, 0, return SCM_UNSPECIFIED; } - else if (scm_is_generalized_vector (ra)) - { - size_t length = scm_c_generalized_vector_length (ra); - for (i = 0; i < length; i++) - ASET (ra, i, scm_call_1 (proc, scm_from_ulong (i))); - return SCM_UNSPECIFIED; - } - else - scm_wrong_type_arg_msg (NULL, 0, ra, "array"); } #undef FUNC_NAME |