Merge branch 'master' into boehm-demers-weiser-gc
[bpt/guile.git] / libguile / srfi-4.c
index 3e43a49..b45d402 100644 (file)
@@ -1,20 +1,21 @@
 /* srfi-4.c --- Uniform numeric vector datatypes.
  *
- *     Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc.
+ *     Copyright (C) 2001, 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
+ * 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.
  *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
  */
 
 #ifdef HAVE_CONFIG_H
@@ -28,6 +29,7 @@
 #include "libguile/_scm.h"
 #include "libguile/__scm.h"
 #include "libguile/srfi-4.h"
+#include "libguile/bytevectors.h"
 #include "libguile/error.h"
 #include "libguile/read.h"
 #include "libguile/ports.h"
@@ -580,6 +582,8 @@ scm_i_generalized_vector_type (SCM v)
     return scm_sym_b;
   else if (scm_is_uniform_vector (v))
     return scm_from_locale_symbol (uvec_tags[SCM_UVEC_TYPE(v)]);
+  else if (scm_is_bytevector (v))
+    return scm_from_locale_symbol ("vu8");
   else
     return SCM_BOOL_F;
 }
@@ -721,6 +725,8 @@ scm_array_handle_uniform_element_size (scm_t_array_handle *h)
     vec = SCM_I_ARRAY_V (vec);
   if (scm_is_uniform_vector (vec))
     return uvec_sizes[SCM_UVEC_TYPE(vec)];
+  if (scm_is_bytevector (vec))
+    return 1U;
   scm_wrong_type_arg_msg (NULL, 0, h->array, "uniform array");
 }
 
@@ -761,6 +767,8 @@ scm_array_handle_uniform_writable_elements (scm_t_array_handle *h)
       char *elts = SCM_UVEC_BASE (vec);
       return (void *) (elts + size*h->base);
     }
+  if (scm_is_bytevector (vec))
+    return SCM_BYTEVECTOR_CONTENTS (vec);
   scm_wrong_type_arg_msg (NULL, 0, h->array, "uniform array");
 }