1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-19 18:20:22 +02:00

Don't use generalized-vector functions in uniform.c

* libguile/uniform.c (scm_is_uniform_vector): Replace
  scm_is_generalized_vector and scm_generalized_vector_get_handle by
  scm_is_array and manual rank check.
  (scm_c_uniform_vector_length): Use scm_c_array_length.
  (scm_c_uniform_vector_ref): Use scm_c_array_ref_1.
  (scm_c_uniform_vector_set): Use scm_c_array_set_1_x.
  (scm_uniform_vector_writable_elements): Use scm_array_get_handle, and
  assert that the rank is 1.

* test-suite/test/arrays.test: Rename the uniform-vector-ref block to
  uniform-vector.  Exercise uniform-vector-length and shared arrays
  remaining uniform.

Modifications by Andy Wingo <wingo@pobox.com>.
This commit is contained in:
Daniel Llorens 2014-02-06 11:17:47 +01:00 committed by Andy Wingo
parent 1fadf369b8
commit c4aca3b9da
2 changed files with 34 additions and 17 deletions

View file

@ -574,12 +574,12 @@
(eqv? 8 (array-ref s2 2))))))
;;;
;;; uniform-vector-ref
;;; uniform-vector
;;;
(with-test-prefix "uniform-vector-ref"
(with-test-prefix "uniform-vector"
(with-test-prefix "byte"
(with-test-prefix "uniform-vector-ref byte"
(let ((a (make-s8vector 1)))
@ -594,7 +594,23 @@
(pass-if "-128"
(begin
(array-set! a -128 0)
(= -128 (uniform-vector-ref a 0)))))))
(= -128 (uniform-vector-ref a 0))))))
(with-test-prefix "shared with rank 1 remain uniform vectors"
(let ((a #f64(1 2 3 4)))
(pass-if "change offset"
(let ((b (make-shared-array a (lambda (i) (list (+ i 1))) 3)))
(and (uniform-vector? b)
(= 3 (uniform-vector-length b))
(array-equal? b #f64(2 3 4)))))
(pass-if "change stride"
(let ((c (make-shared-array a (lambda (i) (list (* i 2))) 2)))
(and (uniform-vector? c)
(= 2 (uniform-vector-length c))
(array-equal? c #f64(1 3))))))))
;;;
;;; syntax