Skip to content

Commit 923ddbc

Browse files
committed
Add Lispworks support
1 parent 78050f4 commit 923ddbc

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

exit-hooks.lisp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
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

8+
9+
810
#+abcl
911
(progn
1012
(defparameter *abcl-exit-hooks* nil)
1113

1214
(defun %abcl-exit-hook-controller ()
1315
(mapc #'funcall *abcl-exit-hooks*))
14-
16+
1517
(defparameter *exit-hook-thread*
1618
(java:jnew-runtime-class "ExitHookThread" :superclass "java.lang.Thread"
1719
:methods `(("run" :void () ,#'(lambda (this)
@@ -20,6 +22,7 @@
2022
(java:jcall "addShutdownHook" (java:jstatic "getRuntime" "java.lang.Runtime")
2123
(java:jnew *exit-hook-thread*)))
2224

25+
#-lispworks
2326
(define-symbol-macro *exit-hooks*
2427
#+sbcl sb-ext:*exit-hooks*
2528
#+ccl ccl:*lisp-cleanup-functions*
@@ -29,7 +32,19 @@
2932
#+clisp custom:*fini-hooks*
3033
#+cmu lisp::*cleanup-functions*)
3134

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

0 commit comments

Comments
 (0)