comparison base/methods.lisp @ 151:30341910a67e

Add make-sequence-like for standard-composition (should make remove-if work) darcs-hash:20071107111403-f76cc-4b52a0c757c3861f3390b7447f992b2cff07e1bd.gz
author David Lewis <d.lewis@gold.ac.uk>
date Wed, 07 Nov 2007 11:14:03 +0000
parents b753a56c373b
children 3b588c566734
comparison
equal deleted inserted replaced
150:b8c73a9b9c10 151:30341910a67e
452 "Returns STANDARD-PERIOD given a real" 452 "Returns STANDARD-PERIOD given a real"
453 (make-standard-period duration-value)) 453 (make-standard-period duration-value))
454 (defmethod make-anchored-period ((onset-value real) (duration-value real)) 454 (defmethod make-anchored-period ((onset-value real) (duration-value real))
455 "Returns STANDARD-ANCHORED-PERIOD given a real" 455 "Returns STANDARD-ANCHORED-PERIOD given a real"
456 (make-standard-anchored-period onset-value duration-value)) 456 (make-standard-anchored-period onset-value duration-value))
457
458 ;; Needed by some sequence functions, notably remove-if.
459 (defmethod sequence:make-sequence-like :around ((o standard-composition) length
460 &key (initial-element nil iep)
461 (initial-contents nil icp))
462 " Around method for make-sequence-like, only with all slots
463 preserved from the source sequence (except onset and duration,
464 which are calculated afresh)."
465 (declare (ignore length initial-element initial-contents iep icp))
466 (let ((new-sequence (call-next-method))
467 (start) (finish))
468 ;; Get timing information
469 (sequence:dosequence (element new-sequence)
470 ;; Actually, this next bit is pretty stupid - I know this is
471 ;; ordered, so this bit could be replaced by
472 ;; (setf (timepoint new-sequence)
473 ;; (timepoint (elt new-sequence 0)))
474 ;; outside of the loop.
475 (when (or (not start)
476 (< (timepoint element) start))
477 (setf start (timepoint element)))
478 (when (or (not finish)
479 (> (timepoint (cut-off element))
480 finish))
481 (setf finish (timepoint (cut-off element)))))
482 (setf (timepoint new-sequence) start
483 (duration new-sequence) (- finish start))
484 (dolist (slotd (sb-mop:class-slots new-sequence) new-sequence)
485 (unless (or (equal (sb-mop:slot-definition-name slotd) 'time)
486 (equal (sb-mop:slot-definition-name slotd) 'interval))
487 (setf (sb-mop:slot-value-using-class (class-of new-sequence)
488 new-sequence
489 slotd)
490 (sb-mop:slot-value-using-class (class-of new-sequence)
491 o ;; if this isn't the same, we're lost anyway
492 slotd))))))