[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Remove Unfolded_repeat_iterator (issue 194100043 by address@hidden)
From: |
nine . fierce . ballads |
Subject: |
Remove Unfolded_repeat_iterator (issue 194100043 by address@hidden) |
Date: |
Fri, 09 Jan 2015 05:03:04 +0000 |
Reviewers: ,
Message:
Does this make sense? TIA.
Description:
Remove Unfolded_repeat_iterator and rely on Sequential_iterator with a
customized elements-callback which is factored out of
unfold-repeats-fully.
Please review this at https://codereview.appspot.com/194100043/
Affected files (+16, -76 lines):
D lily/unfolded-repeat-iterator.cc
M scm/define-music-callbacks.scm
M scm/define-music-types.scm
M scm/music-functions.scm
Index: lily/unfolded-repeat-iterator.cc
diff --git a/lily/unfolded-repeat-iterator.cc
b/lily/unfolded-repeat-iterator.cc
deleted file mode 100644
index
976861fa8bb16eea9b05c36b40e7d69e5a6b6d1e..0000000000000000000000000000000000000000
--- a/lily/unfolded-repeat-iterator.cc
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- This file is part of LilyPond, the GNU music typesetter.
-
- Copyright (C) 2002--2015 Han-Wen Nienhuys <address@hidden>
-
- LilyPond is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- LilyPond is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "music.hh"
-#include "sequential-iterator.hh"
-#include "context.hh"
-
-class Unfolded_repeat_iterator : public Sequential_iterator
-{
-public:
- DECLARE_SCHEME_CALLBACK (constructor, ());
-protected:
- virtual SCM get_music_list () const;
-};
-
-SCM
-Unfolded_repeat_iterator::get_music_list () const
-{
- SCM l = SCM_EOL;
- SCM *tail = &l;
-
- SCM body = get_music ()->get_property ("element");
- SCM alts = get_music ()->get_property ("elements");
- int alt_count = scm_ilength (alts);
- int rep_count = scm_to_int (get_music ()->get_property ("repeat-count"));
-
- for (int i = 0; i < rep_count; i++)
- {
- if (Music::is_smob (body))
- *tail = scm_cons (body, SCM_EOL);
-
- tail = SCM_CDRLOC (*tail);
-
- if (alt_count)
- {
- *tail = scm_cons (scm_car (alts), SCM_EOL);
- tail = SCM_CDRLOC (*tail);
- if (i >= rep_count - alt_count)
-
- alts = scm_cdr (alts);
- }
- }
-
- return l;
-}
-
-IMPLEMENT_CTOR_CALLBACK (Unfolded_repeat_iterator);
Index: scm/define-music-callbacks.scm
diff --git a/scm/define-music-callbacks.scm b/scm/define-music-callbacks.scm
index
0683abdb152b9927d625d6dde55ca1fa07341dbb..7e65125cb62c647510bb3bc149f74d4fe240c37c
100644
--- a/scm/define-music-callbacks.scm
+++ b/scm/define-music-callbacks.scm
@@ -34,6 +34,19 @@ to be used by the sequential-iterator"
(make-music 'BarCheck
'origin location))))
+(define (make-unfolded-set music)
+ (let ((n (ly:music-property music 'repeat-count))
+ (alts (ly:music-property music 'elements))
+ (body (ly:music-property music 'element)))
+ (cond ((<= n 0) '())
+ ((null? alts) (make-list n body))
+ (else
+ (concatenate
+ (zip (make-list n body)
+ (append! (make-list (max 0 (- n (length alts)))
+ (car alts))
+ alts)))))))
+
(define (make-volta-set music)
(let* ((alts (ly:music-property music 'elements))
(lalts (length alts))
Index: scm/define-music-types.scm
diff --git a/scm/define-music-types.scm b/scm/define-music-types.scm
index
b59e9ff0f187ef0616543316f528760b7e4321f4..d1795246b28a478029fac8236b6042bcfb10a008
100644
--- a/scm/define-music-types.scm
+++ b/scm/define-music-types.scm
@@ -718,7 +718,8 @@ brackets start and stop.")
(UnfoldedRepeatedMusic
. ((description . "Repeated music which is fully written (and
played) out.")
- (iterator-ctor . ,ly:unfolded-repeat-iterator::constructor)
+ (iterator-ctor . ,ly:sequential-iterator::constructor)
+ (elements-callback . ,make-unfolded-set)
(start-callback . ,ly:repeated-music::first-start)
(types . (general-music repeated-music unfolded-repeated-music))
(length-callback . ,ly:repeated-music::unfolded-music-length)
Index: scm/music-functions.scm
diff --git a/scm/music-functions.scm b/scm/music-functions.scm
index
4ba6c6517ba534fae13cb932f0a030ef893e14cf..1b679a7228ab964d4cd2bb1de76ccc5aef4c8bc6
100644
--- a/scm/music-functions.scm
+++ b/scm/music-functions.scm
@@ -400,18 +400,7 @@ beats to be distinguished."
(lambda (m)
(and (music-is-of-type? m 'unfolded-repeated-music)
(make-sequential-music
- (ly:music-deep-copy
- (let ((n (ly:music-property m 'repeat-count))
- (alts (ly:music-property m 'elements))
- (body (ly:music-property m 'element)))
- (cond ((<= n 0) '())
- ((null? alts) (make-list n body))
- (else
- (concatenate
- (zip (make-list n body)
- (append! (make-list (max 0 (- n (length alts)))
- (car alts))
- alts))))))))))
+ (ly:music-deep-copy (make-unfolded-set m)))))
(unfold-repeats music)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- Remove Unfolded_repeat_iterator (issue 194100043 by address@hidden),
nine . fierce . ballads <=