guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, wip-array-refactor, updated. release_1


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, wip-array-refactor, updated. release_1-9-0-83-gd3b1e69
Date: Sun, 19 Jul 2009 12:45:30 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=d3b1e6951da7a71db8711f3c5f550d0bd3f298e6

The branch, wip-array-refactor has been updated
       via  d3b1e6951da7a71db8711f3c5f550d0bd3f298e6 (commit)
       via  26d2e5307e0d573ff3f99b824113db88c1e55a00 (commit)
      from  2e0b9842e4581d1f6fd818f03d46e58509ea7d01 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d3b1e6951da7a71db8711f3c5f550d0bd3f298e6
Author: Andy Wingo <address@hidden>
Date:   Sun Jul 19 14:45:14 2009 +0200

    bytevectors no longer have a "typed?" flag
    
    * libguile/bytevectors.h (SCM_F_BYTEVECTOR_TYPED)
      (SCM_BYTEVECTOR_TYPED_P): Remove this "is-typed?" idiom, as "raw"
      bytevectors now have their own type -- vu8.
    
    * libguile/bytevectors.c: Adapt to match. Actually is quite a bit nicer.

commit 26d2e5307e0d573ff3f99b824113db88c1e55a00
Author: Andy Wingo <address@hidden>
Date:   Sun Jul 19 14:39:39 2009 +0200

    add vu8 type, as distinct from u8
    
    * libguile/array-handle.c (scm_init_array_handle)
    * libguile/array-handle.h (scm_t_array_element_type)
    * libguile/uniform.c (scm_i_array_element_type_sizes): OK, break down
      and add another array type: vu8. It's for bytevectors and not
      u8vectors -- so that the two can be written out to bytecode and
      resuscitated, and they still retain their vu8-ness or u8-ness.
    
    * libguile/bytevectors.c: Adjust so that the default type is VU8, not
      U8. Change the vector constructor and array get_handle implementation
      appropriately. All test suites pass now.

-----------------------------------------------------------------------

Summary of changes:
 libguile/array-handle.c    |    1 +
 libguile/array-handle.h    |   27 ++++++++++++++-------------
 libguile/bytevectors.c     |   41 ++++++++++++++++-------------------------
 libguile/bytevectors.h     |    3 ---
 libguile/uniform.c         |    1 +
 test-suite/tests/unif.test |    6 ++++--
 6 files changed, 36 insertions(+), 43 deletions(-)

diff --git a/libguile/array-handle.c b/libguile/array-handle.c
index afa408e..cd5a466 100644
--- a/libguile/array-handle.c
+++ b/libguile/array-handle.c
@@ -138,6 +138,7 @@ scm_init_array_handle (void)
   scm_i_array_element_types[SCM_ARRAY_ELEMENT_TYPE_SCM] = SCM_BOOL_T;
   DEFINE_ARRAY_TYPE (a, CHAR);
   DEFINE_ARRAY_TYPE (b, BIT);
+  DEFINE_ARRAY_TYPE (vu8, VU8);
   DEFINE_ARRAY_TYPE (u8, U8);
   DEFINE_ARRAY_TYPE (s8, S8);
   DEFINE_ARRAY_TYPE (u16, U16);
