aboutsummaryrefslogtreecommitdiff
path: root/src/standard-hooks.lisp
blob: fcf1367075c78f67f6ec84927d7cefad9a9f2be8 (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
;;;; standard-hooks.lisp -- built-in hooks for standard def* macros

(in-package :testiere)

;;; DEFSTRUCT

;; (defstruct moo
;;   #+testiere
;;   (:tests ...)
;;   a b c)

(register-hook
 'cl:defstruct
 #'standard-extractor)

;;; DEFCLASS

;; (defclass fooar ()
;;   (slots...)
;;   #+testiere
;;   (:tests ...))

(defun defclass-restarts-expander (form)
  (let ((name (second form)))
    `((make-unbound
       ()
       (setf (find-class ',name) nil)))))

(register-hook
 'cl:defclass
 #'standard-extractor
 #'defclass-restarts-expander)

;;; DEFMETHOD

;; (defmethod okwhat ((x moo) (y bar) z)
;;   "Here's a method"
;;   #+testiere
;;   (:tests ...)
;;   (flah  (moo-blah x) (barbar y)))

(register-hook 'cl:defmethod #'standard-extractor)

;;; DEFUN

;; (defun add3 (x y z)
;;   "Adds three thigns"
;;   #+testiere
;;   (:tests ...)
;;   (+ x y z))

(defun defun-restarts-expander (form)
  (let ((name (second form)))
    `((make-unbound
       ()
       (fmakunbound ',name)))))

(register-hook 'cl:defun #'standard-extractor #'defun-restarts-expander)

;;; DEFTYPE

;; (deftype optional-number ()
;;   "Its a number, or not"
;;   #+testiere
;;   (:tests ...)
;;   `(or number null))

(register-hook 'cl:deftype #'standard-extractor)