Skip to content

Commit 07d38a6

Browse files
committed
Add Lispworks support
1 parent 78050f4 commit 07d38a6

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

exit-hooks.lisp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
(in-package #:exit-hooks)
44

5-
#-(or sbcl ccl ecl abcl allegro clisp cmu)
5+
#-(or sbcl ccl ecl abcl allegro clisp cmu lispworks)
66
(error "Sorry, not implement for ~a. If you can provide exit-hooks for your implementation, please contact me at icerove@gmail.com~%" (lisp-implementation-type))
77

88
#+abcl
@@ -11,7 +11,7 @@
1111

1212
(defun %abcl-exit-hook-controller ()
1313
(mapc #'funcall *abcl-exit-hooks*))
14-
14+
1515
(defparameter *exit-hook-thread*
1616
(java:jnew-runtime-class "ExitHookThread" :superclass "java.lang.Thread"
1717
:methods `(("run" :void () ,#'(lambda (this)
@@ -20,6 +20,7 @@
2020
(java:jcall "addShutdownHook" (java:jstatic "getRuntime" "java.lang.Runtime")
2121
(java:jnew *exit-hook-thread*)))
2222

23+
#-lispworks
2324
(define-symbol-macro *exit-hooks*
2425
#+sbcl sb-ext:*exit-hooks*
2526
#+ccl ccl:*lisp-cleanup-functions*
@@ -29,7 +30,19 @@
2930
#+clisp custom:*fini-hooks*
3031
#+cmu lisp::*cleanup-functions*)
3132

33+
#+lispworks
34+
(defvar *exit-hooks* nil)
35+
36+
#+lispworks
37+
(defun lw-exit-action ()
38+
(dolist (hook *exit-hooks*)
39+
(funcall hook)))
40+
41+
#+lispworks
42+
(lw:define-action "When quitting image" "Run exit hooks"
43+
'lw-exit-action)
44+
3245
(defun add-exit-hook (func)
33-
(push #+allegro (list 'funcall func)
46+
(push #+allegro (list 'funcall func)
3447
#-allegro func
3548
*exit-hooks*))

0 commit comments

Comments
 (0)