summaryrefslogtreecommitdiff
path: root/libguile/deprecated.c
diff options
context:
space:
mode:
authorDaniel Llorens <daniel.llorens@bluewin.ch>2016-11-18 16:23:05 +0100
committerDaniel Llorens <daniel.llorens@bluewin.ch>2016-11-23 13:05:49 +0100
commitfa4a22971a122e30e6b167bfe7ac209d02ffafc4 (patch)
treee89cbfa9d6f5ce3bdae7f1725971cf697e3ced18 /libguile/deprecated.c
parent0bd7562c961223cd70e772bac8b7ae21b34f1aed (diff)
downloadguile-fa4a22971a122e30e6b167bfe7ac209d02ffafc4.tar.gz
Deprecate scm_from_contiguous_array
scm_from_contiguous_array() was undocumented, unused within Guile, and can be replaced by make-array + array-copy! without requiring contiguity and without loss of performance. * libguile/arrays.c (scm_array_contents): Do not rely on SCM_I_ARRAY_CONTP. * test-suite/tests/arrays.test: Test array-contents with 0-rank array. * libguile/arrays.h: Declare scm_i_shap2ra(), SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG so that scm_from_contiguous_array() can keep using them. * libguile/deprecated.c (scm_from_contiguous_array): Move here from arrays.c. * libguile/deprecated.h (scm_from_contiguous_array): Deprecate. * NEWS: Add deprecation notice.
Diffstat (limited to 'libguile/deprecated.c')
-rw-r--r--libguile/deprecated.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/libguile/deprecated.c b/libguile/deprecated.c
index e94733806..0ea4b5e20 100644
--- a/libguile/deprecated.c
+++ b/libguile/deprecated.c
@@ -729,6 +729,46 @@ scm_unlock_mutex_timed (SCM mx, SCM cond, SCM timeout)
return scm_unlock_mutex (mx);
}
+
+
+SCM
+scm_from_contiguous_array (SCM bounds, const SCM *elts, size_t len)
+#define FUNC_NAME "scm_from_contiguous_array"
+{
+ size_t k, rlen = 1;
+ scm_t_array_dim *s;
+ SCM ra;
+ scm_t_array_handle h;
+
+ scm_c_issue_deprecation_warning
+ ("`scm_from_contiguous_array' is deprecated. Use make-array and array-copy!\n"
+ "instead.\n");
+
+ ra = scm_i_shap2ra (bounds);
+ SCM_SET_ARRAY_CONTIGUOUS_FLAG (ra);
+ s = SCM_I_ARRAY_DIMS (ra);
+ k = SCM_I_ARRAY_NDIM (ra);
+
+ while (k--)
+ {
+ s[k].inc = rlen;
+ SCM_ASSERT_RANGE (1, bounds, s[k].lbnd <= s[k].ubnd + 1);
+ rlen = (s[k].ubnd - s[k].lbnd + 1) * s[k].inc;
+ }
+ if (rlen != len)
+ SCM_MISC_ERROR ("element length and dimensions do not match", SCM_EOL);
+
+ SCM_I_ARRAY_SET_V (ra, scm_c_make_vector (rlen, SCM_UNDEFINED));
+ scm_array_get_handle (ra, &h);
+ memcpy (h.writable_elements, elts, rlen * sizeof(SCM));
+ scm_array_handle_release (&h);
+
+ if (1 == SCM_I_ARRAY_NDIM (ra) && 0 == SCM_I_ARRAY_BASE (ra))
+ if (0 == s->lbnd)
+ return SCM_I_ARRAY_V (ra);
+ return ra;
+}
+#undef FUNC_NAME