summaryrefslogtreecommitdiff
path: root/libguile/srfi-4.i.c
diff options
context:
space:
mode:
authorMarius Vollmer <mvo@zagadka.de>2005-01-02 20:06:08 +0000
committerMarius Vollmer <mvo@zagadka.de>2005-01-02 20:06:08 +0000
commit6e708ef2b1897c3ea4d5ac47720974078d50e9e4 (patch)
tree3dde367b768213b4693cc586b2adf23074f15667 /libguile/srfi-4.i.c
parent9c6e33c62acc203792053b6d5a579bdc22827eec (diff)
downloadguile-6e708ef2b1897c3ea4d5ac47720974078d50e9e4.tar.gz
* weaks.c: Use new vector elements API or simple vector
API, as appropriate. * srfi-4.h, srfi-4.c, srfi-4.i.c (scm_array_handle_uniform_elements, scm_array_handle_uniform_writable_elements, scm_uniform_vector_elements, scm_uniform_vector_writable_elements): (scm_<foo>vector_elements, scm_<foo>vector_writable_elements): Use scm_t_array_handle, deliver length and increment. (scm_array_handle_<foo>_elements, scm_array_handle_<foo>_writable_elements): New. * unif.h, unif.c (scm_t_array_handle, scm_array_get_handle, scm_array_handle_rank, scm_array_handle_dims, scm_array_handle_ref scm_array_handle_set, scm_array_handle_elements scm_array_handle_writable_elements, scm_vector_get_handle): New. (scm_make_uve, scm_array_prototype, scm_list_to_uniform_array, scm_dimensions_to_uniform_array): Deprecated for real. (scm_array_p, scm_i_array_p): Use latter for SCM_DEFINE since snarfing wont allow a mismatch between C and Scheme arglists. (scm_make_shared_array, scm_enclose_array): Correctly use scm_c_generalized_vector_length instead of scm_uniform_vector_length. * weaks.h, weaks.c: Use new internal weak vector API from vectors.h. * Makefile.am (libguile_la_SOURCES, DOT_X_FILES, DOT_DOC_FILES, EXTRA_libguile_la_SOURCES): Changed ramap.c and unif.c from being 'extra' to being regular sources. (noinst_HEADERS): Added quicksort.i.c. * quicksort.i.c: New file. * vectors.h, vector.c (SCM_VECTORP, SCM_VECTOR_LENGTH, SCM_VELTS, SCM_WRITABLE_VELTS, SCM_VECTOR_REF, SCM_VECTOR_SET): Deprecated and reimplemented. Replaced all uses with scm_vector_elements, scm_vector_writable_elements, or SCM_SIMPLE_VECTOR_*, as appropriate. (scm_is_simple_vector, SCM_SIMPLE_VECTOR_LENGTH, SCM_SIMPLE_VECTOR_REF, SCM_SIMPLE_VECTOR_SET, SCM_SIMPLE_VECTOR_LOC): New. (SCM_VECTOR_BASE, SCM_SET_VECTOR_BASE, SCM_VECTOR_MAX_LENGTH, SCM_MAKE_VECTOR_TAG, SCM_SET_VECTOR_LENGTH, SCM_VELTS_AS_STACKITEMS, SCM_SETVELTS, SCM_GC_WRITABLE_VELTS): Removed. (scm_vector_copy): New. (scm_vector_elements, scm_vector_writable_elements): Use scm_t_array_handle, deliver length and increment. Moved to unif.h. Changed all uses. (scm_vector_release_elements, scm_vector_release_writable_elements, (scm_frame_vector_release_elements, scm_frame_vector_release_writable_elements): Removed. (SCM_I_IS_VECTOR, SCM_I_VECTOR_ELTS, SCM_I_VECTOR_WELTS, SCM_I_VECTOR_LENGTH, scm_i_vector_free): New internal API. (SCM_I_WVECTP SCM_I_WVECT_LENGTH SCM_I_WVECT_VELTS SCM_I_WVECT_GC_WVELTS SCM_I_WVECT_TYPE SCM_I_WVECT_GC_CHAIN SCM_I_SET_WVECT_GC_CHAIN, scm_i_allocate_weak_vector): New, for weak vectors.
Diffstat (limited to 'libguile/srfi-4.i.c')
-rw-r--r--libguile/srfi-4.i.c58
1 files changed, 43 insertions, 15 deletions
diff --git a/libguile/srfi-4.i.c b/libguile/srfi-4.i.c
index 21c0895ee..8f3865315 100644
--- a/libguile/srfi-4.i.c
+++ b/libguile/srfi-4.i.c
@@ -1,4 +1,4 @@
-/* This file defines the procedures related to one type of homogenous
+/* This file defines the procedures related to one type of uniform
numeric vector. It is included multiple time in srfi-4.c, once for
each type.
@@ -45,7 +45,7 @@ SCM_DEFINE (F(scm_,TAG,vector_p), S(TAG)"vector?", 1, 0, 0,
SCM_DEFINE (F(scm_make_,TAG,vector), "make-"S(TAG)"vector", 1, 1, 0,
(SCM len, SCM fill),
- "Return a newly allocated homogeneous numeric vector which can\n"
+ "Return a newly allocated uniform numeric vector which can\n"
"hold @var{len} elements. If @var{fill} is given, it is used to\n"
"initialize the elements, otherwise the contents of the vector\n"
"is unspecified.")
@@ -65,7 +65,7 @@ F(scm_take_,TAG,vector) (const CTYPE *data, size_t n)
SCM_DEFINE (F(scm_,TAG,vector), S(TAG)"vector", 0, 0, 1,
(SCM l),
- "Return a newly allocated homogeneous numeric vector containing\n"
+ "Return a newly allocated uniform numeric vector containing\n"
"all argument values.")
#define FUNC_NAME s_F(scm_,TAG,vector)
{
@@ -76,7 +76,7 @@ SCM_DEFINE (F(scm_,TAG,vector), S(TAG)"vector", 0, 0, 1,
SCM_DEFINE (F(scm_,TAG,vector_length), S(TAG)"vector-length", 1, 0, 0,
(SCM uvec),
- "Return the number of elements in the homogeneous numeric vector\n"
+ "Return the number of elements in the uniform numeric vector\n"
"@var{uvec}.")
#define FUNC_NAME s_F(scm_,TAG,vector_length)
{
@@ -87,7 +87,7 @@ SCM_DEFINE (F(scm_,TAG,vector_length), S(TAG)"vector-length", 1, 0, 0,
SCM_DEFINE (F(scm_,TAG,vector_ref), S(TAG)"vector-ref", 2, 0, 0,
(SCM uvec, SCM index),
- "Return the element at @var{index} in the homogeneous numeric\n"
+ "Return the element at @var{index} in the uniform numeric\n"
"vector @var{uvec}.")
#define FUNC_NAME s_F(scm_,TAG,vector_ref)
{
@@ -98,7 +98,7 @@ SCM_DEFINE (F(scm_,TAG,vector_ref), S(TAG)"vector-ref", 2, 0, 0,
SCM_DEFINE (F(scm_,TAG,vector_set_x), S(TAG)"vector-set!", 3, 0, 0,
(SCM uvec, SCM index, SCM value),
- "Set the element at @var{index} in the homogeneous numeric\n"
+ "Set the element at @var{index} in the uniform numeric\n"
"vector @var{uvec} to @var{value}. The return value is not\n"
"specified.")
#define FUNC_NAME s_F(scm_,TAG,vector_set_x)
@@ -110,7 +110,7 @@ SCM_DEFINE (F(scm_,TAG,vector_set_x), S(TAG)"vector-set!", 3, 0, 0,
SCM_DEFINE (F(scm_,TAG,vector_to_list), S(TAG)"vector->list", 1, 0, 0,
(SCM uvec),
- "Convert the homogeneous numeric vector @var{uvec} to a list.")
+ "Convert the uniform numeric vector @var{uvec} to a list.")
#define FUNC_NAME s_F(scm_,TAG,vector_to_list)
{
return uvec_to_list (TYPE, uvec);
@@ -120,7 +120,7 @@ SCM_DEFINE (F(scm_,TAG,vector_to_list), S(TAG)"vector->list", 1, 0, 0,
SCM_DEFINE (F(scm_list_to_,TAG,vector), "list->"S(TAG)"vector", 1, 0, 0,
(SCM l),
- "Convert the list @var{l} to a numeric homogeneous vector.")
+ "Convert the list @var{l} to a numeric uniform vector.")
#define FUNC_NAME s_F(scm_list_to_,TAG,vector)
{
return list_to_uvec (TYPE, l);
@@ -130,7 +130,7 @@ SCM_DEFINE (F(scm_list_to_,TAG,vector), "list->"S(TAG)"vector", 1, 0, 0,
SCM_DEFINE (F(scm_any_to_,TAG,vector), "any->"S(TAG)"vector", 1, 0, 0,
(SCM obj),
"Convert @var{obj}, which can be a list, vector, or\n"
- "homogenous vector, to a numeric homogenous vector of\n"
+ "uniform vector, to a numeric uniform vector of\n"
"type " S(TAG)".")
#define FUNC_NAME s_F(scm_any_to_,TAG,vector)
{
@@ -139,17 +139,45 @@ SCM_DEFINE (F(scm_any_to_,TAG,vector), "any->"S(TAG)"vector", 1, 0, 0,
#undef FUNC_NAME
const CTYPE *
-F(scm_,TAG,vector_elements) (SCM obj)
+F(scm_array_handle_,TAG,_elements) (scm_t_array_handle *h)
{
- uvec_assert (TYPE, obj);
- return (const CTYPE *)SCM_UVEC_BASE (obj);
+ return F(scm_array_handle_,TAG,_writable_elements) (h);
}
CTYPE *
-F(scm_,TAG,vector_writable_elements) (SCM obj)
+F(scm_array_handle_,TAG,_writable_elements) (scm_t_array_handle *h)
{
- uvec_assert (TYPE, obj);
- return (CTYPE *)SCM_UVEC_BASE (obj);
+ SCM vec = h->array;
+ if (SCM_ARRAYP (vec))
+ vec = SCM_ARRAY_V (vec);
+ uvec_assert (TYPE, vec);
+ if (TYPE == SCM_UVEC_C32 || TYPE == SCM_UVEC_C64)
+ return ((CTYPE *)SCM_UVEC_BASE (vec)) + 2*h->base;
+ else
+ return ((CTYPE *)SCM_UVEC_BASE (vec)) + h->base;
+}
+
+const CTYPE *
+F(scm_,TAG,vector_elements) (SCM uvec,
+ scm_t_array_handle *h,
+ size_t *lenp, ssize_t *incp)
+{
+ return F(scm_,TAG,vector_writable_elements) (uvec, h, lenp, incp);
+}
+
+CTYPE *
+F(scm_,TAG,vector_writable_elements) (SCM uvec,
+ scm_t_array_handle *h,
+ size_t *lenp, ssize_t *incp)
+{
+ scm_vector_get_handle (uvec, h);
+ if (lenp)
+ {
+ scm_t_array_dim *dim = scm_array_handle_dims (h);
+ *lenp = dim->ubnd - dim->lbnd + 1;
+ *incp = dim->inc;
+ }
+ return F(scm_array_handle_,TAG,_writable_elements) (h);
}
#undef paste