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
|
@ -58,8 +58,7 @@ SCM_API size_t scm_c_array_rank (SCM ra);
|
|||
SCM_API SCM scm_array_rank (SCM ra);
|
||||
|
||||
SCM_API int scm_is_array (SCM obj);
|
||||
SCM_API SCM scm_array_p (SCM v, SCM unused);
|
||||
SCM_INTERNAL SCM scm_array_p_2 (SCM);
|
||||
SCM_API SCM scm_array_p (SCM v);
|
||||
|
||||
SCM_API int scm_is_typed_array (SCM obj, SCM type);
|
||||
SCM_API SCM scm_typed_array_p (SCM v, SCM type);
|
||||
|
@ -93,28 +92,5 @@ typedef struct scm_t_array_dim
|
|||
ssize_t inc;
|
||||
} scm_t_array_dim;
|
||||
|
||||
/* internal. */
|
||||
|
||||
#define SCM_I_ARRAYP(a) SCM_TYP16_PREDICATE (scm_tc7_array, a)
|
||||
#define SCM_I_ARRAY_NDIM(x) ((size_t) (SCM_CELL_WORD_0 (x)>>17))
|
||||
#define SCM_I_ARRAY_V(a) SCM_CELL_OBJECT_1 (a)
|
||||
#define SCM_I_ARRAY_BASE(a) ((size_t) SCM_CELL_WORD_2 (a))
|
||||
#define SCM_I_ARRAY_DIMS(a) ((scm_t_array_dim *) SCM_CELL_OBJECT_LOC (a, 3))
|
||||
#define SCM_I_ARRAY_SET_V(a, v) SCM_SET_CELL_OBJECT_1(a, v)
|
||||
#define SCM_I_ARRAY_SET_BASE(a, base) SCM_SET_CELL_WORD_2(a, base)
|
||||
|
||||
/* See the array cases in system/vm/assembler.scm. */
|
||||
|
||||
static inline SCM
|
||||
scm_i_raw_array (int ndim)
|
||||
{
|
||||
return scm_words (((scm_t_bits) ndim << 17) + scm_tc7_array, 3 + ndim*3);
|
||||
}
|
||||
|
||||
SCM_INTERNAL SCM scm_i_make_array (int ndim);
|
||||
SCM_INTERNAL int scm_i_print_array (SCM array, SCM port, scm_print_state *pstate);
|
||||
SCM_INTERNAL SCM scm_i_shap2ra (SCM args);
|
||||
|
||||
SCM_INTERNAL void scm_init_arrays (void);
|
||||
|
||||
#endif /* SCM_ARRAYS_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue