X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fpcl%2Fgray-streams.lisp;h=3ad52a1d9ad0b97aea55b614bf05c0de6491aced;hb=696e38f7210c587ba0b54795f4795f58e62fed2d;hp=554c904e491e85d5733096b79f56c69a5e93a267;hpb=504959cef381a69a727263ba2a70108f133f8900;p=sbcl.git diff --git a/src/pcl/gray-streams.lisp b/src/pcl/gray-streams.lisp index 554c904..3ad52a1 100644 --- a/src/pcl/gray-streams.lisp +++ b/src/pcl/gray-streams.lisp @@ -10,6 +10,18 @@ ;;;; more information. (in-package "SB-GRAY") + +;;; BUG-OR-ERROR: because we have extensible streams, wherewith the +;;; 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. +(defmacro bug-or-error (stream fun) + `(error "~@).~@:>" + ,stream ,fun)) + (fmakunbound 'stream-element-type) @@ -25,6 +37,12 @@ (defmethod stream-element-type ((stream fundamental-character-stream)) 'character) + +(defmethod stream-element-type ((stream stream)) + (bug-or-error stream 'stream-element-type)) + +(defmethod stream-element-type ((non-stream t)) + (error 'type-error :datum non-stream :expected-type 'stream)) (defgeneric pcl-open-stream-p (stream) #+sb-doc @@ -39,6 +57,12 @@ (defmethod pcl-open-stream-p ((stream fundamental-stream)) (stream-open-p stream)) +(defmethod pcl-open-stream-p ((stream stream)) + (bug-or-error stream 'open-stream-p)) + +(defmethod pcl-open-stream-p ((non-stream t)) + (error 'type-error :datum non-stream :expected-type 'stream)) + ;;; bootstrapping hack (pcl-open-stream-p (make-string-output-stream)) (setf (fdefinition 'open-stream-p) #'pcl-open-stream-p) @@ -66,12 +90,18 @@ (defgeneric input-stream-p (stream) #+sb-doc (:documentation "Can STREAM perform input operations?")) - + (defmethod input-stream-p ((stream ansi-stream)) (ansi-stream-input-stream-p stream)) - + (defmethod input-stream-p ((stream fundamental-input-stream)) - t)) + t) + + (defmethod input-stream-p ((stream stream)) + (bug-or-error stream 'input-stream-p)) + + (defmethod input-stream-p ((non-stream t)) + (error 'type-error :datum non-stream :expected-type 'stream))) (let () (fmakunbound 'output-stream-p) @@ -84,7 +114,13 @@ (ansi-stream-output-stream-p stream)) (defmethod output-stream-p ((stream fundamental-output-stream)) - t)) + t) + + (defmethod output-stream-p ((stream stream)) + (bug-or-error stream 'output-stream-p)) + + (defmethod output-stream-p ((non-stream t)) + (error 'type-error :datum non-stream :expected-type 'stream))) ;;; character input streams ;;;