summaryrefslogtreecommitdiff
path: root/lily
diff options
context:
space:
mode:
authorDavid Kastrup <dak@gnu.org>2016-06-20 20:37:46 +0200
committerDavid Kastrup <dak@gnu.org>2016-06-24 22:50:09 +0200
commit509f945ca92d53976bf024d999598cc53b5d1cdd (patch)
tree7c0ca78449c1f6ff6090204e5954873bb648c595 /lily
parent69f2bf94c9f57986769f6371bc63ee27a3e6c095 (diff)
Issue 4903/3: Restructure slur engravers
Replaces data members specific to derived classes of Slur_proto_engraver with virtual functions.
Diffstat (limited to 'lily')
-rw-r--r--lily/include/slur-proto-engraver.hh16
-rw-r--r--lily/phrasing-slur-engraver.cc32
-rw-r--r--lily/slur-engraver.cc31
-rw-r--r--lily/slur-proto-engraver.cc18
4 files changed, 65 insertions, 32 deletions
diff --git a/lily/include/slur-proto-engraver.hh b/lily/include/slur-proto-engraver.hh
index 61aef237e4..af4cacf030 100644
--- a/lily/include/slur-proto-engraver.hh
+++ b/lily/include/slur-proto-engraver.hh
@@ -27,12 +27,6 @@
class Slur_proto_engraver : public Engraver
{
protected:
- Slur_proto_engraver (const char* double_property_name,
- const char* grob_name, const char* object_name, const char* event_name) :
- double_property_name_ (double_property_name),
- grob_name_ (grob_name), object_name_ (object_name),
- event_name_ (event_name) {}
-
struct Event_info {
Stream_event *slur_, *note_;
Event_info (Stream_event *slur, Stream_event *note)
@@ -48,11 +42,11 @@ protected:
vector<Grob *> slurs_;
vector<Grob *> end_slurs_;
vector<Grob_info> objects_to_acknowledge_;
- const char* double_property_name_;
- const char* grob_name_;
- const char* object_name_;
- const char* event_name_;
- virtual SCM event_symbol () = 0;
+
+ virtual SCM event_symbol () const = 0;
+ virtual bool double_property () const = 0;
+ virtual SCM grob_symbol () const = 0;
+ virtual const char* object_name () const = 0;
void acknowledge_inline_accidental (Grob_info);
void acknowledge_fingering (Grob_info);
diff --git a/lily/phrasing-slur-engraver.cc b/lily/phrasing-slur-engraver.cc
index a9ed7be853..70b6dc764b 100644
--- a/lily/phrasing-slur-engraver.cc
+++ b/lily/phrasing-slur-engraver.cc
@@ -23,26 +23,46 @@
class Phrasing_slur_engraver : public Slur_proto_engraver
{
+ virtual SCM event_symbol () const;
+ virtual bool double_property () const;
+ virtual SCM grob_symbol () const;
+ virtual const char* object_name () const;
+
protected:
void listen_phrasing_slur (Stream_event *);
void acknowledge_slur (Grob_info);
public:
- SCM event_symbol ();
TRANSLATOR_DECLARATIONS (Phrasing_slur_engraver);
TRANSLATOR_INHERIT (Slur_proto_engraver);
};
-Phrasing_slur_engraver::Phrasing_slur_engraver () :
- Slur_proto_engraver (0, "PhrasingSlur", "phrasing slur", "phrasing-slur-event")
+SCM
+Phrasing_slur_engraver::event_symbol () const
{
+ return ly_symbol2scm ("phrasing-slur-event");
+}
+
+bool
+Phrasing_slur_engraver::double_property () const
+{
+ return false;
}
SCM
-Phrasing_slur_engraver::event_symbol ()
+Phrasing_slur_engraver::grob_symbol () const
+{
+ return ly_symbol2scm ("PhrasingSlur");
+}
+
+const char *
+Phrasing_slur_engraver::object_name () const
+{
+ return "phrasing slur";
+}
+
+Phrasing_slur_engraver::Phrasing_slur_engraver ()
{
- // Need a string constant for memoization
- return ly_symbol2scm ("phrasing-slur-event");
}
void
diff --git a/lily/slur-engraver.cc b/lily/slur-engraver.cc
index 359ab78ef9..88495f4de2 100644
--- a/lily/slur-engraver.cc
+++ b/lily/slur-engraver.cc
@@ -24,24 +24,43 @@
class Slur_engraver : public Slur_proto_engraver
{
+ virtual SCM event_symbol () const;
+ virtual bool double_property () const;
+ virtual SCM grob_symbol () const;
+ virtual const char * object_name () const;
virtual void set_melisma (bool);
public:
- SCM event_symbol ();
TRANSLATOR_DECLARATIONS (Slur_engraver);
TRANSLATOR_INHERIT (Slur_proto_engraver);
};
-Slur_engraver::Slur_engraver () :
- Slur_proto_engraver ("doubleSlurs", "Slur", "slur", "slur-event")
+SCM
+Slur_engraver::event_symbol () const
+{
+ return ly_symbol2scm ("slur-event");
+}
+
+bool
+Slur_engraver::double_property () const
{
+ return to_boolean (get_property ("doubleSlurs"));
}
SCM
-Slur_engraver::event_symbol ()
+Slur_engraver::grob_symbol () const
+{
+ return ly_symbol2scm ("Slur");
+}
+
+const char *
+Slur_engraver::object_name () const
+{
+ return "slur";
+}
+
+Slur_engraver::Slur_engraver ()
{
- // Need a string constant for memoization
- return ly_symbol2scm ("slur-event");
}
void
diff --git a/lily/slur-proto-engraver.cc b/lily/slur-proto-engraver.cc
index 99e8e8ebfc..6ba0df6b7c 100644
--- a/lily/slur-proto-engraver.cc
+++ b/lily/slur-proto-engraver.cc
@@ -58,7 +58,8 @@ Slur_proto_engraver::listen_slur (Stream_event *ev, Stream_event *note)
else if (d == STOP)
stop_events_.push_back (Event_info (ev, note));
else ev->origin ()->warning (_f ("direction of %s invalid: %d",
- event_name_, int (d)));
+ ev->name ().c_str (),
+ int (d)));
}
void
@@ -156,7 +157,7 @@ Slur_proto_engraver::finalize ()
{
for (vsize i = 0; i < slurs_.size (); i++)
{
- slurs_[i]->warning (_f ("unterminated %s", object_name_));
+ slurs_[i]->warning (_f ("unterminated %s", object_name ()));
slurs_[i]->suicide ();
}
slurs_.clear ();
@@ -169,7 +170,7 @@ Slur_proto_engraver::create_slur (const string &spanner_id, Event_info evi, Grob
? unsmob<Grob> (get_property ("currentCommandColumn"))
: 0; // efficiency
SCM cause = evi.slur_ ? evi.slur_->self_scm () : g_cause->self_scm ();
- Spanner *slur = make_spanner (grob_name_, cause);
+ Spanner *slur = make_spanner (grob_symbol (), cause);
slur->set_property ("spanner-id", ly_string2scm (spanner_id));
if (dir)
set_grob_direction (slur, dir);
@@ -179,11 +180,10 @@ Slur_proto_engraver::create_slur (const string &spanner_id, Event_info evi, Grob
if (evi.note_)
note_slurs_[START].insert (Note_slurs::value_type (evi.note_, slur));
- if (double_property_name_
- && to_boolean (get_property (double_property_name_)))
+ if (double_property ())
{
set_grob_direction (slur, DOWN);
- slur = make_spanner (grob_name_, cause);
+ slur = make_spanner (grob_symbol (), cause);
slur->set_property ("spanner-id", ly_string2scm (spanner_id));
set_grob_direction (slur, UP);
if (left_broken)
@@ -210,7 +210,7 @@ Slur_proto_engraver::can_create_slur (const string &id, vsize old_slurs, vsize *
{
// We already have an old slur, so give a warning
// and completely ignore the new slur.
- ev->origin ()->warning (_f ("already have %s", object_name_));
+ ev->origin ()->warning (_f ("already have %s", object_name ()));
if (event_idx)
start_events_.erase (start_events_.begin () + (*event_idx));
return false;
@@ -227,7 +227,7 @@ Slur_proto_engraver::can_create_slur (const string &id, vsize old_slurs, vsize *
if (!c)
{
- slur->programming_error (_f ("%s without a cause", object_name_));
+ slur->programming_error (_f ("%s without a cause", object_name ()));
return true;
}
@@ -294,7 +294,7 @@ Slur_proto_engraver::process_music ()
}
}
else
- stop_events_[i].slur_->origin ()->warning (_f ("cannot end %s", object_name_));
+ stop_events_[i].slur_->origin ()->warning (_f ("cannot end %s", object_name ()));
}
vsize old_slurs = slurs_.size ();