mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-09 05:30:21 +02:00
Give arrays a proper type in C land
As long as we have a tc7 for arrays, we should be able to access it with a struct type instead of casting each word. * libguile/arrays-internal.h: New file. * libguile/arrays.h (scm_array_p): Take just one argument. (SCM_I_ARRAYP): (SCM_I_ARRAY_NDIM): (SCM_I_ARRAY_V): (SCM_I_ARRAY_BASE): (SCM_I_ARRAY_DIMS): (SCM_I_ARRAY_SET_V): (SCM_I_ARRAY_SET_BASE): Remove. (scm_i_raw_array, scm_i_make_array, scm_i_shap2ra, scm_init_arrays): Remove internally-linked decls. * libguile/init.c: * libguile/print.c: * libguile/array-handle.c: Use interfaces from new file. * module/system/vm/assembler.scm: Update, as we now shift the dimension count by only 16. Requires a rebuild!
This commit is contained in:
parent
12e8772403
commit
9ff7c0651c
8 changed files with 248 additions and 178 deletions
|
@ -27,6 +27,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "arrays.h"
|
||||
#include "arrays-internal.h"
|
||||
#include "boolean.h"
|
||||
#include "bitvectors.h"
|
||||
#include "bytevectors.h"
|
||||
|
@ -260,11 +261,14 @@ scm_array_get_handle (SCM array, scm_t_array_handle *h)
|
|||
}
|
||||
break;
|
||||
case scm_tc7_array:
|
||||
scm_array_get_handle (SCM_I_ARRAY_V (array), h);
|
||||
h->array = array;
|
||||
h->base = SCM_I_ARRAY_BASE (array);
|
||||
h->ndims = SCM_I_ARRAY_NDIM (array);
|
||||
h->dims = SCM_I_ARRAY_DIMS (array);
|
||||
{
|
||||
struct scm_array *ra = scm_to_array (array);
|
||||
scm_array_get_handle (scm_array_vector (ra), h);
|
||||
h->array = array;
|
||||
h->base = scm_array_base (ra);
|
||||
h->ndims = scm_array_dimension_count (ra);
|
||||
h->dims = ra->dims;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
scm_wrong_type_arg_msg (NULL, 0, array, "array");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue