X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fpcl%2Fgray-streams.lisp;h=a99099fcb7e30098fa66e9a810d23f167d08188a;hb=c8cc0137e55e6179f6af344f42e54f514660f68b;hp=3ad52a1d9ad0b97aea55b614bf05c0de6491aced;hpb=9afb0bc650cd36dc093be6958a224e86d59d3893;p=sbcl.git diff --git a/src/pcl/gray-streams.lisp b/src/pcl/gray-streams.lisp index 3ad52a1..a99099f 100644 --- a/src/pcl/gray-streams.lisp +++ b/src/pcl/gray-streams.lisp @@ -15,13 +15,19 @@ ;;; user is responsible for some of the protocol implementation, it's ;;; not necessarily a bug in SBCL itself if we fall through to one of ;;; these default methods. +;;; +;;; FIXME: there's a lot of similarity in these Gray stream +;;; implementation generic functions. All of them could (maybe +;;; should?) have two default methods: one on STREAM calling +;;; BUG-OR-ERROR, and one on T signalling a TYPE-ERROR. (defmacro bug-or-error (stream fun) - `(error "~@).~@:>" - ,stream ,fun)) - + `(error + "~@).~@:>" + ,stream ,fun)) (fmakunbound 'stream-element-type) @@ -218,6 +224,10 @@ (defmethod stream-clear-input ((stream fundamental-character-input-stream)) nil) +(defmethod stream-clear-input ((stream stream)) + (bug-or-error stream 'stream-clear-input)) +(defmethod stream-clear-input ((non-stream t)) + (error 'type-error :datum non-stream :expected-type 'stream)) (defgeneric stream-read-sequence (stream seq &optional start end) (:documentation @@ -379,6 +389,10 @@ (defmethod stream-finish-output ((stream fundamental-output-stream)) nil) +(defmethod stream-finish-output ((stream stream)) + (bug-or-error stream 'stream-finish-output)) +(defmethod stream-finish-output ((non-stream t)) + (error 'type-error :datum non-stream :expected-type 'stream)) (defgeneric stream-force-output (stream) #+sb-doc @@ -388,6 +402,10 @@ (defmethod stream-force-output ((stream fundamental-output-stream)) nil) +(defmethod stream-force-output ((stream stream)) + (bug-or-error stream 'stream-force-output)) +(defmethod stream-force-output ((non-stream t)) + (error 'type-error :datum non-stream :expected-type 'stream)) (defgeneric stream-clear-output (stream) #+sb-doc @@ -397,6 +415,10 @@ (defmethod stream-clear-output ((stream fundamental-output-stream)) nil) +(defmethod stream-clear-output ((stream stream)) + (bug-or-error stream 'stream-clear-output)) +(defmethod stream-clear-output ((non-stream t)) + (error 'type-error :datum non-stream :expected-type 'stream)) (defgeneric stream-advance-to-column (stream column) #+sb-doc @@ -470,12 +492,22 @@ "Used by READ-BYTE; returns either an integer, or the symbol :EOF if the stream is at end-of-file.")) +(defmethod stream-read-byte ((stream stream)) + (bug-or-error stream 'stream-read-byte)) +(defmethod stream-read-byte ((non-stream t)) + (error 'type-error :datum non-stream :expected-type 'stream)) + (defgeneric stream-write-byte (stream integer) #+sb-doc (:documentation "Implements WRITE-BYTE; writes the integer to the stream and returns the integer as the result.")) +(defmethod stream-write-byte ((stream stream) integer) + (bug-or-error stream 'stream-write-byte)) +(defmethod stream-write-byte ((non-stream t) integer) + (error 'type-error :datum non-stream :expected-type 'stream)) + ;; Provide a reasonable default for binary Gray streams. We might be ;; able to do better by specializing on the sequence type, but at ;; least the behaviour is reasonable. --tony 2003/05/08.