Require "streamc" only if Allegro version is < 9.0
[iolib.git] / src / streams / gray / classes.lisp
blob9a15f80aef9928ff503d1262904280d5b5177b61
1 ;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*-
2 ;;;
3 ;;; --- fd-streams classes.
4 ;;;
6 (in-package :iolib.streams)
8 ;;;; Stream Buffers
10 (deftype stream-buffer () 'foreign-pointer)
11 (deftype buffer-index () '(unsigned-byte 24))
13 (defstruct (iobuf (:constructor %make-iobuf ()))
14 (data (null-pointer) :type stream-buffer)
15 (size 0 :type buffer-index)
16 (start 0 :type buffer-index)
17 (end 0 :type buffer-index))
19 ;;;; File-Descriptor Mixins
21 (deftype stream-position () '(unsigned-byte 64))
23 (defun default-read-fn (fd buf nbytes)
24 (isys:read fd buf nbytes))
26 (defun default-write-fn (fd buf nbytes)
27 (isys:write fd buf nbytes))
29 (defclass dual-channel-fd-mixin ()
30 ((fd :initform nil :initarg :fd :accessor fd-of
31 :documentation "placeholder")
32 (read-fn :initform #'default-read-fn :initarg :read-fn :accessor read-fn-of)
33 (write-fn :initform #'default-write-fn :initarg :write-fn :accessor write-fn-of))
34 (:documentation "placeholder"))
36 ;;;; Bivalent Socket Gray Stream
38 (defclass dual-channel-gray-stream (trivial-gray-stream-mixin
39 dual-channel-fd-mixin
40 fundamental-binary-input-stream
41 fundamental-binary-output-stream
42 fundamental-character-input-stream
43 fundamental-character-output-stream)
44 ((external-format :initform :default :initarg :external-format
45 :reader external-format-of
46 :documentation "placehold")
47 (eol-writer :reader eol-writer-of)
48 (eol-finder :reader eol-finder-of)
49 (eol-finder/no-hang :reader eol-finder/no-hang-of)
50 (input-buffer :initform nil :type (or iobuf null)
51 :accessor input-buffer-of)
52 (output-buffer :initform nil :type (or iobuf null)
53 :accessor output-buffer-of)
54 ;; Flag used by stream-force-output.
55 (dirty :initform nil :type boolean :accessor dirtyp)
56 ;; Last read char buffer index.
57 (unread-index :initform 0 :type buffer-index
58 :accessor unread-index-of))
59 (:documentation "placeholder"))
61 (defgeneric (setf external-format-of) (external-format stream)
62 (:documentation "placeholder"))
64 (defgeneric drain-input-buffer (stream sequence &key start end)
65 (:documentation ""))
67 (defgeneric input-buffer-size (stream)
68 (:documentation ""))
70 (defgeneric input-buffer-empty-p (stream)
71 (:documentation ""))
73 (defgeneric output-buffer-size (stream)
74 (:documentation ""))
76 (defgeneric output-buffer-empty-p (stream)
77 (:documentation ""))