From e82044bca1b6cfe495de93abbff727a5b41359b8 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Tue, 22 Sep 2015 11:27:11 +0100 Subject: [PATCH] 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. --- src/output-impl.lisp | 12 ++++++++++++ src/output-proto.lisp | 3 +-- 2 files changed, 13 insertions(+), 2 deletions(-) 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 @@ (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 @@ (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 -- 2.11.0