mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 19:50:24 +02:00
add (ice-9 binary-ports)
* module/ice-9/binary-ports.scm: New module. * module/Makefile.am: Add to makefile. * module/rnrs/io/ports.scm: Re-export bindings from (ice-9 binary ports). This will allow the compiler to not pull (rnrs) into its included module set.
This commit is contained in:
parent
7e23d9d0f1
commit
dd0d987fbd
3 changed files with 54 additions and 5 deletions
|
@ -180,6 +180,7 @@ ICE_9_SOURCES = \
|
|||
ice-9/r5rs.scm \
|
||||
ice-9/deprecated.scm \
|
||||
ice-9/and-let-star.scm \
|
||||
ice-9/binary-ports.scm \
|
||||
ice-9/calling.scm \
|
||||
ice-9/common-list.scm \
|
||||
ice-9/control.scm \
|
||||
|
|
49
module/ice-9/binary-ports.scm
Normal file
49
module/ice-9/binary-ports.scm
Normal file
|
@ -0,0 +1,49 @@
|
|||
;;;; binary-ports.scm --- Binary IO on ports
|
||||
|
||||
;;;; Copyright (C) 2009, 2010, 2011 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 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
|
||||
;;;; 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
|
||||
|
||||
;;; Author: Ludovic Courtès <ludo@gnu.org>
|
||||
|
||||
;;; Commentary:
|
||||
;;;
|
||||
;;; The I/O port API of the R6RS is provided by this module. In many areas
|
||||
;;; it complements or refines Guile's own historical port API. For instance,
|
||||
;;; it allows for binary I/O with bytevectors.
|
||||
;;;
|
||||
;;; Code:
|
||||
|
||||
(define-module (ice-9 binary-ports)
|
||||
#:use-module (rnrs bytevectors)
|
||||
#:export (eof-object
|
||||
open-bytevector-input-port
|
||||
make-custom-binary-input-port
|
||||
get-u8
|
||||
lookahead-u8
|
||||
get-bytevector-n
|
||||
get-bytevector-n!
|
||||
get-bytevector-some
|
||||
get-bytevector-all
|
||||
put-u8
|
||||
put-bytevector
|
||||
open-bytevector-output-port
|
||||
make-custom-binary-output-port))
|
||||
|
||||
;; Note that this extension also defines %make-transcoded-port, which is
|
||||
;; not exported but is used by (rnrs io ports).
|
||||
|
||||
(load-extension (string-append "libguile-" (effective-version))
|
||||
"scm_init_r6rs_ports")
|
|
@ -98,7 +98,8 @@
|
|||
make-i/o-decoding-error
|
||||
&i/o-encoding-error i/o-encoding-error?
|
||||
make-i/o-encoding-error i/o-encoding-error-char)
|
||||
(import (only (rnrs base) assertion-violation)
|
||||
(import (ice-9 binary-ports)
|
||||
(only (rnrs base) assertion-violation)
|
||||
(rnrs enums)
|
||||
(rnrs records syntactic)
|
||||
(rnrs exceptions)
|
||||
|
@ -108,9 +109,6 @@
|
|||
(ice-9 rdelim)
|
||||
(except (guile) raise))
|
||||
|
||||
(load-extension (string-append "libguile-" (effective-version))
|
||||
"scm_init_r6rs_ports")
|
||||
|
||||
|
||||
|
||||
;;;
|
||||
|
@ -205,7 +203,8 @@
|
|||
"Return a new textual port based on @var{port}, using
|
||||
@var{transcoder} to encode and decode data written to or
|
||||
read from its underlying binary port @var{port}."
|
||||
(let ((result (%make-transcoded-port port)))
|
||||
;; Hackily get at %make-transcoded-port.
|
||||
(let ((result ((@@ (ice-9 binary-ports) %make-transcoded-port) port)))
|
||||
(set-port-encoding! result (transcoder-codec transcoder))
|
||||
(case (transcoder-error-handling-mode transcoder)
|
||||
((raise)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue