1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 03:30:27 +02:00

* srfi-4.h, srfi-4.c, srfi-4.i.c (scm_i_uniform_vector_ref_proc,

scm_i_uniform_vector_set_proc): New.
(u8ref, u8set, s8ref, s8set, etc): New.
(uvec_reffers, uvec_setters): New.
(uvec_to_list): Use generic scm_array_handle_ref instead of
uvec_fast_ref since scm_array_handle_ref should be faster now.
More changes like this are upcoming.
This commit is contained in:
Marius Vollmer 2005-01-09 22:06:56 +00:00
parent 9598a4060a
commit 4ea4bc4c40
3 changed files with 45 additions and 3 deletions

View file

@ -408,12 +408,10 @@ uvec_to_list (int type, SCM uvec)
SCM res = SCM_EOL;
elts = uvec_elements (type, uvec, &handle, &len, &inc);
if (type < 0)
type = uvec_type (&handle);
for (i = len*inc; i > 0;)
{
i -= inc;
res = scm_cons (uvec_fast_ref (type, elts, i), res);
res = scm_cons (scm_array_handle_ref (&handle, i), res);
}
scm_array_handle_release (&handle);
return res;
@ -1001,6 +999,36 @@ SCM_DEFINE (scm_uniform_vector_write, "uniform-vector-write", 1, 3, 0,
#define CTYPE double
#include "libguile/srfi-4.i.c"
static scm_i_t_array_ref uvec_reffers[12] = {
u8ref, s8ref,
u16ref, s16ref,
u32ref, s32ref,
u64ref, s64ref,
f32ref, f64ref,
c32ref, c64ref
};
static scm_i_t_array_set uvec_setters[12] = {
u8set, s8set,
u16set, s16set,
u32set, s32set,
u64set, s64set,
f32set, f64set,
c32set, c64set
};
scm_i_t_array_ref
scm_i_uniform_vector_ref_proc (SCM uvec)
{
return uvec_reffers[SCM_UVEC_TYPE(uvec)];
}
scm_i_t_array_set
scm_i_uniform_vector_set_proc (SCM uvec)
{
return uvec_setters[SCM_UVEC_TYPE(uvec)];
}
void
scm_init_srfi_4 (void)
{

View file

@ -299,6 +299,8 @@ SCM_API double *scm_c64vector_writable_elements (SCM uvec,
SCM_API SCM scm_i_generalized_vector_type (SCM vec);
SCM_API const char *scm_i_uniform_vector_tag (SCM uvec);
SCM_API scm_i_t_array_ref scm_i_uniform_vector_ref_proc (SCM uvec);
SCM_API scm_i_t_array_set scm_i_uniform_vector_set_proc (SCM uvec);
#if SCM_ENABLE_DEPRECATED

View file

@ -180,6 +180,18 @@ F(scm_,TAG,vector_writable_elements) (SCM uvec,
return F(scm_array_handle_,TAG,_writable_elements) (h);
}
static SCM
F(,TAG,ref) (scm_t_array_handle *handle, ssize_t pos)
{
return uvec_fast_ref (TYPE, handle->elements, pos);
}
static void
F(,TAG,set) (scm_t_array_handle *handle, ssize_t pos, SCM val)
{
uvec_fast_set_x (TYPE, handle->writable_elements, pos, val);
}
#undef paste
#undef s_paste
#undef stringify