mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-19 10:10:23 +02:00
Remove generalized-vectors.[hc]
* libguile/arrays.c: Assume the registry of array element types. * libguile/arrays.h (scm_make_generalized_vector): Last decl from generalized-vectors.h. * libguile/generalized-vectors.h: * libguile/generalized-vectors.c: Remove. Elsewhere remove references to generalized-vectors.
This commit is contained in:
parent
26510db52c
commit
68ae22eb5e
8 changed files with 80 additions and 155 deletions
|
@ -62,7 +62,6 @@ extern "C" {
|
||||||
#include "libguile/frames.h"
|
#include "libguile/frames.h"
|
||||||
#include "libguile/gc.h"
|
#include "libguile/gc.h"
|
||||||
#include "libguile/generalized-arrays.h"
|
#include "libguile/generalized-arrays.h"
|
||||||
#include "libguile/generalized-vectors.h"
|
|
||||||
#include "libguile/goops.h"
|
#include "libguile/goops.h"
|
||||||
#include "libguile/gsubr.h"
|
#include "libguile/gsubr.h"
|
||||||
#include "libguile/guardians.h"
|
#include "libguile/guardians.h"
|
||||||
|
|
|
@ -164,7 +164,6 @@ libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES = \
|
||||||
gc.c \
|
gc.c \
|
||||||
gettext.c \
|
gettext.c \
|
||||||
generalized-arrays.c \
|
generalized-arrays.c \
|
||||||
generalized-vectors.c \
|
|
||||||
goops.c \
|
goops.c \
|
||||||
gsubr.c \
|
gsubr.c \
|
||||||
guardians.c \
|
guardians.c \
|
||||||
|
@ -279,7 +278,6 @@ DOT_X_FILES = \
|
||||||
gc.x \
|
gc.x \
|
||||||
gettext.x \
|
gettext.x \
|
||||||
generalized-arrays.x \
|
generalized-arrays.x \
|
||||||
generalized-vectors.x \
|
|
||||||
goops.x \
|
goops.x \
|
||||||
gsubr.x \
|
gsubr.x \
|
||||||
guardians.x \
|
guardians.x \
|
||||||
|
@ -387,7 +385,6 @@ DOT_DOC_FILES = \
|
||||||
gc.doc \
|
gc.doc \
|
||||||
gettext.doc \
|
gettext.doc \
|
||||||
generalized-arrays.doc \
|
generalized-arrays.doc \
|
||||||
generalized-vectors.doc \
|
|
||||||
goops.doc \
|
goops.doc \
|
||||||
gsubr.doc \
|
gsubr.doc \
|
||||||
guardians.doc \
|
guardians.doc \
|
||||||
|
@ -635,7 +632,6 @@ modinclude_HEADERS = \
|
||||||
gc-inline.h \
|
gc-inline.h \
|
||||||
gettext.h \
|
gettext.h \
|
||||||
generalized-arrays.h \
|
generalized-arrays.h \
|
||||||
generalized-vectors.h \
|
|
||||||
goops.h \
|
goops.h \
|
||||||
gsubr.h \
|
gsubr.h \
|
||||||
guardians.h \
|
guardians.h \
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include "feature.h"
|
#include "feature.h"
|
||||||
#include "fports.h"
|
#include "fports.h"
|
||||||
#include "generalized-arrays.h"
|
#include "generalized-arrays.h"
|
||||||
#include "generalized-vectors.h"
|
|
||||||
#include "gsubr.h"
|
#include "gsubr.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "modules.h"
|
#include "modules.h"
|
||||||
|
@ -56,6 +55,52 @@
|
||||||
|
|
||||||
#include "arrays.h"
|
#include "arrays.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------- */
|
||||||
|
/* Handling of root types */
|
||||||
|
/* ---------------------- */
|
||||||
|
|
||||||
|
struct scm_t_vector_ctor
|
||||||
|
{
|
||||||
|
SCM tag;
|
||||||
|
SCM (*ctor)(SCM, SCM);
|
||||||
|
};
|
||||||
|
|
||||||
|
#define VECTOR_CTORS_N_STATIC_ALLOC 20
|
||||||
|
static struct scm_t_vector_ctor vector_ctors[VECTOR_CTORS_N_STATIC_ALLOC];
|
||||||
|
static int num_vector_ctors_registered = 0;
|
||||||
|
|
||||||
|
static void
|
||||||
|
scm_i_register_vector_constructor (SCM type, SCM (*ctor)(SCM, SCM))
|
||||||
|
{
|
||||||
|
if (num_vector_ctors_registered >= VECTOR_CTORS_N_STATIC_ALLOC)
|
||||||
|
/* need to increase VECTOR_CTORS_N_STATIC_ALLOC, buster */
|
||||||
|
abort ();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vector_ctors[num_vector_ctors_registered].tag = type;
|
||||||
|
vector_ctors[num_vector_ctors_registered].ctor = ctor;
|
||||||
|
num_vector_ctors_registered++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SCM_DEFINE (scm_make_generalized_vector, "make-generalized-vector", 2, 1, 0,
|
||||||
|
(SCM type, SCM len, SCM fill),
|
||||||
|
"Make a generalized vector")
|
||||||
|
#define FUNC_NAME s_scm_make_generalized_vector
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < num_vector_ctors_registered; i++)
|
||||||
|
if (scm_is_eq (vector_ctors[i].tag, type))
|
||||||
|
return vector_ctors[i].ctor(len, fill);
|
||||||
|
scm_wrong_type_arg_msg (FUNC_NAME, SCM_ARG1, type, "array type");
|
||||||
|
}
|
||||||
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------- */
|
||||||
|
/* Basic array library */
|
||||||
|
/* ------------------- */
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
scm_c_array_rank (SCM array)
|
scm_c_array_rank (SCM array)
|
||||||
|
@ -954,11 +999,42 @@ scm_i_print_array (SCM array, SCM port, scm_print_state *pstate)
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------- */
|
||||||
|
/* Init hook */
|
||||||
|
/* ---------------------- */
|
||||||
|
|
||||||
|
#define SCM_VECTOR_IMPLEMENTATION(type, ctor) \
|
||||||
|
SCM_SNARF_INIT (scm_i_register_vector_constructor \
|
||||||
|
(scm_i_array_element_types[type], ctor))
|
||||||
|
|
||||||
|
SCM_VECTOR_IMPLEMENTATION (SCM_ARRAY_ELEMENT_TYPE_SCM, scm_make_vector)
|
||||||
|
SCM_VECTOR_IMPLEMENTATION (SCM_ARRAY_ELEMENT_TYPE_BIT, scm_make_bitvector)
|
||||||
|
SCM_VECTOR_IMPLEMENTATION (SCM_ARRAY_ELEMENT_TYPE_CHAR, scm_make_string)
|
||||||
|
SCM_VECTOR_IMPLEMENTATION (SCM_ARRAY_ELEMENT_TYPE_VU8, scm_make_bytevector)
|
||||||
|
|
||||||
void
|
void
|
||||||
scm_init_arrays ()
|
scm_init_arrays ()
|
||||||
{
|
{
|
||||||
|
#define REGISTER(tag, TAG) \
|
||||||
|
scm_i_register_vector_constructor \
|
||||||
|
(scm_i_array_element_types[SCM_ARRAY_ELEMENT_TYPE_##TAG], \
|
||||||
|
scm_make_##tag##vector)
|
||||||
|
|
||||||
|
REGISTER (u8, U8);
|
||||||
|
REGISTER (s8, S8);
|
||||||
|
REGISTER (u16, U16);
|
||||||
|
REGISTER (s16, S16);
|
||||||
|
REGISTER (u32, U32);
|
||||||
|
REGISTER (s32, S32);
|
||||||
|
REGISTER (u64, U64);
|
||||||
|
REGISTER (s64, S64);
|
||||||
|
REGISTER (f32, F32);
|
||||||
|
REGISTER (f64, F64);
|
||||||
|
REGISTER (c32, C32);
|
||||||
|
REGISTER (c64, C64);
|
||||||
|
|
||||||
scm_add_feature ("array");
|
scm_add_feature ("array");
|
||||||
|
|
||||||
#include "arrays.x"
|
#include "arrays.x"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
Also see ....
|
Also see ....
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* FIXME Superfluous residue from generalized-vector.h - deprecate */
|
||||||
|
SCM_API SCM scm_make_generalized_vector (SCM type, SCM len, SCM fill);
|
||||||
|
|
||||||
/** Arrays */
|
/** Arrays */
|
||||||
|
|
||||||
|
|
|
@ -1,110 +0,0 @@
|
||||||
/* Copyright 1995-1998,2000-2006,2009-2014,2018
|
|
||||||
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
|
|
||||||
<https://www.gnu.org/licenses/>. */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "error.h"
|
|
||||||
#include "gsubr.h"
|
|
||||||
|
|
||||||
#include "generalized-vectors.h"
|
|
||||||
#include "array-handle.h"
|
|
||||||
#include "bytevectors.h"
|
|
||||||
#include "bitvectors.h"
|
|
||||||
#include "strings.h"
|
|
||||||
#include "vectors.h"
|
|
||||||
#include "srfi-4.h"
|
|
||||||
|
|
||||||
struct scm_t_vector_ctor
|
|
||||||
{
|
|
||||||
SCM tag;
|
|
||||||
SCM (*ctor)(SCM, SCM);
|
|
||||||
};
|
|
||||||
|
|
||||||
#define VECTOR_CTORS_N_STATIC_ALLOC 20
|
|
||||||
static struct scm_t_vector_ctor vector_ctors[VECTOR_CTORS_N_STATIC_ALLOC];
|
|
||||||
static int num_vector_ctors_registered = 0;
|
|
||||||
|
|
||||||
static void
|
|
||||||
scm_i_register_vector_constructor (SCM type, SCM (*ctor)(SCM, SCM))
|
|
||||||
{
|
|
||||||
if (num_vector_ctors_registered >= VECTOR_CTORS_N_STATIC_ALLOC)
|
|
||||||
/* need to increase VECTOR_CTORS_N_STATIC_ALLOC, buster */
|
|
||||||
abort ();
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vector_ctors[num_vector_ctors_registered].tag = type;
|
|
||||||
vector_ctors[num_vector_ctors_registered].ctor = ctor;
|
|
||||||
num_vector_ctors_registered++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SCM_DEFINE (scm_make_generalized_vector, "make-generalized-vector", 2, 1, 0,
|
|
||||||
(SCM type, SCM len, SCM fill),
|
|
||||||
"Make a generalized vector")
|
|
||||||
#define FUNC_NAME s_scm_make_generalized_vector
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < num_vector_ctors_registered; i++)
|
|
||||||
if (scm_is_eq (vector_ctors[i].tag, type))
|
|
||||||
return vector_ctors[i].ctor(len, fill);
|
|
||||||
scm_wrong_type_arg_msg (FUNC_NAME, SCM_ARG1, type, "array type");
|
|
||||||
}
|
|
||||||
#undef FUNC_NAME
|
|
||||||
|
|
||||||
#define SCM_VECTOR_IMPLEMENTATION(type, ctor) \
|
|
||||||
SCM_SNARF_INIT (scm_i_register_vector_constructor \
|
|
||||||
(scm_i_array_element_types[type], ctor))
|
|
||||||
|
|
||||||
|
|
||||||
SCM_VECTOR_IMPLEMENTATION (SCM_ARRAY_ELEMENT_TYPE_SCM, scm_make_vector)
|
|
||||||
SCM_VECTOR_IMPLEMENTATION (SCM_ARRAY_ELEMENT_TYPE_BIT, scm_make_bitvector)
|
|
||||||
SCM_VECTOR_IMPLEMENTATION (SCM_ARRAY_ELEMENT_TYPE_CHAR, scm_make_string)
|
|
||||||
|
|
||||||
void
|
|
||||||
scm_init_generalized_vectors ()
|
|
||||||
{
|
|
||||||
scm_i_register_vector_constructor
|
|
||||||
(scm_i_array_element_types[SCM_ARRAY_ELEMENT_TYPE_VU8],
|
|
||||||
scm_make_bytevector);
|
|
||||||
|
|
||||||
#define REGISTER(tag, TAG) \
|
|
||||||
scm_i_register_vector_constructor \
|
|
||||||
(scm_i_array_element_types[SCM_ARRAY_ELEMENT_TYPE_##TAG], \
|
|
||||||
scm_make_##tag##vector)
|
|
||||||
|
|
||||||
REGISTER (u8, U8);
|
|
||||||
REGISTER (s8, S8);
|
|
||||||
REGISTER (u16, U16);
|
|
||||||
REGISTER (s16, S16);
|
|
||||||
REGISTER (u32, U32);
|
|
||||||
REGISTER (s32, S32);
|
|
||||||
REGISTER (u64, U64);
|
|
||||||
REGISTER (s64, S64);
|
|
||||||
REGISTER (f32, F32);
|
|
||||||
REGISTER (f64, F64);
|
|
||||||
REGISTER (c32, C32);
|
|
||||||
REGISTER (c64, C64);
|
|
||||||
|
|
||||||
#include "generalized-vectors.x"
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
#ifndef SCM_GENERALIZED_VECTORS_H
|
|
||||||
#define SCM_GENERALIZED_VECTORS_H
|
|
||||||
|
|
||||||
/* Copyright 1995-1997,1999-2001,2004,2006,2008-2009,2013,2018
|
|
||||||
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
|
|
||||||
<https://www.gnu.org/licenses/>. */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "libguile/snarf.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Generalized vectors */
|
|
||||||
|
|
||||||
SCM_API SCM scm_make_generalized_vector (SCM type, SCM len, SCM fill);
|
|
||||||
|
|
||||||
SCM_INTERNAL void scm_init_generalized_vectors (void);
|
|
||||||
|
|
||||||
#endif /* SCM_GENERALIZED_VECTORS_H */
|
|
|
@ -72,7 +72,6 @@
|
||||||
#include "frames.h"
|
#include "frames.h"
|
||||||
#include "gc.h"
|
#include "gc.h"
|
||||||
#include "generalized-arrays.h"
|
#include "generalized-arrays.h"
|
||||||
#include "generalized-vectors.h"
|
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "goops.h"
|
#include "goops.h"
|
||||||
#include "gsubr.h"
|
#include "gsubr.h"
|
||||||
|
@ -442,7 +441,6 @@ scm_i_init_guile (void *base)
|
||||||
scm_init_stackchk ();
|
scm_init_stackchk ();
|
||||||
|
|
||||||
scm_init_generalized_arrays ();
|
scm_init_generalized_arrays ();
|
||||||
scm_init_generalized_vectors ();
|
|
||||||
scm_init_vectors (); /* Requires array-handle, */
|
scm_init_vectors (); /* Requires array-handle, */
|
||||||
scm_init_uniform ();
|
scm_init_uniform ();
|
||||||
scm_init_bitvectors (); /* Requires smob_prehistory, array-handle */
|
scm_init_bitvectors (); /* Requires smob_prehistory, array-handle */
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
#include "arrays.h"
|
#include "arrays.h"
|
||||||
#include "feature.h"
|
#include "feature.h"
|
||||||
#include "generalized-arrays.h"
|
#include "generalized-arrays.h"
|
||||||
#include "generalized-vectors.h"
|
|
||||||
#include "gsubr.h"
|
#include "gsubr.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "modules.h"
|
#include "modules.h"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue