1 (in-package :lisp-on-lines
)
4 (define-layered-class attribute
()
7 (defgeneric eval-attribute-initarg
(attribute initarg
)
11 (defmethod eval-attribute-initarg (attribute (initarg (eql :function
)))
13 (define-layered-function attribute-value
(object attribute
))
17 (deflayer LISP-ON-LINES
)
18 (ensure-active-layer 'lisp-on-lines
)
20 (defvar *standard-direct-slot-initarg-symbols
*
21 '(:layered
:class
:in-layer
:name
:readers
:writers
:initargs
:allow-other-keys
:special
))
23 (define-layered-function special-slot-values
(description slot-name
)
24 (:method-combination append
))
26 (define-layered-class attribute-special-layered-direct-slot-definition
27 (attribute contextl
::special-layered-direct-slot-definition
)
30 (defmethod shared-initialize :around
((instance attribute-special-layered-direct-slot-definition
) slots
&rest initargs
)
31 (setf (slot-value instance
'initargs
)
32 (apply #'arnesi
:remove-keywords initargs
*standard-direct-slot-initarg-symbols
*))
35 (define-layered-class standard-attribute
36 (attribute contextl
::layered-effective-slot-definition-in-layers
)
39 :layered-accessor description-of
)
42 :layered-accessor attribute-label
47 :layered-accessor attribute-function
53 (define-layered-method attribute-value
(object attribute
)
54 (funcall (attribute-function attribute
) object
))
56 (defmethod shared-initialize :around
((attribute standard-attribute
) slots
&rest initargs
)
57 (declare (ignore initargs
))
58 (setf (attribute-function attribute
)
60 (slot-value attribute
'value
)))
63 (defun attribute-name (attribute)
64 (closer-mop:slot-definition-name attribute
))
66 (define-layered-method slot-value-using-layer
67 ; :in-layer lisp-on-lines
68 :around
(class (attribute standard-attribute
) slot reader
)
69 (loop for
(key var
) on
(special-slot-values (slot-value attribute
'description
)
70 (attribute-name attribute
))
71 :if
(eq (closer-mop:slot-definition-name slot
) key
)
72 :do
(return-from slot-value-using-layer var
))
75 (define-layered-method display-using-description
76 ((attribute standard-attribute
) display object
&rest args
)
77 (declare (ignore args
))
78 (format display
"~@[~A ~]~A" (attribute-label attribute
)
79 (attribute-value object attribute
)))