diff --git a/libguile/array-handle.h b/libguile/array-handle.h
index aba1785..caf9cef 100644
--- a/libguile/array-handle.h
+++ b/libguile/array-handle.h
@@ -68,19 +68,20 @@ typedef enum {
   SCM_ARRAY_ELEMENT_TYPE_SCM = 0, /* SCM values */
   SCM_ARRAY_ELEMENT_TYPE_CHAR = 1, /* characters */
   SCM_ARRAY_ELEMENT_TYPE_BIT = 2, /* packed numeric values */
-  SCM_ARRAY_ELEMENT_TYPE_U8 = 3,
-  SCM_ARRAY_ELEMENT_TYPE_S8 = 4,
-  SCM_ARRAY_ELEMENT_TYPE_U16 = 5,
-  SCM_ARRAY_ELEMENT_TYPE_S16 = 6,
-  SCM_ARRAY_ELEMENT_TYPE_U32 = 7,
-  SCM_ARRAY_ELEMENT_TYPE_S32 = 8,
-  SCM_ARRAY_ELEMENT_TYPE_U64 = 9,
-  SCM_ARRAY_ELEMENT_TYPE_S64 = 10,
-  SCM_ARRAY_ELEMENT_TYPE_F32 = 11,
-  SCM_ARRAY_ELEMENT_TYPE_F64 = 12,
-  SCM_ARRAY_ELEMENT_TYPE_C32 = 13,
-  SCM_ARRAY_ELEMENT_TYPE_C64 = 14,
-  SCM_ARRAY_ELEMENT_TYPE_LAST = 14,
+  SCM_ARRAY_ELEMENT_TYPE_VU8 = 3,
+  SCM_ARRAY_ELEMENT_TYPE_U8 = 4,
+  SCM_ARRAY_ELEMENT_TYPE_S8 = 5,
+  SCM_ARRAY_ELEMENT_TYPE_U16 = 6,
+  SCM_ARRAY_ELEMENT_TYPE_S16 = 7,
+  SCM_ARRAY_ELEMENT_TYPE_U32 = 8,
+  SCM_ARRAY_ELEMENT_TYPE_S32 = 9,
+  SCM_ARRAY_ELEMENT_TYPE_U64 = 10,
+  SCM_ARRAY_ELEMENT_TYPE_S64 = 11,
+  SCM_ARRAY_ELEMENT_TYPE_F32 = 12,
+  SCM_ARRAY_ELEMENT_TYPE_F64 = 13,
+  SCM_ARRAY_ELEMENT_TYPE_C32 = 14,
+  SCM_ARRAY_ELEMENT_TYPE_C64 = 15,
+  SCM_ARRAY_ELEMENT_TYPE_LAST = 15,
 } scm_t_array_element_type;
 
 SCM_INTERNAL SCM scm_i_array_element_types[];
diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c
index c1ce099..ff3ae47 100644
--- a/libguile/bytevectors.c
+++ b/libguile/bytevectors.c
@@ -186,8 +186,6 @@ scm_t_bits scm_tc16_bytevector;
   SCM_SET_SMOB_DATA_2 ((_bv), (scm_t_bits) (_buf))
 #define SCM_BYTEVECTOR_SET_INLINE(bv)                                   \
   SCM_SET_SMOB_FLAGS (bv, SCM_SMOB_FLAGS (bv) | SCM_F_BYTEVECTOR_INLINE)
-#define SCM_BYTEVECTOR_SET_TYPED(bv)                                    \
-  SCM_SET_SMOB_FLAGS (bv, SCM_SMOB_FLAGS (bv) | SCM_F_BYTEVECTOR_TYPED)
 #define SCM_BYTEVECTOR_SET_ELEMENT_TYPE(bv, hint)                          \
   SCM_SET_SMOB_FLAGS (bv, (SCM_SMOB_FLAGS (bv) & 0xFF) | (hint << 8))
 #define SCM_BYTEVECTOR_TYPE_SIZE(var)                           \
@@ -264,16 +262,14 @@ make_bytevector (size_t len, scm_t_array_element_type 
element_type)
 SCM
 scm_c_make_bytevector (size_t len)
 {
-  return make_bytevector (len, SCM_ARRAY_ELEMENT_TYPE_U8);
+  return make_bytevector (len, SCM_ARRAY_ELEMENT_TYPE_VU8);
 }
 
 /* Return a new bytevector of size LEN elements.  */
 SCM
 scm_i_make_typed_bytevector (size_t len, scm_t_array_element_type element_type)
 {
-  SCM ret = make_bytevector (len, element_type);
-  SCM_BYTEVECTOR_SET_TYPED (ret);
-  return ret;
+  return make_bytevector (len, element_type);
 }
 
 /* Return a bytevector of size LEN made up of CONTENTS.  The area pointed to
@@ -281,16 +277,14 @@ scm_i_make_typed_bytevector (size_t len, 
scm_t_array_element_type element_type)
 SCM
 scm_c_take_bytevector (signed char *contents, size_t len)
 {
-  return make_bytevector_from_buffer (len, contents, 
SCM_ARRAY_ELEMENT_TYPE_U8);
+  return make_bytevector_from_buffer (len, contents, 
SCM_ARRAY_ELEMENT_TYPE_VU8);
 }
 
 SCM
 scm_c_take_typed_bytevector (signed char *contents, size_t len,
                              scm_t_array_element_type element_type)
 {
-  SCM ret = make_bytevector_from_buffer (len, contents, element_type);
-  SCM_BYTEVECTOR_SET_TYPED (ret);
-  return ret;
+  return make_bytevector_from_buffer (len, contents, element_type);
 }
 
 /* Shrink BV to C_NEW_LEN (which is assumed to be smaller than its current
@@ -401,11 +395,7 @@ print_bytevector (SCM bv, SCM port, scm_print_state 
*pstate SCM_UNUSED)
   scm_array_get_handle (bv, &h);
 
   scm_putc ('#', port);
-  if (SCM_BYTEVECTOR_TYPED_P (bv))
-    scm_write (scm_array_handle_element_type (&h), port);
-  else
-    scm_puts ("vu8", port);
-
+  scm_write (scm_array_handle_element_type (&h), port);
   scm_putc ('(', port);
   for (i = h.dims[0].lbnd, ubnd = h.dims[0].ubnd, inc = h.dims[0].inc;
        i <= ubnd; i += inc)
@@ -503,7 +493,7 @@ SCM_DEFINE (scm_make_bytevector, "make-bytevector", 1, 1, 0,
       c_fill = (signed char) value;
     }
 
-  bv = make_bytevector (c_len, SCM_ARRAY_ELEMENT_TYPE_U8);
+  bv = make_bytevector (c_len, SCM_ARRAY_ELEMENT_TYPE_VU8);
   if (fill != SCM_UNDEFINED)
     {
       unsigned i;
@@ -632,8 +622,6 @@ SCM_DEFINE (scm_bytevector_copy, "bytevector-copy", 1, 0, 0,
   copy = make_bytevector (c_len, SCM_BYTEVECTOR_ELEMENT_TYPE (bv));
   c_copy = SCM_BYTEVECTOR_CONTENTS (copy);
   memcpy (c_copy, c_bv, c_len);
-  if (SCM_BYTEVECTOR_TYPED_P (bv))
-    SCM_BYTEVECTOR_SET_TYPED (copy);
 
   return copy;
 }
@@ -719,7 +707,7 @@ SCM_DEFINE (scm_u8_list_to_bytevector, 
"u8-list->bytevector", 1, 0, 0,
 
   SCM_VALIDATE_LIST_COPYLEN (1, lst, c_len);
 
-  bv = make_bytevector (c_len, SCM_ARRAY_ELEMENT_TYPE_U8);
+  bv = make_bytevector (c_len, SCM_ARRAY_ELEMENT_TYPE_VU8);
   c_bv = (unsigned char *) SCM_BYTEVECTOR_CONTENTS (bv);
 
   for (i = 0; i < c_len; lst = SCM_CDR (lst), i++)
@@ -1156,7 +1144,7 @@ SCM_DEFINE (scm_bytevector_to_uint_list, 
"bytevector->uint-list",
   if (SCM_UNLIKELY ((c_size == 0) || (c_size >= (ULONG_MAX >> 3L))))   \
     scm_out_of_range (FUNC_NAME, size);                                        
\
                                                                        \
-  bv = make_bytevector (c_len * c_size, SCM_ARRAY_ELEMENT_TYPE_U8);     \
+  bv = make_bytevector (c_len * c_size, SCM_ARRAY_ELEMENT_TYPE_VU8);     \
   c_bv = (char *) SCM_BYTEVECTOR_CONTENTS (bv);                                
\
                                                                        \
   for (c_bv_ptr = c_bv;                                                        
\
@@ -2116,7 +2104,8 @@ const scm_t_bytevector_ref_fn 
bytevector_ref_fns[SCM_ARRAY_ELEMENT_TYPE_LAST + 1
   NULL, /* SCM */
   NULL, /* CHAR */
   NULL, /* BIT */
-  scm_bytevector_u8_ref,
+  scm_bytevector_u8_ref, /* VU8 */
+  scm_bytevector_u8_ref, /* U8 */
   scm_bytevector_s8_ref,
   scm_bytevector_u16_native_ref,
   scm_bytevector_s16_native_ref,
