glyph-name-procedure if style != default. 3 % speed increase (wtk2-fugue1).
2005-07-19 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * lily/*-engraver.cc (various): remove double use of
+ PRECOMPUTED_VIRTUAL function: only use
+ start_translation_timestep() and stop_translation_timestep(), not
+ both.
+
* lily/break-substitution.cc (fast_substitute_grob_array): do
fast_substitute_grob_array for all unordered grob_arrays.
(substitute_grob): return Grob *. Saves packing/unpacking SCMs.
--- /dev/null
+/*
+ timing-engraver.cc -- implement Default_bar_line_engraver
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+#include "engraver.hh"
+#include "context.hh"
+#include "multi-measure-rest.hh"
+#include "grob.hh"
+#include "warn.hh"
+
+
+class Default_bar_line_engraver : public Engraver
+{
+protected:
+ /* Need to know whether we're advancing in grace notes, or not. */
+ Moment last_moment_;
+
+ PRECOMPUTED_VIRTUAL void start_translation_timestep ();
+ PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
+
+public:
+ TRANSLATOR_DECLARATIONS (Default_bar_line_engraver);
+};
+
+#include "translator.icc"
+
+ADD_TRANSLATOR (Default_bar_line_engraver,
+ "This engraver determines what kind of automatic bar lines should be produced, "
+ "and sets @code{whichBar} accordingly. It should be at the same "
+ "level as @ref{Timing_translator}. ",
+ /* creats*/ "",
+ /* accepts */ "",
+ /* acks */ "",
+ /* reads */
+ "measurePosition automaticBars whichBar barAlways defaultBarType "
+ "measureLength",
+ /* write */ "automaticBars");
+
+
+Default_bar_line_engraver::Default_bar_line_engraver ()
+{
+ last_moment_.main_part_ = Rational (-1);
+}
+
+void
+Default_bar_line_engraver::start_translation_timestep ()
+{
+ SCM automatic_bars = get_property ("automaticBars");
+ Moment now = now_mom ();
+ SCM which = get_property ("whichBar");
+
+ /* Set the first bar of the score? */
+ if (!scm_is_string (which))
+ which = SCM_EOL;
+
+ Moment mp = measure_position (context ());
+ bool start_of_measure = (last_moment_.main_part_ != now.main_part_
+ && !mp.main_part_);
+
+ if (!scm_is_string (which) && to_boolean (automatic_bars))
+ {
+ SCM always = get_property ("barAlways");
+
+ if ((start_of_measure && last_moment_.main_part_ >= Moment (0))
+ || to_boolean (always))
+ {
+ /* should this work, or be junked? See input/bugs/no-bars.ly */
+ which = get_property ("defaultBarType");
+ }
+ }
+
+ context ()->set_property ("whichBar", which);
+}
+
+void
+Default_bar_line_engraver::stop_translation_timestep ()
+{
+ context ()->set_property ("whichBar", SCM_EOL);
+ last_moment_ = now_mom ();
+}
class Fingering_engraver : public Engraver
{
- Link_array<Music> reqs_;
+ Link_array<Music> events_;
Link_array<Item> fingerings_;
public:
protected:
virtual bool try_music (Music *m);
PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
- PRECOMPUTED_VIRTUAL void start_translation_timestep ();
PRECOMPUTED_VIRTUAL void process_music ();
virtual void acknowledge_grob (Grob_info);
{
if (m->is_mus_type ("fingering-event"))
{
- reqs_.push (m);
+ events_.push (m);
return true;
}
return false;
void
Fingering_engraver::process_music ()
{
- for (int i = reqs_.size (); i--;)
+ for (int i = events_.size (); i--;)
{
- SCM dir = reqs_[i]->get_property ("direction");
- make_script (to_dir (dir), reqs_[i], i);
+ SCM dir = events_[i]->get_property ("direction");
+ make_script (to_dir (dir), events_[i], i);
}
}
return;
fingerings_.clear ();
-}
-
-void
-Fingering_engraver::start_translation_timestep ()
-{
- reqs_.clear ();
+ events_.clear ();
}
Fingering_engraver::Fingering_engraver ()
virtual void finalize ();
virtual bool try_music (Music *ev);
PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
- PRECOMPUTED_VIRTUAL void start_translation_timestep ();
PRECOMPUTED_VIRTUAL void process_music ();
virtual void acknowledge_grob (Grob_info);
};
item_ = 0;
context ()->set_property ("lastKeySignature", get_property ("keySignature"));
cancellation_ = 0;
+ key_ev_ = 0;
}
void
r->get_property ("tonic"));
}
-void
-Key_engraver::start_translation_timestep ()
-{
- key_ev_ = 0;
-}
-
void
Key_engraver::initialize ()
{
}
SCM log = scm_int2num (Note_head::get_balltype (me));
- SCM proc = me->get_property ("glyph-name-procedure");
-
String suffix = to_string (min (robust_scm2int (me->get_property ("duration-log"), 2), 2));
- if (style != ly_symbol2scm ("default")
- && ly_is_procedure (proc))
- suffix = ly_scm2string (scm_call_2 (proc, log, style));
-
+ if (style != ly_symbol2scm ("default"))
+ {
+ SCM proc = me->get_property ("glyph-name-procedure");
+ if (ly_is_procedure (proc))
+ suffix = ly_scm2string (scm_call_2 (proc, log, style));
+ }
Font_metric *fm = Font_interface::get_default_font (me);
String idx = "noteheads.s" + suffix;
class Rest_engraver : public Engraver
{
- Music *rest_req_;
+ Music *rest_event_;
Item *dot_;
Grob *rest_;
protected:
virtual bool try_music (Music *);
- PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
PRECOMPUTED_VIRTUAL void start_translation_timestep ();
PRECOMPUTED_VIRTUAL void process_music ();
*/
Rest_engraver::Rest_engraver ()
{
- rest_req_ = 0;
+ rest_event_ = 0;
rest_ = 0;
dot_ = 0;
}
void
Rest_engraver::start_translation_timestep ()
{
- rest_req_ = 0;
-}
-
-void
-Rest_engraver::stop_translation_timestep ()
-{
+ rest_event_ = 0;
rest_ = 0;
dot_ = 0;
}
+
void
Rest_engraver::process_music ()
{
- if (rest_req_ && !rest_)
+ if (rest_event_ && !rest_)
{
- rest_ = make_item ("Rest", rest_req_->self_scm ());
+ rest_ = make_item ("Rest", rest_event_->self_scm ());
- int durlog = unsmob_duration (rest_req_->get_property ("duration"))->duration_log ();
+ int durlog = unsmob_duration (rest_event_->get_property ("duration"))->duration_log ();
rest_->set_property ("duration-log",
scm_int2num (durlog));
- int dots = unsmob_duration (rest_req_->get_property ("duration"))->dot_count ();
+ int dots = unsmob_duration (rest_event_->get_property ("duration"))->dot_count ();
if (dots)
{
dot_->set_property ("dot-count", scm_int2num (dots));
}
- Pitch *p = unsmob_pitch (rest_req_->get_property ("pitch"));
+ Pitch *p = unsmob_pitch (rest_event_->get_property ("pitch"));
/*
This is ridiculous -- rests don't have pitch, but we act as if
{
if (m->is_mus_type ("rest-event"))
{
- rest_req_ = m;
+ rest_event_ = m;
return true;
}
return false;
Separating_line_group_engraver::start_translation_timestep ()
{
if (break_item_)
- context ()->unset_property (ly_symbol2scm ("breakableSeparationItem"));
- break_item_ = 0;
+ {
+ context ()->unset_property (ly_symbol2scm ("breakableSeparationItem"));
+ break_item_ = 0;
+ }
}
void
Item *double_percent_;
protected:
virtual bool try_music (Music *);
- PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
PRECOMPUTED_VIRTUAL void start_translation_timestep ();
PRECOMPUTED_VIRTUAL void process_music ();
};
{
repeat_ = 0;
}
-}
-
-void
-Slash_repeat_engraver::stop_translation_timestep ()
-{
beat_slash_ = 0;
}
+
#include "translator.icc"
ADD_TRANSLATOR (Slash_repeat_engraver,
+++ /dev/null
-/*
- timing-engraver.cc -- implement Default_bar_line_engraver
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-#include "engraver.hh"
-#include "context.hh"
-#include "multi-measure-rest.hh"
-#include "grob.hh"
-#include "warn.hh"
-
-
-class Default_bar_line_engraver : public Engraver
-{
-protected:
- /* Need to know whether we're advancing in grace notes, or not. */
- Moment last_moment_;
-
- PRECOMPUTED_VIRTUAL void start_translation_timestep ();
- PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
-
-public:
- TRANSLATOR_DECLARATIONS (Default_bar_line_engraver);
-};
-
-#include "translator.icc"
-
-ADD_TRANSLATOR (Default_bar_line_engraver,
- "This engraver determines what kind of automatic bar lines should be produced, "
- "and sets @code{whichBar} accordingly. It should be at the same "
- "level as @ref{Timing_translator}. ",
- /* creats*/ "",
- /* accepts */ "",
- /* acks */ "",
- /* reads */
- "measurePosition automaticBars whichBar barAlways defaultBarType "
- "measureLength",
- /* write */ "automaticBars");
-
-
-Default_bar_line_engraver::Default_bar_line_engraver ()
-{
- last_moment_.main_part_ = Rational (-1);
-}
-
-void
-Default_bar_line_engraver::start_translation_timestep ()
-{
- SCM automatic_bars = get_property ("automaticBars");
- Moment now = now_mom ();
- SCM which = get_property ("whichBar");
-
- /* Set the first bar of the score? */
- if (!scm_is_string (which))
- which = SCM_EOL;
-
- Moment mp = measure_position (context ());
- bool start_of_measure = (last_moment_.main_part_ != now.main_part_
- && !mp.main_part_);
-
- if (!scm_is_string (which) && to_boolean (automatic_bars))
- {
- SCM always = get_property ("barAlways");
-
- if ((start_of_measure && last_moment_.main_part_ >= Moment (0))
- || to_boolean (always))
- {
- /* should this work, or be junked? See input/bugs/no-bars.ly */
- which = get_property ("defaultBarType");
- }
- }
-
- context ()->set_property ("whichBar", which);
-}
-
-void
-Default_bar_line_engraver::stop_translation_timestep ()
-{
- context ()->set_property ("whichBar", SCM_EOL);
- last_moment_ = now_mom ();
-}