As a side effect, this allows compilation of literal bytevectors
("#vu8(...)"), which gets done by the generic array handling
of the GLIL->assembly compiler.
* doc/ref/api-compound.texi (Generalized Vectors): Mention bytevectors.
(Arrays, Array Syntax): Likewise.
* doc/ref/api-data.texi (Bytevectors as Generalized Vectors): New node.
* libguile/bytevectors.c (scm_i_bytevector_generalized_set_x): New.
* libguile/bytevectors.h (scm_i_bytevector_generalized_set_x): New
declaration.
* libguile/srfi-4.c (scm_i_generalized_vector_type,
scm_array_handle_uniform_element_size,
scm_array_handle_uniform_writable_elements): Add support for
bytevectors.
* libguile/unif.c (type_creator_table): Add `vu8'.
(bytevector_ref, bytevector_set): New functions.
(memoize_ref, memoize_set): Add support for bytevectors.
* libguile/vectors.c (scm_is_generalized_vector,
scm_c_generalized_vector_length, scm_c_generalized_vector_ref,
scm_c_generalized_vector_set_x): Add support for bytevectors.
* test-suite/tests/bytevectors.test ("Generalized Vectors"): New test
set.
Idea and original patch were by Ludovic Courts, this is Neil Jerram's
reworking of it.
* libguile/srfi-4.c (scm_uniform_vector_read_x): Use scm_c_read,
instead of equivalent code here.
* libguile/ports.c (scm_fill_input): Add assertion that read
buffer is empty when called.
(port_and_swap_buffer, swap_buffer): New, for...
(scm_c_read): Use caller's buffer for reading, to avoid making N
1-byte low-level read calls, in the case where the port is
unbuffered (or has a very small buffer).
scm_array_handle_u64_elements,
scm_array_handle_u64_writable_elements, scm_u64vector_elements,
scm_u64vector_writable_elements): Do not define when scm_t_uint64
is not available.
(scm_take_s64vector, scm_array_handle_s64_elements,
scm_array_handle_s64_writable_elements, scm_s64vector_elements,
scm_s64vector_writable_elements): Likewise for scm_t_int64.
(uvec_sizes, uvec_print, uvec_equalp): Use SCM bignums when
scm_t_int64/scm_t_uint64 are not available.
(uvec_mark): New, to mark the bignums.
(alloc_uvec): Initialize bignums.
(uvec_fast_ref): Return bignums directly.
(scm_uint64_min, scm_uint64_max, scm_int64_min, scm_int64_max,
assert_exact_integer): New.
(uvec_fast_set): Use them to validate the bignums.
(scm_init_srfi_4): Set mark function of smob when needed.
Initialize scm_uint64_min, scm_uint64_max, scm_int64_min,
scm_int64_max.
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.
SCM_SMOB_PREDICATE in this file.
(is_uvec): Also recognize one-dimensional uniform numeric arrays
of the right type.
(scm_is_uniform_vector): Likewise.
(uvec_fast_ref): Made BASE param const.
(uvec_writable_elements, uvec_elements): New.
(uvec_to_list, uvec_ref, uvec_set_x, uvec_length,
scm_c_uniform_vector_length, scm_c_uniform_vector_ref,
scm_c_uniform_set_x): Use them to also deal with one-dimensional
arrays.
(scm_uniform_vector_ref, scm_uniform_vector_set_x): Deprecate old
argument convention.
(scm_uniform_vector_to_list): Let uvec_to_list do all the
checking.
(scm_uniform_vector_length): Use uvec_length.
scm_u8vector_elements, etc): Made return value "const".
(scm_uniform_vector_writable_elements,
scm_u8vector_writable_elements, etc): New.
(scm_uniform_vector_release, scm_uniform_vector_release_elements):
Renamed former to latter. Added explicit call to
scm_remember_upto_here_1.
(scm_frame_uniform_vector_release,
scm_frame_uniform_vector_release_elements): Renamed former to latter.
(scm_uniform_vector_release_writable_elements,
scm_frame_uniform_vector_release_writable_elements): New. Takes
crown of longest identifier yet.
Changed all uses as required by the changes above.
(scm_i_uniform_vector_creator): Removed.
(scm_i_generalized_vector_creator): New.
(scm_uniform_vector_length, scm_uniform_element_size): Do not
handle generalized vectors, only uniform numeric vectors.
(alloc_uvec): Do length check here...
(make_uvec): ...but not here.
(coerce_to_uvec): Use new generalized vector functions to handle
all kinds of vectors in one go.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.