@@ -2168,7 +2157,8 @@ const scm_t_bytevector_set_fn 
bytevector_set_fns[SCM_ARRAY_ELEMENT_TYPE_LAST + 1
   NULL, /* SCM */
   NULL, /* CHAR */
   NULL, /* BIT */
-  scm_bytevector_u8_set_x,
+  scm_bytevector_u8_set_x, /* VU8 */
+  scm_bytevector_u8_set_x, /* U8 */
   scm_bytevector_s8_set_x,
   scm_bytevector_u16_native_set_x,
   scm_bytevector_s16_native_set_x,
@@ -2223,7 +2213,7 @@ scm_bootstrap_bytevectors (void)
 
   scm_null_bytevector =
     scm_gc_protect_object
-    (make_bytevector_from_buffer (0, NULL, SCM_ARRAY_ELEMENT_TYPE_U8));
+    (make_bytevector_from_buffer (0, NULL, SCM_ARRAY_ELEMENT_TYPE_VU8));
 
 #ifdef WORDS_BIGENDIAN
   scm_i_native_endianness = scm_permanent_object (scm_from_locale_symbol 
("big"));
@@ -2237,7 +2227,6 @@ scm_bootstrap_bytevectors (void)
 
   {
     scm_t_array_implementation impl;
-    SCM sym_vu8 = scm_permanent_object (scm_from_locale_symbol ("vu8"));
     
     impl.tag = scm_tc16_bytevector;
     impl.mask = 0xffff;
@@ -2245,7 +2234,9 @@ scm_bootstrap_bytevectors (void)
     impl.vset = bv_handle_set_x;
     impl.get_handle = bytevector_get_handle;
     scm_i_register_array_implementation (&impl);
-    scm_i_register_vector_constructor (sym_vu8, scm_make_bytevector);
+    scm_i_register_vector_constructor
+      (scm_i_array_element_types[SCM_ARRAY_ELEMENT_TYPE_VU8],
+       scm_make_bytevector);
   }
 }
 
diff --git a/libguile/bytevectors.h b/libguile/bytevectors.h
index fe16712..e29fe6d 100644
--- a/libguile/bytevectors.h
+++ b/libguile/bytevectors.h
@@ -119,11 +119,8 @@ SCM_API SCM scm_utf32_to_string (SCM, SCM);
 #define SCM_BYTEVECTOR_P(_bv)                   \
   SCM_SMOB_PREDICATE (scm_tc16_bytevector, _bv)
 #define SCM_F_BYTEVECTOR_INLINE 0x1
-#define SCM_F_BYTEVECTOR_TYPED 0x2
 #define SCM_BYTEVECTOR_INLINE_P(_bv)            \
   (SCM_SMOB_FLAGS (_bv) & SCM_F_BYTEVECTOR_INLINE)
-#define SCM_BYTEVECTOR_TYPED_P(_bv)            \
-  (SCM_SMOB_FLAGS (_bv) & SCM_F_BYTEVECTOR_TYPED)
 #define SCM_BYTEVECTOR_ELEMENT_TYPE(_bv)       \
   (SCM_SMOB_FLAGS (_bv) >> 8)
 
diff --git a/libguile/uniform.c b/libguile/uniform.c
index e5ba33e..28125da 100644
--- a/libguile/uniform.c
+++ b/libguile/uniform.c
@@ -35,6 +35,7 @@ const size_t 
scm_i_array_element_type_sizes[SCM_ARRAY_ELEMENT_TYPE_LAST + 1] = {
   0,
   0,
   1,
+  8,
   8, 8,
   16, 16,
   32, 32,
diff --git a/test-suite/tests/unif.test b/test-suite/tests/unif.test
index 61dbeb8..56572b3 100644
--- a/test-suite/tests/unif.test
+++ b/test-suite/tests/unif.test
@@ -1,6 +1,6 @@
 ;;;; unif.test --- tests guile's uniform arrays     -*- scheme -*-
 ;;;;
-;;;; Copyright 2004, 2006 Free Software Foundation, Inc.
+;;;; Copyright 2004, 2006, 2009 Free Software Foundation, Inc.
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
@@ -17,7 +17,9 @@
 ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
USA
 
 (define-module (test-suite test-unif)
-  #:use-module (test-suite lib))
+    #:use-module (test-suite lib)
+    #:use-module (srfi srfi-4)
+    #:use-module (srfi srfi-4 gnu))
 
 ;;;
 ;;; array?


hooks/post-receive
-- 
GNU Guile




reply via email to

[Prev in Thread] Current Thread [Next in Thread]