[cl-plus-ssl-cvs] CVS update: trivial-gray-streams/README trivial-gray-streams/mixin.lisp trivial-gray-streams/package.lisp
David Lichteblau
dlichteblau at common-lisp.net
Fri Nov 25 20:08:45 UTC 2005
Update of /project/cl-plus-ssl/cvsroot/trivial-gray-streams
In directory common-lisp.net:/tmp/cvs-serv29967
Modified Files:
README mixin.lisp package.lisp
Log Message:
read-/write-sequence handling komplett umgestrickt
Date: Fri Nov 25 21:08:44 2005
Author: dlichteblau
Index: trivial-gray-streams/README
diff -u trivial-gray-streams/README:1.1.1.1 trivial-gray-streams/README:1.2
--- trivial-gray-streams/README:1.1.1.1 Wed Nov 9 23:11:00 2005
+++ trivial-gray-streams/README Fri Nov 25 21:08:44 2005
@@ -14,7 +14,10 @@
implementation-specific package you would have to use otherwise to
get at gray stream symbols.
2. For STREAM-READ-SEQUENCE and STREAM-WRITE-SEQUENCE, notice that we
- use two &OPTIONAL arguments.
-3. In order for (2) to work on Lispworks, CLISP, and OpenMCL, make sure to
- subclass all your stream classes from TRIVIAL-GRAY-STREAM-MIXIN if you
- intend to define methods on those two generic functions.
+ use two required arguments and allow additional keyword arguments.
+ So the lambda list when defining a method on either function should look
+ like this:
+ (stream sequence start end &key)
+3. In order for (2) to work on all Lisps, make sure to subclass all your
+ stream classes from TRIVIAL-GRAY-STREAM-MIXIN if you intend to define
+ methods on those two generic functions.
Index: trivial-gray-streams/mixin.lisp
diff -u trivial-gray-streams/mixin.lisp:1.1.1.1 trivial-gray-streams/mixin.lisp:1.2
--- trivial-gray-streams/mixin.lisp:1.1.1.1 Wed Nov 9 23:11:00 2005
+++ trivial-gray-streams/mixin.lisp Fri Nov 25 21:08:44 2005
@@ -2,37 +2,55 @@
(defclass trivial-gray-stream-mixin () ())
-#+lispworks
+(defgeneric stream-read-sequence
+ (stream sequence start end &key &allow-other-keys))
+(defgeneric stream-write-sequence
+ (stream sequence start end &key &allow-other-keys))
+
+(defmethod stream-write-string
+ ((stream trivial-gray-stream-mixin) seq &optional start end)
+ (stream-write-sequence stream seq (or start 0) (or end (length seq))))
+
+#+allegro
+(progn
+ (defmethod excl:stream-read-sequence
+ ((s trivial-gray-stream-mixin) seq &optional start end)
+ (stream-read-sequence s seq (or start 0) (or end (length seq))))
+ (defmethod stream:stream-write-sequence
+ ((s trivial-gray-stream-mixin) seq &optional start end)
+ (stream-write-sequence s seq (or start 0) (or end (length seq)))))
+
+#+cmu
(progn
- (defgeneric stream-read-sequence (stream sequence &optional start end))
- (defgeneric stream-write-sequence (stream sequence &optional start end))
+ (defmethod ext:stream-read-sequence
+ ((s trivial-gray-stream-mixin) seq &optional start end)
+ (stream-read-sequence s seq (or start 0) (or end (length seq))))
+ (defmethod ext:stream-write-sequence
+ ((s trivial-gray-stream-mixin) seq &optional start end)
+ (stream-write-sequence s seq (or start 0) (or end (length seq)))))
+#+lispworks
+(progn
(defmethod stream:stream-read-sequence
((s trivial-gray-stream-mixin) seq start end)
- (stream-read-sequence seq start end))
+ (stream-read-sequence s seq start end))
(defmethod stream:stream-write-sequence
((s trivial-gray-stream-mixin) seq start end)
- (stream-read-sequence seq start end)))
+ (stream-write-sequence s seq start end)))
#+openmcl
(progn
- (defgeneric stream-read-sequence (stream sequence &optional start end))
- (defgeneric stream-write-sequence (stream sequence &optional start end))
-
(defmethod ccl:stream-read-vector
((s trivial-gray-stream-mixin) seq start end)
- (stream-read-sequence seq start end))
+ (stream-read-sequence s seq start end))
(defmethod ccl:stream-write-vector
((s trivial-gray-stream-mixin) seq start end)
- (stream-write-sequence seq start end)))
+ (stream-write-sequence s seq start end)))
#+clisp
(progn
- (defgeneric stream-read-sequence (stream sequence &optional start end))
- (defgeneric stream-write-sequence (stream sequence &optional start end))
-
(defmethod gray:stream-read-byte-sequence
((s trivial-gray-stream-mixin)
seq
@@ -41,7 +59,7 @@
(error "this stream does not support the NO-HANG argument"))
(when interactive
(error "this stream does not support the INTERACTIVE argument"))
- (stream-read-sequence seq start end))
+ (stream-read-sequence s seq start end))
(defmethod gray:stream-write-byte-sequence
((s trivial-gray-stream-mixin)
@@ -51,4 +69,19 @@
(error "this stream does not support the NO-HANG argument"))
(when interactive
(error "this stream does not support the INTERACTIVE argument"))
- (stream-write-sequence seq start end)))
+ (stream-write-sequence s seq start end)))
+
+#+sbcl
+(progn
+ (defmethod sb-gray:stream-read-sequence
+ ((s trivial-gray-stream-mixin) seq &optional start end)
+ (stream-read-sequence s seq (or start 0) (or end (length seq))))
+ (defmethod sb-gray:stream-write-sequence
+ ((s trivial-gray-stream-mixin) seq &optional start end)
+ (stream-write-sequence s seq (or start 0) (or end (length seq))))
+ ;; SBCL extension:
+ (defmethod sb-gray:stream-line-length ((stream trivial-gray-stream-mixin))
+ 80)
+ ;; SBCL should provide this default method, but doesn't?
+ (defmethod stream-terpri ((stream trivial-gray-stream-mixin))
+ (write-char #\newline stream)))
Index: trivial-gray-streams/package.lisp
diff -u trivial-gray-streams/package.lisp:1.1.1.1 trivial-gray-streams/package.lisp:1.2
--- trivial-gray-streams/package.lisp:1.1.1.1 Wed Nov 9 23:11:00 2005
+++ trivial-gray-streams/package.lisp Fri Nov 25 21:08:44 2005
@@ -30,12 +30,6 @@
#+openmcl :ccl
#+lispworks :stream
#-(or sbcl allegro cmu clisp openmcl lispworks) ...
-
- #-(or lispworks clisp openmcl)
- #:stream-read-sequence
- #-(or lispworks clisp openmcl)
- #:stream-write-sequence
-
, at common-symbols)
(:export #:trivial-gray-stream-mixin
#:stream-read-sequence
More information about the cl-plus-ssl-cvs
mailing list