1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-06 04:00:26 +02:00

Pull generalized-vectors from under typed vectors

This commit is contained in:
Daniel Llorens 2020-02-06 15:40:51 +01:00
parent f188424557
commit 0910fcde46
3 changed files with 24 additions and 24 deletions

View file

@ -29,9 +29,10 @@
#include "generalized-vectors.h" #include "generalized-vectors.h"
#include "array-handle.h" #include "array-handle.h"
#include "vectors.h"
#include "bitvectors.h" #include "bitvectors.h"
#include "strings.h" #include "strings.h"
#include "vectors.h"
#include "srfi-4.h"
struct scm_t_vector_ctor struct scm_t_vector_ctor
{ {
@ -70,6 +71,10 @@ SCM_DEFINE (scm_make_generalized_vector, "make-generalized-vector", 2, 1, 0,
} }
#undef FUNC_NAME #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_SCM, scm_make_vector)
SCM_VECTOR_IMPLEMENTATION (SCM_ARRAY_ELEMENT_TYPE_BIT, scm_make_bitvector) SCM_VECTOR_IMPLEMENTATION (SCM_ARRAY_ELEMENT_TYPE_BIT, scm_make_bitvector)
@ -78,5 +83,23 @@ SCM_VECTOR_IMPLEMENTATION (SCM_ARRAY_ELEMENT_TYPE_CHAR, scm_make_string)
void void
scm_init_generalized_vectors () scm_init_generalized_vectors ()
{ {
#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" #include "generalized-vectors.x"
} }

View file

@ -31,10 +31,6 @@
SCM_API SCM scm_make_generalized_vector (SCM type, SCM len, SCM fill); SCM_API SCM scm_make_generalized_vector (SCM type, SCM len, SCM fill);
SCM_INTERNAL void scm_i_register_vector_constructor (SCM type, SCM (*ctor)(SCM, SCM)); SCM_INTERNAL void scm_i_register_vector_constructor (SCM type, SCM (*ctor)(SCM, SCM));
#define SCM_VECTOR_IMPLEMENTATION(type, ctor) \
SCM_SNARF_INIT (scm_i_register_vector_constructor \
(scm_i_array_element_types[type], ctor))
SCM_INTERNAL void scm_init_generalized_vectors (void); SCM_INTERNAL void scm_init_generalized_vectors (void);
#endif /* SCM_GENERALIZED_VECTORS_H */ #endif /* SCM_GENERALIZED_VECTORS_H */

View file

@ -31,7 +31,6 @@
#include "error.h" #include "error.h"
#include "eval.h" #include "eval.h"
#include "extensions.h" #include "extensions.h"
#include "generalized-vectors.h"
#include "gsubr.h" #include "gsubr.h"
#include "modules.h" #include "modules.h"
#include "numbers.h" #include "numbers.h"
@ -273,24 +272,6 @@ SCM_DEFINE (scm_make_srfi_4_vector, "make-srfi-4-vector", 2, 1, 0,
void void
scm_init_srfi_4 (void) scm_init_srfi_4 (void)
{ {
#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 "srfi-4.x" #include "srfi-4.x"
} }