From 24da4e8114654b9d990c93116abb3988909ac102 Mon Sep 17 00:00:00 2001 From: reuter Date: Fri, 5 Aug 2005 21:37:15 +0000 Subject: [PATCH] * lily/ligature-engaver.cc, lily/coherent-ligature-engaver.cc, lily/gregorian-ligature-engaver.cc, lily/include/ligature-engraver.hh, lily/include/coherent-ligature-engraver.hh, lily/include/gregorian-ligature-engraver.hh: make these classes truely abstract. This should fix some internal oddities such as duplicate as well as dead translator/property declarations, and also some dead code. * lily/ligature-bracket-engraver.cc, lily/ligature-engraver.cc: bugfix: avoid message "junking empty ligature" on ligature brackets by collecting dummy grobs. --- ChangeLog | 15 +++++++++ lily/coherent-ligature-engraver.cc | 24 ++------------ lily/gregorian-ligature-engraver.cc | 20 ++---------- lily/include/coherent-ligature-engraver.hh | 5 +-- lily/include/gregorian-ligature-engraver.hh | 6 ++-- lily/include/ligature-engraver.hh | 24 +++----------- lily/ligature-bracket-engraver.cc | 12 +++++++ lily/ligature-engraver.cc | 35 +++++---------------- 8 files changed, 50 insertions(+), 91 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3bf1d552f1..daa9720efd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2005-08-05 Jürgen Reuter + + * lily/ligature-engaver.cc, lily/coherent-ligature-engaver.cc, + lily/gregorian-ligature-engaver.cc, + lily/include/ligature-engraver.hh, + lily/include/coherent-ligature-engraver.hh, + lily/include/gregorian-ligature-engraver.hh: make these classes + truely abstract. This should fix some internal oddities such as + duplicate as well as dead translator/property declarations, and + also some dead code. + + * lily/ligature-bracket-engraver.cc, lily/ligature-engraver.cc: + bugfix: avoid message "junking empty ligature" on ligature + brackets by collecting dummy grobs. + 2005-08-05 Han-Wen Nienhuys * lily/tuplet-bracket.cc (print): default right overshoot to 0.0 diff --git a/lily/coherent-ligature-engraver.cc b/lily/coherent-ligature-engraver.cc index 0d777f3754..ed89983026 100644 --- a/lily/coherent-ligature-engraver.cc +++ b/lily/coherent-ligature-engraver.cc @@ -105,10 +105,6 @@ if (incr_scm != SCM_EOL) /* (Paper_column::is_musical (l)) */ } #endif -Coherent_ligature_engraver::Coherent_ligature_engraver () -{ -} - /* * TODO: move this function to class Item? */ @@ -196,14 +192,6 @@ compute_delta_pitches (Array primitives) primitive->set_property ("delta-pitch", scm_from_int (0)); } -void -Coherent_ligature_engraver::build_ligature (Spanner *, Array) -{ - programming_error ("Coherent_ligature_engraver::build_ligature (): " - "this is an abstract method that should not be called, " - "but overridden by a subclass"); -} - void Coherent_ligature_engraver::typeset_ligature (Spanner *ligature, Array primitives) @@ -217,13 +205,5 @@ Coherent_ligature_engraver::typeset_ligature (Spanner *ligature, collect_accidentals (ligature, primitives); } -#include "translator.icc" - -ADD_ACKNOWLEDGER (Coherent_ligature_engraver, note_head); -ADD_ACKNOWLEDGER (Coherent_ligature_engraver, rest); -ADD_TRANSLATOR (Coherent_ligature_engraver, - /* descr */ "This is an abstract class. Subclasses such as Gregorian_ligature_engraver handle ligatures by glueing special ligature heads together.", - /* creats*/ "", - /* accepts */ "ligature-event", - /* reads */ "", - /* write */ ""); +// no ADD_ACKNOWLEDGER / ADD_ACKNOWLEDGER / ADD_TRANSLATOR macro calls +// since this class is abstract diff --git a/lily/gregorian-ligature-engraver.cc b/lily/gregorian-ligature-engraver.cc index a38c9ef095..29690da2f9 100644 --- a/lily/gregorian-ligature-engraver.cc +++ b/lily/gregorian-ligature-engraver.cc @@ -245,14 +245,6 @@ provide_context_info (Array primitives) scm_from_int (prev_context_info)); } -void -Gregorian_ligature_engraver::transform_heads (Spanner *, Array) -{ - programming_error ("Gregorian_ligature_engraver::transform_heads (): " - "this is an abstract method that should not be called, " - "but overridden by a subclass"); -} - void Gregorian_ligature_engraver::build_ligature (Spanner *ligature, Array primitives) @@ -273,13 +265,5 @@ Gregorian_ligature_engraver::stop_translation_timestep () pes_or_flexa_req_ = 0; } -#include "translator.icc" - -ADD_ACKNOWLEDGER (Gregorian_ligature_engraver, rest); -ADD_ACKNOWLEDGER (Gregorian_ligature_engraver, note_head); -ADD_TRANSLATOR (Gregorian_ligature_engraver, - /* descr */ "This is an abstract class. Subclasses such as Vaticana_ligature_engraver handle ligatures by glueing special ligature heads together.", - /* creats*/ "", - /* accepts */ "ligature-event", - /* reads */ "", - /* write */ ""); +// no ADD_ACKNOWLEDGER / ADD_ACKNOWLEDGER / ADD_TRANSLATOR macro calls +// since this class is abstract diff --git a/lily/include/coherent-ligature-engraver.hh b/lily/include/coherent-ligature-engraver.hh index c90677aac7..6fcbdd6244 100644 --- a/lily/include/coherent-ligature-engraver.hh +++ b/lily/include/coherent-ligature-engraver.hh @@ -13,11 +13,12 @@ class Coherent_ligature_engraver : public Ligature_engraver { public: - TRANSLATOR_DECLARATIONS (Coherent_ligature_engraver); + // no TRANSLATOR_DECLARATIONS (Coherent_ligature_engraver) needed + // since this class is abstract protected: virtual void build_ligature (Spanner *ligature, - Array primitives); /* abstract */ + Array primitives) = 0; virtual void typeset_ligature (Spanner *ligature, Array primitives); virtual void get_set_column (Item *, Paper_column *); diff --git a/lily/include/gregorian-ligature-engraver.hh b/lily/include/gregorian-ligature-engraver.hh index efcb73ae16..9a8ae4c217 100644 --- a/lily/include/gregorian-ligature-engraver.hh +++ b/lily/include/gregorian-ligature-engraver.hh @@ -15,13 +15,15 @@ class Gregorian_ligature_engraver : public Coherent_ligature_engraver Music *pes_or_flexa_req_; public: - TRANSLATOR_DECLARATIONS (Gregorian_ligature_engraver); + // no TRANSLATOR_DECLARATIONS (Gregorian_ligature_engraver) needed + // since this class is abstract protected: + Gregorian_ligature_engraver (); virtual bool try_music (Music *); virtual void build_ligature (Spanner *ligature, Array primitives); virtual void transform_heads (Spanner *ligature, - Array primitives); /* abstract method */ + Array primitives) = 0; void stop_translation_timestep (); }; diff --git a/lily/include/ligature-engraver.hh b/lily/include/ligature-engraver.hh index 80c8537af6..ce3cba4aa8 100644 --- a/lily/include/ligature-engraver.hh +++ b/lily/include/ligature-engraver.hh @@ -11,25 +11,10 @@ #include "engraver.hh" #include "moment.hh" - -/* - * FIXME: Spanner *create_ligature_spanner () and virtual void - * typeset_ligature (...) are abstract methods, such that we would - * like to declare them abstract: - * - * virtual Spanner *create_ligature_spanner () = 0; - * virtual void typeset_ligature (...) = 0; - * - * Unfortunately, clone_const_helper() (as expanded from the - * TRANSLATOR_DECLARATIONS macro) requires this class to be - * instantiatable, such that it may not have any abstract virtual - * functions. As a workaround, the actually abstract methods are - * implemented, but produce a programming_error whenever called. --jr - */ - class Ligature_engraver : public Engraver { protected: + Ligature_engraver (); void stop_translation_timestep (); virtual void finalize (); @@ -38,14 +23,15 @@ protected: DECLARE_ACKNOWLEDGER (note_head); virtual bool try_music (Music *); void process_music (); - virtual Spanner *create_ligature_spanner (); /* abstract method */ + virtual Spanner *create_ligature_spanner () = 0; virtual void typeset_ligature (Spanner *ligature, - Array primitives); /* abstract method */ + Array primitives) = 0; virtual Spanner *current_ligature (); SCM brew_ligature_primitive_proc; public: - TRANSLATOR_DECLARATIONS (Ligature_engraver); + // no TRANSLATOR_DECLARATIONS (Ligature_engraver) needed since this + // class is abstract private: Drul_array events_drul_; diff --git a/lily/ligature-bracket-engraver.cc b/lily/ligature-bracket-engraver.cc index b483f66058..13a9e72ccb 100644 --- a/lily/ligature-bracket-engraver.cc +++ b/lily/ligature-bracket-engraver.cc @@ -21,6 +21,8 @@ class Ligature_bracket_engraver : public Ligature_engraver { protected: virtual Spanner *create_ligature_spanner (); + virtual void typeset_ligature (Spanner *ligature, + Array primitives); DECLARE_ACKNOWLEDGER (rest); DECLARE_ACKNOWLEDGER (note_column); public: @@ -37,6 +39,12 @@ Ligature_bracket_engraver::create_ligature_spanner () return make_spanner ("LigatureBracket", SCM_EOL); } +void +Ligature_bracket_engraver::typeset_ligature (Spanner *, Array) +{ + // no real ligature to typeset; the LigatureBracket just does it +} + void Ligature_bracket_engraver::acknowledge_note_column (Grob_info info) { @@ -44,6 +52,10 @@ Ligature_bracket_engraver::acknowledge_note_column (Grob_info info) { Tuplet_bracket::add_column (current_ligature (), dynamic_cast (info.grob ())); + + // avoid "junking empty ligature" message by acknowledging dummy + // note head + Ligature_engraver::acknowledge_note_head (Grob_info ()); } } diff --git a/lily/ligature-engraver.cc b/lily/ligature-engraver.cc index d200e65ba3..e13798034b 100644 --- a/lily/ligature-engraver.cc +++ b/lily/ligature-engraver.cc @@ -89,15 +89,6 @@ Ligature_engraver::try_music (Music *m) return false; } -Spanner * -Ligature_engraver::create_ligature_spanner () -{ - programming_error ("Ligature_engraver::create_ligature_spanner (): " - "this is an abstract method that should not be called, " - "but overridden by a subclass"); - return 0; -} - /* * This method should do something that comes close to the following * .ly snippet: @@ -214,14 +205,6 @@ Ligature_engraver::process_music () } } -void -Ligature_engraver::typeset_ligature (Spanner *, Array) -{ - programming_error ("Ligature_engraver::typeset_ligature (): " - "this is an abstract method that should not be called, " - "but overridden by a subclass"); -} - void Ligature_engraver::stop_translation_timestep () { @@ -272,8 +255,11 @@ Ligature_engraver::acknowledge_note_head (Grob_info info) if (ligature_) { primitives_.push (info); - info.grob ()->set_property ("print-function", - brew_ligature_primitive_proc); + if (info.grob ()) + { + info.grob ()->set_property ("print-function", + brew_ligature_primitive_proc); + } } } @@ -289,12 +275,5 @@ Ligature_engraver::acknowledge_rest (Grob_info info) } } - -ADD_ACKNOWLEDGER (Ligature_engraver, rest); -ADD_ACKNOWLEDGER (Ligature_engraver, note_head); -ADD_TRANSLATOR (Ligature_engraver, - /* descr */ "Abstract class; a concrete subclass handles Ligature_events by engraving Ligatures in a concrete style.", - /* creats */ "", - /* accepts */ "ligature-event", - /* reads */ "", - /* write */ ""); +// no ADD_ACKNOWLEDGER / ADD_ACKNOWLEDGER / ADD_TRANSLATOR macro calls +// since this class is abstract -- 2.39.5