Skip to content

Commit

Permalink
Added DEFINE-CACHED-SLOTS-CLASS
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Feb 7, 2016
1 parent 808b0f6 commit dde4611
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 6 additions & 1 deletion class-slots.lisp
Expand Up @@ -21,7 +21,6 @@
(defmethod c2mop:validate-superclass ((class cached-slots-class) (superclass cached-slots-class))
T)


(defmethod initialize-instance :after ((class cached-slots-class) &key)
(setf (class-all-direct-slots class)
(compute-all-direct-slots class)))
Expand Down Expand Up @@ -52,3 +51,9 @@
(standard-class class)
(symbol (find-class class)))))
(nreverse slots)))

(defmacro define-cached-slots-class (name direct-superclasses direct-slots &rest options)
`(eval-when (:compile-toplevel :load-toplevel :execute)
(defclass ,name ,direct-superclasses ,direct-slots
,@options
(:metaclass cached-slots-class))))
8 changes: 8 additions & 0 deletions documentation.lisp
Expand Up @@ -54,6 +54,14 @@ is a CACHED-SLOTS-CLASS, the CLASS-ALL-DIRECT-SLOTS value is used
directly instead of traversing further. This does not apply for
the passed class.
See CACHED-SLOTS-CLASS")

((define-cached-slots-class)
"Shorthand macro around defclass to define a cached-slots-class.
All this does is wrap the defclass in an EVAL-WHEN and add the
metaclass option for cached-slots-class.
See CACHED-SLOTS-CLASS"))

(setdocs
Expand Down
3 changes: 2 additions & 1 deletion package.lisp
Expand Up @@ -12,7 +12,8 @@
(:export
#:cached-slots-class
#:class-all-direct-slots
#:compute-all-direct-slots)
#:compute-all-direct-slots
#:define-cached-slots-class)
;; command.lisp
(:export
#:command-event
Expand Down

0 comments on commit dde4611

Please sign in to comment.