#ifndef SCM_ARRAYS_INTERNAL_H #define SCM_ARRAYS_INTERNAL_H /* Copyright 1995-1997,1999-2001,2004,2006,2008-2010,2012,2018,2025 Free Software Foundation, Inc. This file is part of Guile. Guile 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 the License, or (at your option) any later version. Guile is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Guile. If not, see . */ #include "libguile/arrays.h" struct scm_array { scm_t_bits tag_and_ndims; SCM vector; size_t base; struct scm_t_array_dim dims[]; }; /* There is a naming confusion: scm_is_array exists and is used for generalized arrays, allowing e.g. (array? #(1 2 3)) to be true. Here we are concerned with proper multidimensional arrays, which are their own data type. Mostly we can use this "struct scm_array" as a way to avoid confusion, but we have to name this function "scm_is_tagged_array" instead of "scm_is_array" as we would like. */ static inline int scm_is_tagged_array (SCM x) { return SCM_HAS_TYP7 (x, scm_tc7_array); } static inline struct scm_array* scm_to_array (SCM x) { if (!scm_is_tagged_array (x)) abort (); return (struct scm_array *) SCM_UNPACK_POINTER (x); } static inline SCM scm_from_array (struct scm_array *x) { return SCM_PACK_POINTER (x); } static inline size_t scm_array_dimension_count (struct scm_array *array) { return array->tag_and_ndims >> 16; } static inline SCM scm_array_vector (struct scm_array *array) { return array->vector; } static inline size_t scm_array_base (struct scm_array *array) { return array->base; } SCM_INTERNAL struct scm_array* scm_i_make_array (SCM v, size_t base, int ndim); SCM_INTERNAL int scm_i_print_array (SCM array, SCM port, scm_print_state *pstate); SCM_INTERNAL void scm_init_arrays (void); #endif /* SCM_ARRAYS_INTERNAL_H */