lloda pushed a commit to branch wip-vector-cleanup
in repository guile.

commit ed3c64459c9a8185329f79d890d9b09e7da215df
Author: Daniel Llorens <ll...@sarc.name>
AuthorDate: Thu Feb 6 16:15:47 2020 +0100

    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.
---
 libguile.h                     |   1 -
 libguile/Makefile.am           |   4 --
 libguile/arrays.c              |  80 +++++++++++++++++++++++++++++-
 libguile/arrays.h              |   2 +
 libguile/generalized-vectors.c | 110 -----------------------------------------
 libguile/generalized-vectors.h |  35 -------------
 libguile/init.c                |   2 -
 libguile/random.c              |   1 -
 8 files changed, 80 insertions(+), 155 deletions(-)

diff --git a/libguile.h b/libguile.h
index 2372635..12d8100 100644
--- a/libguile.h
+++ b/libguile.h
@@ -62,7 +62,6 @@ extern "C" {
 #include "libguile/frames.h"
 #include "libguile/gc.h"
 #include "libguile/generalized-arrays.h"
-#include "libguile/generalized-vectors.h"
 #include "libguile/goops.h"
 #include "libguile/gsubr.h"
 #include "libguile/guardians.h"
diff --git a/libguile/Makefile.am b/libguile/Makefile.am
index d4cfec7..8e933a2 100644
--- a/libguile/Makefile.am
+++ b/libguile/Makefile.am
@@ -164,7 +164,6 @@ libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES =             
                \
        gc.c                                    \
        gettext.c                               \
        generalized-arrays.c                    \
-       generalized-vectors.c                   \
        goops.c                                 \
        gsubr.c                                 \
        guardians.c                             \
@@ -279,7 +278,6 @@ DOT_X_FILES =                                       \
        gc.x                                    \
        gettext.x                               \
        generalized-arrays.x                    \
-       generalized-vectors.x                   \
        goops.x                                 \
        gsubr.x                                 \
        guardians.x                             \
@@ -387,7 +385,6 @@ DOT_DOC_FILES =                             \
        gc.doc                                  \
        gettext.doc                             \
        generalized-arrays.doc                  \
-       generalized-vectors.doc                 \
        goops.doc                               \
        gsubr.doc                               \
        guardians.doc                           \
@@ -635,7 +632,6 @@ modinclude_HEADERS =                                \
        gc-inline.h                             \
        gettext.h                               \
        generalized-arrays.h                    \
-       generalized-vectors.h                   \
        goops.h                                 \
        gsubr.h                                 \
        guardians.h                             \
diff --git a/libguile/arrays.c b/libguile/arrays.c
index d5f4f6a..0531f14 100644
--- a/libguile/arrays.c
+++ b/libguile/arrays.c
@@ -39,7 +39,6 @@
 #include "feature.h"
 #include "fports.h"
 #include "generalized-arrays.h"
-#include "generalized-vectors.h"
 #include "gsubr.h"
 #include "list.h"
 #include "modules.h"
@@ -56,7 +55,53 @@
 
 #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
 scm_c_array_rank (SCM array)
 {
@@ -954,11 +999,42 @@ scm_i_print_array (SCM array, SCM port, scm_print_state 
*pstate)
   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
 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");
 
 #include "arrays.x"
-
 }
diff --git a/libguile/arrays.h b/libguile/arrays.h
index 7221fdb..f96a019 100644
--- a/libguile/arrays.h
+++ b/libguile/arrays.h
@@ -31,6 +31,8 @@
    Also see ....
  */
 
+/* FIXME Superfluous residue from generalized-vector.h - deprecate */
+SCM_API SCM scm_make_generalized_vector (SCM type, SCM len, SCM fill);
 
 /** Arrays */
 
diff --git a/libguile/generalized-vectors.c b/libguile/generalized-vectors.c
deleted file mode 100644
index 33fe02d..0000000
--- a/libguile/generalized-vectors.c
+++ /dev/null
@@ -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"
-}
diff --git a/libguile/generalized-vectors.h b/libguile/generalized-vectors.h
deleted file mode 100644
index 4d347d3..0000000
--- a/libguile/generalized-vectors.h
+++ /dev/null
@@ -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 */
diff --git a/libguile/init.c b/libguile/init.c
index 2a9f963..d248ba7 100644
--- a/libguile/init.c
+++ b/libguile/init.c
@@ -72,7 +72,6 @@
 #include "frames.h"
 #include "gc.h"
 #include "generalized-arrays.h"
-#include "generalized-vectors.h"
 #include "gettext.h"
 #include "goops.h"
 #include "gsubr.h"
@@ -442,7 +441,6 @@ scm_i_init_guile (void *base)
   scm_init_stackchk ();
 
   scm_init_generalized_arrays ();
-  scm_init_generalized_vectors ();
   scm_init_vectors ();  /* Requires array-handle, */
   scm_init_uniform ();
   scm_init_bitvectors ();  /* Requires smob_prehistory, array-handle */
diff --git a/libguile/random.c b/libguile/random.c
index 6fd567c..ed234f8 100644
--- a/libguile/random.c
+++ b/libguile/random.c
@@ -35,7 +35,6 @@
 #include "arrays.h"
 #include "feature.h"
 #include "generalized-arrays.h"
-#include "generalized-vectors.h"
 #include "gsubr.h"
 #include "list.h"
 #include "modules.h"

Reply via email to