Changeset 4893
- Timestamp:
- Jul 22, 2006, 10:57:47 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ccl/level-1/l1-streams.lisp (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/level-1/l1-streams.lisp
r4890 r4893 31 31 32 32 (defclass stream () 33 ((direction :initarg :direction :initform nil :reader stream-direction) 34 (closed :initform nil))) 33 ()) 35 34 36 35 (defclass input-stream (stream) … … 38 37 39 38 (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 40 53 41 54 ;;; The "direction" argument only helps us dispatch on two-way streams: … … 224 237 (%strerror error-number) context))) 225 238 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)))))232 239 233 240 … … 278 285 279 286 (defmethod open-stream-p ((stream stream)) 280 (not (slot-value stream 'closed)))287 t) 281 288 282 289 (defmethod stream-fresh-line ((stream output-stream)) … … 353 360 (dirty nil) 354 361 (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)) 356 367 357 368 358 369 ;;; Functions on ioblocks. So far, we aren't saying anything 359 370 ;;; 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))) 360 383 361 384 … … 1052 1075 (typep s 'fundamental-input-stream)) 1053 1076 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) 1055 1084 ()) 1056 1085 … … 1058 1087 'character) 1059 1088 1060 (defclass fundamental-binary-stream (fundamental-stream )1089 (defclass fundamental-binary-stream (fundamental-stream binary-stream) 1061 1090 ()) 1062 1091 1092 (defclass character-input-stream (input-stream character-stream) 1093 ()) 1094 1063 1095 (defclass fundamental-character-input-stream (fundamental-input-stream 1064 fundamental-character-stream) 1096 fundamental-character-stream 1097 character-input-stream) 1065 1098 ()) 1066 1099 … … 1086 1119 (generic-read-line s)) 1087 1120 1121 (defclass character-output-stream (output-stream character-stream) 1122 ()) 1123 1088 1124 (defclass fundamental-character-output-stream (fundamental-output-stream 1089 fundamental-character-stream) 1125 fundamental-character-stream 1126 character-output-stream) 1090 1127 ()) 1091 1128 1129 (defclass binary-input-stream (input-stream binary-stream) 1130 ()) 1131 1092 1132 (defclass fundamental-binary-input-stream (fundamental-input-stream 1093 fundamental-binary-stream) 1133 fundamental-binary-stream 1134 binary-input-stream) 1094 1135 ()) 1095 1136 1096 1137 (defclass fundamental-binary-output-stream (fundamental-output-stream 1097 fundamental-binary-stream) 1138 fundamental-binary-stream 1139 binary-output-stream) 1098 1140 ()) 1099 1141 1100 1142 1101 1143 (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))) 1103 1145 1104 1146 (defmethod stream-write-byte ((s t) b) 1105 1147 (declare (ignore b)) 1106 (report-bad-arg s '(and output-stream fundamental-binary-stream)))1148 (report-bad-arg s '(and output-stream binary-stream))) 1107 1149 1108 1150 (defmethod stream-length ((s stream) &optional new) … … 1584 1626 (error "~s is closed" s))) 1585 1627 1628 (defmethod open-stream-p ((s string-stream)) 1629 (not (null (%string-stream-string s)))) 1630 1586 1631 (defmethod close ((s string-stream) &key abort) 1587 1632 (declare (ignore abort)) … … 1593 1638 (defmethod print-object ((s string-stream) out) 1594 1639 (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)))) 1597 1641 1598 1642 (defclass string-output-stream (string-stream fundamental-character-output-stream) … … 1806 1850 (element-type :initarg :element-type :reader %buffered-stream-element-type))) 1807 1851 1852 (defmethod open-stream-p ((s buffered-stream-mixin)) 1853 (with-slots (ioblock) s 1854 (not (null ioblock)))) 1855 1808 1856 (defun stream-ioblock (stream &optional (error-if-nil t)) 1809 1857 (with-slots (ioblock) stream
Note:
See TracChangeset
for help on using the changeset viewer.
