src/output-{proto,impl}.lisp: `sequencer''s :constraints initarg takes names.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 22 Sep 2015 10:27:11 +0000 (11:27 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 8 Oct 2015 20:54:22 +0000 (21:54 +0100)
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
src/output-proto.lisp

index df42115..7c3f436 100644 (file)
   (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)
index 65068f3..a87c7c0 100644 (file)
@@ -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