ViewVC logotype

Contents of /src/code/struct.lisp

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.26 - (show annotations)
Tue Oct 12 21:52:44 2010 UTC (3 years, 6 months ago) by rtoy
Branch: MAIN
CVS Tags: GIT-CONVERSION, cross-sol-x86-merged, cross-sol-x86-base, snapshot-2010-12, snapshot-2010-11, snapshot-2011-09, snapshot-2011-06, snapshot-2011-07, snapshot-2011-04, snapshot-2011-02, snapshot-2011-03, snapshot-2011-01, cross-sol-x86-2010-12-20, cross-sparc-branch-base, HEAD
Branch point for: cross-sparc-branch, cross-sol-x86-branch
Changes since 1.25: +14 -2 lines
Make read-char and read-byte signal errors when given the wrong kind
of streams.  This is a change from current 20a and 20b behavior which
didn't signal errors, but matches the behavior for releases 19f and

But allow them to work on binary-text-streams.  This is the same
behavior as before for binary-text-stream streams.

However, read-sequence no longer allows reading from streams into
arbitrary objects, unless the stream is a binary-text-stream stream.

  fd-stream-in/fd-stream-out if we have a character or
  binary-text-stream stream.
o Don't update the fd-stream-string-buffer or lisp-stream-in-buffer if
  we have a binary-text-stream because that will mess up how
  fast-read-char and fast-read-byte dispatch to do the right thing for
  binary-text-stream streams.

o Set the fd-stream-in and fd-stream-bin slots appropriately depending
  on whether we have a character, binary, or binary-text-stream
o Only create the lisp-stream-in-buffer if we do NOT have a
  binary-text-stream.  (Binary streams didn't use the
  lisp-stream-buffer previously, so no change there.  Character
  streams use the lisp-stream-buffer and/or lisp-string-buffer.)
o Set the fd-stream-flags appropriately for the kind of stream this
  is.  Checking a fixnum is faster than checking the type of a stream.

o Add FLAGS slot to LISP-STREAM so we can tell what kind of stream
  (character, binary, binary-text-stream) we have.

o Change FAST-READ-CHAR so that if we have a have a binary or
  binary-text-stream stream, we dispatch to the fast-read-char methods
  to do the right thing, including signaling an error for the wrong
  kind of stream.
o Change FAST-READ-BYTE so that if we do not have a binary stream, we
  dispatch to the fast-read-char method to do the right thing.

o With the above changes, we can no longer write characters to a
  binary stream, like a FASL file.  Make the fasl file a
  binary-text-stream so that we can.  (Alternatively, we could create
  the FASL header as a string, convert to octets and dump the octest
  to the file.  This is easier, and should still be fast for writing
1 ;;; -*- Log: code.log; Package: Lisp -*-
2 ;;;
3 ;;; **********************************************************************
4 ;;; This code was written as part of the CMU Common Lisp project at
5 ;;; Carnegie Mellon University, and has been placed in the public domain.
6 ;;;
7 (ext:file-comment
8 "$Header: /tiger/var/lib/cvsroots/cmucl/src/code/struct.lisp,v 1.26 2010/10/12 21:52:44 rtoy Exp $")
9 ;;;
10 ;;; **********************************************************************
11 ;;;
12 ;;; This file contains structure definitions that need to be compiled early
13 ;;; for bootstrapping reasons.
14 ;;;
15 (in-package "LISP")
16 (intl:textdomain "cmucl")
18 ;;;; The stream structure:
20 (defconstant in-buffer-length 512 "The size of a stream in-buffer.")
21 (deftype in-buffer-type ()
22 `(simple-array (unsigned-byte 8) (,in-buffer-length)))
24 ;;; Change the kind of lisp-stream to :instance so that the defstruct
25 ;;; doesn't flame out.
26 ;;;
27 (eval-when (compile eval)
28 (setf (info type kind 'lisp-stream) :instance))
30 (defstruct (lisp-stream (:print-function %print-stream))
31 ;;
32 ;; Buffered input.
33 (in-buffer nil :type (or in-buffer-type null))
34 (in-index in-buffer-length :type index) ; Index into in-buffer
35 (in #'ill-in :type function) ; Read-Char function
36 (bin #'ill-bin :type function) ; Byte input function
37 (n-bin #'ill-n-bin :type function) ; N-Byte input function
38 (out #'ill-out :type function) ; Write-Char function
39 (bout #'ill-bout :type function) ; Byte output function
40 (sout #'ill-out :type function) ; String output function
41 (misc #'do-nothing :type function) ; Less used methods
42 ;;
43 ;; A string to hold characters that have been converted from
44 ;; in-buffer. The very first character is for unreading. New
45 ;; characters are stored starting at index 1.
46 #+unicode
47 (string-buffer nil :type (or null simple-string))
48 ;;
49 ;; Index into string-buffer where the next character should be read
50 ;; from.
51 #+unicode
52 (string-index 0 :type index)
53 ;;
54 ;; Number of characters in string-buffer. (This isn't the length of
55 ;; string-buffer, but the number of characters in the buffer, since
56 ;; many octets may be consumed to produce one character.)
57 #+unicode
58 (string-buffer-len 0 :type index)
59 ;;
60 ;; An array holding the number of octets consumed for each character
61 ;; in string-buffer. This is basically unused, except by
62 ;; FILE-POSITION so that we can get the correct file position.
63 #+unicode
64 (octet-count nil :type (or null (simple-array (unsigned-byte 8) (*))))
65 ;;
66 ;; Flags indicating if the stream is a character stream, binary
67 ;; stream or binary-text-stream. This is somewhat redundant because
68 ;; binary-text-stream is its own type (defstruct). But we can't
69 ;; easily distinguish a character stream from a binary stream.
70 ;;
71 ;; #b001 - character (only) stream
72 ;; #b010 - binary (only) stream
73 ;; #b100 - binary-text-stream (supports character and binary)
74 ;;
75 ;; It is an error if both character and binary bits are set.
76 (flags 0 :type fixnum))
78 (declaim (inline streamp))
79 (defun streamp (stream)
80 (typep stream 'stream))
82 ;;; Alien value structures:
84 (in-package "ALIEN")
86 (defstruct (alien-value
87 (:print-function %print-alien-value))
88 (sap (required-argument) :type system-area-pointer)
89 (type (required-argument) :type alien-type))

  ViewVC Help
Powered by ViewVC 1.1.5