-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
hooks.lisp
44 lines (33 loc) · 1.52 KB
/
hooks.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(in-package #:org.shirakumo.radiance.lib.modularize)
(defvar *modularize-hooks* (make-hash-table :test 'eql))
(defvar *delete-hooks* (make-hash-table :test 'eql))
(defun modularize-hook (identifier)
(gethash identifier *modularize-hooks*))
(defun (setf modularize-hook) (function identifier)
(setf (gethash identifier *modularize-hooks*) function))
(defun remove-modularize-hook (identifier)
(remhash identifier *modularize-hooks*))
(defun call-modularize-hooks (package)
(loop for hook being the hash-values of *modularize-hooks*
do (funcall hook package)))
(defmacro define-modularize-hook ((modulevar &optional identifier) &body body)
`(eval-when (:compile-toplevel :load-toplevel :execute)
(setf (modularize-hook
(or ,identifier
(intern (package-name *package*) "KEYWORD")))
(lambda (,modulevar) ,@body))))
(defun delete-hook (identifier)
(gethash identifier *delete-hooks*))
(defun (setf delete-hook) (function identifier)
(setf (gethash identifier *delete-hooks*) function))
(defun remove-delete-hook (identifier)
(remhash identifier *delete-hooks*))
(defun call-delete-hooks (package)
(loop for hook being the hash-values of *delete-hooks*
do (funcall hook package)))
(defmacro define-delete-hook ((modulevar &optional identifier) &body body)
`(eval-when (:compile-toplevel :load-toplevel :execute)
(setf (delete-hook
(or ,identifier
(intern (package-name *package*) "KEYWORD")))
(lambda (,modulevar) ,@body))))