/[slime]/slime/swank-cmucl.lisp
ViewVC logotype

Diff of /slime/swank-cmucl.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by heller, Fri Oct 17 21:18:04 2003 UTC revision 1.9 by heller, Sun Oct 19 21:38:45 2003 UTC
# Line 43  Line 43 
43             (return count))))             (return count))))
44      (t (lisp::string-out-misc stream operation arg1 arg2))))      (t (lisp::string-out-misc stream operation arg1 arg2))))
45    
46    (defstruct (slime-input-stream
47                 (:include lisp::lisp-stream
48                           (lisp::n-bin #'slime-input-stream/n-bin)
49                           (lisp::in #'read-char) ; make read-line happy.
50                           (lisp::bin #'read-byte)
51                           (lisp::in-buffer
52                            (make-array lisp::in-buffer-length
53                                        :element-type '(unsigned-byte 8)))
54                           (lisp::in-index lisp::in-buffer-length))))
55    
56    (defvar *read-input-catch-tag* 0)
57    
58    (defun slime-input-stream/n-bin (stream buffer start requested eof-errorp)
59      (let ((*read-input-catch-tag* (1+ *read-input-catch-tag*)))
60        (send-to-emacs `(:read-input ,requested ,*read-input-catch-tag*))
61        (let ((input (catch *read-input-catch-tag*
62                       (read-from-emacs))))
63          (loop for c across input
64                for i from start
65                do (setf (aref buffer i) (char-code c)))
66          (length input))))
67    
68    (defslimefun take-input (tag input)
69      (throw tag input))
70    
71  (defun create-swank-server (port &key reuse-address (address "localhost"))  (defun create-swank-server (port &key reuse-address (address "localhost"))
72    "Create a SWANK TCP server."    "Create a SWANK TCP server."
73    (let* ((hostent (ext:lookup-host-entry address))    (let* ((hostent (ext:lookup-host-entry address))
# Line 60  Line 85 
85    
86  (defun setup-request-handler (socket)  (defun setup-request-handler (socket)
87    "Setup request handling for SOCKET."    "Setup request handling for SOCKET."
88    (let ((stream (sys:make-fd-stream socket    (let* ((stream (sys:make-fd-stream socket
89                                      :input t :output t                                      :input t :output t
90                                      :element-type 'unsigned-byte))                                      :element-type 'unsigned-byte))
91          (output (make-slime-output-stream)))           (input (make-slime-input-stream))
92             (output (make-slime-output-stream))
93             (io (make-two-way-stream input output)))
94      (system:add-fd-handler socket      (system:add-fd-handler socket
95                             :input (lambda (fd)                             :input (lambda (fd)
96                                      (declare (ignore fd))                                      (declare (ignore fd))
97                                      (serve-request stream output)))))                                      (serve-request stream output input io)))))
98    
99  (defun serve-request (*emacs-io* *slime-output*)  (defun serve-request (*emacs-io* *slime-output* *slime-input* *slime-io*)
100    "Read and process a request from a SWANK client.    "Read and process a request from a SWANK client.
101  The request is read from the socket as a sexp and then evaluated."  The request is read from the socket as a sexp and then evaluated."
102    (let ((completed nil))    (let ((completed nil))

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.5