-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprocess-two-way-stream.lisp
28 lines (26 loc) · 1.18 KB
/
process-two-way-stream.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(defpackage :cl-smt-lib/process-two-way-stream
(:use :cl :cl-smt-lib/fundamental-two-way-stream :uiop/launch-program)
(:export :process-two-way-stream
:make-process-two-way-stream
:input
:output
:process))
(in-package :cl-smt-lib/process-two-way-stream)
;;; A process wrapped in a two-way stream.
(defclass process-two-way-stream (fundamental-two-way-stream)
((process :initarg :process :initform (error "process argument is required")
:reader process))
(:documentation
"A fundamental-two-way-stream wrapping a single process' input and output."))
(defun make-process-two-way-stream (program &rest args)
"Wrap PROCESS in an PROCESS-TWO-WAY-STREAM object."
(let ((process (launch-program (format nil "~{~a~^ ~}" (cons program args))
:input :stream
:output :stream
:wait nil
:search t)))
(make-instance 'process-two-way-stream
#+ALLEGRO :element-type #+ALLEGRO '(unsigned-byte 8)
:input (process-info-output process)
:output (process-info-input process)
:process process)))