guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 13/27: Move bitvector functions using array_handle to li


From: Daniel Llorens
Subject: [Guile-commits] 13/27: Move bitvector functions using array_handle to libguile/array-handle.[ch]
Date: Wed, 8 Apr 2020 04:03:50 -0400 (EDT)

lloda pushed a commit to branch wip-vector-cleanup
in repository guile.

commit 252a4113bda28d7ae092e73fde966cccbaa0e6d5
Author: Daniel Llorens <address@hidden>
AuthorDate: Wed Feb 5 17:23:40 2020 +0100

    Move bitvector functions using array_handle to libguile/array-handle.[ch]
---
 NEWS-wip-vector-cleanup.txt |  2 ++
 libguile/array-handle.c     | 28 +++++++++++++++++++++++++++-
 libguile/array-handle.h     |  4 ++++
 libguile/bitvectors.c       | 22 ----------------------
 libguile/bitvectors.h       |  5 +----
 libguile/posix.c            |  1 +
 libguile/vectors.c          |  1 -
 libguile/vectors.h          |  2 --
 8 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/NEWS-wip-vector-cleanup.txt b/NEWS-wip-vector-cleanup.txt
index c0cbaf2..b8770e1 100644
--- a/NEWS-wip-vector-cleanup.txt
+++ b/NEWS-wip-vector-cleanup.txt
@@ -58,6 +58,8 @@ instead of the correct result #1@1(0 1 2 0 0). This buggy 
support has been remov
 
 * Rationale / TODO
 
+The ultimate goal of this patch set is to have arrays be strictly layered 
above typed vectors so they can be replaced by a different implementation 
without affecting the latter.
+
 ** Status as of 3.0.0
   
   - The _elements functions require the array handle interface even for true 
vectors, when all of handle, inc and off are unnecessary. This creates a burden 
(having to declare & release handles, etc).
diff --git a/libguile/array-handle.c b/libguile/array-handle.c
index 6ca19cc..6c30d77 100644
--- a/libguile/array-handle.c
+++ b/libguile/array-handle.c
@@ -333,6 +333,10 @@ scm_array_handle_release (scm_t_array_handle *h)
    */
 }
 
+// -----------------------------------------------
+// scm_array_handle_TYPE_(writable_)elements FIXME
+// -----------------------------------------------
+
 const SCM *
 scm_array_handle_elements (scm_t_array_handle *h)
 {
@@ -352,10 +356,32 @@ scm_array_handle_writable_elements (scm_t_array_handle *h)
 }
 
 // -----------------------------------------------
-// FIXME adding scm_array1_xxx_(writable_)elements
+// scm_array1_TYPE_(writable_)elements FIXME
 // -----------------------------------------------
 
 const uint32_t *
+scm_array_handle_bit_elements (scm_t_array_handle *h)
+{
+  if (h->element_type != SCM_ARRAY_ELEMENT_TYPE_BIT)
+    scm_wrong_type_arg_msg (NULL, 0, h->array, "bit array");
+  return ((const uint32_t *) h->elements) + h->base/32;
+}
+
+uint32_t *
+scm_array_handle_bit_writable_elements (scm_t_array_handle *h)
+{
+  if (h->writable_elements != h->elements)
+    scm_wrong_type_arg_msg (NULL, 0, h->array, "mutable bit array");
+  return (uint32_t *) scm_array_handle_bit_elements (h);
+}
+
+size_t
+scm_array_handle_bit_elements_offset (scm_t_array_handle *h)
+{
+  return h->base % 32;
+}
+
+const uint32_t *
 scm_array1_bit_elements (SCM vec, size_t *lenp, ssize_t *incp, size_t *offp)
 {
   scm_t_array_handle h;
diff --git a/libguile/array-handle.h b/libguile/array-handle.h
index 4a97bc1..c2ff204 100644
--- a/libguile/array-handle.h
+++ b/libguile/array-handle.h
@@ -127,6 +127,10 @@ scm_array_handle_set (scm_t_array_handle *h, ssize_t p, 
SCM v)
 
 SCM_INTERNAL void scm_init_array_handle (void);
 
+SCM_API const uint32_t *scm_array_handle_bit_elements (scm_t_array_handle *h);
+SCM_API uint32_t *scm_array_handle_bit_writable_elements (scm_t_array_handle 
*h);
+SCM_API size_t scm_array_handle_bit_elements_offset (scm_t_array_handle *h);
+
 SCM_API const uint32_t * scm_array1_bit_elements (SCM vec, size_t *lenp, 
ssize_t *incp, size_t *offp);
 SCM_API uint32_t * scm_array1_bit_writable_elements (SCM vec, size_t *lenp, 
ssize_t *incp, size_t *offp);
 
diff --git a/libguile/bitvectors.c b/libguile/bitvectors.c
index fa549bb..9ae410d 100644
--- a/libguile/bitvectors.c
+++ b/libguile/bitvectors.c
@@ -183,28 +183,6 @@ SCM_DEFINE (scm_bitvector_length, "bitvector-length", 1, 
0, 0,
 }
 #undef FUNC_NAME
 
-const uint32_t *
-scm_array_handle_bit_elements (scm_t_array_handle *h)
-{
-  if (h->element_type != SCM_ARRAY_ELEMENT_TYPE_BIT)
-    scm_wrong_type_arg_msg (NULL, 0, h->array, "bit array");
-  return ((const uint32_t *) h->elements) + h->base/32;
-}
-
-uint32_t *
-scm_array_handle_bit_writable_elements (scm_t_array_handle *h)
-{
-  if (h->writable_elements != h->elements)
-    scm_wrong_type_arg_msg (NULL, 0, h->array, "mutable bit array");
-  return (uint32_t *) scm_array_handle_bit_elements (h);
-}
-
-size_t
-scm_array_handle_bit_elements_offset (scm_t_array_handle *h)
-{
-  return h->base % 32;
-}
-
 #define SCM_VALIDATE_BITVECTOR(pos, v)                          \
   do {                                                          \
     SCM_ASSERT_TYPE (IS_BITVECTOR (v), v, pos, __func__,        \
diff --git a/libguile/bitvectors.h b/libguile/bitvectors.h
index 1c5b7df..b3a30b5 100644
--- a/libguile/bitvectors.h
+++ b/libguile/bitvectors.h
@@ -22,7 +22,7 @@
 
 
 
-#include "libguile/array-handle.h"
+#include "libguile/scm.h"
 
 
 
@@ -54,9 +54,6 @@ SCM_API SCM scm_c_make_bitvector (size_t len, SCM fill);
 SCM_API size_t scm_c_bitvector_length (SCM vec);
 SCM_API SCM scm_c_bitvector_ref (SCM vec, size_t idx);
 SCM_API void scm_c_bitvector_set_x (SCM vec, size_t idx, SCM val);
-SCM_API const uint32_t *scm_array_handle_bit_elements (scm_t_array_handle *h);
-SCM_API uint32_t *scm_array_handle_bit_writable_elements (scm_t_array_handle 
*h);
-SCM_API size_t scm_array_handle_bit_elements_offset (scm_t_array_handle *h);
 SCM_API const uint32_t *scm_bitvector_elements (SCM vec, size_t *lenp);
 SCM_API uint32_t *scm_bitvector_writable_elements (SCM vec, size_t *lenp);
 
diff --git a/libguile/posix.c b/libguile/posix.c
index ca561f0..d7ecda5 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -65,6 +65,7 @@
 
 #include "async.h"
 #include "bitvectors.h"
+#include "array-handle.h"
 #include "dynwind.h"
 #include "extensions.h"
 #include "feature.h"
diff --git a/libguile/vectors.c b/libguile/vectors.c
index 56f475f..6df2dc5 100644
--- a/libguile/vectors.c
+++ b/libguile/vectors.c
@@ -405,7 +405,6 @@ SCM_DEFINE (scm_vector_move_right_x, "vector-move-right!", 
5, 0, 0,
 
 SCM_VECTOR_IMPLEMENTATION (SCM_ARRAY_ELEMENT_TYPE_SCM, scm_make_vector)
 
-
 void
 scm_init_vectors ()
 {
diff --git a/libguile/vectors.h b/libguile/vectors.h
index 455e394..fe5f927 100644
--- a/libguile/vectors.h
+++ b/libguile/vectors.h
@@ -83,8 +83,6 @@ SCM_API SCM *scm_vector_writable_elements (SCM vec, size_t 
*lenp);
 #define SCM_I_VECTOR_LENGTH(x) (((size_t) SCM_CELL_WORD_0 (x)) >> 8)
 
 SCM_INTERNAL SCM  scm_i_vector_equal_p (SCM x, SCM y);
-
-
 SCM_INTERNAL void scm_init_vectors (void);
 
 #endif  /* SCM_VECTORS_H */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]