Add defconstructor.
This commit is contained in:
parent
35888b9b26
commit
addde28629
|
@ -5,6 +5,7 @@
|
|||
:author "K. Isom <kyle@metacircular.net>"
|
||||
:license "MIT License"
|
||||
:serial t
|
||||
:depends-on (#:closer-mop)
|
||||
:components ((:file "package")
|
||||
(:file "on")
|
||||
(:file "lol")
|
||||
|
|
17
kutils.lisp
17
kutils.lisp
|
@ -75,11 +75,18 @@ additional args provided to the lambda."
|
|||
'()
|
||||
(apply #'build-slot-list name slots)))
|
||||
(args (build-arg-list slots)))
|
||||
`(progn
|
||||
(defclass ,name ,superclass
|
||||
,slots
|
||||
,docstring
|
||||
,@body))))
|
||||
`(defclass ,name ,superclass
|
||||
,slots
|
||||
,docstring
|
||||
,@body)))
|
||||
|
||||
(defmacro defconstructor (class-name)
|
||||
(let* ((class (find-class class-name))
|
||||
(slot-list (when class
|
||||
(mapcar #'closer-mop:slot-definition-name
|
||||
(closer-mop:class-slots class)))))
|
||||
`(defun ,(mksymb "make-" class-name) (&key ,@slot-list)
|
||||
(make-instance ',class-name ,@(flatten (build-arg-list slot-list))))))
|
||||
|
||||
;;; hash-table functions.
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#:mksymb
|
||||
#:mkkw
|
||||
#:defclass!
|
||||
#:defconstructor
|
||||
#:enable-hash-table-reader
|
||||
#:hashkeys
|
||||
#:sethash
|
||||
|
|
Loading…
Reference in New Issue