summaryrefslogtreecommitdiff
path: root/libguile/deprecated.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2020-04-18 22:16:31 +0200
committerAndy Wingo <wingo@pobox.com>2020-04-18 22:16:31 +0200
commitf897efa9f10bbafa6839274d8bbb739fc02ce562 (patch)
tree7683a9672c126961b2b998551fa53ac5116d119d /libguile/deprecated.c
parentd7fea134530e552e15732fba01257cf6fba10fec (diff)
downloadguile-f897efa9f10bbafa6839274d8bbb739fc02ce562.tar.gz
bitvector-flip-all-bits! replaces bit-invert!
* NEWS: Add entry. * doc/ref/api-data.texi (Bit Vectors): Update. * libguile/bitvectors.h: * libguile/bitvectors.c (scm_c_bitvector_flip_all_bits_x): New function. * libguile/deprecated.h: * libguile/deprecated.c (scm_bit_invert_x): Deprecate. * module/ice-9/sandbox.scm (mutable-bitvector-bindings): Replace bit-invert! with bitvector-flip-all-bits!. * module/system/vm/frame.scm (available-bindings): Use the new interface. * test-suite/tests/bitvectors.test: Update.
Diffstat (limited to 'libguile/deprecated.c')
-rw-r--r--libguile/deprecated.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/libguile/deprecated.c b/libguile/deprecated.c
index 3682a0c04..b48982b10 100644
--- a/libguile/deprecated.c
+++ b/libguile/deprecated.c
@@ -206,6 +206,35 @@ SCM_DEFINE (scm_bitvector_fill_x, "bitvector-fill!", 2, 0, 0,
}
#undef FUNC_NAME
+SCM_DEFINE (scm_bit_invert_x, "bit-invert!", 1, 0, 0,
+ (SCM v),
+ "Modify the bit vector @var{v} by replacing each element with\n"
+ "its negation.")
+#define FUNC_NAME s_scm_bit_invert_x
+{
+ scm_c_issue_deprecation_warning
+ ("bit-invert! is deprecated. Use bitvector-flip-all-bits!, or "
+ "scalar array accessors in a loop for generic arrays.");
+
+ if (scm_is_bitvector (v))
+ scm_c_bitvector_flip_all_bits_x (v);
+ else
+ {
+ size_t off, len;
+ ssize_t inc;
+ scm_t_array_handle handle;
+
+ scm_bitvector_writable_elements (v, &handle, &off, &len, &inc);
+ for (size_t i = 0; i < len; i++)
+ scm_array_handle_set (&handle, i*inc,
+ scm_not (scm_array_handle_ref (&handle, i*inc)));
+ scm_array_handle_release (&handle);
+ }
+
+ return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
SCM_DEFINE (scm_bit_count, "bit-count", 2, 0, 0,
(SCM b, SCM bitvector),
"Return the number of occurrences of the boolean @var{b} in\n"