Skip to content

Commit

Permalink
Add copy-instance function
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Mar 7, 2018
1 parent 7a25149 commit d3f53df
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions toolkit.lisp
Expand Up @@ -76,6 +76,14 @@
(c2mop:finalize-inheritance class))
(c2mop:class-default-initargs class)))

(defmethod copy-instance ((instance standard-object) &key deep)
(let ((copy (allocate-instance (class-of instance))))
(loop for slot in (c2mop:class-slots (class-of instance))
for name = (c2mop:slot-definition-name slot)
for value = (slot-value instance name)
do (setf (slot-value copy name) (if deep (copy-instance value) value)))
copy))

(defun executable-directory ()
(pathname-utils:to-directory
(or (first (uiop:command-line-arguments))
Expand Down

0 comments on commit d3f53df

Please sign in to comment.