X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fsb-simple-streams%2Ffndb.lisp;h=2471f0713430ebe68548ef4d5bf175d0dfa6ee12;hb=a3d4610158f227d53cb5eac287dd2661e975fc70;hp=6d8579f4429ef829d57bc2773b3a30cecb5f7807;hpb=8dc1241068db5855115a9e25488a8962718a6c79;p=sbcl.git diff --git a/contrib/sb-simple-streams/fndb.lisp b/contrib/sb-simple-streams/fndb.lisp index 6d8579f..2471f07 100644 --- a/contrib/sb-simple-streams/fndb.lisp +++ b/contrib/sb-simple-streams/fndb.lisp @@ -22,24 +22,24 @@ Here's a (smarter) replacement: (defun result-type-open-class (call) (declare (type sb-c::combination call)) (let* ((not-set '#:not-set) - (not-constant '#:not-constant) - (direction not-set) - (if-exists not-set) - (if-does-not-exist not-set) - (class not-set)) + (not-constant '#:not-constant) + (direction not-set) + (if-exists not-set) + (if-does-not-exist not-set) + (class not-set)) ;; find (the first occurence of) each interesting keyword argument (do ((args (cdr (combination-args call)) (cddr args))) - ((null args)) + ((null args)) (macrolet ((maybe-set (var) - `(when (and (eq ,var not-set) (cadr args)) - (if (constant-continuation-p (cadr args)) - (setq ,var (continuation-value (cadr args))) - (setq ,var not-constant))))) - (case (continuation-value (car args)) - (:direction (maybe-set direction)) - (:if-exists (maybe-set if-exists)) - (:if-does-not-exist (maybe-set if-does-not-exist)) - (:class (maybe-set class))))) + `(when (and (eq ,var not-set) (cadr args)) + (if (constant-continuation-p (cadr args)) + (setq ,var (continuation-value (cadr args))) + (setq ,var not-constant))))) + (case (continuation-value (car args)) + (:direction (maybe-set direction)) + (:if-exists (maybe-set if-exists)) + (:if-does-not-exist (maybe-set if-does-not-exist)) + (:class (maybe-set class))))) ;; and set default values for any that weren't set above (when (eq direction not-set) (setq direction :input)) (when (eq if-exists not-constant) (setq if-exists nil)) @@ -51,11 +51,11 @@ Here's a (smarter) replacement: ;; direction is :output or :io or not-constant and :if-exists is nil ;; :if-does-not-exist is nil (if (or (and (or (eq direction :probe) (eq direction not-constant)) - (not (eq if-does-not-exist :error))) - (and (or (eq direction :output) (eq direction :io) - (eq direction not-constant)) - (eq if-exists nil)) - (eq if-does-not-exist nil)) + (not (eq if-does-not-exist :error))) + (and (or (eq direction :output) (eq direction :io) + (eq direction not-constant)) + (eq if-exists nil)) + (eq if-does-not-exist nil)) (specifier-type `(or null ,class)) (specifier-type class)))) @@ -64,33 +64,35 @@ TODO (rudi 2003-05-19): make the above work, make (defknown open) use it. ||# -(handler-bind ((error #'continue)) - (sb-c:defknown open (t &rest t - &key (:direction (member :input :output :io :probe)) - (:element-type sb-kernel:type-specifier) - (:if-exists (member :error :new-version :rename - :rename-and-delete :overwrite - :append :supersede nil)) - (:if-does-not-exist (member :error :create nil)) - (:external-format (member :default)) - (:class (or symbol class)) - (:mapped (member t nil)) - (:input-handle (or null fixnum stream)) - (:output-handle (or null fixnum stream)) - &allow-other-keys) +(sb-c:defknown open (t &rest t + &key (:direction (member :input :output :io :probe)) + (:element-type sb-kernel:type-specifier) + (:if-exists (member :error :new-version :rename + :rename-and-delete :overwrite + :append :supersede nil)) + (:if-does-not-exist (member :error :create nil)) + (:external-format keyword) + (:class (or symbol class)) + (:mapped (member t nil)) + (:input-handle (or null fixnum stream)) + (:output-handle (or null fixnum stream)) + &allow-other-keys) (or stream null) () - ;; :derive-type #'result-type-open-class - ) - - (sb-c:defknown listen (&optional sb-kernel:streamlike - (or null (integer 1 10) (member character))) - boolean (sb-c::unsafely-flushable sb-c::explicit-check)) - - (sb-c:defknown read-sequence (sequence stream &key (:start sb-int:index) - (:end sb-kernel:sequence-end) - (:partial-fill boolean)) - (sb-int:index) ()) - - (sb-c:defknown clear-input (&optional stream boolean) null - (sb-c::explicit-check))) + ;; :derive-type #'result-type-open-class + :overwrite-fndb-silently t) + +(sb-c:defknown listen (&optional sb-kernel:stream-designator + (or null (integer 1 10) (member character))) + boolean (sb-c::unsafely-flushable sb-c::explicit-check) + :overwrite-fndb-silently t) + +(sb-c:defknown read-sequence (sequence stream &key (:start sb-int:index) + (:end sb-kernel:sequence-end) + (:partial-fill boolean)) + (sb-int:index) () + :overwrite-fndb-silently t) + +(sb-c:defknown clear-input (&optional stream boolean) null + (sb-c::explicit-check) + :overwrite-fndb-silently t)