-/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2006, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
- *
+/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2006, 2008, 2009, 2010,
+ * 2011, 2012, 2014 Free Software Foundation, Inc.
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3 of
int
scm_is_vector (SCM obj)
{
- if (SCM_I_IS_VECTOR (obj))
+ if (SCM_I_IS_NONWEAK_VECTOR (obj))
return 1;
- if (SCM_I_ARRAYP (obj) && SCM_I_ARRAY_NDIM (obj) == 1)
+ if (SCM_I_WVECTP (obj))
+ {
+ scm_c_issue_deprecation_warning
+ ("Expecting vector? to be true for weak vectors is deprecated. "
+ "Use weak-vector? instead.");
+ return 1;
+ }
+ if (SCM_I_ARRAYP (obj) && SCM_I_ARRAY_NDIM (obj) == 1)
{
SCM v = SCM_I_ARRAY_V (obj);
- return SCM_I_IS_VECTOR (v);
+ if (SCM_I_IS_VECTOR (v))
+ {
+ scm_c_issue_deprecation_warning
+ ("Expecting vector? to be true for rank-1 arrays is deprecated. "
+ "Use array?, array-rank, and array-type instead.");
+ return 1;
+ }
+ return 0;
}
return 0;
}
int
scm_is_simple_vector (SCM obj)
{
- return SCM_I_IS_VECTOR (obj);
+ if (SCM_I_IS_NONWEAK_VECTOR (obj))
+ return 1;
+ if (SCM_I_WVECTP (obj))
+ {
+ scm_c_issue_deprecation_warning
+ ("Expecting scm_is_simple_vector to be true for weak vectors is "
+ "deprecated. Use scm_is_weak_vector instead.");
+ return 1;
+ }
+ return 0;
}
const SCM *
scm_vector_length (SCM v)
{
if (SCM_I_IS_VECTOR (v))
- return scm_from_size_t (SCM_I_VECTOR_LENGTH (v));
+ {
+ if (SCM_I_WVECTP (v))
+ scm_c_issue_deprecation_warning
+ ("Using vector-length on weak vectors is deprecated. "
+ "Use weak-vector-length from (ice-9 weak-vectors) instead.");
+ return scm_from_size_t (SCM_I_VECTOR_LENGTH (v));
+ }
else if (SCM_I_ARRAYP (v) && SCM_I_ARRAY_NDIM (v) == 1)
{
scm_t_array_dim *dim = SCM_I_ARRAY_DIMS (v);
+ scm_c_issue_deprecation_warning
+ ("Using vector-length on arrays is deprecated. "
+ "Use array-length instead.");
return scm_from_size_t (dim->ubnd - dim->lbnd + 1);
}
+ else if (SCM_UNPACK (g_vector_length))
+ {
+ scm_c_issue_deprecation_warning
+ ("Using vector-length as a primitive-generic is deprecated.");
+ return scm_call_generic_1 (g_vector_length, v);
+ }
else
- SCM_WTA_DISPATCH_1 (g_vector_length, v, 1, NULL);
+ {
+ scm_wrong_type_arg_msg ("vector-length", 1, v, "vector");
+ return SCM_UNDEFINED; /* not reached */
+ }
}
size_t
scm_c_vector_length (SCM v)
{
- if (SCM_I_IS_VECTOR (v))
+ if (SCM_I_IS_NONWEAK_VECTOR (v))
return SCM_I_VECTOR_LENGTH (v);
else
return scm_to_size_t (scm_vector_length (v));
SCM
scm_c_vector_ref (SCM v, size_t k)
{
- if (SCM_I_IS_VECTOR (v))
+ if (SCM_I_IS_NONWEAK_VECTOR (v))
{
register SCM elt;
scm_out_of_range (NULL, scm_from_size_t (k));
elt = (SCM_I_VECTOR_ELTS(v))[k];
- if (SCM_UNPACK (elt) == 0 && SCM_I_WVECTP (v))
- /* ELT was a weak pointer and got nullified by the GC. */
- return SCM_BOOL_F;
-
return elt;
}
+ else if (SCM_I_WVECTP (v))
+ {
+ scm_c_issue_deprecation_warning
+ ("Using vector-ref on weak vectors is deprecated. "
+ "Instead, use weak-vector-ref from (ice-9 weak-vectors).");
+ return scm_c_weak_vector_ref (v, k);
+ }
else if (SCM_I_ARRAYP (v) && SCM_I_ARRAY_NDIM (v) == 1)
{
scm_t_array_dim *dim = SCM_I_ARRAY_DIMS (v);
{
register SCM elt;
+ scm_c_issue_deprecation_warning
+ ("Using vector-ref on arrays is deprecated. "
+ "Use array-ref instead.");
+
if (k >= dim->ubnd - dim->lbnd + 1)
scm_out_of_range (NULL, scm_from_size_t (k));
k = SCM_I_ARRAY_BASE (v) + k*dim->inc;
elt = (SCM_I_VECTOR_ELTS (vv))[k];
if (SCM_UNPACK (elt) == 0 && (SCM_I_WVECTP (vv)))
- /* ELT was a weak pointer and got nullified by the GC. */
- return SCM_BOOL_F;
+ {
+ scm_c_issue_deprecation_warning
+ ("Weak arrays are deprecated. Use weak vectors instead.");
+ /* ELT was a weak pointer and got nullified by the GC. */
+ return SCM_BOOL_F;
+ }
return elt;
}
scm_wrong_type_arg_msg (NULL, 0, v, "non-uniform vector");
}
+ else if (SCM_UNPACK (g_vector_ref))
+ {
+ scm_c_issue_deprecation_warning
+ ("Using vector-ref as a primitive-generic is deprecated.");
+ return scm_call_generic_2 (g_vector_ref, v, scm_from_size_t (k));
+ }
else
- SCM_WTA_DISPATCH_2 (g_vector_ref, v, scm_from_size_t (k), 2, NULL);
+ {
+ scm_wrong_type_arg_msg ("vector-ref", 1, v, "vector");
+ return SCM_UNDEFINED; /* not reached */
+ }
}
SCM_GPROC (s_vector_set_x, "vector-set!", 3, 0, 0, scm_vector_set_x, g_vector_set_x);
void
scm_c_vector_set_x (SCM v, size_t k, SCM obj)
{
- if (SCM_I_IS_VECTOR (v))
+ if (SCM_I_IS_NONWEAK_VECTOR (v))
{
if (k >= SCM_I_VECTOR_LENGTH (v))
scm_out_of_range (NULL, scm_from_size_t (k));
(SCM_I_VECTOR_WELTS(v))[k] = obj;
- if (SCM_I_WVECTP (v))
- {
- /* Make it a weak pointer. */
- GC_PTR link = (GC_PTR) & ((SCM_I_VECTOR_WELTS (v))[k]);
- SCM_I_REGISTER_DISAPPEARING_LINK (link, obj);
- }
+ }
+ else if (SCM_I_WVECTP (v))
+ {
+ scm_c_issue_deprecation_warning
+ ("Using vector-set! on weak vectors is deprecated. "
+ "Instead, use weak-vector-set! from (ice-9 weak-vectors).");
+ scm_c_weak_vector_set_x (v, k, obj);
}
else if (SCM_I_ARRAYP (v) && SCM_I_ARRAY_NDIM (v) == 1)
{
SCM vv = SCM_I_ARRAY_V (v);
if (SCM_I_IS_VECTOR (vv))
{
+ scm_c_issue_deprecation_warning
+ ("Using vector-set! on arrays is deprecated. "
+ "Use array-set! instead, but note the change in argument order.");
+
if (k >= dim->ubnd - dim->lbnd + 1)
scm_out_of_range (NULL, scm_from_size_t (k));
k = SCM_I_ARRAY_BASE (v) + k*dim->inc;
if (SCM_I_WVECTP (vv))
{
/* Make it a weak pointer. */
- GC_PTR link = (GC_PTR) & ((SCM_I_VECTOR_WELTS (vv))[k]);
- SCM_I_REGISTER_DISAPPEARING_LINK (link, obj);
+ SCM *link = & SCM_I_VECTOR_WELTS (vv)[k];
+ SCM_I_REGISTER_DISAPPEARING_LINK ((void **) link, SCM2PTR (obj));
+ scm_c_issue_deprecation_warning
+ ("Weak arrays are deprecated. Use weak vectors instead.");
}
}
else
scm_wrong_type_arg_msg (NULL, 0, v, "non-uniform vector");
}
- else
+ else if (SCM_UNPACK (g_vector_set_x))
{
- if (SCM_UNPACK (g_vector_set_x))
- scm_apply_generic (g_vector_set_x,
- scm_list_3 (v, scm_from_size_t (k), obj));
- else
- scm_wrong_type_arg_msg (NULL, 0, v, "vector");
+ scm_c_issue_deprecation_warning
+ ("Using vector-set! as a primitive-generic is deprecated.");
+ scm_call_3 (g_vector_set_x, v, scm_from_size_t (k), obj);
}
+ else
+ scm_wrong_type_arg_msg ("vector-set!", 1, v, "vector");
}
SCM_DEFINE (scm_make_vector, "make-vector", 1, 1, 0,