-
Notifications
You must be signed in to change notification settings - Fork 19
/
closer-mcl.lisp
47 lines (40 loc) · 1.69 KB
/
closer-mcl.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
45
46
47
(in-package :closer-mop)
;; We need a new standard-class for various things.
(defclass standard-class (cl:standard-class) ())
(define-validate-superclass-method standard-class cl:standard-class)
(defmethod ccl::create-reader-method-function
((class standard-class)
(reader-method-class standard-reader-method)
(dslotd standard-direct-slot-definition))
(let ((slot-name (slot-definition-name dslotd)))
(compile nil `(lambda (object) (slot-value object ',slot-name)))))
(defmethod ccl::create-writer-method-function
((class standard-class)
(writer-method-class standard-writer-method)
(dslotd standard-direct-slot-definition))
(let ((slot-name (slot-definition-name dslotd)))
(compile nil `(lambda (new-value object)
(setf (slot-value object ',slot-name) new-value)))))
(defgeneric typep (object type)
(:method (object type)
(cl:typep object type))
(:method (object (type class))
(member (class-of object)
(class-precedence-list type))))
(defgeneric subtypep (type1 type2)
(:method (type1 type2)
(cl:subtypep type1 type2))
(:method ((type1 class) (type2 symbol))
(let ((class2 (find-class type2 nil)))
(if class2
(member class2 (class-precedence-list type1))
(cl:subtypep type1 type2))))
(:method ((type1 symbol) (type2 class))
(let ((class1 (find-class type1 nil)))
(if class1
(member type2 (class-precedence-list class1))
(cl:subtypep type1 type2))))
(:method ((type1 class) (type2 class))
(member type2 (class-precedence-list type1))))
(eval-when (:compile-toplevel :load-toplevel :execute)
(pushnew :closer-mop *features*))