* doc/ref/api-data.texi (Arrays as arrays of arrays): Clarify
ambiguities, fix examples.
* libguile/arrays.c (make-shared-array): Make error messages specific to
each error case, report relevant arguments.
(array_from_pos): Return NULL on error instead of reporting error
ourselves.
(array_from_get_o): Handle the trivial case.
(scm_array_slice, scm_array_cell_ref, scm_array_cell_set_x): Don't
build error arguments before error happens. Let array_from_get_o
handle the trivial case.
This flag was set, but never used in Guile, and there was no documented
API to access it.
To check if an array is contiguous, use (array-contents <> #t).
* libguile/arrays.h (scm_i_raw_array): New function.
SCM_I_ARRAY_CONTIGUOUS, SCM_SET_ARRAY_CONTIGUOUS_FLAG,
SCM_CLR_ARRAY_CONTIGUOUS_FLAG, SCM_I_ARRAY_CONTP: Remove.
scm_t_array_dim: Declare here, not in array-handle.h.
SCM_I_ARRAY_NDIM: Shift by one bit since the contp flag isn't there
anymore.
* module/syste/vm/assembler.scm: Match removal of contp flag.
* libguile/arrays.c (scm_i_make_array): Reuse scm_i_raw_array.
(scm_i_ra_set_contp): Remove.
(scm_transpose_array): Don't set or clear the contp flag.
(scm_make_shared_array): Don't set or clear the contp flag.
(scm_make_typed_array): Don't set the contp flag.
* libguile/array-map.c (scm_i_array_rebase): Reuse scm_i_raw_array.
As the FSF advises, 'There is no legal significance to using the
three-character sequence “(C)”, but it does no harm.' It does take up
space though! For that reason, we remove it here from our C files.
* module/ice-9/arrays.scm (array-print-prefix): New private function.
* libguile/arrays.c (scm_i_print_array): Reuse (array-print-prefix) from
(ice-9 arrays). Make sure to release the array handle.
* module/ice-9/pretty-print.scm (truncated-print): Support
bitvectors.
Don't try to guess the array prefix but call array-print-prefix from
(ice-9 arrays) instead.
Fix call to print-sequence to support non-zero lower bound arrays.
* test-suite/tests/arrays.test: Test that arrays print properly.
* test-suite/tests/print.test: Test truncated-print with bitvectors,
non-zero lower bound arrays.
scm_from_contiguous_array() was undocumented, unused within Guile, and
can be replaced by make-array + array-copy! without requiring contiguity
and without loss of performance.
* libguile/arrays.c (scm_array_contents): Do not rely on
SCM_I_ARRAY_CONTP.
* test-suite/tests/arrays.test: Test array-contents with 0-rank array.
* libguile/arrays.h: Declare scm_i_shap2ra(),
SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG so that
scm_from_contiguous_array() can keep using them.
* libguile/deprecated.c (scm_from_contiguous_array): Move here from
arrays.c.
* libguile/deprecated.h (scm_from_contiguous_array): Deprecate.
* NEWS: Add deprecation notice.
* libguile/arrays.c (scm_shared_array_root): Adopt uniform check order.
(scm_shared_array_offset, scm_shared_array_increments): Use the array
fields directly just as scm_shared_array_root does.
(scm_c_array_rank): Moved from libguile/generalized-arrays.c. Don't
use array handles, but follow the same type check sequence as the
other array functions (shared-array-root, etc).
(scm_array_rank): Moved from libguile/generalized-arrays.h.
* libguile/arrays.h: Move prototypes here.
* test-suite/tests/arrays.test: Tests for shared-array-offset,
shared-array-increments.
* libguile/root.h:
* libguile/root.c: Remove these files.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_internal_cwdr, scm_call_with_dynamic_root)
(scm_dynamic_root, scm_apply_with_dynamic_root): Deprecate.
Remove all root.h usage, which was vestigial.
* module/ice-9/serialize.scm: Use (current-thread) instead
of (dynamic-root).
* libguile/arrays.c (scm_i_print_array): Print the dimension whenever
the array is a true scm_tc7_array.
* test-suite/tests/arrays.test: Check that non-vector 1D arrays print as
expected.
This fixes a compiler issue where (uniform-array->bytevector #2f64())
failed because of the stricter definition of uniform-vector? on this branch.
Perhaps it would be better if uniform-array->bytevector didn't require
a contiguous argument.
* libguile/arrays.c: (scm_array_contents): return the root regardless of
the value of SCM_I_ARRAY_DIMS (ra)->inc.
* test-suite/tests/arrays.test: check.
* libguile/arrays.c
- scm_shared_array_root: check for SCM_I_ARRAYP first.
- scm_i_shap2ra:
* check valid bounds in the '(lbnd ubnd) case. This makes
(make-array 0 '(4 -3)) fail with a 'bad dimension' instead of
with a 'wrong index' error.
* use ssize_t for lbnd/ubnd/inc, not long.
- scm_make_shared_array: use ssize_t for indices, not long.
- scm_transpose_array: use size_t for ndim, not ulong.
- scm_i_print_array: idem.
* libguile/arrays.c (scm_array_contents): Branch cases not on
scm_is_generalized_vector but on SCM_I_ARRAYP. Thus lbnd!=0, which
could happen with scm_is_generalized_vector, never appears in the
output.
* test-suite/tests/arrays.test: Test array-contents.
* libguile/array-handle.h (scm_t_vector_ref, scm_t_vector_set): Rename
from scm_t_array_ref, scm_t_array_set. These were named
scm_i_t_array_ref and scm_i_t_array_set in 1.8 and 2.0. Change to
take the vector directly, instead of the array handle. In this way,
generic array handles are layered on top of specific implementations
of backing stores.
Remove scm_t_array_implementation, introduced in 2.0 but never
documented. It was a failed attempt to layer the array implementation
that actually introduced too many layers, as it prevented the "vref"
and "vset" members of scm_t_array_handle (called "ref" and "set" in
1.8, not present in 2.0) from specializing on array backing stores.
(scm_i_register_array_implementation) (scm_i_array_implementation_for_obj):
Remove these internal interfaces.
(scm_t_array_handle): Adapt to scm_t_vector_ref / scm_t_vector_set
change.
(scm_array_handle_ref, scm_array_handle_set): Adapt to change in
vref/vset prototype.
* libguile/array-handle.c (scm_array_get_handle): Inline all the
necessary initializations here for all specific array types.
* libguile/array-map.c (rafill, racp, ramap, rafe, array_index_map_1):
* libguile/arrays.c: Remove array implementation code.
* libguile/bitvectors.h:
* libguile/bitvectors.c: Remove array implementation code.
(scm_i_bitvector_bits): New internal interface.
* libguile/bytevectors.c: Remove array implementation code.
* libguile/srfi-4.h: Remove declarations for internal procedures that
don't exist (!).
* libguile/strings.c: Remove array implementation code.
* libguile/vectors.c: Remove array implementation code.
* libguile/array-map.c
- rafill, ramap, rafe, racp: object from SCM_I_ARRAY_V always
has base 0, lbnd 0 and inc 1; make use of this.
* libguile/arrays.c
- array_handle_ref, array_handle_set: idem.
- array_get_handle: sanity check.
* libguile/generalized-vectors.c
- scm_c_generalized_vector_ref, scm_c_generalized_vector_set_x:
pos should be base when idx is lbnd. Furthermore, pos should be signed and
have its overflow checked; do this by handling the job to
scm_c_array_ref_1, scm_c_array_set_1_x.
* libguile/generalized-vectors.h
- fix prototypes.
* libguile/arrays.c (scm_transpose_array)
- Use scm_c_array_rank(), which contains an implicit is_array test.
- Handle the rank 0 case.
* test-suite/tests/arrays.test
- Add test for rank 0 case.
- Add failure test for non array argument.
* libguile/arrays.c (scm_from_contiguous_typed_array):
* libguile/bytevectors.c (scm_uniform_array_to_bytevector): For
bitvectors, round up the length to 32-bit units, as they are stored
internally. Otherwise I think this probably does the wrong thing for
the last word on big-endian systems.
* libguile/bitvectors.c (BITVECTOR_LENGTH, BITVECTOR_BITS):
(scm_c_make_bitvector): Reorder the length and pointer words to match
the layout of bytevectors.
* module/language/cps/primitives.scm (*branching-primcall-arities*):
* module/system/vm/assembler.scm (br-if-bitvector):
* module/system/vm/disassembler.scm (code-annotation): Add bitvector
test support.
* module/system/vm/assembler.scm (<uniform-vector-backing-store>): Add
an element-size field.
(intern-constant): Adapt make-uniform-vector-backing-store call. Use
uniform-array->bytevector, as the old compiler did.
(link-data): Add bitvector cases.
Moved scm_i_struct_hash from struct.c to hash.c and made it static.
The port's alist is now a field of 'scm_t_port'.
Conflicts:
libguile/arrays.c
libguile/hash.c
libguile/ports.c
libguile/print.h
libguile/read.c
* libguile/arrays.c (read_decimal_integer): Move to read.c.
(scm_i_read_array): Remove. Incorporate the code into the
'scm_read_array' static function in read.c.
* libguile/arrays.h (scm_i_read_array): Remove prototype.
* libguile/read.c (read_decimal_integer): Move here from read.c.
(scm_read_array): Incorporate the code from 'scm_i_read_array'. Call
'scm_read_vector' and 'scm_read_sexp' instead of 'scm_read'.
* libguile/tags.h (scm_tc7_array): Allocate a tag for arrays.
* libguile/arrays.h (SCM_I_ARRAYP): Change to use scm_tc7_array. The
previous definition was not externally usable because scm_i_tc16_array
was internal.
(scm_i_print_array): Declare, though internally.
* libguile/arrays.c (scm_i_make_array): Use scm_cell with the tc7
instead of NEWSMOB.
(scm_i_print_array): Make not static.
(SCM_ARRAY_IMPLEMENTATION): Adapt.
(scm_init_arrays): Remove array smob declaration.
* libguile/eq.c (scm_equal_p): Refactor to put the string, pointer, and
bytevector cases in the switch. Add a case for arrays.
* libguile/goops.c: Add <array> declarations.
* libguile/print.c (iprin1): Call scm_i_print_array as needed.
* libguile/evalext.c (scm_self_evaluating_p): Add a case for arrays.
* libguile/ports.c (scm_putc, scm_puts):
* libguile/ports.h (scm_putc_unlocked, scm_puts_unlocked): Separate into
_unlocked and locked variants. Change all callers to use the
_unlocked versions.
* libguile/ports.c (scm_c_read_unlocked, scm_c_read, scm_getc_unlocked)
(scm_getc): Split getc and read operations into locked and unlocked
variants. Change most uses to use the _unlocked version.