mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-24 20:30:28 +02:00
Moved content into core; only the skeletons remains.
This commit is contained in:
parent
a4022e691e
commit
0d0f372f5b
3 changed files with 18 additions and 1971 deletions
1757
srfi/srfi-4.c
1757
srfi/srfi-4.c
File diff suppressed because it is too large
Load diff
110
srfi/srfi-4.h
110
srfi/srfi-4.h
|
@ -1,5 +1,5 @@
|
|||
#ifndef SCM_SRFI_4_H
|
||||
#define SCM_SRFI_4_H
|
||||
#ifndef SCM_SRFI_SRFI_4_H
|
||||
#define SCM_SRFI_SRFI_4_H
|
||||
/* srfi-4.c --- Homogeneous numeric vector datatypes.
|
||||
*
|
||||
* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
|
@ -20,108 +20,8 @@
|
|||
*/
|
||||
|
||||
|
||||
/* SCM_SRFI4_API is a macro prepended to all function and data definitions
|
||||
which should be exported or imported in the resulting dynamic link
|
||||
library in the Win32 port. */
|
||||
/* All SRFI-4 procedures are in in the core now. */
|
||||
|
||||
#if defined (SCM_SRFI4_IMPORT)
|
||||
# define SCM_SRFI4_API __declspec (dllimport) extern
|
||||
#elif defined (SCM_SRFI4_EXPORT) || defined (DLL_EXPORT)
|
||||
# define SCM_SRFI4_API __declspec (dllexport) extern
|
||||
#else
|
||||
# define SCM_SRFI4_API extern
|
||||
#endif
|
||||
#include <libguile.h>
|
||||
|
||||
SCM_SRFI4_API SCM scm_u8vector_p (SCM obj);
|
||||
SCM_SRFI4_API SCM scm_make_u8vector (SCM n, SCM fill);
|
||||
SCM_SRFI4_API SCM scm_u8vector (SCM l);
|
||||
SCM_SRFI4_API SCM scm_u8vector_length (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_u8vector_ref (SCM uvec, SCM index);
|
||||
SCM_SRFI4_API SCM scm_u8vector_set_x (SCM uvec, SCM index, SCM value);
|
||||
SCM_SRFI4_API SCM scm_u8vector_to_list (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_list_to_u8vector (SCM l);
|
||||
|
||||
SCM_SRFI4_API SCM scm_s8vector_p (SCM obj);
|
||||
SCM_SRFI4_API SCM scm_make_s8vector (SCM n, SCM fill);
|
||||
SCM_SRFI4_API SCM scm_s8vector (SCM l);
|
||||
SCM_SRFI4_API SCM scm_s8vector_length (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_s8vector_ref (SCM uvec, SCM index);
|
||||
SCM_SRFI4_API SCM scm_s8vector_set_x (SCM uvec, SCM index, SCM value);
|
||||
SCM_SRFI4_API SCM scm_s8vector_to_list (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_list_to_s8vector (SCM l);
|
||||
|
||||
SCM_SRFI4_API SCM scm_u16vector_p (SCM obj);
|
||||
SCM_SRFI4_API SCM scm_make_u16vector (SCM n, SCM fill);
|
||||
SCM_SRFI4_API SCM scm_u16vector (SCM l);
|
||||
SCM_SRFI4_API SCM scm_u16vector_length (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_u16vector_ref (SCM uvec, SCM index);
|
||||
SCM_SRFI4_API SCM scm_u16vector_set_x (SCM uvec, SCM index, SCM value);
|
||||
SCM_SRFI4_API SCM scm_u16vector_to_list (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_list_to_u16vector (SCM l);
|
||||
|
||||
SCM_SRFI4_API SCM scm_s16vector_p (SCM obj);
|
||||
SCM_SRFI4_API SCM scm_make_s16vector (SCM n, SCM fill);
|
||||
SCM_SRFI4_API SCM scm_s16vector (SCM l);
|
||||
SCM_SRFI4_API SCM scm_s16vector_length (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_s16vector_ref (SCM uvec, SCM index);
|
||||
SCM_SRFI4_API SCM scm_s16vector_set_x (SCM uvec, SCM index, SCM value);
|
||||
SCM_SRFI4_API SCM scm_s16vector_to_list (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_list_to_s16vector (SCM l);
|
||||
|
||||
SCM_SRFI4_API SCM scm_u32vector_p (SCM obj);
|
||||
SCM_SRFI4_API SCM scm_make_u32vector (SCM n, SCM fill);
|
||||
SCM_SRFI4_API SCM scm_u32vector (SCM l);
|
||||
SCM_SRFI4_API SCM scm_u32vector_length (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_u32vector_ref (SCM uvec, SCM index);
|
||||
SCM_SRFI4_API SCM scm_u32vector_set_x (SCM uvec, SCM index, SCM value);
|
||||
SCM_SRFI4_API SCM scm_u32vector_to_list (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_list_to_u32vector (SCM l);
|
||||
|
||||
SCM_SRFI4_API SCM scm_s32vector_p (SCM obj);
|
||||
SCM_SRFI4_API SCM scm_make_s32vector (SCM n, SCM fill);
|
||||
SCM_SRFI4_API SCM scm_s32vector (SCM l);
|
||||
SCM_SRFI4_API SCM scm_s32vector_length (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_s32vector_ref (SCM uvec, SCM index);
|
||||
SCM_SRFI4_API SCM scm_s32vector_set_x (SCM uvec, SCM index, SCM value);
|
||||
SCM_SRFI4_API SCM scm_s32vector_to_list (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_list_to_s32vector (SCM l);
|
||||
|
||||
SCM_SRFI4_API SCM scm_u64vector_p (SCM obj);
|
||||
SCM_SRFI4_API SCM scm_make_u64vector (SCM n, SCM fill);
|
||||
SCM_SRFI4_API SCM scm_u64vector (SCM l);
|
||||
SCM_SRFI4_API SCM scm_u64vector_length (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_u64vector_ref (SCM uvec, SCM index);
|
||||
SCM_SRFI4_API SCM scm_u64vector_set_x (SCM uvec, SCM index, SCM value);
|
||||
SCM_SRFI4_API SCM scm_u64vector_to_list (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_list_to_u64vector (SCM l);
|
||||
|
||||
SCM_SRFI4_API SCM scm_s64vector_p (SCM obj);
|
||||
SCM_SRFI4_API SCM scm_make_s64vector (SCM n, SCM fill);
|
||||
SCM_SRFI4_API SCM scm_s64vector (SCM l);
|
||||
SCM_SRFI4_API SCM scm_s64vector_length (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_s64vector_ref (SCM uvec, SCM index);
|
||||
SCM_SRFI4_API SCM scm_s64vector_set_x (SCM uvec, SCM index, SCM value);
|
||||
SCM_SRFI4_API SCM scm_s64vector_to_list (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_list_to_s64vector (SCM l);
|
||||
|
||||
SCM_SRFI4_API SCM scm_f32vector_p (SCM obj);
|
||||
SCM_SRFI4_API SCM scm_make_f32vector (SCM n, SCM fill);
|
||||
SCM_SRFI4_API SCM scm_f32vector (SCM l);
|
||||
SCM_SRFI4_API SCM scm_f32vector_length (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_f32vector_ref (SCM uvec, SCM index);
|
||||
SCM_SRFI4_API SCM scm_f32vector_set_x (SCM uvec, SCM index, SCM value);
|
||||
SCM_SRFI4_API SCM scm_f32vector_to_list (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_list_to_f32vector (SCM l);
|
||||
|
||||
SCM_SRFI4_API SCM scm_f64vector_p (SCM obj);
|
||||
SCM_SRFI4_API SCM scm_make_f64vector (SCM n, SCM fill);
|
||||
SCM_SRFI4_API SCM scm_f64vector (SCM l);
|
||||
SCM_SRFI4_API SCM scm_f64vector_length (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_f64vector_ref (SCM uvec, SCM index);
|
||||
SCM_SRFI4_API SCM scm_f64vector_set_x (SCM uvec, SCM index, SCM value);
|
||||
SCM_SRFI4_API SCM scm_f64vector_to_list (SCM uvec);
|
||||
SCM_SRFI4_API SCM scm_list_to_f64vector (SCM l);
|
||||
|
||||
SCM_SRFI4_API void scm_init_srfi_4 (void);
|
||||
|
||||
#endif /* SCM_SRFI_4_H */
|
||||
#endif /* SCM_SRFI_SRFI_4_H */
|
||||
|
|
122
srfi/srfi-4.scm
122
srfi/srfi-4.scm
|
@ -1,6 +1,6 @@
|
|||
;;; srfi-4.scm --- Homogeneous Numeric Vector Datatypes
|
||||
|
||||
;; Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2001, 2002, 2004 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
|
||||
|
@ -20,13 +20,15 @@
|
|||
|
||||
;;; Commentary:
|
||||
|
||||
;; This module implements homogeneous numeric vectors as defined in SRFI-4.
|
||||
;; This module is fully documented in the Guile Reference Manual.
|
||||
;; This module exports the homogeneous numeric vector procedures as
|
||||
;; defined in SRFI-4. They are fully documented in the Guile
|
||||
;; Reference Manual.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define-module (srfi srfi-4)
|
||||
:export (
|
||||
(define-module (srfi srfi-4))
|
||||
|
||||
(re-export
|
||||
;;; Unsigned 8-bit vectors.
|
||||
u8vector? make-u8vector u8vector u8vector-length u8vector-ref
|
||||
u8vector-set! u8vector->list list->u8vector
|
||||
|
@ -66,112 +68,4 @@
|
|||
;;; 64-bit floating point vectors.
|
||||
f64vector? make-f64vector f64vector f64vector-length f64vector-ref
|
||||
f64vector-set! f64vector->list list->f64vector
|
||||
))
|
||||
|
||||
|
||||
;; Make 'srfi-4 available as a feature identifiere to `cond-expand'.
|
||||
;;
|
||||
(cond-expand-provide (current-module) '(srfi-4))
|
||||
|
||||
|
||||
;; Load the compiled primitives from the shared library.
|
||||
;;
|
||||
(load-extension "libguile-srfi-srfi-4-v-2" "scm_init_srfi_4")
|
||||
|
||||
|
||||
;; Reader extension for #f32() and #f64() vectors.
|
||||
;;
|
||||
(define (hash-f char port)
|
||||
(if (or (char=? (peek-char port) #\3)
|
||||
(char=? (peek-char port) #\6))
|
||||
(let* ((obj (read port)))
|
||||
(if (number? obj)
|
||||
(cond ((= obj 32)
|
||||
(let ((l (read port)))
|
||||
(if (list? l)
|
||||
(list->f32vector l)
|
||||
(error "syntax error in #f32() vector literal"))))
|
||||
((= obj 64)
|
||||
(let ((l (read port)))
|
||||
(if (list? l)
|
||||
(list->f64vector l)
|
||||
(error "syntax error in #f64() vector literal"))))
|
||||
(else
|
||||
(error "syntax error in #f...() vector literal")))
|
||||
(error "syntax error in #f...() vector literal")))
|
||||
#f))
|
||||
|
||||
|
||||
;; Reader extension for #u8(), #u16(), #u32() and #u64() vectors.
|
||||
;;
|
||||
(define (hash-u char port)
|
||||
(if (or (char=? (peek-char port) #\8)
|
||||
(char=? (peek-char port) #\1)
|
||||
(char=? (peek-char port) #\3)
|
||||
(char=? (peek-char port) #\6))
|
||||
(let ((obj (read port)))
|
||||
(cond ((= obj 8)
|
||||
(let ((l (read port)))
|
||||
(if (list? l)
|
||||
(list->u8vector l)
|
||||
(error "syntax error in #u8() vector literal"))))
|
||||
((= obj 16)
|
||||
(let ((l (read port)))
|
||||
(if (list? l)
|
||||
(list->u16vector l)
|
||||
(error "syntax error in #u16() vector literal"))))
|
||||
((= obj 32)
|
||||
(let ((l (read port)))
|
||||
(if (list? l)
|
||||
(list->u32vector l)
|
||||
(error "syntax error in #u32() vector literal"))))
|
||||
((= obj 64)
|
||||
(let ((l (read port)))
|
||||
(if (list? l)
|
||||
(list->u64vector l)
|
||||
(error "syntax error in #u64() vector literal"))))
|
||||
(else
|
||||
(error "syntax error in #u...() vector literal"))))
|
||||
(error "syntax error in #u...() vector literal")))
|
||||
|
||||
|
||||
;; Reader extension for #s8(), #s16(), #s32() and #s64() vectors.
|
||||
;;
|
||||
(define (hash-s char port)
|
||||
(if (or (char=? (peek-char port) #\8)
|
||||
(char=? (peek-char port) #\1)
|
||||
(char=? (peek-char port) #\3)
|
||||
(char=? (peek-char port) #\6))
|
||||
(let ((obj (read port)))
|
||||
(cond ((= obj 8)
|
||||
(let ((l (read port)))
|
||||
(if (list? l)
|
||||
(list->s8vector l)
|
||||
(error "syntax error in #s8() vector literal"))))
|
||||
((= obj 16)
|
||||
(let ((l (read port)))
|
||||
(if (list? l)
|
||||
(list->s16vector l)
|
||||
(error "syntax error in #s16() vector literal"))))
|
||||
((= obj 32)
|
||||
(let ((l (read port)))
|
||||
(if (list? l)
|
||||
(list->s32vector l)
|
||||
(error "syntax error in #s32() vector literal"))))
|
||||
((= obj 64)
|
||||
(let ((l (read port)))
|
||||
(if (list? l)
|
||||
(list->s64vector l)
|
||||
(error "syntax error in #s64() vector literal"))))
|
||||
(else
|
||||
(error "syntax error in #s...() vector literal"))))
|
||||
(error "syntax error in #s...() vector literal")))
|
||||
|
||||
|
||||
;; Install the hash extensions.
|
||||
;;
|
||||
(read-hash-extend #\f hash-f)
|
||||
(read-hash-extend #\u hash-u)
|
||||
(read-hash-extend #\s hash-s)
|
||||
|
||||
;;; srfi-4.scm ends here
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue