<commit_before>;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; indent-tabs-mode: nil -*-
;;;
;;; --- fd-streams classes.
;;;

(in-package :iolib.streams)

;;;; Types

(deftype ub8  () '(unsigned-byte 8))
(deftype ub16 () '(unsigned-byte 16))
(deftype ub32 () '(unsigned-byte 32))
(deftype sb8  () '(signed-byte 8))
(deftype sb16 () '(signed-byte 16))
(deftype sb32 () '(signed-byte 32))

(deftype ub8-sarray (&optional (size '*))
  `(simple-array ub8 (,size)))

(deftype ub8-vector () '(vector ub8))

(deftype ub16-sarray (&optional (size '*))
  `(simple-array ub16 (,size)))

;;;; Socket Buffers

(deftype stream-buffer () 'foreign-pointer)
(deftype buffer-index () '(unsigned-byte 24))

(defstruct (iobuf (:constructor %make-iobuf ()))
  (data  (null-pointer) :type stream-buffer)
  (size  0              :type buffer-index)
  (start 0              :type buffer-index)
  (end   0              :type buffer-index))

;;;; File-Descriptor Mixins

(deftype stream-position () '(unsigned-byte 64))

(defun default-read-fn (fd buf nbytes)
  (isys:%sys-read fd buf nbytes))

(defun default-write-fn (fd buf nbytes)
  (isys:%sys-write fd buf nbytes))

(defclass dual-channel-fd-mixin ()
  ((input-fd  :initform nil :initarg :input-fd :accessor input-fd-of
              :documentation "placeholder")
   (read-fn :initform 'default-read-fn :initarg :read-fn :accessor read-fn-of)
   (output-fd :initform nil :initarg :output-fd :accessor output-fd-of
              :documentation "placeholder")
   (write-fn :initform 'default-write-fn :initarg :write-fn :accessor write-fn-of))
  (:documentation "placeholder"))
<commit_msg>Call DEFAULT-{READ,WRITE}-FN through their function objects.<commit_after>;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; indent-tabs-mode: nil -*-
;;;
;;; --- fd-streams classes.
;;;

(in-package :iolib.streams)

;;;; Types

(deftype ub8  () '(unsigned-byte 8))
(deftype ub16 () '(unsigned-byte 16))
(deftype ub32 () '(unsigned-byte 32))
(deftype sb8  () '(signed-byte 8))
(deftype sb16 () '(signed-byte 16))
(deftype sb32 () '(signed-byte 32))

(deftype ub8-sarray (&optional (size '*))
  `(simple-array ub8 (,size)))

(deftype ub8-vector () '(vector ub8))

(deftype ub16-sarray (&optional (size '*))
  `(simple-array ub16 (,size)))

;;;; Socket Buffers

(deftype stream-buffer () 'foreign-pointer)
(deftype buffer-index () '(unsigned-byte 24))

(defstruct (iobuf (:constructor %make-iobuf ()))
  (data  (null-pointer) :type stream-buffer)
  (size  0              :type buffer-index)
  (start 0              :type buffer-index)
  (end   0              :type buffer-index))

;;;; File-Descriptor Mixins

(deftype stream-position () '(unsigned-byte 64))

(defun default-read-fn (fd buf nbytes)
  (isys:%sys-read fd buf nbytes))

(defun default-write-fn (fd buf nbytes)
  (isys:%sys-write fd buf nbytes))

(defclass dual-channel-fd-mixin ()
  ((input-fd  :initform nil :initarg :input-fd :accessor input-fd-of
              :documentation "placeholder")
   (read-fn :initform #'default-read-fn :initarg :read-fn :accessor read-fn-of)
   (output-fd :initform nil :initarg :output-fd :accessor output-fd-of
              :documentation "placeholder")
   (write-fn :initform #'default-write-fn :initarg :write-fn :accessor write-fn-of))
  (:documentation "placeholder"))

{'fraction_non_alphanumeric': 0.17727688090161436, 'fraction_numerical': 0.021321961620469083, 'mean_word_length': 3.618846694796062, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5423978', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1145, 'n_words': 291}