Skip to content

Commit 4e396ae

Browse files
Adds a new macro, defsketchx, for adding additional superclasses.
1 parent 6b3681f commit 4e396ae

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
@@ -268,8 +268,8 @@
268268

269269
;;; DEFSKETCH macro
270270

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

310+
(defmacro defsketchx (sketch-name superclasses binding-forms &body body)
311+
(make-defsketch sketch-name superclasses binding-forms body))
312+
310313
(defmacro defsketch (sketch-name binding-forms &body body)
314+
(make-defsketch sketch-name (list) binding-forms body))
315+
316+
(defun make-defsketch (sketch-name superclasses binding-forms body)
311317
(let ((bindings (parse-bindings sketch-name binding-forms
312318
(class-bindings (find-class 'sketch)))))
313319
`(progn
314-
,(define-sketch-defclass sketch-name bindings)
320+
,(define-sketch-defclass sketch-name superclasses bindings)
315321
,@(define-sketch-channel-observers bindings)
316322
,(define-sketch-prepare-method sketch-name bindings)
317323
,(define-sketch-draw-method sketch-name bindings body)

0 commit comments

Comments
 (0)