ソースを参照

SBCL file-position support

avodonosov 16 年 前
コミット
3e98754f4b
2 ファイル変更10 行追加3 行削除
  1. 2 2
      README
  2. 8 1
      mixin.lisp

+ 2 - 2
README

@@ -29,9 +29,9 @@ Extensions
 Generic function STREAM-READ-SEQUENCE (stream sequence start end &key)
 Generic function STREAM-WRITE-SEQUENCE (stream sequence start end &key)
 
-	See above.
+        See above.
 
 Generic function STREAM-FILE-POSITION (stream) => file position
 Generic function (SETF STREAM-FILE-POSITION) (position-spec stream) => successp
 
-	Will only be called by LispWorks and CLISP.
+        Will only be called by LispWorks, CLISP and SBCL.

+ 8 - 1
mixin.lisp

@@ -131,7 +131,7 @@
 
   (defmethod gray:stream-position ((stream trivial-gray-stream-mixin) position)
     (if position
-	(setf (stream-file-position stream) position)
+        (setf (stream-file-position stream) position)
         (stream-file-position stream))))
 
 #+sbcl
@@ -142,6 +142,11 @@
   (defmethod sb-gray:stream-write-sequence
       ((s trivial-gray-stream-mixin) seq &optional start end)
     (stream-write-sequence s seq (or start 0) (or end (length seq))))
+  (defmethod sb-gray:stream-file-position 
+      ((stream trivial-gray-stream-mixin) &optional position)
+    (if position
+        (setf (stream-file-position stream) position)
+        (stream-file-position stream)))
   ;; SBCL extension:
   (defmethod sb-gray:stream-line-length ((stream trivial-gray-stream-mixin))
     80))
@@ -150,7 +155,9 @@
 (progn
   (defmethod gray:stream-read-sequence
     ((s trivial-gray-stream-mixin) seq &optional start end)
+    (format t "trivial-read~%")
     (stream-read-sequence s seq (or start 0) (or end (length seq))))
   (defmethod gray:stream-write-sequence
     ((s trivial-gray-stream-mixin) seq &optional start end)
+    (format t "trivial-write~%")
     (stream-write-sequence s seq (or start 0) (or end (length seq)))))