Changeset 12164


Ignore:
Timestamp:
May 30, 2009, 2:42:40 PM (10 years ago)
Author:
mikel
Message:

SLIME can now request that CCL load and start swank, and automatically connect the SLIME session to the resulting swank server. The UI for this process is still severely impoverished and, in fact, wrong.

Location:
trunk/source/cocoa-ide
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/cocoa-ide/swank-ccl-ide.el

    r12156 r12164  
    2525(defvar *ccl-swank-listener-proc* nil)
    2626
    27 
     27(defvar *ccl-swank-output* nil)
    2828;;; TODO: make this filter function start up a connection to
    2929;;;       the CCL swank server if it reads a success message,
     
    3131;;;       failure message
    3232(defun slime-ccl-swank-filter (process string)
    33   (message (concat "CCL swank listener: " string)))
     33  (let* ((status (read string))
     34         (active? (plist-get status :active)))
     35    (if active?
     36        (let ((port (plist-get status :port)))
     37          (slime-connect *ccl-swank-listener-host* port)))))
    3438
    3539(defvar $emacs-ccl-swank-request-marker "[emacs-ccl-swank-request]")
    3640
    37 (defun request-ccl-load-swank (&optional host listener-port connection-port )
     41(defun request-ccl-load-swank (&optional host listener-port connection-port loader-path)
    3842  (let* ((host (or host *ccl-swank-listener-host*))
    3943         (listener-port (or listener-port *ccl-swank-listener-port*))
    4044         (connection-port (or connection-port slime-port))
    41          (ping (concat $emacs-ccl-swank-request-marker (format "%d" connection-port) ":" (swank-loader-path) "\n"))
     45         (loader-path (or loader-path (swank-loader-path)))
     46         (ping (concat $emacs-ccl-swank-request-marker (format "%d" connection-port) ":" loader-path "\n"))
    4247         (ccl-proc (open-network-stream "SLIME CCL Swank" nil host listener-port)))
    4348    (setq *ccl-swank-listener-proc* ccl-proc)
  • trunk/source/cocoa-ide/swank.lisp

    r12156 r12164  
    160160  (swank-active? status))
    161161
    162 (defun send-swank-ready (tcp-stream swank-status)
    163   (let ((response (format nil "(:active t :loader ~S :port ~D)"
    164                           (swank-requested-loader swank-status)
    165                           (swank-requested-port swank-status))))
     162(defun send-swank-response (tcp-stream status)
     163  (let ((response (format nil "(:active ~S :loader ~S :port ~D)"
     164                          (swank-active? status)
     165                          (swank-requested-loader status)
     166                          (swank-requested-port status))))
    166167    (format tcp-stream response)
    167     (force-output)))
    168 
    169 (defun send-swank-load-failed (tcp-stream swank-status)
    170   (let ((response (format nil "(:active nil :loader ~S :port ~D)"
    171                           (swank-requested-loader swank-status)
    172                           (swank-requested-port swank-status))))
    173     (format tcp-stream response)
    174     (force-output)))
     168    (finish-output tcp-stream)))
    175169
    176170(defun handle-swank-client (c)
     
    178172    (multiple-value-bind (swank-path requested-port)
    179173        (parse-swank-ping msg)
    180       (let* ((swank-status (load-and-start-swank swank-path requested-port)))
    181         (if (swank-ready? swank-status)
    182             (send-swank-ready c swank-status)
    183             (send-swank-load-failed c swank-status))))))
     174      (load-and-start-swank swank-path requested-port))))
    184175
    185176;;; the real deal
     
    187178;;; if it fails, it returns a CONDITION object
    188179(defun start-swank-listener (&optional (port *default-swank-listener-port*))
    189   (handler-case (with-open-socket (sock :type :stream :connect :passive :local-port port :reuse-address t)
     180  (handler-case (with-open-socket (sock :type :stream :connect :passive :local-port port :reuse-address t :auto-close t)
    190181                  (loop
    191182                     (format t "~%swank listener loop...")
    192183                     (force-output)
    193                      (let ((client-sock (accept-connection sock)))
    194                        (process-run-function "CCL Swank Listener"
    195                                              #'handle-swank-client client-sock))))
     184                     (let* ((client-sock (accept-connection sock))
     185                            (status (handle-swank-client client-sock)))
     186                       (send-swank-response client-sock status))))
    196187    (ccl::socket-creation-error (c) (nslog-condition c "Unable to create a socket for the swank-listener: ") c)
    197188    (ccl::socket-error (c) (nslog-condition c "Swank-listener failed trying to accept a client conection: ") c)
    198     (serious-condition (c) (nslog-condition c "Unable to start up the swank listener") c)))
     189    (serious-condition (c) (nslog-condition c "Error in the swank-listener:") c)))
    199190
    200191;;; maybe-start-swank-listener
Note: See TracChangeset for help on using the changeset viewer.