/[cmucl]/src/code/stream.lisp
ViewVC logotype

Diff of /src/code/stream.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by wlott, Fri Nov 29 19:47:19 1991 UTC revision 1.14 by ram, Thu Dec 10 01:08:40 1992 UTC
# Line 1  Line 1 
1  ;;; -*- Log: code.log; Package: Lisp -*-  ;;; -*- Package: Lisp -*-
2  ;;;  ;;;
3  ;;; **********************************************************************  ;;; **********************************************************************
4  ;;; This code was written as part of the CMU Common Lisp project at  ;;; This code was written as part of the CMU Common Lisp project at
# Line 11  Line 11 
11  ;;;  ;;;
12  ;;; **********************************************************************  ;;; **********************************************************************
13  ;;;  ;;;
 ;;; $Header$  
 ;;;  
14  ;;; Stream functions for Spice Lisp.  ;;; Stream functions for Spice Lisp.
15  ;;; Written by Skef Wholey and Rob MacLachlan.  ;;; Written by Skef Wholey and Rob MacLachlan.
16  ;;;  ;;;
17  ;;; This file contains the machine-independent stream functions.  Another  ;;; This file contains the OS-independent stream functions.
 ;;; file (VAXIO, SPIO, or VMIO) contains functions used by this file for  
 ;;; a specific machine.  
