summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Chou <starrynte@gmail.com>2016-07-25 17:45:29 -0700
committerDavid Kastrup <dak@gnu.org>2016-08-13 19:07:35 +0200
commit12b68a3172f040e768b7d229aa14fb4838e75742 (patch)
tree34958b013f03e4b9e95c7b43bd7d411224cf10f2
parentbd455870308f261a3b87c47a4a0077ea56a4e6fe (diff)
Issue 4954/1: Change spanner-id to be a key instead of a string
Also changes argument \= to be a key. Backport-by: David Kastrup <dak@gnu.org>
-rw-r--r--Documentation/notation/expressive.itely3
-rw-r--r--lily/include/slur-engraver.hh4
-rw-r--r--lily/slur-engraver.cc22
-rw-r--r--ly/grace-init.ly4
-rw-r--r--ly/spanners-init.ly11
-rw-r--r--scm/define-grob-properties.scm2
-rw-r--r--scm/define-grobs.scm2
-rw-r--r--scm/define-music-properties.scm2
-rw-r--r--scm/define-music-types.scm2
9 files changed, 22 insertions, 30 deletions
diff --git a/Documentation/notation/expressive.itely b/Documentation/notation/expressive.itely
index d3f0235246..3c249389c2 100644
--- a/Documentation/notation/expressive.itely
+++ b/Documentation/notation/expressive.itely
@@ -685,7 +685,8 @@ occurences of outer slurs actually indicate phrasing, and phrasing
slurs may overlap a regular slur, see @ref{Phrasing slurs}. When
multiple regular slurs are needed in a single @code{Voice},
matching slur starts and ends need to be labelled by preceding
-them with @code{\=} followed by an identifying number or string.
+them with @code{\=} followed by an identifying key (a symbol or
+non-negative integer).
@lilypond[verbatim,quote]
\fixed c' {
diff --git a/lily/include/slur-engraver.hh b/lily/include/slur-engraver.hh
index 572e7ea023..1885625ed9 100644
--- a/lily/include/slur-engraver.hh
+++ b/lily/include/slur-engraver.hh
@@ -60,8 +60,8 @@ protected:
void stop_translation_timestep ();
void process_music ();
- bool can_create_slur (const string&, vsize, vsize *, Stream_event *);
- void create_slur (const string &spanner_id, Event_info evi, Grob *g_cause, Direction dir, bool left_broken);
+ bool can_create_slur (SCM, vsize, vsize *, Stream_event *);
+ void create_slur (SCM spanner_id, Event_info evi, Grob *g_cause, Direction dir, bool left_broken);
bool try_to_end (Event_info evi);
virtual void set_melisma (bool);
diff --git a/lily/slur-engraver.cc b/lily/slur-engraver.cc
index 1a06ca6422..80ceb5f431 100644
--- a/lily/slur-engraver.cc
+++ b/lily/slur-engraver.cc
@@ -189,14 +189,14 @@ Slur_engraver::finalize ()
}
void
-Slur_engraver::create_slur (const string &spanner_id, Event_info evi, Grob *g_cause, Direction dir, bool left_broken)
+Slur_engraver::create_slur (SCM spanner_id, Event_info evi, Grob *g_cause, Direction dir, bool left_broken)
{
Grob *ccc = left_broken
? unsmob<Grob> (get_property ("currentCommandColumn"))
: 0; // efficiency
SCM cause = evi.slur_ ? evi.slur_->self_scm () : g_cause->self_scm ();
Spanner *slur = make_spanner (grob_symbol (), cause);
- slur->set_property ("spanner-id", ly_string2scm (spanner_id));
+ slur->set_property ("spanner-id", spanner_id);
if (dir)
set_grob_direction (slur, dir);
if (left_broken)
@@ -209,7 +209,7 @@ Slur_engraver::create_slur (const string &spanner_id, Event_info evi, Grob *g_ca
{
set_grob_direction (slur, DOWN);
slur = make_spanner (grob_symbol (), cause);
- slur->set_property ("spanner-id", ly_string2scm (spanner_id));
+ slur->set_property ("spanner-id", spanner_id);
set_grob_direction (slur, UP);
if (left_broken)
slur->set_bound (LEFT, ccc);
@@ -221,7 +221,7 @@ Slur_engraver::create_slur (const string &spanner_id, Event_info evi, Grob *g_ca
}
bool
-Slur_engraver::can_create_slur (const string &id, vsize old_slurs, vsize *event_idx, Stream_event *ev)
+Slur_engraver::can_create_slur (SCM id, vsize old_slurs, vsize *event_idx, Stream_event *ev)
{
for (vsize j = slurs_.size (); j--;)
{
@@ -229,7 +229,7 @@ Slur_engraver::can_create_slur (const string &id, vsize old_slurs, vsize *event_
Direction updown = to_dir (ev->get_property ("direction"));
// Check if we already have a slur with the same spanner-id.
- if (id == robust_scm2string (slur->get_property ("spanner-id"), ""))
+ if (ly_is_equal (id, slur->get_property ("spanner-id")))
{
if (j < old_slurs)
{
@@ -280,13 +280,13 @@ Slur_engraver::can_create_slur (const string &id, vsize old_slurs, vsize *event_
bool
Slur_engraver::try_to_end (Event_info evi)
{
- string id = robust_scm2string (evi.slur_->get_property ("spanner-id"), "");
+ SCM id = evi.slur_->get_property ("spanner-id");
// Find the slurs that are ended with this event (by checking the spanner-id)
bool ended = false;
for (vsize j = slurs_.size (); j--;)
{
- if (id == robust_scm2string (slurs_[j]->get_property ("spanner-id"), ""))
+ if (ly_is_equal (id, slurs_[j]->get_property ("spanner-id")))
{
ended = true;
end_slurs_.push_back (slurs_[j]);
@@ -305,16 +305,14 @@ Slur_engraver::process_music ()
{
for (vsize i = 0; i < stop_events_.size (); i++)
{
- string id = robust_scm2string
- (stop_events_[i].slur_->get_property ("spanner-id"), "");
+ SCM id = stop_events_[i].slur_->get_property ("spanner-id");
bool ended = try_to_end (stop_events_[i]);
if (ended)
{
// Ignore redundant stop events for this id
for (vsize j = stop_events_.size (); --j > i;)
{
- if (id == robust_scm2string
- (stop_events_[j].slur_->get_property ("spanner-id"), ""))
+ if (ly_is_equal (id, stop_events_[j].slur_->get_property ("spanner-id")))
stop_events_.erase (stop_events_.begin () + j);
}
}
@@ -326,7 +324,7 @@ Slur_engraver::process_music ()
for (vsize i = start_events_.size (); i--;)
{
Stream_event *ev = start_events_[i].slur_;
- string id = robust_scm2string (ev->get_property ("spanner-id"), "");
+ SCM id = ev->get_property ("spanner-id");
Direction updown = to_dir (ev->get_property ("direction"));
if (can_create_slur (id, old_slurs, &i, ev))
diff --git a/ly/grace-init.ly b/ly/grace-init.ly
index 6fe32f49fb..a46111e4d9 100644
--- a/ly/grace-init.ly
+++ b/ly/grace-init.ly
@@ -1,7 +1,7 @@
\version "2.17.6"
-startGraceSlur = #(make-music 'SlurEvent 'span-direction START 'spanner-id "grace")
-stopGraceSlur = #(make-music 'SlurEvent 'span-direction STOP 'spanner-id "grace")
+startGraceSlur = #(make-music 'SlurEvent 'span-direction START 'spanner-id 'grace)
+stopGraceSlur = #(make-music 'SlurEvent 'span-direction STOP 'spanner-id 'grace)
startGraceMusic = {
diff --git a/ly/spanners-init.ly b/ly/spanners-init.ly
index 756a55579e..8d8a69444f 100644
--- a/ly/spanners-init.ly
+++ b/ly/spanners-init.ly
@@ -1,18 +1,15 @@
\version "2.19.29"
"\\=" =
-#(define-event-function (id event) (number-or-string? ly:event?)
+#(define-event-function (id event) (key? ly:event?)
(_i "This sets the @code{spanner-id} property of the following
-@var{event} to the given @var{id} (numbers will be converted to a
-string). This can be used to tell LilyPond how to connect overlapping
+@var{event} to the given @var{id} (non-negative integer or symbol).
+This can be used to tell LilyPond how to connect overlapping
or parallel slurs or phrasing slurs within a single @code{Voice}.
@lilypond[quote,verbatim]
\\fixed c' { c\\=1( d\\=2( e\\=1) f\\=2) }
@end lilypond\n")
- (set! (ly:music-property event 'spanner-id)
- (if (number? id)
- (number->string id)
- id))
+ (set! (ly:music-property event 'spanner-id) id)
event)
startGroup = #(make-span-event 'NoteGroupingEvent START)
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index cb9103a6fc..7ca44b6f3d 100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -992,7 +992,7 @@ override:
\\override MultiMeasureRest
#'spacing-pair = #'(staff-bar . staff-bar)
@end example")
- (spanner-id ,string? "An identifier to distinguish concurrent spanners.")
+ (spanner-id ,key? "An identifier to distinguish concurrent spanners.")
(springs-and-rods ,boolean? "Dummy variable for triggering
spacing routines.")
(stacking-dir ,ly:dir? "Stack objects in which direction?")
diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index f525edd69a..6ca25b586e 100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -1787,7 +1787,6 @@
(height-limit . 2.0)
(minimum-length . 1.5)
(ratio . 0.333)
- (spanner-id . "")
(springs-and-rods . ,ly:spanner::set-spacing-rods)
(stencil . ,ly:slur::print)
(thickness . 1.1)
@@ -1957,7 +1956,6 @@
(line-thickness . 0.8)
(minimum-length . 1.5)
(ratio . 0.25)
- (spanner-id . "")
(springs-and-rods . ,ly:spanner::set-spacing-rods)
(stencil . ,ly:slur::print)
(thickness . 1.2)
diff --git a/scm/define-music-properties.scm b/scm/define-music-properties.scm
index 4df3f93340..f8c567d1fa 100644
--- a/scm/define-music-properties.scm
+++ b/scm/define-music-properties.scm
@@ -183,7 +183,7 @@ If zero, signals a beat containing varying durations.")
Options are @code{'text} and @code{'hairpin}.")
(span-text ,markup? "The displayed text for dynamic text
spanners (e.g., cresc.)")
- (spanner-id ,string? "Identifier to distinguish concurrent spanners.")
+ (spanner-id ,key? "Identifier to distinguish concurrent spanners.")
(start-callback ,procedure? "Function to compute the negative length
of starting grace notes. This property can only be defined as initializer
in @file{scm/@/define-music-types.scm}.")
diff --git a/scm/define-music-types.scm b/scm/define-music-types.scm
index e0190eda55..348bcd0e87 100644
--- a/scm/define-music-types.scm
+++ b/scm/define-music-types.scm
@@ -438,7 +438,6 @@ goes down).")
. ((description . "Start or end phrasing slur.
Syntax: @var{note}@code{\\(} and @var{note}@code{\\)}")
- (spanner-id . "")
(types . (post-event span-event event phrasing-slur-event))
))
@@ -570,7 +569,6 @@ Syntax: @code{\\skip} @var{duration}")
. ((description . "Start or end slur.
Syntax: @var{note}@code{(} and @var{note}@code{)}")
- (spanner-id . "")
(types . (post-event span-event event slur-event))
))