summaryrefslogtreecommitdiff
path: root/libguile/array-handle.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2020-04-14 22:08:45 +0200
committerAndy Wingo <wingo@pobox.com>2020-04-14 22:18:02 +0200
commitd804177be4525feb517feb63ca09502d187fc016 (patch)
treefe99bbf9aa760874d717c8e9d7ee693f2c0d7e8d /libguile/array-handle.c
parentff9979b6bc6a72e03085d7ce21fd3f8f1bd39b64 (diff)
downloadguile-d804177be4525feb517feb63ca09502d187fc016.tar.gz
bitvector-bit-set? / bitvector-bit-clear? replace bitvector-ref
This is an opportunity to make a new interface that can be more efficient in 3.0 (because no generic array support), easier to read (no need for 'not'), and more consistent with other bitvector interfaces. * NEWS: Add entry. * doc/ref/api-data.texi (Bit Vectors): Update. * libguile/array-handle.h (bitvector_ref, scm_array_get_handle): Adapt to bitvector changes. * libguile/bitvectors.h: * libguile/bitvectors.c (scm_c_bitvector_bit_is_set) (scm_c_bitvector_bit_is_clear): New functions. * libguile/deprecated.h: * libguile/deprecated.c (scm_bitvector_ref): Deprecate. * module/ice-9/sandbox.scm (bitvector-bindings): Replace bitvector-ref with bitvector-bit-set? / bitvector-bit-clear?. * module/system/vm/disassembler.scm (instruction-has-fallthrough): Use bitvector-bit-clear?. * test-suite/tests/bitvectors.test: Update.
Diffstat (limited to 'libguile/array-handle.c')
-rw-r--r--libguile/array-handle.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libguile/array-handle.c b/libguile/array-handle.c
index 4b69e67a1..f547bf518 100644
--- a/libguile/array-handle.c
+++ b/libguile/array-handle.c
@@ -27,6 +27,7 @@
#include <string.h>
#include "arrays.h"
+#include "boolean.h"
#include "bitvectors.h"
#include "bytevectors.h"
#include "list.h"
@@ -167,6 +168,12 @@ initialize_vector_handle (scm_t_array_handle *h, size_t len,
h->vset = vset;
}
+static SCM
+bitvector_ref (SCM bv, size_t idx)
+{
+ return scm_from_bool (scm_c_bitvector_bit_is_set (bv, idx));
+}
+
void
scm_array_get_handle (SCM array, scm_t_array_handle *h)
{
@@ -194,7 +201,8 @@ scm_array_get_handle (SCM array, scm_t_array_handle *h)
case scm_tc7_bitvector:
initialize_vector_handle (h, scm_c_bitvector_length (array),
SCM_ARRAY_ELEMENT_TYPE_BIT,
- scm_c_bitvector_ref, scm_c_bitvector_set_x,
+ bitvector_ref,
+ scm_c_bitvector_set_x,
scm_i_bitvector_bits (array),
scm_i_is_mutable_bitvector (array));
break;