Changeset 4893


Ignore:
Timestamp:
Jul 22, 2006, 10:57:47 PM (18 years ago)
Author:
Gary Byers
Message:

Bootstrapping stuff.

Move along, nothing to see here.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/level-1/l1-streams.lisp

    r4890 r4893  
    3131
    3232(defclass stream ()
    33   ((direction :initarg :direction :initform nil :reader stream-direction)
    34    (closed :initform nil)))
     33  ())
    3534
    3635(defclass input-stream (stream)
     
    3837
    3938(defclass output-stream (stream) ())
     39
     40(defmethod stream-direction ((s stream))
     41  )
     42
     43(defmethod stream-direction ((s input-stream))
     44  (if (typep s 'output-stream)
     45    :io
     46    :input))
     47
     48(defmethod stream-direction ((s output-stream))
     49  (if (typep s 'input-stream)
     50    :io
     51    :output))
     52
    4053
    4154;;; The "direction" argument only helps us dispatch on two-way streams:
     
    224237                                 (%strerror error-number) context)))
    225238
    226 (defmethod initialize-instance :after ((stream input-stream) &key)
    227   (let ((direction (slot-value stream 'direction)))
    228     (if (null direction)
    229       (set-slot-value stream 'direction :input)
    230       (if (eq direction :output)
    231         (set-slot-value stream 'direction :io)))))
    232239
    233240
     
    278285
    279286(defmethod open-stream-p ((stream stream))
    280   (not (slot-value stream 'closed)))
     287  t)
    281288
    282289(defmethod stream-fresh-line ((stream output-stream))
     
    353360  (dirty nil)
    354361  (outbuf-lock nil)
    355   (owner nil))
     362  (owner nil)
     363  (read-char-function 'ioblock-no-char-input)
     364  (read-byte-function 'ioblock-no-binary-input)
     365  (write-char-function 'ioblock-no-char-output)
     366  (write-byte-function 'ioblock-no-binary-output))
    356367
    357368
    358369;;; Functions on ioblocks.  So far, we aren't saying anything
    359370;;; about how streams use them.
     371
     372(defun ioblock-no-binary-input (ioblock)
     373  (report-bad-arg (ioblock-stream ioblock) '(and binary-stream input-stream)))
     374
     375(defun ioblock-no-binary-output (ioblock)
     376  (report-bad-arg (ioblock-stream ioblock) '(and binary-stream output-stream)))
     377
     378(defun ioblock-no-character-input (ioblock)
     379  (report-bad-arg (ioblock-stream ioblock) '(and character-stream input-stream)))
     380
     381(defun ioblock-no-character-output (ioblock)
     382  (report-bad-arg (ioblock-stream ioblock) '(and character-stream output-stream)))
    360383
    361384
     
    10521075  (typep s 'fundamental-input-stream))
    10531076
    1054 (defclass fundamental-character-stream (fundamental-stream)
     1077(defclass binary-stream (stream)
     1078    ())
     1079
     1080(defclass character-stream (stream)
     1081    ())
     1082
     1083(defclass fundamental-character-stream (fundamental-stream character-stream)
    10551084    ())
    10561085
     
    10581087  'character)
    10591088
    1060 (defclass fundamental-binary-stream (fundamental-stream)
     1089(defclass fundamental-binary-stream (fundamental-stream binary-stream)
    10611090    ())
    10621091
     1092(defclass character-input-stream (input-stream character-stream)
     1093    ())
     1094
    10631095(defclass fundamental-character-input-stream (fundamental-input-stream
    1064                                               fundamental-character-stream)
     1096                                              fundamental-character-stream
     1097                                              character-input-stream)
    10651098    ())
    10661099
     
    10861119  (generic-read-line s))
    10871120
     1121(defclass character-output-stream (output-stream character-stream)
     1122    ())
     1123
    10881124(defclass fundamental-character-output-stream (fundamental-output-stream
    1089                                                fundamental-character-stream)
     1125                                               fundamental-character-stream
     1126                                               character-output-stream)
    10901127    ())
    10911128
     1129(defclass binary-input-stream (input-stream binary-stream)
     1130    ())
     1131
    10921132(defclass fundamental-binary-input-stream (fundamental-input-stream
    1093                                            fundamental-binary-stream)
     1133                                           fundamental-binary-stream
     1134                                           binary-input-stream)
    10941135    ())
    10951136
    10961137(defclass fundamental-binary-output-stream (fundamental-output-stream
    1097                                             fundamental-binary-stream)
     1138                                            fundamental-binary-stream
     1139                                            binary-output-stream)
    10981140    ())
    10991141
    11001142
    11011143(defmethod stream-read-byte ((s t))
    1102   (report-bad-arg s '(and input-stream fundamental-binary-stream)))
     1144  (report-bad-arg s '(and input-stream binary-stream)))
    11031145
    11041146(defmethod stream-write-byte ((s t) b)
    11051147  (declare (ignore b))
    1106   (report-bad-arg s '(and output-stream fundamental-binary-stream)))
     1148  (report-bad-arg s '(and output-stream binary-stream)))
    11071149
    11081150(defmethod stream-length ((s stream) &optional new)
     
    15841626      (error "~s is closed" s)))
    15851627
     1628(defmethod open-stream-p ((s string-stream))
     1629  (not (null (%string-stream-string s))))
     1630
    15861631(defmethod close  ((s string-stream) &key abort)
    15871632  (declare (ignore abort))
     
    15931638(defmethod print-object ((s string-stream) out)
    15941639  (print-unreadable-object (s out :type t :identity t)
    1595     (let* ((closed (slot-value s 'closed)))
    1596       (when closed (format out "~s" closed)))))
     1640    (unless (open-stream-p s)  (format out " ~s" :closed))))
    15971641
    15981642(defclass string-output-stream (string-stream fundamental-character-output-stream)
     
    18061850   (element-type :initarg :element-type :reader %buffered-stream-element-type)))
    18071851
     1852(defmethod open-stream-p ((s buffered-stream-mixin))
     1853  (with-slots (ioblock) s
     1854    (not (null ioblock))))
     1855 
    18081856(defun stream-ioblock (stream &optional (error-if-nil t))
    18091857  (with-slots (ioblock) stream
Note: See TracChangeset for help on using the changeset viewer.