Changeset 5360


Ignore:
Timestamp:
Oct 17, 2006, 1:01:19 PM (18 years ago)
Author:
Gary Byers
Message:

(SETF STREAM-EXTERNAL-FORMAT) for ioblock-based character streams.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/level-1/l1-streams.lisp

    r5357 r5360  
    4444(defmethod stream-direction ((s stream))
    4545  )
     46
     47(defmethod stream-domain ((s stream))
     48  t)
     49
    4650
    4751(defmethod stream-direction ((s input-stream))
     
    31263130               (>= n min)
    31273131               (case (case unit-size
    3128                        (16 (logior (ash (aref buf 0) 8)
    3129                                    (aref buf 1)))
    3130                        (32 (logior (ash (aref buf 0) 24)
    3131                                    (ash (aref buf 1) 16)
    3132                                    (ash (aref buf 2) 8)
    3133                                    (aref buf 3))))
     3132                       (16 (%native-u8-ref-u16 buf 0))
     3133                       (32 (%native-u8-ref-u32 buf 0)))
    31343134                 (#.byte-order-mark-char-code
    31353135                  (setf (io-buffer-idx inbuf) min)
     
    34573457(defclass file-stream (stream)
    34583458    ())
     3459
     3460(defmethod stream-domain ((s file-stream))
     3461  :file)
     3462
    34593463
    34603464
     
    49474951
    49484952(defun unread-data-available-p (fd)
     4953  #+freebsd-target
     4954  (fd-input-available-p fd 0)
     4955  #-freebsd-target
    49494956  (rlet ((arg (* :char) (%null-ptr)))
    49504957    (when (zerop (syscall syscalls::ioctl fd #$FIONREAD arg))
     
    54815488    (stream-line-column stream)))       
    54825489
     5490(defun (setf %ioblock-external-format) (ef ioblock)
     5491  (let* ((encoding (get-character-encoding (external-format-character-encoding ef)))
     5492         (line-termination (external-format-line-termination ef)))
     5493    (when (eq encoding (get-character-encoding nil))
     5494      (setq encoding nil))
     5495    (when (ioblock-inbuf ioblock)
     5496      (setup-ioblock-input ioblock t (ioblock-element-type ioblock) (ioblock-sharing ioblock) encoding line-termination))
     5497    (when (ioblock-outbuf ioblock)
     5498      (setup-ioblock-output ioblock t (ioblock-element-type ioblock) (ioblock-sharing ioblock) encoding line-termination))
     5499    ef))
    54835500
    54845501(defmethod stream-external-format ((s basic-character-stream))
    54855502  (%ioblock-external-format (stream-ioblock s t)))
    54865503
     5504(defmethod (setf stream-external-format) (new (s basic-character-stream))
     5505  (setf (%ioblock-external-format (stream-ioblock s t))
     5506        (normalize-external-format (stream-domain s) new)))
     5507
    54875508(defmethod stream-external-format ((s buffered-stream-mixin))
    54885509  (%ioblock-external-format (stream-ioblock s t)))
Note: See TracChangeset for help on using the changeset viewer.