1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-25 20:50:31 +02:00

Remove all deprecated interfaces

We're on a new version series, let's remove deprecated things.  Also
reduces the amount of work we need to do in adapting to a new GC,
notably for bignums.

* configure.ac (--disable-tmpnam): Remove flag, tmpnam is gone.
* doc/ref/posix.texi (File System): Remove tmpnam docs.
* libguile/bitvectors.c (scm_bitvector_to_list): Remove deprecated
branch treating arrays as bitvectors.
* libguile/deprecated.c: Remove all deprecated code.  Whee!
* libguile/deprecated.h: Remove deprecated decls.
* libguile/posix.c (scm_tmpnam): Remove.
* libguile/struct.c (scm_is_valid_vtable_layout): Remove support for 'r'
fields.
* libguile/vectors.c (scm_vector_copy_partial, scm_vector_to_list)
(scm_vector_move_left_x, scm_vector_move_right_x): Remove generalized
array cases.
* test-suite/tests/vectors.test ("vector->list"): Remove shared array
test
This commit is contained in:
Andy Wingo 2025-04-30 13:14:58 +02:00
parent dd0e455755
commit 1a3f427d4e
10 changed files with 78 additions and 1221 deletions

View file

@ -1,4 +1,4 @@
/* Copyright 1995-1996,1998-2001,2006,2008-2012,2014,2018-2020
/* Copyright 1995-1996,1998-2001,2006,2008-2012,2014,2018-2020,2025
Free Software Foundation, Inc.
This file is part of Guile.
@ -268,51 +268,27 @@ SCM_DEFINE (scm_vector_copy_partial, "vector-copy", 1, 2, 0,
#define FUNC_NAME s_scm_vector_copy_partial
{
SCM result;
if (SCM_I_IS_VECTOR (vec))
{
size_t cstart = 0, cend = SCM_I_VECTOR_LENGTH (vec);
SCM_VALIDATE_VECTOR (1, vec);
size_t cstart = 0, cend = SCM_I_VECTOR_LENGTH (vec);
if (!SCM_UNBNDP (start))
{
cstart = scm_to_size_t (start);
SCM_ASSERT_RANGE (SCM_ARG2, start, cstart<=cend);
if (!SCM_UNBNDP (end))
{
size_t e = scm_to_size_t (end);
SCM_ASSERT_RANGE (SCM_ARG3, end, e>=cstart && e<=cend);
cend = e;
}
}
size_t len = cend-cstart;
result = make_vector (len);
memcpy (SCM_I_VECTOR_WELTS (result), SCM_I_VECTOR_ELTS (vec) + cstart,
len * sizeof(SCM));
}
else
if (!SCM_UNBNDP (start))
{
scm_t_array_handle handle;
size_t i, len;
ssize_t inc;
const SCM *src;
SCM *dst;
cstart = scm_to_size_t (start);
SCM_ASSERT_RANGE (SCM_ARG2, start, cstart<=cend);
src = scm_vector_elements (vec, &handle, &len, &inc);
scm_c_issue_deprecation_warning
("Using vector-copy on arrays is deprecated. "
"Use array-copy instead.");
if (SCM_UNBNDP (start))
scm_misc_error (s_scm_vector_copy_partial, "Too many arguments", SCM_EOL);
result = make_vector (len);
dst = SCM_I_VECTOR_WELTS (result);
for (i = 0; i < len; i++, src += inc)
dst[i] = *src;
scm_array_handle_release (&handle);
if (!SCM_UNBNDP (end))
{
size_t e = scm_to_size_t (end);
SCM_ASSERT_RANGE (SCM_ARG3, end, e>=cstart && e<=cend);
cend = e;
}
}
size_t len = cend-cstart;
result = make_vector (len);
memcpy (SCM_I_VECTOR_WELTS (result), SCM_I_VECTOR_ELTS (vec) + cstart,
len * sizeof(SCM));
return result;
}
#undef FUNC_NAME
@ -377,32 +353,13 @@ SCM_DEFINE (scm_vector_to_list, "vector->list", 1, 0, 0,
{
SCM res = SCM_EOL;
if (SCM_I_IS_VECTOR (vec))
{
ssize_t len = SCM_I_VECTOR_LENGTH (vec);
const SCM * data = SCM_I_VECTOR_ELTS (vec);
for (ssize_t i = len-1; i >= 0; --i)
res = scm_cons (data[i], res);
}
else
{
const SCM *data;
scm_t_array_handle handle;
size_t i, count, len;
ssize_t inc;
SCM_VALIDATE_VECTOR (1, vec);
data = scm_vector_elements (vec, &handle, &len, &inc);
scm_c_issue_deprecation_warning
("Using vector->list on arrays is deprecated. "
"Use array->list instead.");
ssize_t len = SCM_I_VECTOR_LENGTH (vec);
const SCM * data = SCM_I_VECTOR_ELTS (vec);
for (ssize_t i = len-1; i >= 0; --i)
res = scm_cons (data[i], res);
for (i = (len - 1) * inc, count = 0;
count < len;
i -= inc, count++)
res = scm_cons (data[i], res);
scm_array_handle_release (&handle);
}
return res;
}
#undef FUNC_NAME
@ -468,53 +425,24 @@ SCM_DEFINE (scm_vector_move_left_x, "vector-move-left!", 5, 0, 0,
"@var{start1} is greater than @var{start2}.")
#define FUNC_NAME s_scm_vector_move_left_x
{
if (SCM_I_IS_VECTOR (vec1) && SCM_I_IS_VECTOR (vec2))
{
SCM_VALIDATE_MUTABLE_VECTOR (1, vec2);
const SCM *elts1 = SCM_I_VECTOR_ELTS (vec1);
SCM *elts2 = SCM_I_VECTOR_WELTS (vec2);
size_t len1 = SCM_I_VECTOR_LENGTH (vec1);
size_t len2 = SCM_I_VECTOR_LENGTH (vec2);
SCM_VALIDATE_VECTOR (1, vec1);
SCM_VALIDATE_VECTOR (4, vec2);
size_t i, j, e;
i = scm_to_unsigned_integer (start1, 0, len1);
e = scm_to_unsigned_integer (end1, i, len1);
SCM_ASSERT_RANGE (SCM_ARG3, end1, (e-i) <= len2);
j = scm_to_unsigned_integer (start2, 0, len2);
SCM_ASSERT_RANGE (SCM_ARG5, start2, j <= len2 - (e - i));
for (; i < e; ++i, ++j)
elts2[j] = elts1[i];
}
else
{
scm_t_array_handle handle1, handle2;
const SCM *elts1;
SCM *elts2;
size_t len1, len2;
ssize_t inc1, inc2;
size_t i, j, e;
SCM_VALIDATE_MUTABLE_VECTOR (1, vec2);
const SCM *elts1 = SCM_I_VECTOR_ELTS (vec1);
SCM *elts2 = SCM_I_VECTOR_WELTS (vec2);
size_t len1 = SCM_I_VECTOR_LENGTH (vec1);
size_t len2 = SCM_I_VECTOR_LENGTH (vec2);
elts1 = scm_vector_elements (vec1, &handle1, &len1, &inc1);
elts2 = scm_vector_writable_elements (vec2, &handle2, &len2, &inc2);
scm_c_issue_deprecation_warning
("Using vector-move-left! on arrays is deprecated. "
"Use array-copy-in-order! instead.");
size_t i, j, e;
i = scm_to_unsigned_integer (start1, 0, len1);
e = scm_to_unsigned_integer (end1, i, len1);
SCM_ASSERT_RANGE (SCM_ARG3, end1, (e-i) <= len2);
j = scm_to_unsigned_integer (start2, 0, len2);
SCM_ASSERT_RANGE (SCM_ARG5, start2, j <= len2 - (e - i));
for (; i < e; ++i, ++j)
elts2[j] = elts1[i];
i = scm_to_unsigned_integer (start1, 0, len1);
e = scm_to_unsigned_integer (end1, i, len1);
SCM_ASSERT_RANGE (SCM_ARG3, end1, (e-i) <= len2);
j = scm_to_unsigned_integer (start2, 0, len2);
SCM_ASSERT_RANGE (SCM_ARG5, start2, j <= len2 - (e - i));
i *= inc1;
e *= inc1;
j *= inc2;
for (; i < e; i += inc1, j += inc2)
elts2[j] = elts1[i];
scm_array_handle_release (&handle2);
scm_array_handle_release (&handle1);
}
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
@ -530,64 +458,28 @@ SCM_DEFINE (scm_vector_move_right_x, "vector-move-right!", 5, 0, 0,
"@var{start1} is less than @var{start2}.")
#define FUNC_NAME s_scm_vector_move_right_x
{
if (SCM_I_IS_VECTOR (vec1) && SCM_I_IS_VECTOR (vec2))
SCM_VALIDATE_VECTOR (1, vec1);
SCM_VALIDATE_VECTOR (4, vec2);
SCM_VALIDATE_MUTABLE_VECTOR (1, vec2);
const SCM *elts1 = SCM_I_VECTOR_ELTS (vec1);
SCM *elts2 = SCM_I_VECTOR_WELTS (vec2);
size_t len1 = SCM_I_VECTOR_LENGTH (vec1);
size_t len2 = SCM_I_VECTOR_LENGTH (vec2);
size_t i, j, e;
i = scm_to_unsigned_integer (start1, 0, len1);
e = scm_to_unsigned_integer (end1, i, len1);
SCM_ASSERT_RANGE (SCM_ARG3, end1, (e-i) <= len2);
j = scm_to_unsigned_integer (start2, 0, len2);
SCM_ASSERT_RANGE (SCM_ARG5, start2, j <= len2 - (e - i));
j += (e - i);
while (i < e)
{
SCM_VALIDATE_MUTABLE_VECTOR (1, vec2);
const SCM *elts1 = SCM_I_VECTOR_ELTS (vec1);
SCM *elts2 = SCM_I_VECTOR_WELTS (vec2);
size_t len1 = SCM_I_VECTOR_LENGTH (vec1);
size_t len2 = SCM_I_VECTOR_LENGTH (vec2);
size_t i, j, e;
i = scm_to_unsigned_integer (start1, 0, len1);
e = scm_to_unsigned_integer (end1, i, len1);
SCM_ASSERT_RANGE (SCM_ARG3, end1, (e-i) <= len2);
j = scm_to_unsigned_integer (start2, 0, len2);
SCM_ASSERT_RANGE (SCM_ARG5, start2, j <= len2 - (e - i));
j += (e - i);
while (i < e)
{
--e;
--j;
elts2[j] = elts1[e];
}
}
else
{
scm_t_array_handle handle1, handle2;
const SCM *elts1;
SCM *elts2;
size_t len1, len2;
ssize_t inc1, inc2;
size_t i, j, e;
elts1 = scm_vector_elements (vec1, &handle1, &len1, &inc1);
elts2 = scm_vector_writable_elements (vec2, &handle2, &len2, &inc2);
scm_c_issue_deprecation_warning
("Using vector-move-right! on arrays is deprecated. "
"Use array-copy-in-order! instead.");
i = scm_to_unsigned_integer (start1, 0, len1);
e = scm_to_unsigned_integer (end1, i, len1);
SCM_ASSERT_RANGE (SCM_ARG3, end1, (e-i) <= len2);
j = scm_to_unsigned_integer (start2, 0, len2);
SCM_ASSERT_RANGE (SCM_ARG5, start2, j <= len2 - (e - i));
j += (e - i);
i *= inc1;
e *= inc1;
j *= inc2;
while (i < e)
{
e -= inc1;
j -= inc2;
elts2[j] = elts1[e];
}
scm_array_handle_release (&handle2);
scm_array_handle_release (&handle1);
--e;
--j;
elts2[j] = elts1[e];
}
return SCM_UNSPECIFIED;