(in-package "SB!IMPL")
-(deftype string-stream ()
- '(or string-input-stream string-output-stream
- fill-pointer-output-stream))
-
;;;; standard streams
;;; The initialization of these streams is performed by
(stream-misc-dispatch out operation arg1 arg2)))))))
\f
+;;;; string streams
+(defstruct (string-stream
+ (:include ansi-stream)
+ (:constructor nil)
+ (:copier nil))
+ (string nil :type string))
+
;;;; string input streams
(defstruct (string-input-stream
- (:include ansi-stream
+ (:include string-stream
(in #'string-inch)
(bin #'string-binch)
(n-bin #'string-stream-read-n-bytes)
- (misc #'string-in-misc))
+ (misc #'string-in-misc)
+ (string nil :type simple-string))
(:constructor internal-make-string-input-stream
(string current end))
(:copier nil))
- (string nil :type simple-string)
(current nil :type index)
(end nil :type index))
;;;; string output streams
(defstruct (string-output-stream
- (:include ansi-stream
+ (:include string-stream
(out #'string-ouch)
(sout #'string-sout)
- (misc #'string-out-misc))
+ (misc #'string-out-misc)
+ ;; The string we throw stuff in.
+ (string (make-string 40) :type simple-string))
(:constructor make-string-output-stream ())
(:copier nil))
- ;; The string we throw stuff in.
- (string (make-string 40) :type simple-string)
;; Index of the next location to use.
(index 0 :type fixnum))
(satisfies array-has-fill-pointer-p)))
(defstruct (fill-pointer-output-stream
- (:include ansi-stream
+ (:include string-stream
(out #'fill-pointer-ouch)
(sout #'fill-pointer-sout)
- (misc #'fill-pointer-misc))
+ (misc #'fill-pointer-misc)
+ ;; a string with a fill pointer where we stuff
+ ;; the stuff we write
+ (string (error "missing argument")
+ :type string-with-fill-pointer
+ :read-only t))
(:constructor make-fill-pointer-output-stream (string))
- (:copier nil))
- ;; a string with a fill pointer where we stuff the stuff we write
- (string (error "missing argument")
- :type string-with-fill-pointer
- :read-only t))
+ (:copier nil)))
(defun fill-pointer-ouch (stream character)
(let* ((buffer (fill-pointer-output-stream-string stream))
(make-string-output-stream)
(make-string-input-stream "foo"))
type-error)))
+
+;;; bug 225: STRING-STREAM was not a class
+(eval `(defgeneric bug225 (s)
+ ,@(mapcar (lambda (class)
+ `(:method :around ((s ,class)) (cons ',class (call-next-method))))
+ '(stream string-stream sb-impl::string-input-stream
+ sb-impl::string-output-stream))
+ (:method (class) nil)))
+
+(assert (equal (bug225 (make-string-input-stream "hello"))
+ '(sb-impl::string-input-stream string-stream stream)))
+(assert (equal (bug225 (make-string-output-stream))
+ '(sb-impl::string-output-stream string-stream stream)))
+
\f
;;; success
(quit :unix-status 104)