Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add open-p slot to FUNDAMENTAL-STREAM and update default methods #469

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions level-1/l1-streams.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3483,14 +3483,22 @@
;;; Fundamental streams.

(defclass fundamental-stream (stream)
())
((open-p :initform t :accessor fundamental-stream-open-p)))

(defclass fundamental-input-stream (fundamental-stream input-stream)
((shared-resource :initform nil :accessor input-stream-shared-resource)))

(defclass fundamental-output-stream (fundamental-stream output-stream)
())

(defmethod open-stream-p ((stream fundamental-stream))
(fundamental-stream-open-p stream))

(defmethod close ((stream fundamental-stream) &key abort)
(declare (ignore abort))
(prog1 (open-stream-p stream)
(setf (fundamental-stream-open-p stream) nil)))

(defmethod input-stream-p ((x t))
(report-bad-arg x 'stream))

Expand Down Expand Up @@ -3552,9 +3560,9 @@

(defmethod stream-listen ((s fundamental-character-input-stream))
(let* ((ch (stream-read-char-no-hang s)))
(when (and ch (not (eq ch :eof)))
(stream-unread-char s ch))
ch))
(and (not (null ch))
(not (eq ch :eof))
(progn (stream-unread-char stream ch) t))))

(defmethod stream-clear-input ((s fundamental-character-input-stream))
)
Expand Down