Skip to content

Commit 32f6926

Browse files
Adds a new macro, defsketchx, for adding additional superclasses.
1 parent 3ced63a commit 32f6926

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/package.lisp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
:draw
1616

1717
:defsketch
18+
:defsketchx
1819

1920
:sketch-title
2021
:sketch-width

src/sketch.lisp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@
269269

270270
;;; DEFSKETCH macro
271271

272-
(defun define-sketch-defclass (name bindings)
273-
`(defclass ,name (sketch)
272+
(defun define-sketch-defclass (name superclasses bindings)
273+
`(defclass ,name (sketch ,@superclasses)
274274
(,@(loop for b in bindings
275275
unless (eq 'sketch (binding-prefix b))
276276
collect `(,(binding-name b)
@@ -308,11 +308,17 @@
308308
collect `(,(binding-accessor b) *sketch*)
309309
collect (binding-name b)))))
310310

311+
(defmacro defsketchx (sketch-name superclasses binding-forms &body body)
312+
(make-defsketch sketch-name superclasses binding-forms body))
313+
311314
(defmacro defsketch (sketch-name binding-forms &body body)
315+
(make-defsketch sketch-name (list) binding-forms body))
316+
317+
(defun make-defsketch (sketch-name superclasses binding-forms body)
312318
(let ((bindings (parse-bindings sketch-name binding-forms
313319
(class-bindings (find-class 'sketch)))))
314320
`(progn
315-
,(define-sketch-defclass sketch-name bindings)
321+
,(define-sketch-defclass sketch-name superclasses bindings)
316322
,@(define-sketch-channel-observers bindings)
317323
,(define-sketch-prepare-method sketch-name bindings)
318324
,(define-sketch-draw-method sketch-name bindings body)

0 commit comments

Comments
 (0)