Move swank related code to a new debug module
This commit is contained in:
parent
230566830d
commit
11f65bdb09
3 changed files with 46 additions and 11 deletions
42
src/debug.lisp
Normal file
42
src/debug.lisp
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#|
|
||||
This file is a part of stoe project.
|
||||
Copyright (c) 2014 Renaud Casenave-Péré (renaud@casenave-pere.fr)
|
||||
|#
|
||||
|
||||
(in-package :cl-user)
|
||||
(defpackage stoe.debug
|
||||
(:nicknames :debug)
|
||||
(:use :cl
|
||||
:utils))
|
||||
(in-package :stoe.debug)
|
||||
|
||||
(defvar *swank-server-port* 4006)
|
||||
|
||||
(defun initialize (&optional argv)
|
||||
"Initialize the debug module.
|
||||
Check if the current thread is named `repl-thread' and if not,
|
||||
start the swank server to accept remote connection."
|
||||
(format t "Initialize Debug module~%")
|
||||
(when (not (string= (thread:thread-name (thread:current-thread)) "repl-thread"))
|
||||
#+swank
|
||||
(swank:create-server :port *swank-server-port* :dont-close nil)))
|
||||
|
||||
(defun finalize ()
|
||||
"Finalize the debug module."
|
||||
(format t "Finalize Debug module~%")
|
||||
(when (not (string= (thread:thread-name (thread:current-thread)) "repl-thread"))
|
||||
#+swank
|
||||
(swank:stop-server *swank-server-port*)))
|
||||
|
||||
(add-hook modules:*initialize-hook* #'initialize)
|
||||
(add-hook modules:*finalize-hook* #'finalize)
|
||||
|
||||
(defun update (delta-time)
|
||||
"Eval the repl each frame."
|
||||
#+swank
|
||||
(let ((conn (or swank::*emacs-connection*
|
||||
(swank::default-connection))))
|
||||
(when conn
|
||||
(swank::handle-requests conn t))))
|
||||
|
||||
(add-hook modules:*update-hook* #'update)
|
||||
|
|
@ -11,7 +11,6 @@
|
|||
:aif
|
||||
:awhen
|
||||
:restartable
|
||||
:eval-repl
|
||||
:add-hook :remove-hook :run-hook
|
||||
:update-current-time :get-delta-time
|
||||
:make-clock :clock-time :clock-delta
|
||||
|
|
@ -32,7 +31,7 @@
|
|||
,@body)))
|
||||
|
||||
(defmacro restartable (unprotected &body body)
|
||||
"Provide a Continue restart unless unprotected is t."
|
||||
"Provide a Continue restart unless `unprotected' is t."
|
||||
`(if ,unprotected
|
||||
(progn
|
||||
,@body)
|
||||
|
|
@ -41,14 +40,6 @@
|
|||
,@body)
|
||||
(continue () :report "Continue"))))
|
||||
|
||||
(defun eval-repl ()
|
||||
"Eval the repl if the main-loop is run through it."
|
||||
#+swank
|
||||
(let ((conn (or swank::*emacs-connection*
|
||||
(swank::default-connection))))
|
||||
(when conn
|
||||
(swank::handle-requests conn t))))
|
||||
|
||||
(defmacro add-hook (hook fun)
|
||||
"Setup `fun' to be called within specified `hook'."
|
||||
`(unless (member ,fun ,hook)
|
||||
|
|
|
|||
4
stoe.asd
4
stoe.asd
|
|
@ -18,7 +18,7 @@
|
|||
:version "0.1"
|
||||
:author "Renaud Casenave-Péré"
|
||||
:license "GPL3"
|
||||
:depends-on ()
|
||||
:depends-on (:swank)
|
||||
:components ((:module "src"
|
||||
:components
|
||||
((:file "thread")
|
||||
|
|
@ -26,6 +26,8 @@
|
|||
(:file "utils")
|
||||
(:file "modules"
|
||||
:depends-on ("utils"))
|
||||
(:file "debug"
|
||||
:depends-on ("modules" "thread"))
|
||||
(:file "jobs"
|
||||
:depends-on ("thread" "containers" "utils"))
|
||||
(:file "file"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue