Added make-custom-textual-input-port and make-custom-textual-output-port
This commit is contained in:
parent
85a54dbbbf
commit
b6299fbec2
|
@ -25,6 +25,8 @@
|
||||||
open-string-input-port
|
open-string-input-port
|
||||||
make-custom-binary-input-port
|
make-custom-binary-input-port
|
||||||
make-custom-binary-output-port
|
make-custom-binary-output-port
|
||||||
|
make-custom-textual-input-port
|
||||||
|
make-custom-textual-output-port
|
||||||
transcoded-port port-transcoder
|
transcoded-port port-transcoder
|
||||||
close-port close-input-port close-output-port
|
close-port close-input-port close-output-port
|
||||||
port-eof?
|
port-eof?
|
||||||
|
@ -69,6 +71,8 @@
|
||||||
open-string-input-port
|
open-string-input-port
|
||||||
make-custom-binary-input-port
|
make-custom-binary-input-port
|
||||||
make-custom-binary-output-port
|
make-custom-binary-output-port
|
||||||
|
make-custom-textual-input-port
|
||||||
|
make-custom-textual-output-port
|
||||||
transcoded-port port-transcoder
|
transcoded-port port-transcoder
|
||||||
close-port close-input-port close-output-port
|
close-port close-input-port close-output-port
|
||||||
port-eof?
|
port-eof?
|
||||||
|
@ -188,6 +192,12 @@
|
||||||
($make-port 0 0 bv 0 #f #f attrs id read! write! get-position
|
($make-port 0 0 bv 0 #f #f attrs id read! write! get-position
|
||||||
set-position! close)))
|
set-position! close)))
|
||||||
|
|
||||||
|
(define ($make-custom-textual-port attrs id
|
||||||
|
read! write! get-position set-position! close buffer-size)
|
||||||
|
(let ([bv (make-string buffer-size)])
|
||||||
|
($make-port 0 0 bv 0 #f #f attrs id read! write! get-position
|
||||||
|
set-position! close)))
|
||||||
|
|
||||||
(define (make-custom-binary-input-port id
|
(define (make-custom-binary-input-port id
|
||||||
read! get-position set-position! close)
|
read! get-position set-position! close)
|
||||||
;;; FIXME: get-position and set-position! are ignored for now
|
;;; FIXME: get-position and set-position! are ignored for now
|
||||||
|
@ -218,6 +228,38 @@
|
||||||
id #f write! get-position
|
id #f write! get-position
|
||||||
set-position! close 256))
|
set-position! close 256))
|
||||||
|
|
||||||
|
(define (make-custom-textual-input-port id
|
||||||
|
read! get-position set-position! close)
|
||||||
|
;;; FIXME: get-position and set-position! are ignored for now
|
||||||
|
(define who 'make-custom-textual-input-port)
|
||||||
|
(unless (string? id)
|
||||||
|
(error who "id is not a string" id))
|
||||||
|
(unless (procedure? read!)
|
||||||
|
(error who "read! is not a procedure" read!))
|
||||||
|
(unless (or (procedure? close) (not close))
|
||||||
|
(error who "close should be either a procedure or #f" close))
|
||||||
|
($make-custom-textual-port
|
||||||
|
(fxior fast-get-tag fast-get-char-tag)
|
||||||
|
id read! #f get-position
|
||||||
|
set-position! close 256))
|
||||||
|
|
||||||
|
(define (make-custom-textual-output-port id
|
||||||
|
write! get-position set-position! close)
|
||||||
|
;;; FIXME: get-position and set-position! are ignored for now
|
||||||
|
(define who 'make-custom-textual-output-port)
|
||||||
|
(unless (string? id)
|
||||||
|
(error who "id is not a string" id))
|
||||||
|
(unless (procedure? write!)
|
||||||
|
(error who "read! is not a procedure" write!))
|
||||||
|
(unless (or (procedure? close) (not close))
|
||||||
|
(error who "close should be either a procedure or #f" close))
|
||||||
|
($make-custom-textual-port
|
||||||
|
(fxior fast-put-tag fast-put-char-tag)
|
||||||
|
id #f write! get-position
|
||||||
|
set-position! close 256))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(define (input-transcoder-attrs x)
|
(define (input-transcoder-attrs x)
|
||||||
(cond
|
(cond
|
||||||
[(not x) ;;; binary input port
|
[(not x) ;;; binary input port
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
1213
|
1214
|
||||||
|
|
|
@ -1097,11 +1097,11 @@
|
||||||
[lookahead-u8 i r ip]
|
[lookahead-u8 i r ip]
|
||||||
[make-bytevector i r bv]
|
[make-bytevector i r bv]
|
||||||
[make-custom-binary-input-port i r ip]
|
[make-custom-binary-input-port i r ip]
|
||||||
[make-custom-binary-input/output-port r ip]
|
|
||||||
[make-custom-binary-output-port i r ip]
|
[make-custom-binary-output-port i r ip]
|
||||||
[make-custom-textual-input-port r ip]
|
[make-custom-textual-input-port i r ip]
|
||||||
|
[make-custom-textual-output-port i r ip]
|
||||||
|
[make-custom-binary-input/output-port r ip]
|
||||||
[make-custom-textual-input/output-port r ip]
|
[make-custom-textual-input/output-port r ip]
|
||||||
[make-custom-textual-output-port r ip]
|
|
||||||
[make-i/o-decoding-error i r ip]
|
[make-i/o-decoding-error i r ip]
|
||||||
[make-i/o-encoding-error i r ip]
|
[make-i/o-encoding-error i r ip]
|
||||||
[make-i/o-error i r ip is fi]
|
[make-i/o-error i r ip is fi]
|
||||||
|
|
|
@ -477,12 +477,12 @@
|
||||||
#f)])
|
#f)])
|
||||||
(let f ([i 0])
|
(let f ([i 0])
|
||||||
(unless (fx= i 10000)
|
(unless (fx= i 10000)
|
||||||
(put-u8 p (mod i 256))
|
(put-u8 p (mod i 37))
|
||||||
(f (+ i 1))))
|
(f (+ i 1))))
|
||||||
(flush-output-port p)
|
(flush-output-port p)
|
||||||
(let f ([i 0] [ls (reverse ls)])
|
(let f ([i 0] [ls (reverse ls)])
|
||||||
(unless (null? ls)
|
(unless (null? ls)
|
||||||
(assert (fx= (mod i 256) (car ls)))
|
(assert (fx= (mod i 37) (car ls)))
|
||||||
(f (fx+ i 1) (cdr ls))))))
|
(f (fx+ i 1) (cdr ls))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -606,11 +606,11 @@
|
||||||
[lookahead-u8 C ip]
|
[lookahead-u8 C ip]
|
||||||
[make-bytevector C bv]
|
[make-bytevector C bv]
|
||||||
[make-custom-binary-input-port C ip]
|
[make-custom-binary-input-port C ip]
|
||||||
[make-custom-binary-input/output-port S ip]
|
|
||||||
[make-custom-binary-output-port C ip]
|
[make-custom-binary-output-port C ip]
|
||||||
[make-custom-textual-input-port S ip]
|
[make-custom-textual-input-port C ip]
|
||||||
|
[make-custom-textual-output-port C ip]
|
||||||
|
[make-custom-binary-input/output-port S ip]
|
||||||
[make-custom-textual-input/output-port S ip]
|
[make-custom-textual-input/output-port S ip]
|
||||||
[make-custom-textual-output-port S ip]
|
|
||||||
[make-i/o-decoding-error C ip]
|
[make-i/o-decoding-error C ip]
|
||||||
[make-i/o-encoding-error C ip]
|
[make-i/o-encoding-error C ip]
|
||||||
[make-i/o-error C ip is fi]
|
[make-i/o-error C ip is fi]
|
||||||
|
|
Loading…
Reference in New Issue