18  ;;;  ;;;
19  (in-package "LISP")  (in-package "LISP")
20    
21  (export '(make-broadcast-stream make-synonym-stream  (export '(broadcast-stream make-broadcast-stream broadcast-stream-streams
22            make-broadcast-stream make-concatenated-stream make-two-way-stream            synonym-stream make-synonym-stream synonym-stream-symbol
23            make-echo-stream make-string-input-stream make-string-output-stream            concatenated-stream make-concatenated-stream
24              concatenated-stream-streams
25              two-way-stream make-two-way-stream two-way-stream-input-stream
26              two-way-stream-output-stream
27              echo-stream make-echo-stream echo-stream-input-stream
28              echo-stream-output-stream
29              make-string-input-stream make-string-output-stream
30            get-output-stream-string stream-element-type input-stream-p            get-output-stream-string stream-element-type input-stream-p
31            output-stream-p close read-line read-char            output-stream-p open-stream-p interactive-stream-p
32              close read-line read-char
33            unread-char peek-char listen read-char-no-hang clear-input read-byte            unread-char peek-char listen read-char-no-hang clear-input read-byte
34            write-char write-string write-line terpri fresh-line            write-char write-string write-line terpri fresh-line
35            finish-output force-output clear-output write-byte            finish-output force-output clear-output write-byte
36            stream streamp *standard-input* *standard-output*            stream streamp string-stream
37              *standard-input* *standard-output*
38            *error-output* *query-io* *debug-io* *terminal-io* *trace-output*))            *error-output* *query-io* *debug-io* *terminal-io* *trace-output*))
39    
40  (in-package 'system)  (in-package 'system)
41  (export '(make-indenting-stream read-n-bytes))  (export '(make-indenting-stream read-n-bytes))
42  (in-package 'lisp)  (in-package 'lisp)
43    
44    (deftype string-stream ()
45      '(or string-input-stream string-output-stream
46           fill-pointer-output-stream))
47    
48  ;;;; Standard streams:  ;;;; Standard streams:
49  ;;;  ;;;
50  ;;; The initialization of these streams is performed by Stream-Init,  ;;; The initialization of these streams is performed by Stream-Init,
# Line 113  Line 121 
121  ;;;  :file-length       - Return the file length of a file stream.  ;;;  :file-length       - Return the file length of a file stream.
122  ;;;  :file-position     - Return or change the current position of a file stream.  ;;;  :file-position     - Return or change the current position of a file stream.
123  ;;;  :file-name         - Return the name of an associated file.  ;;;  :file-name         - Return the name of an associated file.
124    ;;;  :interactive-p     - Is this an interactive device?
125  ;;;  ;;;
126  ;;;    In order to do almost anything useful, it is necessary to  ;;;    In order to do almost anything useful, it is necessary to
127  ;;; define a new type of structure that includes stream, so that the  ;;; define a new type of structure that includes stream, so that the
# Line 161  Line 170 
170         (or (not (eq (stream-out stream) #'ill-out))         (or (not (eq (stream-out stream) #'ill-out))
171             (not (eq (stream-bout stream) #'ill-bout)))))             (not (eq (stream-bout stream) #'ill-bout)))))
172    
173    (defun open-stream-p (stream)
174      "Return true if Stream is not closed."
175      (declare (type stream stream))
176      (not (eq (stream-in stream) #'closed-flame)))
177    
178  (defun stream-element-type (stream)  (defun stream-element-type (stream)
179    "Returns a type specifier for the kind of object returned by the Stream."    "Returns a type specifier for the kind of object returned by the Stream."
180    (if (streamp stream)    (if (streamp stream)
181        (funcall (stream-misc stream) stream :element-type)        (funcall (stream-misc stream) stream :element-type)
182        (error "~S is not a stream." stream)))        (error "~S is not a stream." stream)))
183    
184    (defun interactive-stream-p (stream)
185      "Return true if Stream does I/O on a terminal or other interactive device."
186      (declare (type stream stream))
187      (funcall (stream-misc stream) stream :interactive-p))
188    
189  (defun close (stream &key abort)  (defun close (stream &key abort)
190    "Closes the given Stream.  No more I/O may be performed, but inquiries    "Closes the given Stream.  No more I/O may be performed, but inquiries
191    may still be made.  If :Abort is non-nil, an attempt is made to clean    may still be made.  If :Abort is non-nil, an attempt is made to clean
# Line 428  Line 447 
447                               (:print-function %print-broadcast-stream)                               (:print-function %print-broadcast-stream)
448                               (:constructor make-broadcast-stream (&rest streams)))                               (:constructor make-broadcast-stream (&rest streams)))
449    ;; This is a list of all the streams we broadcast to.    ;; This is a list of all the streams we broadcast to.
450    streams)    (streams () :type list :read-only t))
451    
452  (setf (documentation 'make-broadcast-stream 'function)  (setf (documentation 'make-broadcast-stream 'function)
453   "Returns an ouput stream which sends its output to all of the given streams.")   "Returns an ouput stream which sends its output to all of the given streams.")
# Line 481  Line 500 
500                             (:print-function %print-synonym-stream)                             (:print-function %print-synonym-stream)
501                             (:constructor make-synonym-stream (symbol)))                             (:constructor make-synonym-stream (symbol)))
502    ;; This is the symbol, the value of which is the stream we are synonym to.    ;; This is the symbol, the value of which is the stream we are synonym to.
503    symbol)    (symbol :type symbol :read-only t))
504    
505  (defun %print-synonym-stream (s stream d)  (defun %print-synonym-stream (s stream d)
506    (declare (ignore d))    (declare (ignore d))
# Line 553  Line 572 
572              (:print-function %print-two-way-stream)              (:print-function %print-two-way-stream)
573              (:constructor make-two-way-stream (input-stream output-stream)))              (:constructor make-two-way-stream (input-stream output-stream)))
574    ;; We read from this stream...    ;; We read from this stream...
575    input-stream    (input-stream (required-argument) :type stream :read-only t)
576    ;; And write to this one    ;; And write to this one
577    output-stream)    (output-stream (required-argument) :type stream :read-only t))
578    
579  (defun %print-two-way-stream (s stream d)  (defun %print-two-way-stream (s stream d)
580    (declare (ignore d))    (declare (ignore d))
# Line 625  Line 644 
644    current    current
645    ;; This is a list of all the streams.  We need to remember them so that    ;; This is a list of all the streams.  We need to remember them so that
646    ;; we can close them.    ;; we can close them.
647    streams)    (streams nil :type list :read-only t))
648    
649  (defun %print-concatenated-stream (s stream d)  (defun %print-concatenated-stream (s stream d)
650    (declare (ignore d))    (declare (ignore d))

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.5