From: Mark Wooding Date: Tue, 22 Sep 2015 10:27:11 +0000 (+0100) Subject: src/output-{proto,impl}.lisp: `sequencer''s :constraints initarg takes names. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/commitdiff_plain/e82044bca1b6cfe495de93abbff727a5b41359b8?ds=sidebyside src/output-{proto,impl}.lisp: `sequencer''s :constraints initarg takes names. The `constraints' slot of a `sequencer' object maintains a list of constraints, each of which is a list of `sequencer-item' objects, and this list is ordered with the most-recently added constraint first. Previously the :constraints initarg just set this list directly, which isn't really very satisfactory. Instead, handle the initarg specially, reversing it, and converting item names into the actual items, interning them properly. This isn't completely right, because there's no way at this time to attach handler functions to the implicitly created items, but it's way better than nothing. --- diff --git a/src/output-impl.lisp b/src/output-impl.lisp index df42115..7c3f436 100644 --- a/src/output-impl.lisp +++ b/src/output-impl.lisp @@ -32,6 +32,18 @@ (defmethod print-object ((item sequencer-item) stream) (print-unreadable-object (item stream :type t) (prin1 (sequencer-item-name item) stream))) +(defmethod shared-initialize ((sequencer sequencer) slot-names + &key (constraints nil constraintsp)) + (call-next-method) + (when constraintsp + (setf (slot-value sequencer 'constraints) + (mapcar (lambda (constraint) + (mapcar (lambda (name) + (ensure-sequencer-item sequencer name)) + constraint)) + (reverse constraints)))) + sequencer) + (defmethod ensure-sequencer-item ((sequencer sequencer) name) (with-slots (table) sequencer (or (gethash name table) diff --git a/src/output-proto.lisp b/src/output-proto.lisp index 65068f3..a87c7c0 100644 --- a/src/output-proto.lisp +++ b/src/output-proto.lisp @@ -41,8 +41,7 @@ (defstruct (sequencer-item (export '(sequencer sequencer-constraints sequencer-table)) (defclass sequencer () - ((constraints :initarg :constraints :initform nil - :type list :accessor sequencer-constraints) + ((constraints :initform nil :type list :accessor sequencer-constraints) (table :initform (make-hash-table :test #'equal) :reader sequencer-table)) (:documentation