Changeset 441
- Timestamp:
- Jan 30, 2004, 3:56:26 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/ccl/level-1/l1-streams.lisp (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/level-1/l1-streams.lisp
r424 r441 24 24 ;;; 25 25 26 27 26 (defclass stream () 28 27 ((direction :initarg :direction :initform nil :reader stream-direction) … … 39 38 40 39 ;;; Some generic stream functions: 40 (defmethod stream-length ((x t) &optional new) 41 (declare (ignore new)) 42 (report-bad-arg x 'stream)) 43 44 (defmethod stream-position ((x t) &optional new) 45 (declare (ignore new)) 46 (report-bad-arg x 'stream)) 47 48 (defmethod stream-element-type ((x t)) 49 (report-bad-arg x 'stream)) 41 50 42 51 ;;; For input streams: … … 244 253 (defmethod stream-finish-output ((stream output-stream)) nil) 245 254 255 256 246 257 (defmethod stream-clear-output ((stream output-stream)) nil) 247 258 … … 274 285 (defmethod interactive-stream-p ((stream stream)) nil) 275 286 287 (defmethod stream-clear-input ((x t)) 288 (report-bad-arg x 'stream)) 276 289 (defmethod stream-clear-input ((stream input-stream)) nil) 277 290 … … 1174 1187 1175 1188 (defun make-synonym-stream (symbol) 1176 (make-instance 'synonym-stream :symbol symbol))1189 (make-instance 'synonym-stream :symbol (require-type symbol 'symbol))) 1177 1190 1178 1191 … … 1238 1251 1239 1252 (defun make-two-way-stream (in out) 1253 (unless (input-stream-p in) 1254 (require-type in 'input-stream)) 1255 (unless (output-stream-p out) 1256 (require-type out 'output-stream)) 1240 1257 (make-instance 'two-way-stream :input-stream in :output-stream out)) 1241 1258 … … 1389 1406 (broadcast-method stream-advance-to-column (s new)) 1390 1407 (broadcast-method stream-start-line-p (s)) 1391 (broadcast-method stream-fresh-line (s))1392 1408 (broadcast-method stream-terpri (s)) 1393 1409 (broadcast-method stream-force-output (s)) … … 1396 1412 (broadcast-method stream-write-vector (s v start end))) 1397 1413 1414 (defun last-broadcast-stream (s) 1415 (car (last (broadcast-stream-streams s)))) 1416 1417 (defmethod stream-fresh-line ((s broadcast-stream)) 1418 (let* ((did-output-newline nil)) 1419 (dolist (sub (broadcast-stream-streams s) did-output-newline) 1420 (setq did-output-newline (stream-fresh-line sub))))) 1421 1422 (defmethod stream-element-type ((s broadcast-stream)) 1423 (let* ((last (last-broadcast-stream s))) 1424 (if last 1425 (stream-element-type last) 1426 t))) 1427 1428 (defmethod stream-length ((s broadcast-stream) &optional new) 1429 (unless new 1430 (let* ((last (last-broadcast-stream s))) 1431 (if last 1432 (stream-length last) 1433 0)))) 1434 1435 (defmethod stream-position ((s broadcast-stream) &optional new) 1436 (unless new 1437 (let* ((last (last-broadcast-stream s))) 1438 (if last 1439 (stream-position last) 1440 0)))) 1441 1442 (defmethod file-stream-external-format ((s broadcast-stream)) 1443 (let* ((last (last-broadcast-stream s))) 1444 (if last 1445 (file-stream-external-format last) 1446 :default))) 1398 1447 1399 1448 (defun make-broadcast-stream (&rest streams) … … 2195 2244 (io-buffer (ioblock-outbuf ioblock)) 2196 2245 (buf (%null-ptr)) 2197 (octets (ioblock-elements-to-octets ioblock count))) 2246 (octets-to-write (ioblock-elements-to-octets ioblock count)) 2247 (octets octets-to-write)) 2198 2248 (declare (fixnum octets)) 2199 2249 (declare (dynamic-extent buf)) … … 2206 2256 (case (%unix-fd-kind fd) 2207 2257 (:file (fd-fsync fd)))) 2208 count)2258 octets-to-write) 2209 2259 (let* ((written (with-eagain fd :output 2210 2260 (fd-write fd buf octets)))) … … 2249 2299 (element-type 'base-char) 2250 2300 (if-exists :error) 2251 (if-does-not-exist (if (or (eq direction :input) 2252 ;(eq if-exists :overwrite) 2253 (eq if-exists :append)) 2254 :error 2255 :create)) 2301 (if-does-not-exist (cond ((eq direction :probe) 2302 nil) 2303 ((or (eq direction :input) 2304 (eq if-exists :overwrite) 2305 (eq if-exists :append)) 2306 :error) 2307 (t :create))) 2256 2308 (external-format :default) 2257 2309 (class *default-file-stream-class*) … … 2287 2339 2288 2340 (defun file-length (stream) 2289 (stream-length stream)) 2341 (etypecase stream 2342 ;; Don't use an OR type here 2343 (file-stream (stream-length stream)) 2344 (broadcast-stream (stream-length stream)))) 2290 2345 2291 2346 (defun file-position (stream &optional position)
Note:
See TracChangeset
for help on using the changeset viewer.
