+2004-02-16 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * lily/include/grob-info.hh: origin_contexts() now does not
+ include the originating engraver
+
+ * lily/translator-group.cc (translator_each): clean up contents,
+ remove superfluous stubs. Engraver_group_engraver and
+ Performer_group_performer are the only classes using multiple
+ inheritance.
+
+ * lily/include/score-context.hh (class Score_context): interface
+ between Score_{engraver,performer} and Global_context.
+
+ * lily/include/global-context.hh (Context): change from
+ global-translator. This is the entry point for contexts; it is not
+ tweakable using \translator{}. Score is no longer the top context,
+ but sits underneath Global.
+
+ * lily/include/context.hh (class Context): brain surgery: split
+ out Context functionality from Translator_group. Context is now a
+ separate type from Translator.
+
+2004-02-15 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * lily/include/translator.hh (class Translator): make
+ get_score_context() and get_global_translator (), and use the one
+ which is appropriate.
+
+ * lily/context.cc: partially put functionality of Translator_group
+ into Context.
+
+ * lily/include/context.hh (Translator): new class: put between
+ Translator and Translator_group.
+
+ * lily/new-accidental-engraver.cc: remove file.
+
2004-02-16 Heikki Junes <hjunes@cc.hut.fi>
* input/regression/{many}.ly: improve descriptions: use complete
2004-02-15 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * lily/music.cc (LY_DEFINE): rename to ly:music-list?
+
+ * scripts/convert-ly.py (conv): add ly:music-list change.
+
* lily/grob.cc: edit doc string.
* scm/define-grob-properties.scm (all-user-grob-properties):
* input/test/maximum-rest-count.ly: remove file.
* scripts/convert-ly.py (FatalConversionError.subst_in_trans):
- conversion rule for \translator{}. Apply everywhere.
+ conversion rule for \translator { }. Apply everywhere.
* lily/parser.yy (music_property_def): set property for \once in
the PropertyMusic itself, not the ContextSpec.
\context Voice { \grace b16 c4 }
@end lilypond
-@item @code{\lyrics @{ @dots{} @}}
+@item @code{\lyrics @{ twinkle @}}
@tab entering lyrics
@tab
-@item @code{\context Lyrics}
+
+@item @code{\new Lyrics}
@tab printing lyrics
@tab
+twinkle
+@c cheating ..
+@c@li lypond[fragment]
+@c \lyrics \new Lyrics { twinkle }
+@c @end lilypond
@item @code{twin -- kle}
@tab lyric hyphen
@table @code
@item verbatim
-CONTENTS is copied into the source enclosed in a verbatim block,
-followed by any text given with the @code{intertext} option, then
+@var{contents} is copied into the source, enclosed in a verbatim block;
+followed by any text given with the @code{intertext} option; then
the actual music is displayed. This option does not work with
the short version of the music blocks:
@item fragment
@item nofragment
overrides @command{lilypond-book} auto detection of what type of code is
-in the LilyPond block, voice contents or complete code.
+in the LilyPond block, voice contents, or complete code.
@item indent=@var{size}\\@var{unit}
sets indentation of the first music system to @var{size},
where @var{unit} = cm, mm, in, or pt. This option affects LilyPond,
-not the text layout. For single-line fragments the default is to
+not the text layout. For single-line fragments, the default is to
use no indentation.
For example
@item relative, relative=@var{N}
uses relative octave mode. By default, notes are specified relative
-central C. The optional integer argument specifies the octave of the
+to central C. The optional integer argument specifies the octave of the
starting note, where the default @code{1} is central C.
@end table
@noindent
or to use the @option{--output} command line option, and change to
-that director before running La@TeX{} or @file{makeinfo}:
+that directory before running La@TeX{} or @file{makeinfo}:
@example
lilypond-book --output=out yourfile.lytex
@item @option{-P @var{process}}, @option{--process=@var{COMMAND}}
Process lilypond snippets using @var{command}. The default command is
-@var{lilypon-bin}.
+@var{lilypond-bin}.
@item @option{--verbose}
Be verbose.
<< \notes \relative c'' \context Voice = duet { \time 3/4
g2 e4 a2 f4 g2. }
\lyrics << \lyricsto "duet" \new Lyrics {
- \set stanza = "1"
+ \set stanza = "B."
+ \set vocName = "Bert"
Hi, my name is bert. }
\lyricsto "duet" \new Lyrics {
- \set stanza = "2"
- Ooooo, ch\'e -- ri, je t'aime. }
+ \set stanza = "E."
+ \set vocName = "Ernie"
+ Ooooo, ch\'e -- ri, je t'aime.
+ }
>> >>
}
@end lilypond
Stanza numbers can be added by setting @code{stanza}, e.g.
@example
- \set stanza = "Bert"
+ \set stanza = "B."
@dots{}
- \set stanza = "Ernie"
+ \set stanza = "E."
@end example
Notice how dots are surrounded with spaces in @code{\lyrics} mode, to
prevent @code{stanza} being interpreted as a single
string.
-Names of the singers should be added using @code{Lyrics
-. vocalName} and @code{Lyrics . vocNam}, analogous to instrument
-annotations for staves.
-
+This example also demonstrates how names of the singers can be added
+using @code{vocalName} analogous to instrument annotations for staves.
+A short version may be entered as @code{vocNam}.
+
To make empty spaces in lyrics, use @code{\skip}.
MAJOR_VERSION=2
MINOR_VERSION=1
PATCH_LEVEL=23
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=hwn2
\version "2.1.22"
-\header {texidoc="In lyrics, hyphens may be used."}
+\header {
+ texidoc = "In lyrics, hyphens may be used."
+}
\score{
<<
\context Staff \notes { c' (c') (c') c' }
+++ /dev/null
-\version "2.1.23"
-\header { texidoc = "Collision between multimeasure rests in different voices
-may be avoided. " }
-\score {
- \context Staff \notes <<
- \new Voice {
- \override MultiMeasureRest #'staff-position = #3
- R1
- }
- \new Voice {
- \override MultiMeasureRest #'staff-position = #-3
- R1
- }
- >>
- \paper {
- \translator {
- \StaffContext
- \remove Multi_measure_rest_engraver
- \remove Bar_engraver
- }
- \translator {
- \VoiceContext
- \consists Multi_measure_rest_engraver
- \consists Bar_engraver
- }
- raggedright = ##t
- }
-}
-
\version "2.1.22"
-\header {texidoc = "Tuplets may contain rests. "}
+\header {
+
+ texidoc = "Tuplets may contain rests. "
+
+}
\score {
\context Voice \notes \relative c'' {
}
>>
- \paper { linewidth = -1.0
+ \paper {
+ raggedright = ##t
- \translator {
- \StaffContext
- \consists Horizontal_bracket_engraver }
-
- }
+ \translator {
+ \StaffContext
+ \consists Horizontal_bracket_engraver
+ }
+
+ }
\midi { \tempo 8 = 60 }
}
#include "event.hh"
+
#include "item.hh"
#include "tie.hh"
#include "rhythmic-head.hh"
#include "engraver.hh"
#include "arpeggio.hh"
#include "warn.hh"
-#include "translator-group.hh"
+#include "context.hh"
#include "protected-scm.hh"
/**
bool done_;
Music * melodic_;
Grob * accidental_;
- Translator_group *origin_;
+ Context *origin_;
Grob* head_;
Accidental_entry();
};
static void
-set_property_on_children (Translator_group * trans, const char * sym, SCM val)
+set_property_on_children (Context * trans, const char * sym, SCM val)
{
trans->set_property (sym, val);
- for (SCM p = trans->trans_group_list_; gh_pair_p (p); p = ly_cdr(p)) {
- Translator_group *trg = dynamic_cast<Translator_group*> (unsmob_translator (ly_car (p)));
- set_property_on_children(trg,sym,ly_deep_copy(val));
- }
+ for (SCM p = trans->context_list_; gh_pair_p (p); p = ly_cdr(p))
+ {
+ Context *trg = unsmob_context (ly_car (p));
+ set_property_on_children(trg, sym, ly_deep_copy(val));
+ }
}
Accidental_engraver::Accidental_engraver ()
{
last_keysig_ = get_property ("keySignature");
- Translator_group * trans_ = daddy_trans_;
+ Context * trans_ = daddy_context_;
while (trans_)
{
- trans_ -> set_property ("localKeySignature", ly_deep_copy (last_keysig_));
- trans_ = trans_->daddy_trans_;
+ trans_ -> set_property ("localKeySignature",
+ ly_deep_copy (last_keysig_));
+ trans_ = trans_->daddy_context_;
}
- set_property_on_children (daddy_trans_,"localKeySignature", last_keysig_);
+ set_property_on_children (daddy_context_,"localKeySignature", last_keysig_);
}
/*
}
static int
-number_accidentals (Music * note, Pitch *pitch, Translator_group * origin,
+number_accidentals (Music * note, Pitch *pitch, Context * origin,
SCM accidentals, SCM curbarnum)
{
int number = 0;
*/
else if (gh_symbol_p (rule))
{
- Translator_group * dad = origin;
+ Context * dad = origin;
while (dad && !dad->is_alias (rule))
- dad = dad->daddy_trans_;
+ dad = dad->daddy_context_;
if (dad)
origin = dad;
accidentals_[i].done_ = true;
Grob * support = accidentals_[i].head_;
Music * note = accidentals_[i].melodic_;
- Translator_group * origin = accidentals_[i].origin_;
+ Context * origin = accidentals_[i].origin_;
Pitch * pitch = unsmob_pitch (note->get_mus_property ("pitch"));
if (!pitch)
(localsig, on_s, gh_cons (scm_int2num (a), barnum));
}
origin->set_property ("localKeySignature", localsig);
- origin = origin->daddy_trans_;
+ origin = origin->daddy_context_;
}
}
}
{
Accidental_entry entry ;
entry.head_ = info.grob_;
- entry.origin_ = info.origin_trans_->daddy_trans_;
+ entry.origin_ = info.origin_trans_->daddy_context_;
entry.melodic_ = note;
accidentals_.push (entry);
*/
if (last_keysig_ != sig)
{
- Translator_group * trans_ = daddy_trans_;
+ Context * trans_ = daddy_context_;
while (trans_)
{
trans_ -> set_property ("localKeySignature", ly_deep_copy (sig));
- trans_ = trans_->daddy_trans_;
+ trans_ = trans_->daddy_context_;
}
- set_property_on_children(daddy_trans_,"localKeySignature", sig);
+ set_property_on_children(daddy_context_,"localKeySignature", sig);
last_keysig_ = sig;
}
ADD_INTERFACE(Accidental_placement,
"accidental-placement-interface",
- "Take care of complex accidental collisions.",
+ "Resolve accidental collisions.",
"left-padding padding right-padding accidental-grobs positioning-done")
ADD_INTERFACE (Align_interface, "align-interface",
- " Order grobs top to bottom/left to right/right to left etc.",
- "forced-distance stacking-dir align-dir threshold positioning-done center-element elements axes");
+ "Order grobs from top to bottom, left to right, right to left or bottom"
+ "to top."
+ ,
+ "forced-distance stacking-dir align-dir threshold positioning-done "
+ "center-element elements axes");
struct Foobar
}
ADD_INTERFACE (Ambitus, "ambitus-interface",
- "An ambitus represents the pitch range of a voice.",
+ "An object that represents the pitch range of a voice.",
"c0-position pitch-min pitch-max accidentals note-head-style join-heads");
#include "simple-music-iterator.hh"
-#include "translator-group.hh"
+#include "context.hh"
#include "music.hh"
/**
#include "audio-element-info.hh"
#include "translator-group.hh"
+#include "context.hh"
Audio_element_info::Audio_element_info (Audio_element*s, Music *r)
{
}
-Link_array<Translator>
-Audio_element_info::origin_transes (Translator* end) const
+Link_array<Context>
+Audio_element_info::origin_contexts (Translator* end) const
{
- Translator * t = origin_trans_;
- Link_array<Translator> r;
+ Context * t = origin_trans_->daddy_context_;
+ Link_array<Context> r;
do {
r.push (t);
- t = t->daddy_trans_;
- } while (t && t != end->daddy_trans_);
+ t = t->daddy_context_;
+ } while (t && t != end->daddy_context_);
return r;
}
#include "item.hh"
#include "spanner.hh"
#include "duration.hh"
+#include "context.hh"
/*
TODO: figure what to do in grace?
stems_ = new Link_array<Item>;
grouping_ = new Beaming_info_list;
- beam_settings_ = updated_grob_properties (daddy_trans_, ly_symbol2scm ("Beam"));
+ beam_settings_ = updated_grob_properties (daddy_context_, ly_symbol2scm ("Beam"));
beam_start_moment_ = now_mom ();
beam_start_location_ = *unsmob_moment (get_property ("measurePosition"));
*/
#include "music.hh"
-#include "translator-group.hh"
+#include "context.hh"
#include "event.hh"
#include "music-wrapper-iterator.hh"
#include "direction.hh"
Auto_change_iterator::change_to (Music_iterator *it, SCM to_type_sym,
String to_id)
{
- Translator_group * current = it->get_outlet ();
- Translator_group * last = 0;
+ Context * current = it->get_outlet ();
+ Context * last = 0;
/*
Cut & Paste from Change_iterator (ugh).
while (current && !current->is_alias (to_type_sym))
{
last = current;
- current = current->daddy_trans_;
+ current = current->daddy_context_;
}
if (current && current->id_string_ == to_id)
if (current)
if (last)
{
- Translator_group * dest =
- it->get_outlet ()->find_create_translator (to_type_sym, to_id, SCM_EOL);
- current->remove_translator (last);
- dest->add_used_group_translator (last);
+ Context * dest =
+ it->get_outlet ()->find_create_context (to_type_sym, to_id, SCM_EOL);
+ current->remove_context (last);
+ dest->add_context (last);
}
else
{
Auto_change_iterator::process (Moment m)
{
Music_wrapper_iterator::process (m);
-
Moment now = get_outlet ()->now_mom ();
Moment *splitm = 0;
#include "engraver.hh"
#include "engraver-group-engraver.hh"
#include "warn.hh"
+#include "context.hh"
/**
Put stuff in a Spanner with an Axis_group_interface.
if (!staffline_)
return ;
- String type = get_daddy_grav ()->context_name ();
+ String type = daddy_context_->context_name ();
SCM dims = get_property ("verticalExtent");
if (is_number_pair (dims))
*/
- return me->has_extent_callback_b (group_extent_callback_proc, a) ||
- (me->has_extent_callback_b (Hara_kiri_group_spanner::y_extent_proc, a));
+ return me->has_extent_callback (group_extent_callback_proc, a) ||
+ (me->has_extent_callback (Hara_kiri_group_spanner::y_extent_proc, a));
}
Interval
/*
why so convoluted ? (fixme/documentme?)
*/
- if (me->has_extent_callback_b (Grob::stencil_extent_proc, a1))
+ if (me->has_extent_callback (Grob::stencil_extent_proc, a1))
me->set_extent (Axis_group_interface::group_extent_callback_proc,a1);
- if (me->has_extent_callback_b (Grob::stencil_extent_proc, a2))
+ if (me->has_extent_callback (Grob::stencil_extent_proc, a2))
me->set_extent (Axis_group_interface::group_extent_callback_proc,a2);
}
ADD_INTERFACE (Axis_group_interface, "axis-group-interface",
- "a group of coupled grobs",
+ "An object that groups other layout objects.",
"axes");
#include "simple-music-iterator.hh"
#include "event.hh"
-#include "translator-group.hh"
+#include "context.hh"
/*
Check bar checks. We do this outside the engravers so that you can
Simple_music_iterator::process(m);
if (!m.to_bool ())
{
- Translator_group *tr = get_outlet ();
+ Context *tr = get_outlet ();
SCM mp = tr->get_property ("measurePosition");
SCM sync= tr->get_property ("barCheckSynchronize");
{
if (!bar_)
{
- top_engraver ()->forbid_breaks (); // guh. Use properties!
+ get_score_engraver ()->forbid_breaks (); // guh. Use properties!
}
else
typeset_bar ();
#include "item.hh"
#include "moment.hh"
#include "engraver.hh"
-#include "translator-group.hh"
+#include "context.hh"
/*
(c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "engraver-group-engraver.hh"
+
#include "engraver.hh"
#include "event.hh"
#include "beam.hh"
#include "drul-array.hh"
#include "item.hh"
#include "spanner.hh"
+#include "context.hh"
class Beam_engraver : public Engraver
{
void set_melisma (bool);
Moment last_stem_added_at_;
- virtual void stop_translation_timestep ();
+ virtual void stop_translation_timestep ();
virtual void start_translation_timestep ();
virtual void finalize ();
virtual bool valid_end_point ();
public:
- TRANSLATOR_DECLARATIONS( Beam_engraver );
+ TRANSLATOR_DECLARATIONS(Beam_engraver);
};
{
SCM b = get_property ("autoBeaming");
if (!to_boolean (b))
- daddy_trans_->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F);
+ daddy_context_->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F);
}
void
{
if (beam_ && !to_boolean (get_property ("allowBeamBreak")))
{
- top_engraver ()->forbid_breaks ();
+ get_score_engraver ()->forbid_breaks ();
}
if (start_ev_)
#include "event.hh"
#include "audio-item.hh"
#include "audio-column.hh"
-#include "global-translator.hh"
+#include "global-context.hh"
#include "warn.hh"
class Beam_performer : public Performer {
{
SCM b = get_property ("autoBeaming");
if (!to_boolean (b))
- daddy_trans_->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F);
+ daddy_context_->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F);
}
void
ADD_INTERFACE (Beam, "beam-interface",
- "A beam. \n\n"
-" "
-"#'thickness= weight of beams, in staffspace "
-" "
-" "
-"We take the least squares line through the ideal-length stems, and "
-"then damp that using "
-" \n"
-" damped = tanh (slope) \n"
-" \n"
-"this gives an unquantized left and right position for the beam end. "
-"Then we take all combinations of quantings near these left and right "
-"positions, and give them a score (according to how close they are to "
-"the ideal slope, how close the result is to the ideal stems, etc.). We "
-"take the best scoring combination. "
-,
- "knee positioning-done position-callbacks concaveness-gap concaveness-threshold dir-function quant-score auto-knee-gap gap gap-count chord-tremolo beamed-stem-shorten shorten least-squares-dy damping flag-width-function neutral-direction positions space-function thickness");
+ "A beam. \n\n"
+ "The @code{thickness} property is the weight of beams, and is measured "
+ "in staffspace"
+ ,
+ "knee positioning-done position-callbacks concaveness-gap "
+ "concaveness-threshold dir-function quant-score auto-knee-gap gap "
+ "gap-count chord-tremolo beamed-stem-shorten shorten least-squares-dy "
+ "damping flag-width-function neutral-direction positions space-function "
+ "thickness");
ADD_INTERFACE (Break_aligned_interface, "break-aligned-interface",
"Items that are aligned in prefatory matter.\n"
"\n"
- "The spacing of these items is controlled by the space-alist\n"
- "property. It contains a list break-align-symbols with a specification\n"
+ "The spacing of these items is controlled by the @code{space-alist}\n"
+ "property. It contains a list @code{break-align-symbol}s with a specification\n"
"of the associated space. The space specification can be "
"@table @code\n"
"@item (minimum-space . @var{spc}))\n"
" Add @var{spc} amount of space.\n"
"@end table\n"
"\n"
- "Special keys for the alist are 'first-note and 'next-note, signifying\n"
+ "Special keys for the alist are @code{first-note} and @code{next-note}, signifying\n"
"the first note on a line, and the next note halfway a line.\n"
"\n"
"Rules for this spacing are much more complicated than this. \n"
"break-align-symbol space-alist");
ADD_INTERFACE (Break_align_interface, "break-alignment-interface",
- "See @ref{break-aligned-interface}.",
- "positioning-done");
+ "The object that performs break aligment. See @ref{break-aligned-interface}.",
+ "positioning-done");
*/
#include "change-iterator.hh"
-#include "translator-group.hh"
+#include "context.hh"
#include "music.hh"
#include "warn.hh"
-
+#include "input.hh"
void
void
Change_iterator::process (Moment m)
{
- Translator_group * current = get_outlet ();
- Translator_group * last = 0;
+ Context * current = get_outlet ();
+ Context * last = 0;
SCM to_type = get_music ()->get_mus_property ("change-to-type");
String to_id = ly_scm2string (get_music ()->get_mus_property ("change-to-id"));
while (current && !current->is_alias (to_type))
{
last = current;
- current = current->daddy_trans_;
+ current = current->daddy_context_;
}
if (current && current->id_string_ == to_id)
if (current)
if (last)
{
- Translator_group * dest =
- get_outlet ()->find_create_translator (to_type, to_id, SCM_EOL);
- current->remove_translator (last);
- dest->add_used_group_translator (last);
+ Context * dest =
+ get_outlet ()->find_create_context (to_type, to_id, SCM_EOL);
+ current->remove_context (last);
+ dest->add_context (last);
}
else
{
#include "item.hh"
#include "pitch.hh"
#include "protected-scm.hh"
-#include "translator-group.hh"
+#include "context.hh"
#include "warn.hh"
class Chord_name_engraver : public Engraver
SCM name_proc = get_property ("chordNameFunction");
SCM markup = scm_call_4 (name_proc, pitches, bass, inversion,
- daddy_trans_->self_scm());
+ daddy_context_->self_scm ());
/*
Ugh.
ADD_INTERFACE (Chord_name, "chord-name-interface",
- "generate a chord name",
+ "A chord name.",
"begin-of-line-visible");
}
void
-Chord_tremolo_iterator::derived_substitute (Translator_group*f, Translator_group*t)
+Chord_tremolo_iterator::derived_substitute (Context *f, Context *t)
{
if (child_iter_)
child_iter_->substitute_outlet (f,t);
#include <ctype.h>
-#include "translator-group.hh"
+#include "context.hh"
#include "bar-line.hh"
#include "staff-symbol-referencer.hh"
#include "engraver.hh"
SCM basic = ly_symbol2scm ("Clef");
- execute_pushpop_property (daddy_trans_, basic, glyph_sym, SCM_UNDEFINED);
- execute_pushpop_property (daddy_trans_, basic, glyph_sym, glyph);
+ execute_pushpop_property (daddy_context_, basic, glyph_sym, SCM_UNDEFINED);
+ execute_pushpop_property (daddy_context_, basic, glyph_sym, glyph);
}
/**
if (to_boolean (force_clef))
{
- Translator_group * w = daddy_trans_->where_defined (ly_symbol2scm ("forceClef"));
+ Context * w = daddy_context_->where_defined (ly_symbol2scm ("forceClef"));
w->set_property ("forceClef", SCM_EOL);
}
}
}
ADD_INTERFACE (Cluster,"cluster-interface",
- "A graphically drawn musical cluster. "
-"\n\n"
-"@code{padding} adds to the vertical extent of the shape (top and "
-"bottom) and is expressed in units of staffspace. Since the pitch "
-"range of a single pitch is infinitely small, if padding is set to "
-"@code{0.0}, this possibly results in an invisible shape, if you,for "
-"example, say @code{c-\\startCluster d e-\\endCluster}. The default "
-"value for @code{padding} therefore is @code{0.25}, such that a single "
-"pitch roughly shows the same height as a note head. "
-"\n\n"
-"@code{style} controls the shape of cluster segments. Valid values include 'leftsided-stairs', 'rightsided-stairs', 'centered-stairs', and 'ramp'.\n"
+ "A graphically drawn musical cluster. "
+ "\n\n"
+ "@code{padding} adds to the vertical extent of the shape (top and "
+ "bottom). \n\n"
+ "The property @code{style} controls the shape of cluster segments. Valid values "
+ "include @code{leftsided-stairs}, @code{rightsided-stairs}, @code{centered-stairs}, "
+ "and @code{ramp}.\n"
,
"style padding columns");
#include "warn.hh"
#include "spanner.hh"
#include "tie.hh"
+#include "global-context.hh"
/*
Moment next = now;
next.main_part_ += note_dur.get_length ();
- top_engraver ()->add_moment_to_process (next);
+
+ get_global_context ()->add_moment_to_process (next);
do_nothing_until_ = next.main_part_;
}
#include "warn.hh"
#include "music-output-def.hh"
#include "ly-smobs.icc"
+#include "score-context.hh"
int
Context_def::print_smob (SCM smob, SCM port, scm_print_state*)
Link_array<Context_def>
-Context_def::path_to_acceptable_translator (SCM type_sym, Music_output_def* odef) const
+Context_def::path_to_acceptable_context (SCM type_sym, Music_output_def* odef) const
{
assert (gh_symbol_p (type_sym));
Link_array<Context_def> accepteds;
for (SCM s = accepted; gh_pair_p (s); s = ly_cdr (s))
{
- Context_def *t = unsmob_context_def (odef->find_translator (ly_car (s)));
+ Context_def *t = unsmob_context_def (odef->find_context_def (ly_car (s)));
if (!t)
continue;
accepteds.push (t);
Context_def * g = accepteds[i];
Link_array<Context_def> result
- = g->path_to_acceptable_translator (type_sym, odef);
+ = g->path_to_acceptable_context (type_sym, odef);
if (result.size () && result.size () < best_depth)
{
result.insert (g,0);
IMPLEMENT_DEFAULT_EQUAL_P (Context_def);
-
-
SCM
Context_def::get_translator_names (SCM user_mod) const
{
}
-Translator_group *
+Context *
Context_def::instantiate (SCM ops)
{
- Translator * g = get_translator (translator_group_type_);
- g = g->clone ();
+ Context * tg = 0;
- Translator_group *tg = dynamic_cast<Translator_group*> (g);
+ if (context_name_ == ly_symbol2scm ("Score"))
+ tg = new Score_context ();
+ else
+ tg = new Context ();
+
+
tg->definition_ = self_scm ();
SCM trans_names = get_translator_names (ops);
- tg->simple_trans_list_ = names_to_translators (trans_names, tg);
+
+ Translator * g = get_translator (translator_group_type_);
+ g = g->clone ();
+
+ g->simple_trans_list_ = names_to_translators (trans_names, tg);
+ tg->implementation_ = g->self_scm ();
+ g->daddy_context_ = tg;
+
+ scm_gc_unprotect_object (g->self_scm ());
+
tg->accepts_list_ = get_accepted (ops);
+
return tg;
}
}
void
-Context_def::apply_default_property_operations (Translator_group *tg)
+Context_def::apply_default_property_operations (Context *tg)
{
apply_property_operations (tg , property_ops_);
}
*/
#include "music-wrapper-iterator.hh"
-#include "translator-group.hh"
+#include "context.hh"
class Context_specced_music_iterator : public Music_wrapper_iterator
{
c_id = ly_scm2string (ci);
SCM ops = get_music ()->get_mus_property ("property-operations");
- Translator_group* a
- = get_outlet ()->find_create_translator (ct, c_id, ops);
+ Context * a
+ = get_outlet ()->find_create_context (ct, c_id, ops);
if (a)
set_translator (a);
+/*
+ context.cc -- implement Context
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
#include "translator-group.hh"
#include "context-def.hh"
+#include "context.hh"
#include "warn.hh"
#include "music-output-def.hh"
#include "scm-hash.hh"
#include "main.hh"
+#include "ly-smobs.icc"
+#include "score-context.hh"
bool
-Translator_group::is_removable () const
+Context::is_removable () const
+{
+ return context_list_ == SCM_EOL && ! iterator_count_ &&
+ !dynamic_cast<Score_context const*> (this)
+ ;
+}
+
+
+void
+Context::check_removal ()
+{
+ for (SCM p = context_list_; gh_pair_p (p); p = gh_cdr (p))
+ {
+ Context *trg = unsmob_context (ly_car (p));
+
+ trg->check_removal ();
+ if (trg->is_removable ())
+ {
+ recurse_down_translators (trg, &Translator::finalize, false);
+ remove_context (trg);
+ }
+ }
+}
+
+Context::Context (Context const&)
+{
+ assert (false);
+}
+
+Scheme_hash_table*
+Context::properties_dict () const
{
- return trans_group_list_ == SCM_EOL && ! iterator_count_;
+ return Scheme_hash_table::unsmob (properties_scm_);
}
-Translator_group *
-Translator_group::find_existing_translator (SCM n, String id)
+void
+Context::add_context (Context*t)
+{
+ SCM ts = t->self_scm ();
+ context_list_ = gh_append2 (context_list_,
+ gh_cons (ts, SCM_EOL));
+
+ t->daddy_context_ = this;
+ if (!t->init_)
+ {
+ t->init_ = true;
+
+ scm_gc_unprotect_object (ts);
+ Context_def * td = unsmob_context_def (t->definition_);
+
+ /*
+ this can not move before add_context(), because \override
+ operations require that we are in the hierarchy.
+ */
+ td->apply_default_property_operations (t);
+
+ recurse_down_translators (t, &Translator::initialize, true);
+ }
+}
+
+Context::Context ()
+{
+ daddy_context_ = 0;
+ init_ = false;
+ iterator_count_ = 0;
+ implementation_ = SCM_EOL;
+ properties_scm_ = SCM_EOL;
+ accepts_list_ = SCM_EOL;
+ context_list_ = SCM_EOL;
+ definition_ = SCM_EOL;
+
+ smobify_self ();
+
+ Scheme_hash_table *tab = new Scheme_hash_table ;
+ properties_scm_ = tab->self_scm ();
+ scm_gc_unprotect_object (tab->self_scm ());
+}
+
+Context *
+Context::find_existing_context (SCM n, String id)
{
if ((is_alias (n) && (id_string_ == id || id.is_empty ())) || n == ly_symbol2scm ("Current"))
return this;
- Translator_group* r = 0;
- for (SCM p = trans_group_list_; !r && gh_pair_p (p); p = ly_cdr (p))
+ Context* r = 0;
+ for (SCM p = context_list_; !r && gh_pair_p (p); p = ly_cdr (p))
{
- Translator * t = unsmob_translator (ly_car (p));
+ Context * t = unsmob_context (ly_car (p));
- r = dynamic_cast<Translator_group*> (t)->find_existing_translator (n, id);
+ r = dynamic_cast<Context*> (t)->find_existing_context (n, id);
}
return r;
}
-Translator_group*
-Translator_group::find_create_translator (SCM n, String id, SCM operations)
+Context*
+Context::find_create_context (SCM n, String id,
+ SCM operations)
{
- Translator_group * existing = find_existing_translator (n,id);
+ Context * existing = find_existing_context (n,id);
if (existing)
return existing;
if (n == ly_symbol2scm ("Bottom"))
{
- Translator_group* tg = get_default_interpreter ();
+ Context* tg = get_default_interpreter ();
tg->id_string_ = id;
return tg;
}
TODO: use accepts_list_.
*/
Link_array<Context_def> path
- = unsmob_context_def (definition_)->path_to_acceptable_translator (n, get_output_def ());
+ = unsmob_context_def (definition_)->path_to_acceptable_context (n, get_output_def ());
if (path.size ())
{
- Translator_group * current = this;
+ Context * current = this;
// start at 1. The first one (index 0) will be us.
for (int i=0; i < path.size (); i++)
{
SCM ops = (i == path.size () -1) ? operations : SCM_EOL;
- Translator_group * new_group
+ Context * new_group
= path[i]->instantiate (ops);
if (i == path.size () -1)
new_group->id_string_ = id;
}
- current->add_fresh_group_translator (new_group);
+ current->add_context (new_group);
apply_property_operations (new_group, ops);
current = new_group;
return current;
}
- Translator_group *ret = 0;
- if (daddy_trans_)
- ret = daddy_trans_->find_create_translator (n, id, operations);
+ Context *ret = 0;
+ if (daddy_context_)
+ ret = daddy_context_->find_create_context (n, id, operations);
else
{
warning (_f ("Cannot find or create `%s' called `%s'",
none.
*/
SCM
-default_child_context_name (Translator_group const *tg)
+default_child_context_name (Context const *tg)
{
return gh_pair_p (tg->accepts_list_)
? ly_car (scm_last_pair (tg->accepts_list_))
bool
-Translator_group::is_bottom_context () const
+Context::is_bottom_context () const
{
return !gh_symbol_p (default_child_context_name (this));
}
-Translator_group*
-Translator_group::get_default_interpreter ()
+Context*
+Context::get_default_interpreter ()
{
if (!is_bottom_context ())
{
SCM nm = default_child_context_name (this);
- SCM st = get_output_def ()->find_translator (nm);
+ SCM st = get_output_def ()->find_context_def (nm);
Context_def *t = unsmob_context_def (st);
if (!t)
warning (_f ("can't find or create: `%s'", ly_symbol2string (nm).to_str0 ()));
t = unsmob_context_def (this->definition_);
}
- Translator_group *tg = t->instantiate (SCM_EOL);
- add_fresh_group_translator (tg);
+ Context *tg = t->instantiate (SCM_EOL);
+ add_context (tg);
if (!tg->is_bottom_context ())
return tg->get_default_interpreter ();
else
/*
PROPERTIES
*/
-Translator_group*
-Translator_group::where_defined (SCM sym) const
+Context*
+Context::where_defined (SCM sym) const
{
if (properties_dict ()->contains (sym))
{
- return (Translator_group*)this;
+ return (Context*)this;
}
- return (daddy_trans_) ? daddy_trans_->where_defined (sym) : 0;
+ return (daddy_context_) ? daddy_context_->where_defined (sym) : 0;
}
/*
return SCM_EOL when not found.
*/
SCM
-Translator_group::internal_get_property (SCM sym) const
+Context::internal_get_property (SCM sym) const
{
SCM val =SCM_EOL;
if (properties_dict ()->try_retrieve (sym, &val))
return val;
- if (daddy_trans_)
- return daddy_trans_->internal_get_property (sym);
+ if (daddy_context_)
+ return daddy_context_->internal_get_property (sym);
return val;
}
bool
-Translator_group::is_alias (SCM sym) const
+Context::is_alias (SCM sym) const
{
if (sym == ly_symbol2scm ("Bottom")
&& !gh_pair_p (accepts_list_))
}
void
-Translator_group::internal_set_property (SCM sym, SCM val)
+Context::internal_set_property (SCM sym, SCM val)
{
#ifndef NDEBUG
if (internal_type_checking_global_b)
TODO: look up to check whether we have inherited var?
*/
void
-Translator_group::unset_property (SCM sym)
+Context::unset_property (SCM sym)
{
properties_dict ()->remove (sym);
}
+/**
+ Remove a context from the hierarchy.
+ */
+Context *
+Context::remove_context (Context*trans)
+{
+ assert (trans);
+
+ context_list_ = scm_delq_x (trans->self_scm (), context_list_);
+ trans->daddy_context_ = 0;
+ return trans;
+}
+
+/*
+ ID == "" means accept any ID.
+ */
+Context *
+find_context_below (Context * where,
+ String type, String id)
+{
+ if (where->is_alias (ly_symbol2scm (type.to_str0 ())))
+ {
+ if (id == "" || where->id_string_ == id)
+ return where;
+ }
+
+ Context * found = 0;
+ for (SCM s = where->context_list_;
+ !found && gh_pair_p (s); s = gh_cdr (s))
+ {
+ Context * tr = unsmob_context (gh_car (s));
+
+ found = find_context_below (tr, type, id);
+ }
+
+ return found;
+}
+
+SCM
+Context::properties_as_alist () const
+{
+ return properties_dict()->to_alist();
+}
+
+String
+Context::context_name () const
+{
+ Context_def * td = unsmob_context_def (definition_ );
+ return ly_symbol2string (td->get_context_name ());
+}
+
+
+Score_context*
+Context::get_score_context () const
+{
+ if (Score_context *sc =dynamic_cast<Score_context*> ((Context*)this))
+ return sc;
+ else if (daddy_context_)
+ return daddy_context_->get_score_context ();
+ else
+ return 0;
+}
+
+Music_output_def *
+Context::get_output_def () const
+{
+ return (daddy_context_)
+ ? daddy_context_->get_output_def () : 0;
+}
+
+Context::~Context()
+{
+
+}
+
+Moment
+Context::now_mom () const
+{
+ return daddy_context_->now_mom();
+}
+
+int
+Context::print_smob (SCM s, SCM port, scm_print_state *)
+{
+ Context *sc = (Context *) ly_cdr (s);
+
+ scm_puts ("#<", port);
+ scm_puts (classname (sc), port);
+ if (Context_def *d=unsmob_context_def (sc->definition_))
+ {
+ scm_puts (" ", port);
+ scm_display (d->get_context_name (), port);
+ }
+
+ if (Context *td=dynamic_cast<Context *> (sc))
+ {
+ scm_puts ("=", port);
+ scm_puts (td->id_string_.to_str0 (), port);
+ }
+
+
+ scm_puts (" ", port);
+ scm_display (sc->implementation_, port);
+
+#if 0
+ Translator * tr = unsmob_translator (sc->implementation_);
+ if (Translator_group *tg = dynamic_cast<Translator_group*> (tr))
+ scm_display (tg->get_simple_trans_list (), port);
+#endif
+
+ /*
+ don't try to print properties, that is too much hassle.
+ */
+ scm_puts (" >", port);
+
+ return 1;
+}
+
+SCM
+Context::mark_smob (SCM sm)
+{
+ Context * me = (Context*) SCM_CELL_WORD_1 (sm);
+
+ scm_gc_mark (me->context_list_);
+ scm_gc_mark (me->definition_);
+ scm_gc_mark (me->properties_scm_);
+ scm_gc_mark (me->accepts_list_);
+ scm_gc_mark (me->implementation_);
+
+ return me->properties_scm_;
+}
+
+IMPLEMENT_SMOBS (Context);
+IMPLEMENT_DEFAULT_EQUAL_P (Context);
+IMPLEMENT_TYPE_P(Context,"ly:context?");
+
+bool
+Context::try_music (Music* m)
+{
+ Translator* t = unsmob_translator (implementation_);
+ if (!t)
+ return false;
+
+ bool b = t->try_music (m);
+ if (!b && daddy_context_)
+ b = daddy_context_->try_music (m);
+
+ return b;
+}
+
+
+Global_context*
+Context::get_global_context () const
+{
+ if (dynamic_cast<Global_context *>((Context*) this))
+ return dynamic_cast<Global_context *> ((Context*) this);
+
+ if (daddy_context_)
+ return daddy_context_->get_global_context ();
+
+ programming_error ("No Global context!");
+ return 0;
+}
}
ADD_INTERFACE (Custos, "custos-interface",
- "Engrave custodes",
+ "A custos object.",
"style adjust-if-on-staffline neutral-direction neutral-position");
ADD_INTERFACE (Dot_column, "dot-column-interface",
- "Interface that groups dots so they form a column",
- "positioning-done direction stem");
+ "Groups dot objects so they form a column, and position dots so they do not "
+ "clash with staff lines "
+ ,
+ "positioning-done direction stem");
ADD_INTERFACE (Dots, "dots-interface",
- "The dots to go with a notehead/rest. A separate interface, since they "
-" are a party in collision resolution. "
-" #'direction is the Direction to handle staff-line collisions in.",
- "direction dot-count");
+ "The dots to go with a notehead or rest."
+ "@code{direction} sets the preferred direction to move in case of staff "
+ "line collisions.",
+ "direction dot-count");
Item *p = make_item ("Script");
SCM desc = SCM_EOL;
make_script_from_event (p, &desc,
- daddy_trans_, script,
+ daddy_context_, script,
0);
if (p->get_grob_property ("follow-into-staff"))
#include "event.hh"
#include "audio-item.hh"
#include "audio-column.hh"
-#include "global-translator.hh"
+#include "global-context.hh"
#include "warn.hh"
class Drum_note_performer : public Performer {
virtual bool try_music (Music *ev) ;
virtual void stop_translation_timestep ();
virtual void create_audio_elements ();
-
- Global_translator* get_global_translator ();
private:
Link_array<Music> note_evs_;
Link_array<Audio_note> notes_;
note_evs_.clear ();
}
-Global_translator*
-Drum_note_performer::get_global_translator ()
-{
- Translator *t = this;
- Global_translator *global =0;
- do
- {
- t = t->daddy_trans_ ;
- global = dynamic_cast<Global_translator*> (t);
- }
- while (!global);
-
- return global;
-}
-
-
void
Drum_note_performer::stop_translation_timestep ()
{
// why don't grace notes show up here?
// --> grace notes effectively do not get delayed
- Global_translator* global = get_global_translator ();
+ Global_context * global = get_global_context ();
for (int i=0; i < notes_.size (); i++)
{
Audio_note* n = notes_[i];
#include "engraver.hh"
#include "group-interface.hh"
#include "directional-element-interface.hh"
-#include "translator-group.hh"
+#include "context.hh"
#include "axis-group-interface.hh"
#include "script.hh"
{
cresc_ = make_spanner ("TextSpanner");
cresc_->set_grob_property ("style", s);
- daddy_trans_->set_property ((start_type
+ daddy_context_->set_property ((start_type
+ "Spanner").to_str0 (), SCM_EOL);
s = get_property ((start_type + "Text").to_str0 ());
/*
{
cresc_->set_grob_property ("edge-text",
gh_cons (s, scm_makfrom0str ("")));
- daddy_trans_->set_property ((start_type + "Text").to_str0 (),
+ daddy_context_->set_property ((start_type + "Text").to_str0 (),
SCM_EOL);
}
}
#include "warn.hh"
#include "paper-score.hh"
#include "grob.hh"
+#include "context.hh"
+
+
void
Engraver_group_engraver::announce_grob (Grob_info info)
{
announce_infos_.push (info);
- Engraver::announce_grob (info);
+ get_daddy_engraver ()->announce_grob (info);
}
-void
-Engraver_group_engraver::process_acknowledged_grobs_in_simple_children ()
-{
- for (SCM p = get_simple_trans_list (); gh_pair_p (p); p = ly_cdr (p))
- {
- Translator * t = unsmob_translator (ly_car (p));
- Engraver * eng = dynamic_cast<Engraver*> (t);
- if (eng)
- eng->process_acknowledged_grobs ();
- }
-}
SCM find_acknowledge_engravers (SCM gravlist, SCM meta);
SCM find_accept_engravers (SCM gravlist, SCM music_descr);
{
Translator * t = unsmob_translator (ly_car (p));
Engraver * eng = dynamic_cast<Engraver*> (t);
- if (eng && eng!= info.origin_trans_)
+ if (eng && eng != info.origin_trans_)
eng->acknowledge_grob (info);
}
}
}
+
void
Engraver_group_engraver::do_announces ()
{
- for (SCM p = trans_group_list_; gh_pair_p (p); p =ly_cdr (p))
+ do
{
- Translator * t = unsmob_translator (ly_car (p));
- dynamic_cast<Engraver_group_engraver*> (t)->do_announces ();
- }
+ engraver_each (get_simple_trans_list (),
+ &Engraver::process_acknowledged_grobs);
+
+ if (!announce_infos_.size())
+ break;
- process_acknowledged_grobs_in_simple_children ();
-
- do
- {
acknowledge_grobs ();
announce_infos_.clear ();
- process_acknowledged_grobs_in_simple_children ();
}
- while (announce_infos_.size ());
+ while (1);
}
-/*
- order is : top to bottom (as opposed to do_announces)
- */
-void
-Engraver_group_engraver::process_music ()
-{
- for (SCM p = get_simple_trans_list (); gh_pair_p (p); p =ly_cdr (p))
- {
- Translator * t = unsmob_translator (ly_car (p));
- Engraver * eng = dynamic_cast<Engraver*> (t);
-
- if (eng)
- eng->process_music ();
- }
- for (SCM p = trans_group_list_; gh_pair_p (p); p =ly_cdr (p))
- {
- Translator * t = unsmob_translator (ly_car (p));
- Engraver*eng = dynamic_cast<Engraver*> (t);
- if (eng)
- eng->process_music ();
- }
-}
-
void
Engraver_group_engraver::initialize ()
{
- /*
- docme: why bool_f.
-
- */
SCM tab = scm_make_vector (gh_int2scm (61), SCM_BOOL_F);
- set_property ("acknowledgeHashTable", tab);
+ daddy_context_->set_property ("acknowledgeHashTable", tab);
Translator_group::initialize ();
}
}
+/* c&p engraver-group.cc */
+void
+recurse_down_engravers (Context * c, Engraver_method ptr, bool context_first)
+{
+ Engraver_group_engraver * tg
+ = dynamic_cast<Engraver_group_engraver*> (unsmob_translator (c->implementation_));
+
+
+ if (!context_first)
+ {
+ engraver_each (tg->get_simple_trans_list (),
+ ptr);
+
+ (tg->*ptr) ();
+ }
+
+ for (SCM s = c->context_list_ ; gh_pair_p (s);
+ s =gh_cdr (s))
+ {
+ recurse_down_engravers (unsmob_context (gh_car (s)), ptr, context_first);
+ }
+
+ if (context_first)
+ {
+ engraver_each (tg->get_simple_trans_list (),
+ ptr);
+ (tg->*ptr) ();
+ }
+}
+
+
+void
+engraver_each (SCM list, Engraver_method method)
+{
+ for (SCM p = list; gh_pair_p (p); p = ly_cdr (p))
+ {
+ Engraver * e = dynamic_cast<Engraver*>(unsmob_translator (ly_car (p)));
+ if (e)
+ (e->*method) ();
+ }
+}
#include "warn.hh"
#include "spanner.hh"
#include "item.hh"
+#include "context.hh"
+#include "score-context.hh"
+
+Engraver_group_engraver*
+Engraver::get_daddy_engraver () const
+{
+ return dynamic_cast<Engraver_group_engraver*> (get_daddy_translator ());
+}
void
Engraver::announce_grob (Grob_info inf)
{
- get_daddy_grav ()->announce_grob (inf);
+ get_daddy_engraver ()->announce_grob (inf);
}
+
/*
CAUSE is the object (typically a Music object) that
was the reason for making E.
if (!i.origin_trans_)
i.origin_trans_ = this;
-
-
- get_daddy_grav ()->announce_grob (i);
+ get_daddy_engraver ()->announce_grob (i);
}
void
Engraver::typeset_grob (Grob*p)
{
- get_daddy_grav ()->typeset_grob (p);
+ Engraver *dad = get_daddy_engraver ();
+ dad->typeset_grob (p);
}
-Engraver_group_engraver*
-Engraver::get_daddy_grav () const
-{
- return (daddy_trans_)
- ? dynamic_cast<Engraver_group_engraver *> (daddy_trans_)
- : 0;
-}
void
Engraver::process_music ()
Score_engraver*
-Engraver::top_engraver () const
+Engraver::get_score_engraver () const
+{
+ SCM t = get_score_context ()->implementation_;
+ return dynamic_cast<Score_engraver*> (unsmob_translator (t));
+}
+
+
+void
+Engraver::do_announces ()
{
- return dynamic_cast<Score_engraver*> (top_translator());
}
ENTER_DESCRIPTION(Engraver,
(c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "translator-group.hh"
+#include "context.hh"
#include "warn.hh"
#include "event-chord-iterator.hh"
#include "music-list.hh"
{
}
-Translator_group*
+Context *
Event_chord_iterator::get_req_translator ()
{
assert (get_outlet ());
#include "text-item.hh"
#include "event.hh"
#include "item.hh"
-#include "translator-group.hh"
+#include "context.hh"
class Figured_bass_engraver : public Engraver
{
for (int i = 0; i <figures_.size (); i++)
l = gh_cons (figures_[i]->self_scm(), l);
- SCM markup = scm_call_2 (proc, l, daddy_trans_->self_scm ());
+ SCM markup = scm_call_2 (proc, l, daddy_context_->self_scm ());
figure_ = make_item ("BassFigure");
figure_->set_grob_property ("text", markup);
*/
-
+#include "input.hh"
#include "folded-repeat-iterator.hh"
#include "repeated-music.hh"
#include "music-list.hh"
#include "simultaneous-music-iterator.hh"
-#include "translator-group.hh"
+#include "context.hh"
Folded_repeat_iterator::Folded_repeat_iterator ()
{
}
void
-Folded_repeat_iterator::derived_substitute (Translator_group*f, Translator_group*t)
+Folded_repeat_iterator::derived_substitute (Context *f, Context *t)
{
if (main_iter_)
main_iter_->substitute_outlet (f,t);
/*
We only want to process a grob once.
*/
- if (gi.origin_trans_->daddy_trans_ != daddy_trans_)
+ if (gi.origin_trans_->daddy_context_ != daddy_context_)
return ;
if (gh_number_p (sz) && gh_scm2double (sz))
Grob *g = unsmob_grob (gh_cdar (busy));
if (Rhythmic_head::has_interface (g))
{
- top_engraver()->forbid_breaks();
+ get_score_engraver()->forbid_breaks();
}
busy = gh_cdr(busy);
}
--- /dev/null
+/*
+ global-translator.cc -- implement global_context
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+#include <stdio.h>
+
+#include "warn.hh"
+#include "music.hh"
+#include "event.hh"
+#include "music-list.hh"
+#include "music-iterator.hh"
+#include "global-context.hh"
+#include "score-context.hh"
+#include "context-def.hh"
+#include "music-output-def.hh"
+
+Global_context::Global_context (Music_output_def*o)
+{
+ output_def_ = o;
+ accepts_list_ = scm_list_n (ly_symbol2scm ("Score"),
+ SCM_UNDEFINED);
+ definition_ = o->find_context_def (ly_symbol2scm ("Global"));
+}
+
+Music_output_def*
+Global_context::get_output_def () const
+{
+ return output_def_;
+}
+
+void
+Global_context::add_moment_to_process (Moment m)
+{
+ if (m > final_mom_)
+ return;
+
+ if (m < now_mom_)
+ programming_error ("Trying to freeze in time.");
+
+ for (int i=0; i < extra_mom_pq_.size (); i++)
+ if (extra_mom_pq_[i] == m)
+ return;
+ extra_mom_pq_.insert (m);
+}
+
+Moment
+Global_context::sneaky_insert_extra_moment (Moment w)
+{
+ while (extra_mom_pq_.size () && extra_mom_pq_.front () <= w)
+ w = extra_mom_pq_.get ();
+ return w;
+}
+
+int
+Global_context::get_moments_left () const
+{
+ return extra_mom_pq_.size ();
+}
+
+void
+Global_context::prepare (Moment m)
+{
+ prev_mom_ = now_mom_;
+ now_mom_ = m;
+
+ if (get_score_context ())
+ get_score_context ()->prepare (m);
+}
+
+Moment
+Global_context::now_mom () const
+{
+ return now_mom_;
+}
+
+Score_context*
+Global_context::get_score_context () const
+{
+ return (gh_pair_p (context_list_))
+ ? dynamic_cast<Score_context*> (unsmob_context (gh_car (context_list_)))
+ : 0;
+}
+
+Music_output*
+Global_context::get_output ()
+{
+ return get_score_context ()->get_output ();
+}
+
+void
+Global_context::one_time_step ()
+{
+ get_score_context ()->one_time_step ();
+ apply_finalizations ();
+ check_removal ();
+}
+
+void
+Global_context::finish ()
+{
+ if (get_score_context ())
+ get_score_context ()->finish ();
+}
+
+void
+Global_context::run_iterator_on_me (Music_iterator * iter)
+{
+ if (iter-> ok ())
+ prev_mom_ = now_mom_ = iter->pending_moment ();
+
+ bool first = true;
+ while (iter->ok () || get_moments_left ())
+ {
+ Moment w;
+ w.set_infinite (1);
+ if (iter->ok ())
+ {
+ w = iter->pending_moment ();
+ }
+
+ w = sneaky_insert_extra_moment (w);
+ if (w.main_part_.is_infinity ())
+ break ;
+
+#if 0
+ // printf ("proccing %s\n ", w.to_string ().to_str0 ());
+ if (first)
+ {
+ /*
+ Huh?
+ */
+ set_property ("measurePosition", w.smobbed_copy ());
+ }
+#endif
+
+ prepare (w);
+
+ if (iter->ok ())
+ iter->process (w);
+
+ if (!get_score_context ())
+ {
+ SCM key = ly_symbol2scm ("Score");
+ Context_def * t = unsmob_context_def (get_output_def ()
+ ->find_context_def (key));
+ if (!t)
+ error (_f ("can't find `%s' context", "Score"));
+
+ add_context (t->instantiate (SCM_EOL));
+
+ Score_context *sc = dynamic_cast<Score_context*> (t);
+ sc->prepare (w);
+ }
+
+ one_time_step ();
+ first = false;
+ }
+}
+
+void
+Global_context::apply_finalizations ()
+{
+ SCM lst = get_property ("finalizations");
+ set_property ("finalizations" , SCM_EOL);
+ for (SCM s = lst ; gh_pair_p (s); s = gh_cdr (s))
+ {
+ scm_primitive_eval (gh_car (s));
+ }
+}
+
+/*
+ Add a function to execute before stepping to the next time step.
+ */
+void
+Global_context::add_finalization (SCM x)
+{
+ SCM lst = get_property ("finalizations");
+ lst = scm_cons (x, lst);
+ set_property ("finalizations" ,lst);
+}
+
-/*
- global-translator.cc -- implement Global_translator
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-#include <stdio.h>
-
-#include "warn.hh"
-#include "music.hh"
-#include "event.hh"
-#include "music-list.hh"
-#include "music-iterator.hh"
-#include "global-translator.hh"
-
-Global_translator::Global_translator ()
-{
- output_def_ = 0;
-}
-
-Music_output_def*
-Global_translator::get_output_def () const
-{
- return output_def_;
-}
-
-void
-Global_translator::add_moment_to_process (Moment m)
-{
- if (m > final_mom_)
- return;
-
- if (m < now_mom_)
- programming_error ("Trying to freeze in time.");
-
- for (int i=0; i < extra_mom_pq_.size (); i++)
- if (extra_mom_pq_[i] == m)
- return;
- extra_mom_pq_.insert (m);
-}
-
-Moment
-Global_translator::sneaky_insert_extra_moment (Moment w)
-{
- while (extra_mom_pq_.size () && extra_mom_pq_.front () <= w)
- w = extra_mom_pq_.get ();
- return w;
-}
-
-int
-Global_translator::get_moments_left () const
-{
- return extra_mom_pq_.size ();
-}
-
-void
-Global_translator::prepare (Moment m)
-{
- prev_mom_ = now_mom_;
- now_mom_ = m;
-}
-
-Moment
-Global_translator::now_mom () const
-{
- return now_mom_;
-}
-
-
-
-Music_output*
-Global_translator::get_output ()
-{
- return 0;
-}
-
-void
-Global_translator::one_time_step ()
-{
-}
-
-void
-Global_translator::start ()
-{
-}
-void
-Global_translator::finish ()
-{
-}
-
-void
-Global_translator::run_iterator_on_me (Music_iterator * iter)
-{
- if (iter-> ok ())
- prev_mom_ = now_mom_ = iter->pending_moment ();
-
- bool first = true;
- while (iter->ok () || get_moments_left ())
- {
- Moment w;
- w.set_infinite (1);
- if (iter->ok ())
- {
- w = iter->pending_moment ();
- }
-
- w = sneaky_insert_extra_moment (w);
- if (w.main_part_.is_infinity ())
- break ;
-
-
- // printf ("proccing %s\n ", w.to_string ().to_str0 ());
- if (first)
- {
- first = false;
- set_property ("measurePosition", w.smobbed_copy ());
- }
-
- prepare (w);
- if (iter->ok ())
- iter->process (w);
-
- one_time_step ();
- }
-}
-
-void
-Global_translator::apply_finalizations ()
-{
- SCM lst = get_property ("finalizations");
- set_property ("finalizations" , SCM_EOL);
- for (SCM s = lst ; gh_pair_p (s); s = gh_cdr (s))
- {
- scm_primitive_eval (gh_car (s));
- }
-}
-
-/*
- Add a function to execute before stepping to the next time step.
- */
-void
-Global_translator::add_finalization (SCM x)
-{
- SCM lst = get_property ("finalizations");
- lst = scm_cons (x, lst);
- set_property ("finalizations" ,lst);
-}
-
-
-Global_translator *
-Translator::top_translator()const
-{
- if (dynamic_cast<Global_translator*>((Translator*)this))
- return dynamic_cast<Global_translator*> ((Translator*)this);
-
- if (daddy_trans_)
- return daddy_trans_->top_translator ();
-
- programming_error ("No top translator!");
- return 0;
-}
#include "grace-iterator.hh"
-#include "global-translator.hh"
+#include "global-context.hh"
#include "warn.hh"
void
#include "grob-info.hh"
#include "music.hh"
#include "translator-group.hh"
-
+#include "context.hh"
Grob_info::Grob_info ()
{
return unsmob_music (cause);
}
-Link_array<Translator>
-Grob_info::origin_transes (Translator* end) const
+Link_array<Context>
+Grob_info::origin_contexts (Translator* end) const
{
- Translator * t = origin_trans_;
- Link_array<Translator> r;
+ Context * t = origin_trans_->daddy_context_;
+ Link_array<Context> r;
do {
r.push (t);
- t = t->daddy_trans_;
- } while (t && t != end->daddy_trans_);
+ t = t->daddy_context_;
+ } while (t && t != end->daddy_context_);
return r;
}
(c) 2001--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "translator-group.hh"
+#include "context.hh"
#include "engraver.hh"
#include "grob.hh"
#include "warn.hh"
void
Grob_pq_engraver::initialize ()
{
- daddy_trans_->set_property ("busyGrobs", SCM_EOL);
+ daddy_context_->set_property ("busyGrobs", SCM_EOL);
}
void
busy = scm_merge_x (current_list, busy, ly_grob_pq_less_p_proc);
current_grobs_.clear ();
- daddy_trans_->set_property ("busyGrobs", busy);
+ daddy_context_->set_property ("busyGrobs", busy);
}
void
}
if (start_busy != busy)
- daddy_trans_->set_property ("busyGrobs", busy);
+ daddy_context_->set_property ("busyGrobs", busy);
}
"Grob properties are stored as GUILE association lists, with symbols as\n"
"keys. All lookup functions identify undefined properties with\n"
"end-of-list (i.e. @code{'()} in Scheme or @code{SCM_EOL} in C)\n"
-"\n"
-"Properties are stored in two ways:\n"
-"@itemize @bullet\n"
-"@item mutable properties.\n"
-"Grob properties that change from object to object. The storage of\n"
-"these are private to a grob. For example pointers to other grobs are\n"
-"always stored in the mutable properties.\n"
-"\n"
-"@item immutable properties.\n"
-"Grob properties that are shared across different grobs of the same\n"
-"type. The storage is shared, and hence it is read-only. Typically, this\n"
-"is used to store function callbacks, and default settings. They are\n"
-"initially read from @file{scm/grob-description.scm}.\n"
-"@end itemize\n"
"\n")
{
Grob * sc = unsmob_grob (grob);
LY_DEFINE (ly_get_original,
"ly:get-original",
1, 0, 0, (SCM grob),
- "Return the original Grob of @var{grob}")
+ "Return the unbroken original Grob of @var{grob}.")
{
Grob *me = unsmob_grob (grob);
SCM_ASSERT_TYPE (me, grob, SCM_ARG1, __FUNCTION__, "grob");
void
Grob::add_offset_callback (SCM cb, Axis a)
{
- if (!has_offset_callback_b (cb, a))
+ if (!has_offset_callback (cb, a))
{
dim_cache_[a].offset_callbacks_ = gh_cons (cb, dim_cache_[a].offset_callbacks_);
dim_cache_[a].offsets_left_ ++;
}
bool
-Grob::has_extent_callback_b (SCM cb, Axis a)const
+Grob::has_extent_callback (SCM cb, Axis a)const
{
return scm_equal_p (cb, dim_cache_[a].dimension_) == SCM_BOOL_T;
}
bool
-Grob::has_offset_callback_b (SCM cb, Axis a)const
+Grob::has_offset_callback (SCM cb, Axis a)const
{
return scm_memq (cb, dim_cache_[a].offset_callbacks_) != SCM_BOOL_F;
}
"\n"
"Grobs have a properties: Scheme variables, that can be read and set. "
"They have two types. Immutable variables "
- "define the default style and behavior. They are shared between many objects "
+ "define the default style and behavior. They are shared between many objects. "
"They can be changed using @code{\\override} and @code{\\revert}. "
"\n\n"
"Mutable properties are variables that are specific to one grob. Typically, "
ADD_INTERFACE (Hairpin, "hairpin-interface",
- "hairpin crescendo.",
+ "A hairpin (de)crescendo.",
"grow-direction height if-text-padding");
ADD_INTERFACE (Hara_kiri_group_spanner,"hara-kiri-group-interface",
- " As Vertical_group_spanner, but keep track of interesting items. If \
-we don't contain any interesting items after linebreaking, then \
-gracefully commit suicide. Objective: don't disgrace Lily by \
-typesetting empty lines in orchestral scores.", \
- "items-worth-living remove-first");
+ "A group spanner that keeps track of interesting items. If it "
+ "doesn't contain any after linebreaking, then it "
+ "will remove itself and all its children."
+ ,
+ "items-worth-living remove-first");
/**
Data container for broadcasts
*/
-struct Audio_element_info {
+class Audio_element_info {
+public:
Audio_element * elem_;
Music *event_;
- Translator * origin_trans_;
- Link_array<Translator> origin_transes (Translator*) const;
+ Translator *origin_trans_;
+
+ Link_array<Context> origin_contexts (Translator*) const;
Audio_element_info (Audio_element*, Music*);
Audio_element_info ();
Chord_tremolo_iterator ();
Chord_tremolo_iterator (Chord_tremolo_iterator const & );
protected:
- virtual void derived_substitute (Translator_group*f, Translator_group*t) ;
+ virtual void derived_substitute (Context *f, Context *t) ;
virtual void derived_mark () const;
virtual Moment pending_moment () const;
SCM get_translator_names (SCM) const;
void set_acceptor (SCM accepts, bool add);
- Link_array<Context_def> path_to_acceptable_translator (SCM type_string, Music_output_def* odef) const;
- Translator_group * instantiate (SCM extra_ops);
+ Link_array<Context_def> path_to_acceptable_context (SCM type_string, Music_output_def* odef) const;
+ Context * instantiate (SCM extra_ops);
SCM to_alist () const;
bool is_alias (SCM) const;
static SCM make_scm () ;
SCM clone_scm ()const;
- void apply_default_property_operations (Translator_group*);
+ void apply_default_property_operations (Context *);
private:
DECLARE_SMOBS (Context_def,foo);
Context_def ();
+/*
+ context.hh -- declare Context
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ */
+
+#ifndef CONTEXT_HH
+#define CONTEXT_HH
+
+#include "moment.hh"
+#include "lily-proto.hh"
+
+
+class Context
+{
+ Scheme_hash_table *properties_dict () const;
+ Context (Context const &src);
+
+ DECLARE_SMOBS (Context, dummy);
+
+ void terminate ();
+public:
+ SCM definition_;
+ SCM properties_scm_;
+ SCM context_list_;
+ SCM accepts_list_;
+ Context * daddy_context_;
+
+ Context ();
+ void execute_pushpop_property (SCM prop, SCM sym, SCM val);
+ SCM internal_get_property (SCM name_sym) const;
+
+ Context *remove_context (Context*trans);
+ void check_removal ();
+
+ SCM properties_as_alist () const;
+ void unset_property (SCM var_sym);
+ void internal_set_property (SCM var_sym, SCM value);
+
+ Context *where_defined (SCM name_sym) const;
+ String context_name () const;
+ Global_context * get_global_context () const;
+
+ virtual Score_context * get_score_context () const;
+ bool is_alias (SCM) const;
+ void add_context (Context *trans);
+ bool is_bottom_context () const;
+ bool is_removable () const;
+ bool try_music (Music *);
+
+ virtual Music_output_def *get_output_def () const;
+ virtual Moment now_mom () const;
+ Context *find_existing_context (SCM context_name, String id);
+ Context *find_create_context (SCM context_name,
+ String id, SCM ops);
+ Link_array<Context> path_to_acceptable_context (SCM alias,
+ Music_output_def*) const;
+ Context *get_default_interpreter ();
+ String id_string_;
+
+ SCM implementation_;
+private:
+ friend class Interpretation_context_handle;
+ int iterator_count_;
+ bool init_;
+};
+
+/*
+ Context arg?
+ */
+
+void apply_property_operations (Context*tg, SCM pre_init_ops);
+void execute_pushpop_property (Context * trg, SCM prop, SCM eltprop, SCM val);
+SCM updated_grob_properties (Context* tg, SCM sym);
+Context * find_context_below (Context * where,
+ String type, String id);
+
+Context * unsmob_context (SCM);
+
+#define set_property(x,y) internal_set_property(ly_symbol2scm(x),y)
+
+/*
+ C&P!
+ */
+#define get_property(x) internal_get_property(ly_symbol2scm(x))
+DECLARE_UNSMOB(Context,context);
+
+#endif /* CONTEXT_HH */
+
#include "translator-group.hh"
-/**
- Group a number of engravers. Usually delegates everything to its contents.
- Postfix: group
- */
-class Engraver_group_engraver : public Engraver,
+class Engraver_group_engraver : public virtual Engraver,
public virtual Translator_group
{
protected:
Array<Grob_info> announce_infos_;
-
-
public:
TRANSLATOR_DECLARATIONS(Engraver_group_engraver);
virtual void initialize ();
virtual void do_announces ();
virtual void announce_grob (Grob_info);
- virtual void process_music ();
private:
virtual void acknowledge_grobs ();
- virtual void process_acknowledged_grobs_in_simple_children ();
};
+typedef void (Engraver::*Engraver_method) (void);
+
+void recurse_down_engravers (Context * c, Engraver_method ptr, bool context_first);
+void engraver_each (SCM list, Engraver_method method);
+
#endif // ENGRAVERGROUP_HH
virtual void announce_grob (Grob*, SCM cause);
virtual void announce_grob (Grob_info);
virtual void process_music ();
-
- Score_engraver * top_engraver () const;
-
+ virtual void do_announces ();
+ Engraver_group_engraver*get_daddy_engraver () const;
public:
- Engraver_group_engraver * get_daddy_grav () const;
+ Score_engraver * get_score_engraver () const;
/**
override other ctor
*/
TRANSLATOR_DECLARATIONS(Engraver);
};
-#define make_item(x) make_item_from_properties (daddy_trans_, ly_symbol2scm (x))
-#define make_spanner(x) make_spanner_from_properties (daddy_trans_, ly_symbol2scm (x))
-Item* make_item_from_properties (Translator_group* tg, SCM x);
-Spanner* make_spanner_from_properties (Translator_group * tg, SCM x);
+#define make_item(x) make_item_from_properties (daddy_context_, ly_symbol2scm (x))
+#define make_spanner(x) make_spanner_from_properties (daddy_context_, ly_symbol2scm (x))
+Item* make_item_from_properties (Context * tg, SCM x);
+Spanner* make_spanner_from_properties (Context * tg, SCM x);
+
/**
Find a bottom notation context to deliver events to.
*/
- virtual Translator_group* get_req_translator ();
+ virtual Context * get_req_translator ();
/*
Folded_repeat_iterator (Folded_repeat_iterator const &src);
Folded_repeat_iterator ();
virtual void derived_mark () const;
- virtual void derived_substitute (Translator_group*f, Translator_group*t) ;
+ virtual void derived_substitute (Context *f, Context *t) ;
virtual void construct_children ();
--- /dev/null
+/*
+ global-context.hh -- declare Global_context
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+
+#ifndef GLOBAL_CONTEXT_HH
+#define GLOBAL_CONTEXT_HH
+
+#include "context.hh"
+#include "pqueue.hh"
+
+class Global_context : public virtual Context
+{
+ PQueue<Moment> extra_mom_pq_;
+ Music_output_def* output_def_;
+
+ friend class Music_output_def;
+public:
+ Global_context (Music_output_def*);
+ int get_moments_left () const;
+ Moment sneaky_insert_extra_moment (Moment);
+ void add_moment_to_process (Moment);
+ void run_iterator_on_me (Music_iterator*);
+ virtual Score_context*get_score_context () const;
+
+ void apply_finalizations ();
+ void add_finalization (SCM);
+
+ virtual Music_output *get_output ();
+ virtual void prepare (Moment);
+ virtual void one_time_step ();
+ virtual void finish ();
+ virtual Music_output_def* get_output_def () const;
+ virtual Moment now_mom () const;
+
+ Moment final_mom_;
+ Moment prev_mom_;
+ Moment now_mom_;
+protected:
+};
+
+
+
+#endif // GLOBAL_CONTEXT_HH
+++ /dev/null
-/*
- global-translator.hh -- declare Global_translator
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef GLOBAL_TRANSLATOR_HH
-#define GLOBAL_TRANSLATOR_HH
-
-#include "translator-group.hh"
-#include "moment.hh"
-#include "pqueue.hh"
-
-class Global_translator : public virtual Translator_group
-{
- PQueue<Moment> extra_mom_pq_;
- Music_output_def* output_def_;
- friend class Music_output_def;
-public:
- VIRTUAL_COPY_CONS (Translator);
- Global_translator ();
-
- int get_moments_left () const;
- Moment sneaky_insert_extra_moment (Moment);
- void add_moment_to_process (Moment);
- void run_iterator_on_me (Music_iterator*);
-
- void apply_finalizations ();
- void add_finalization (SCM);
-
- virtual Music_output *get_output ();
- virtual void prepare (Moment);
- virtual void one_time_step ();
- virtual void finish ();
- virtual void start ();
- virtual Music_output_def* get_output_def () const;
- virtual Moment now_mom () const;
-
- Moment final_mom_;
- Moment prev_mom_;
- Moment now_mom_;
-protected:
-};
-
-
-
-#endif // GLOBAL_TRANSLATOR_HH
#include "lily-proto.hh"
#include "parray.hh"
-/**
+/*
Data container for broadcasts.
*/
struct Grob_info {
public:
Music * music_cause ();
- Link_array<Translator> origin_transes (Translator*) const;
+ Link_array<Context> origin_contexts (Translator*) const;
Grob_info ();
};
// duh. slim down interface here. (todo)
- bool has_offset_callback_b (SCM callback, Axis)const;
+ bool has_offset_callback (SCM callback, Axis)const;
void add_offset_callback (SCM callback, Axis);
- bool has_extent_callback_b (SCM, Axis)const;
+ bool has_extent_callback (SCM, Axis)const;
void set_extent (SCM , Axis);
Real get_offset (Axis a) const;
~Interpretation_context_handle ();
Interpretation_context_handle ();
Interpretation_context_handle* clone () const;
- void set_translator (Translator_group*);
+ void set_translator (Context *);
bool try_music (Music *);
void operator = (Interpretation_context_handle const&);
Interpretation_context_handle (Interpretation_context_handle const&);
- Translator_group * get_outlet () const;
+ Context * get_outlet () const;
int get_count () const;
void quit ();
private:
- Translator_group * outlet_;
+ Context * outlet_;
void down ();
- void up (Translator_group*);
+ void up (Context *);
};
#endif /* INTERPRETATION_CONTEXT_HANDLE_HH */
class Chord_tremolo_iterator;
class Cluster_engraver;
class Column_x_positions;
+class Context;
class Context_specced_music;
class Engraver;
class Engraver;
class Folded_repeat_iterator;
class Font_metric;
class Font_size_engraver;
-class Global_translator;
+class Global_context;
class Gourlay_breaking;
class Grace_engraver_group;
class Grace_iterator;
class Score;
class Grob;
class Score_engraver;
+class Score_context;
class Score_performer;
class Sequential_music;
class Sequential_music_iterator;
void init_type_ ## CL ()\
{\
SCM subr = scm_c_define_gsubr (FUNCNAME, 1, 0, 0, (Scheme_function_unknown) CL::smob_p);\
- ly_add_function_documentation (subr, FUNCNAME, "(SCM x)", "Check if @var{x} is a " #CL " object");\
+ ly_add_function_documentation (subr, FUNCNAME, "(SCM x)", "Check if @var{x} is a @code{" #CL "} object");\
scm_c_export (FUNCNAME, NULL);\
}\
ADD_SCM_INIT_FUNC (init_type_ ## CL, init_type_ ## CL)
/**
The translation unit that we this iterator is reporting to now.
*/
- Translator_group* get_outlet () const;
+ Context * get_outlet () const;
- void set_translator (Translator_group*);
+ void set_translator (Context *);
/** Get an iterator matching the type of MUS, and use TRANS to find
an accompanying translation unit
*/
static SCM get_static_get_iterator (Music * mus);
- void init_translator (Music *, Translator_group *);
+ void init_translator (Music *, Context *);
void quit ();
- void substitute_outlet (Translator_group* from, Translator_group *to);
- virtual void derived_substitute (Translator_group*, Translator_group*);
+ void substitute_outlet (Context * from, Context *to);
+ virtual void derived_substitute (Context *, Context *);
virtual Moment pending_moment () const;
virtual bool ok () const;
Music_output_def (Music_output_def const&);
Music_output_def ();
- Global_translator *get_global_translator ();
- Translator_group *get_group_translator (String type) const;
+ Context *get_group_translator (String type) const;
void assign_translator (SCM transdef);
- SCM find_translator (SCM name) const;
+ SCM find_context_def (SCM name) const;
String outname_string () ;
SCM get_scmvar (String id)const;
SCM lookup_variable (SCM sym) const;
DECLARE_SCHEME_CALLBACK(constructor, ());
Music_wrapper_iterator ();
- virtual void derived_substitute (Translator_group*f, Translator_group*t) ;
+ virtual void derived_substitute (Context *f, Context *t) ;
virtual void derived_mark () const;
virtual void construct_children () ;
DECLARE_SCHEME_CALLBACK(constructor, ());
Percent_repeat_iterator ();
protected:
- virtual void derived_substitute (Translator_group*f, Translator_group*t) ;
+ virtual void derived_substitute (Context *f, Context *t) ;
virtual void derived_mark () const;
virtual Moment pending_moment () const;
#include "performer.hh"
#include "translator-group.hh"
-/**
- Group a number of performers. Usually delegates everything to its contents.
-*/
+typedef void (Performer::*Performer_method) (void);
class Performer_group_performer : public Performer, public virtual Translator_group {
public:
TRANSLATOR_DECLARATIONS(Performer_group_performer);
virtual void do_announces ();
- virtual void process_music ();
virtual void announce_element (Audio_element_info);
protected:
Array<Audio_element_info> announce_infos_;
- void create_audio_elements ();
private:
void acknowledge_audio_elements ();
};
+void recurse_down_performers (Context * c, Performer_method ptr,
+ bool context_first);
+void performer_each (SCM list, Performer_method method);
+
#endif // PERFORMER_GROUP_PERFORMER_HH
public:
VIRTUAL_COPY_CONS (Translator);
friend class Performer_group_performer;
- Performer_group_performer* get_daddy_perf () const;
+ Performer_group_performer* get_daddy_performer () const;
protected:
virtual void announce_element (Audio_element_info);
virtual int get_tempo () const;
virtual void play_element (Audio_element * elem );
virtual void process_music ();
+ virtual void do_announces ();
};
--- /dev/null
+/*
+score-context.hh -- declare Score_notation_context
+
+source file of the GNU LilyPond music typesetter
+
+(c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ */
+
+#ifndef SCORE_CONTEXT_HH
+#define SCORE_CONTEXT_HH
+
+#include "global-context.hh"
+
+
+class Score_context : public Context
+{
+ public:
+ virtual Music_output *get_output ();
+ virtual void prepare (Moment);
+ virtual void finish ();
+ virtual void one_time_step ();
+};
+
+
+
+#endif /* SCORE_CONTEXT_HH */
#define SCORE_ENGRAVER_HH
#include "engraver-group-engraver.hh"
-#include "global-translator.hh"
+#include "score-translator.hh"
-/**
- Top level engraver. Puts elements into appropriate columns.
- */
-class Score_engraver :
- public Engraver_group_engraver, public Global_translator
+class Score_engraver : public virtual Score_translator,
+ public virtual Engraver_group_engraver
{
System *system_;
int breaks_; // used for stat printing
void set_columns (Paper_column*,Paper_column*);
void typeset_all ();
protected:
- /* Global_translator */
- virtual void prepare (Moment);
+ /* Score_translator */
virtual void finish ();
+ virtual void prepare (Moment);
virtual void one_time_step ();
-
+
/* Engraver_group_engraver interface */
virtual void acknowledge_grob (Grob_info);
virtual bool try_music (Music*);
#define SCORE_PERFORMER_HH
#include "performer-group-performer.hh"
-#include "global-translator.hh"
+#include "score-translator.hh"
/**
Top level performer. Completely takes care of MIDI output
*/
-class Score_performer:
- public Performer_group_performer, public Global_translator
+class Score_performer : public Score_translator, public virtual Performer_group_performer
{
public:
TRANSLATOR_DECLARATIONS(Score_performer);
Performance *performance_;
protected:
- virtual void finish ();
virtual void prepare (Moment mom);
virtual void one_time_step ();
- virtual void start ();
virtual void initialize ();
virtual void announce_element (Audio_element_info);
virtual int get_tempo () const;
};
void make_script_from_event (Grob *p,
- SCM * descr, Translator_group*tg,
+ SCM * descr, Context *tg,
SCM type,
int index);
#endif /* Stem_SCRIPT_HH */
DECLARE_SCHEME_CALLBACK(constructor, ());
Sequential_iterator ();
Sequential_iterator (Sequential_iterator const&);
- virtual void derived_substitute (Translator_group*f, Translator_group*t) ;
+ virtual void derived_substitute (Context *f, Context *t) ;
virtual void derived_mark () const;
public:
Simultaneous_music_iterator ();
Simultaneous_music_iterator (Simultaneous_music_iterator const&);
- virtual void derived_substitute (Translator_group*f, Translator_group*t) ;
+ virtual void derived_substitute (Context *f, Context *t) ;
virtual void derived_mark () const;
DECLARE_SCHEME_CALLBACK(constructor, ());
};
-void apply_push_property (Translator_group*trans, SCM syms, SCM eprop, SCM val);
-void apply_pop_property (Translator_group*trans, SCM syms, SCM eprop);
-
#endif // PROPERTY_HH
#endif
#include "parray.hh"
#include "smobs.hh"
-// egcs
-typedef void (Translator::*Method_pointer) (void);
-#define set_property(x,y) internal_set_property(ly_symbol2scm(x),y)
+typedef void (Translator::*Translator_method) (void);
-class Scheme_hash_table;
-
-
-/** Make some kind of Elements from Events. Elements are made by
- hierarchically grouped Translators
- */
class Translator_group : public virtual Translator {
-public:
- String id_string_;
-private:
- int iterator_count_;
- friend class Interpretation_context_handle;
-
- Scheme_hash_table *properties_dict () const;
- SCM add_translator (SCM, Translator*);
protected:
- ~Translator_group ();
-
- virtual SCM get_simple_trans_list ();
-
+
public:
- void execute_pushpop_property (SCM prop, SCM sym, SCM val);
- SCM internal_get_property (SCM name_sym) const;
- SCM properties_as_alist () const;
- void unset_property (SCM var_sym);
- void internal_set_property (SCM var_sym, SCM value);
-
- Translator_group *where_defined (SCM name_sym) const;
- String context_name () const;
- Translator_group (Translator_group const &);
- Translator_group ();
-
- bool is_alias (SCM) const;
- void add_fresh_group_translator (Translator *trans);
- void add_used_group_translator (Translator *trans);
- bool is_bottom_context () const;
- bool is_removable () const;
- void terminate_translator (Translator*r);
- Translator *remove_translator (Translator*trans);
- void check_removal ();
- Translator_group *find_existing_translator (SCM context_name, String id);
- Translator_group *find_create_translator (SCM context_name,
- String id, SCM ops);
- Link_array<Translator_group>
- path_to_acceptable_translator (SCM alias,
- Music_output_def*) const;
- Translator_group*get_default_interpreter ();
VIRTUAL_COPY_CONS (Translator);
+
public:
- bool try_music_on_nongroup_children (Music *m);
-
- virtual void do_announces ();
+ virtual Translator_group* get_daddy_translator ()const;
+ virtual SCM get_simple_trans_list ();
virtual bool try_music (Music* req);
- virtual void stop_translation_timestep ();
- virtual void start_translation_timestep ();
virtual void initialize ();
- virtual void finalize ();
- virtual void each (Method_pointer);
};
-bool melisma_busy (Translator* tr); // where to put this? --hwn
-void apply_property_operations (Translator_group*tg, SCM pre_init_ops);
-SCM names_to_translators (SCM namelist, Translator_group*tg);
-void execute_pushpop_property (Translator_group * trg,
- SCM prop, SCM eltprop, SCM val);
-SCM updated_grob_properties (Translator_group* tg, SCM sym);
+SCM names_to_translators (SCM namelist, Context*tg);
+void recurse_down_translators (Context * c, Translator_method ptr, bool context_first);
+void translator_each (SCM list, Translator_method method);
+
#endif // TRANSLATOR_GROUP_HH
Music_output_def * output_def_;
Translator (Translator const &);
+ Context * daddy_context_ ;
-
- Translator_group * daddy_trans_ ;
void removal_processing ();
virtual Music_output_def *get_output_def () const;
-
SCM internal_get_property (SCM symbol) const;
-
+ virtual Translator_group* get_daddy_translator ()const;
virtual Moment now_mom () const;
- /*
- ugh: bubbled up.
- */
- SCM definition_;
- SCM properties_scm_;
- SCM trans_group_list_;
- SCM accepts_list_;
- virtual SCM get_simple_trans_list ();
public:
DECLARE_SMOBS (Translator, dummy);
-private:
- /*
- ugh: bubbled up from Translator_group.
- */
-
protected: // should be private.
SCM simple_trans_list_;
friend class Context_def;
public:
- Global_translator * top_translator () const;
+ Score_context * get_score_context () const;
+ Global_context * get_global_context () const;
+
TRANSLATOR_DECLARATIONS(Translator);
virtual bool try_music (Music *req);
virtual void stop_translation_timestep ();
virtual void start_translation_timestep ();
- virtual void do_announces () ;
virtual void initialize () ;
virtual void finalize ();
};
-
/**
A macro to automate administration of translators.
*/
Translator*get_translator (SCM s);
DECLARE_UNSMOB(Translator,translator);
+bool melisma_busy (Translator*);
#endif // TRANSLATOR_HH
#include "side-position-interface.hh"
#include "align-interface.hh"
#include "axis-group-interface.hh"
-#include "translator-group.hh"
+#include "context.hh"
#include "text-item.hh"
class Instrument_name_engraver : public Engraver
void
Instrument_name_engraver::initialize ()
{
- daddy_trans_->set_property ("instrumentSupport", SCM_EOL);
+ daddy_context_->set_property ("instrumentSupport", SCM_EOL);
}
void
SCM nl = gh_cons (i.grob_->self_scm (),
get_property ("instrumentSupport"));
- daddy_trans_->set_property ("instrumentSupport", nl);
+ daddy_context_->set_property ("instrumentSupport", nl);
}
}
*/
#include "interpretation-context-handle.hh"
-#include "translator-group.hh"
+#include "context.hh"
Interpretation_context_handle::Interpretation_context_handle ()
{
}
void
-Interpretation_context_handle::up (Translator_group*t)
+Interpretation_context_handle::up (Context *t)
{
outlet_ = t;
t->iterator_count_ ++;
}
void
-Interpretation_context_handle::set_translator (Translator_group*trans)
+Interpretation_context_handle::set_translator (Context *trans)
{
if (outlet_ ==trans)
return;
up (trans);
}
-Translator_group*
+Context *
Interpretation_context_handle::get_outlet () const
{
#include "item.hh"
#include "bar-line.hh"
#include "staff-symbol-referencer.hh"
-#include "translator-group.hh"
+#include "context.hh"
#include "engraver.hh"
#include "pitch.hh"
#include "protected-scm.hh"
if (gh_scm2int (ly_cdar (s)))
accs = gh_cons (ly_car (s), accs);
- daddy_trans_->set_property ("keySignature", accs);
- daddy_trans_->set_property ("tonic" ,
+ daddy_context_->set_property ("keySignature", accs);
+ daddy_context_->set_property ("tonic" ,
r->get_mus_property ("tonic"));
}
Key_engraver::start_translation_timestep ()
{
key_ev_ = 0;
- daddy_trans_->set_property ("lastKeySignature", get_property ("keySignature"));
+ daddy_context_->set_property ("lastKeySignature", get_property ("keySignature"));
}
void
Key_engraver::initialize ()
{
- daddy_trans_->set_property ("keySignature", SCM_EOL);
- daddy_trans_->set_property ("lastKeySignature", SCM_EOL);
+ daddy_context_->set_property ("keySignature", SCM_EOL);
+ daddy_context_->set_property ("lastKeySignature", SCM_EOL);
Pitch p(0,0,0);
- daddy_trans_->set_property ("tonic", p.smobbed_copy ());
+ daddy_context_->set_property ("tonic", p.smobbed_copy ());
}
#include "note-head.hh"
#include "rest.hh"
#include "warn.hh"
-#include "translator-group.hh"
+#include "context.hh"
+
/*
* This abstract class provides the general framework for ligatures of
{
SCM target_callback = ly_symbol2scm ("print-function");
SCM source_callback = ly_symbol2scm ("ligature-primitive-callback");
- SCM noteHeadProperties = updated_grob_properties (daddy_trans_, ly_symbol2scm ("NoteHead"));
+ SCM noteHeadProperties = updated_grob_properties (daddy_context_, ly_symbol2scm ("NoteHead"));
SCM value = ly_cdr (scm_sloppy_assq (source_callback, noteHeadProperties));
- execute_pushpop_property (daddy_trans_, ly_symbol2scm ("NoteHead"),
+ execute_pushpop_property (daddy_context_, ly_symbol2scm ("NoteHead"),
target_callback, value);
}
{
SCM symbol = ly_symbol2scm ("NoteHead");
SCM key = ly_symbol2scm ("print-function");
- execute_pushpop_property (daddy_trans_, symbol, key, SCM_UNDEFINED);
+ execute_pushpop_property (daddy_context_, symbol, key, SCM_UNDEFINED);
}
void
if (ligature_)
{
// TODO: maybe forbid breaks only if not transcribing
- top_engraver ()->forbid_breaks ();
+ get_score_engraver ()->forbid_breaks ();
}
if (reqs_drul_[START])
ADD_INTERFACE(Line_interface, "line-interface",
"Generic line objects. Any object using lines supports this. Normally,"
- "you get a straight line. If dash-period is defined, a dashed line is "
- "produced; the length of the dashes is tuned with"
+ "you get a straight line. If @code{dash-period} is defined, a dashed line is "
+ "produced; the length of the dashes is tuned with "
"@code{dash-fraction}. If the latter is set to 0, a dotted line is "
- "produced. If @code{dash-fraction} is negative, the line is set "
+ "produced. If @code{dash-fraction} is negative, the line is made "
"transparent.",
"dash-period dash-fraction thickness style")
ADD_INTERFACE (Line_spanner, "line-spanner-interface",
- "Generic line drawn between two objects, eg. for use with glissandi.\n"
-"gap is measured in staff-spaces.\n"
-"The property 'type is one of: line, dashed-line, trill, dotted-line or zigzag.\n"
-"\n",
- "gap zigzag-width zigzag-length thickness");
+ "Generic line drawn between two objects, e.g. for use with glissandi.\n"
+ "The property @code{style} can be @code{line}, "
+ "@code{dashed-line}, @code{trill}, \n"
+ "@code{dotted-line} or @code{zigzag}.\n"
+ "\n"
+ ,
+ "gap zigzag-width zigzag-length thickness");
LY_DEFINE(ly_filled_box ,"ly:round-filled-box",
3, 0, 0,
(SCM xext, SCM yext, SCM blot),
- "Make a filled-box of dimensions @var{xext}, @var{yext} and roundness @var{blot}.")
+ "Make a @code{Stencil} "
+ " that prints a filled-box of dimensions @var{xext}, "
+ "@var{yext} and roundness @var{blot}."
+ )
{
SCM_ASSERT_TYPE(is_number_pair (xext), xext, SCM_ARG1, __FUNCTION__, "number pair") ;
SCM_ASSERT_TYPE(is_number_pair (yext), yext, SCM_ARG2, __FUNCTION__, "number pair") ;
*/
-#include "translator-group.hh"
+#include "context.hh"
#include "lyric-combine-music.hh"
#include "event.hh"
#include "note-head.hh"
virtual bool ok () const;
virtual void derived_mark () const;
- virtual void derived_substitute (Translator_group*,Translator_group*) ;
+ virtual void derived_substitute (Context *,Context *) ;
private:
bool get_busy_status ()const ;
bool melisma_busy ();
};
+#include "translator.hh"
+
bool
melisma_busy (Translator* tr)
{
- SCM melisma_properties = tr->get_property ("melismaBusyProperties");
+ SCM melisma_properties = tr->daddy_context_->get_property ("melismaBusyProperties");
bool busy = false;
for (; gh_pair_p (melisma_properties);
}
void
-Lyric_combine_music_iterator::derived_substitute (Translator_group*f,Translator_group* t)
+Lyric_combine_music_iterator::derived_substitute (Context *f,Context * t)
{
if (music_iter_)
music_iter_->substitute_outlet (f,t);
if (try_music (busy_req))
return true;
- Translator_group * tr = music_iter_->get_outlet ();
+ Context * tr = music_iter_->get_outlet ();
SCM grobs = tr->get_property ("busyGrobs");
Moment now = tr->now_mom();
*/
-#include "translator-group.hh"
+#include "context.hh"
#include "engraver.hh"
#include "note-head.hh"
#include "lyric-extender.hh"
void add_lyric_extender (Grob_info);
void add_stanza_number (Grob_info);
Phrasing_association *get_phrasing_assoc (String nm);
- String get_voice_name_for_lyric (Translator_group*tr);
+ String get_voice_name_for_lyric (Context *tr);
Link_array<Phrasing_association> assocs_;
};
String
-Lyric_phrasing_engraver::get_voice_name_for_lyric (Translator_group*tr)
+Lyric_phrasing_engraver::get_voice_name_for_lyric (Context *tr)
{
SCM voice_context = tr->get_property ("associatedVoiceContext");
if (Translator *vc = unsmob_translator (voice_context))
{
- return dynamic_cast<Translator_group*> (vc)->id_string_;
+ return dynamic_cast<Context *> (vc)->id_string_;
}
SCM voice = tr->get_property ("associatedVoice");
void
Lyric_phrasing_engraver::add_lyric_extender (Grob_info inf)
{
- Translator_group * tr = inf.origin_trans_->daddy_trans_;
+ Context * tr = inf.origin_trans_->daddy_context_;
while (tr && !tr->is_alias (ly_symbol2scm ("Lyrics")))
- tr = tr->daddy_trans_;
+ tr = tr->daddy_context_;
if (!tr)
return;
void
Lyric_phrasing_engraver::add_stanza_number (Grob_info inf)
{
- Translator_group * tr = inf.origin_trans_->daddy_trans_;
+ Context * tr = inf.origin_trans_->daddy_context_;
while (tr && !tr->is_alias (ly_symbol2scm ("Lyrics")))
- tr = tr->daddy_trans_;
+ tr = tr->daddy_context_;
if (!tr)
return;
void
Lyric_phrasing_engraver::add_voice_phrasing (Grob_info inf)
{
- Translator_group * tr = inf.origin_trans_->daddy_trans_;
+ Context * tr = inf.origin_trans_->daddy_context_;
while (tr && !tr->is_alias (ly_symbol2scm ("Voice")))
- tr = tr->daddy_trans_;
+ tr = tr->daddy_context_;
if (!tr)
return;
void
Lyric_phrasing_engraver::add_lyric_phrasing (Grob_info inf)
{
- Translator_group * tr = inf.origin_trans_->daddy_trans_;
+ Context * tr = inf.origin_trans_->daddy_context_;
while (tr && !tr->is_alias (ly_symbol2scm ("Lyrics")))
- tr = tr->daddy_trans_;
+ tr = tr->daddy_context_;
if (!tr)
return;
#include <ctype.h>
#include "bar-line.hh"
-
+#include "context.hh"
#include "engraver-group-engraver.hh"
#include "engraver.hh"
#include "item.hh"
{
int mark_count = gh_scm2int (m);
mark_count ++;
- daddy_trans_->set_property ("rehearsalMark",
- gh_int2scm (mark_count));
+ daddy_context_->set_property ("rehearsalMark",
+ gh_int2scm (mark_count));
}
if (gh_number_p (m))
- m = scm_call_2 (proc, m, daddy_trans_->self_scm ());
+ m = scm_call_2 (proc, m, daddy_context_->self_scm ());
else
warning ("rehearsalMark does not have integer value.");
}
(c) 2002--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "score-engraver.hh"
#include "spanner.hh"
#include "warn.hh"
#include "side-position-interface.hh"
+#include "global-context.hh"
+#include "engraver.hh"
class Measure_grouping_engraver : public Engraver
{
stop_grouping_mom_ = now.main_part_ + Rational(grouplen - 1) * bl ;
- top_engraver ()->add_moment_to_process (Moment (stop_grouping_mom_));
+ get_global_context ()->add_moment_to_process (Moment (stop_grouping_mom_));
if (grouplen == 3)
grouping_->set_grob_property ("style", ly_symbol2scm ("triangle"));
}
ADD_INTERFACE (Measure_grouping,"measure-grouping-interface",
- "indicate groups of beats. Valid choices for 'type are 'bracket and 'triangle.",
+ "This objectt indicates groups of beats. "
+ "Valid choices for @code{style} are @code{bracket} and @code{triangle}.",
"thickness style height");
#include "engraver.hh"
#include "event.hh"
#include "grob.hh"
-#include "translator-group.hh"
+#include "context.hh"
+
/**
Signal existence of melismas.
#include "engraver.hh"
#include "engraver-group-engraver.hh"
#include "item.hh"
+#include "context.hh"
/**
put stuff over or next to bars. Examples: bar numbers, marginal notes,
SCM proc = get_property ("metronomeMarkFormatter");
SCM result= scm_call_2 (proc, mark_ev_->self_scm (),
- daddy_trans_->self_scm());
+ daddy_context_->self_scm());
text_->set_grob_property ("text", result);
}
}
LY_DEFINE (ly_moment_less_p,"ly:moment<?", 2,0,0, (SCM a, SCM b),
- "Comparation.")
+ "Compare two moments.")
{
Moment * ma = unsmob_moment (a);
Moment * mb = unsmob_moment (b);
#include "warn.hh"
#include "music-iterator.hh"
-#include "translator-group.hh"
+#include "context.hh"
#include "music-wrapper.hh"
#include "music-wrapper-iterator.hh"
#include "simple-music-iterator.hh"
{
}
-Translator_group*
+Context *
Music_iterator::get_outlet () const
{
return handle_.get_outlet ();
}
void
-Music_iterator::set_translator (Translator_group *trans)
+Music_iterator::set_translator (Context *trans)
{
handle_.set_translator (trans);
}
}
void
-Music_iterator::init_translator (Music *m, Translator_group *report)
+Music_iterator::init_translator (Music *m, Context *report)
{
music_ = m;
assert (m);
}
void
-Music_iterator::substitute_outlet (Translator_group*f, Translator_group *t)
+Music_iterator::substitute_outlet (Context *f, Context *t)
{
if (get_outlet () == f)
set_translator (t);
}
void
-Music_iterator::derived_substitute (Translator_group*,Translator_group*)
+Music_iterator::derived_substitute (Context *,Context *)
{
}
#include "warn.hh"
#include "music-output-def.hh"
-#include "global-translator.hh"
+#include "global-context.hh"
#include "context-def.hh"
#include "main.hh"
#include "file-path.hh"
find the translator for NAME. NAME must be a symbol.
*/
SCM
-Music_output_def::find_translator (SCM name) const
+Music_output_def::find_context_def (SCM name) const
{
SCM val =SCM_EOL;
translator_tab_->try_retrieve (name, &val);
}
-Global_translator *
-Music_output_def::get_global_translator ()
-{
- SCM key = ly_symbol2scm ("Score");
- Context_def * t = unsmob_context_def (find_translator (key));
-
- if (!t)
- error (_f ("can't find `%s' context", "Score"));
-
- Translator_group * tg = t->instantiate (SCM_EOL);
- dynamic_cast<Global_translator*> (tg)->output_def_ = this;
-
-
- tg->initialize ();
-
- return dynamic_cast <Global_translator *> (tg);
-}
-
int
Music_output_def::print_smob (SCM s, SCM p, scm_print_state *)
{
}
void
-Music_wrapper_iterator::derived_substitute (Translator_group*f,Translator_group*t)
+Music_wrapper_iterator::derived_substitute (Context *f,Context *t)
{
if (child_iter_)
// to do property args
LY_DEFINE(ly_extended_make_music,
"ly:make-bare-music", 2, 0, 0, (SCM type, SCM props),
- "Make a music object/expression of type @var{type}, init with\n"
-"@var{props}. Warning: this interface will likely change in the near\n"
-"future.\n"
-"\n"
-"Music is the data type that music expressions are stored in. The data\n"
-"type does not yet offer many manipulations.\n"
-"\n"
-"WARNING: only for internal use. Please use make-music-by-name. \n"
-)
+ "Make a C++ music object of type @var{type}, initialize with\n"
+ "@var{props}. \n\n"
+ ""
+ "This function is for internal use, and is only called by "
+ "@code{make-music-by-name}, which is the preferred interface "
+ "for creating music objects. "
+ )
{
SCM_ASSERT_TYPE(gh_string_p (type), type, SCM_ARG1, __FUNCTION__, "string");
// to do property args
LY_DEFINE(ly_get_mutable_properties,
"ly:get-mutable-properties", 1, 0, 0, (SCM mus),
-"Return an alist signifying the mutable properties of @var{mus}.\n"
-"The immutable properties are not available; they should be initialized\n"
-"by the functions make-music-by-name function.\n"
-)
+ "Return an alist containing the mutable properties of @var{mus}.\n"
+ "The immutable properties are not available; they should be initialized\n"
+ "by the @code{make-music-by-name} function.\n"
+ )
{
Music *m = unsmob_music (mus);
SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__, "music");
return m->get_property_alist (true);
}
-LY_DEFINE(ly_music_list_p,"music-list?", 1, 0, 0,
+LY_DEFINE(ly_music_list_p,"ly:music-list?", 1, 0, 0,
(SCM l),"Type predicate: return true if @var{l} is a list of music objects.")
{
if (scm_list_p (l) != SCM_BOOL_T)
+++ /dev/null
-/*
- new-accidental-engraver.cc -- implement new_accidental_engraver
-
- (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- Modified 2001--2004 by Rune Zedeler <rz@daimi.au.dk>
-
- This is an experimental file - producing correct accidentals but
- unfortunately ruining the spacing. -rz
-
-*/
-
-#include "event.hh"
-
-#include "item.hh"
-#include "tie.hh"
-#include "rhythmic-head.hh"
-#include "engraver-group-engraver.hh"
-#include "accidental-placement.hh"
-#include "side-position-interface.hh"
-#include "engraver.hh"
-#include "arpeggio.hh"
-#include "warn.hh"
-
-#include "translator-group.hh"
-
-/**
-
-
-FIXME: should not compute vertical positioning of accidentals, but
-get them from the noteheads
-
-The algorithm for accidentals should be documented, and made
-tweakable.
-
-*/
-
-struct New_accidental_entry {
- int pass_done_;
- int number_accidentals_;
- int number_cautionaries_;
- bool different_;
- Music * melodic_;
- Grob * accidental_;
- Translator_group *origin_;
- Grob* head_;
- New_accidental_entry();
-};
-
-New_accidental_entry::New_accidental_entry()
-{
- pass_done_ = 0;
- number_accidentals_ = 0;
- number_cautionaries_ = 0;
- different_ = false;
- melodic_ = 0;
- accidental_ = 0;
- origin_ = 0;
- head_ = 0;
-}
-
-struct New_accidental_engraver : Engraver {
-protected:
- TRANSLATOR_DECLARATIONS (New_accidental_engraver);
- virtual void process_music ();
- virtual void acknowledge_grob (Grob_info);
- virtual void stop_translation_timestep ();
- virtual void process_acknowledged_grobs ();
- virtual void finalize ();
- virtual void process_grobs_first_pass ();
- virtual void process_grobs_second_pass ();
-
- public:
-
- /*
- TODO -> property.
-
- This is not a property, and it is not protected. This poses a
- very small risk of the value being GC'd from under us.
- */
- SCM last_keysig_;
-
- /*
- Urgh. Since the accidentals depend on lots of variables, we have to
- store all information before we can really create the accidentals.
- */
- Link_array<Grob> arpeggios_;
-
- Grob * accidental_placement_;
-
-
- /*
- The next
- */
- Array<New_accidental_entry> accidentals_;
-
- Link_array<Grob> ties_;
-
-
-};
-
-
-New_accidental_engraver::New_accidental_engraver ()
-{
- last_keysig_ = SCM_BOOL_F;
- accidental_placement_ = 0;
-}
-
-/* inserts the source alist into the destination alist, erasing old entries.
- result is: dest = merged
-*/
-static SCM merge_alists_front_x (SCM src, SCM dest) {
- if(gh_pair_p(src)) {
- dest = merge_alists_front_x(ly_cdr(src),dest);
- dest = ly_assoc_front_x(dest, ly_caar(src), ly_cdar(src));
- }
- return dest;
-}
-
-static void merge_property_on_children (Translator_group * trans,
- const char * from_sym, const char * to_sym)
-{
- SCM from = trans->get_property(from_sym);
- SCM to = trans->get_property(to_sym);
- to = merge_alists_front_x(from, to);
- trans->set_property (to_sym, to);
- trans->set_property (from_sym, SCM_EOL);
- for (SCM p = trans -> trans_group_list_; gh_pair_p (p); p = ly_cdr(p)) {
- Translator_group *trg = dynamic_cast<Translator_group*> (unsmob_translator (ly_car (p)));
- merge_property_on_children(trg, from_sym, to_sym);
- }
-}
-
-static void merge_property_on_family (Translator_group * trans,
- const char * from_sym, const char * to_sym)
-{
- merge_property_on_children (trans, from_sym, to_sym);
- trans = trans->daddy_trans_;
- while (trans)
- {
- SCM from = trans->get_property(from_sym);
- SCM to = trans->get_property(to_sym);
- to = merge_alists_front_x(from, to);
- trans->set_property (to_sym, to);
- trans->set_property (from_sym, SCM_EOL);
- trans = trans->daddy_trans_;
- }
-}
-
-static void set_property_on_children (Translator_group * trans, const char * sym, SCM val)
-{
- trans->set_property (sym, val);
- for (SCM p = trans -> trans_group_list_; gh_pair_p (p); p = ly_cdr(p)) {
- Translator_group *trg = dynamic_cast<Translator_group*> (unsmob_translator (ly_car (p)));
- set_property_on_children(trg,sym,ly_deep_copy(val));
- }
-}
-
-static void set_property_on_family(Translator_group * trans, const char * sym, SCM val)
-{
- set_property_on_children (trans, sym, val);
- trans = trans->daddy_trans_;
- while (trans)
- {
- trans -> set_property (sym, ly_deep_copy (val));
- trans = trans->daddy_trans_;
- }
-}
-
-/*
-calculates the number of accidentals on basis of the current local key sig
- (passed as argument)
- Returns number of accidentals (0, 1 or 2).
- Negative (-1 or -2) if accidental has changed.
-
-*/
-static int
-number_accidentals (SCM sig, Music * note, Pitch *pitch, SCM curbarnum, SCM lazyness,
- bool ignore_octave_b)
-{
- int n = pitch->get_notename ();
- int o = pitch->get_octave ();
- int a = pitch->get_alteration ();
- int curbarnum_i = gh_scm2int (curbarnum);
- int accbarnum_i = 0;
-
- SCM prev;
- if (ignore_octave_b)
- prev = ly_assoc_cdr (gh_int2scm (n), sig);
- else
- prev = scm_assoc (gh_cons (gh_int2scm (o), gh_int2scm (n)), sig);
-
- /* should really be true unless prev == SCM_BOOL_F */
- if (gh_pair_p (prev) && gh_pair_p (ly_cdr (prev)))
- {
- accbarnum_i = gh_scm2int (ly_cddr (prev));
- prev = gh_cons (ly_car (prev), ly_cadr (prev));
- }
-
- /* If an accidental was not found or the accidental was too old */
- if (prev == SCM_BOOL_F ||
- (gh_number_p (lazyness) && curbarnum_i > accbarnum_i + gh_scm2int (lazyness)))
- prev = scm_assoc (gh_int2scm (n), sig);
-
-
- SCM prev_acc = (prev == SCM_BOOL_F) ? gh_int2scm (0) : ly_cdr (prev);
-
- int p = gh_number_p (prev_acc) ? gh_scm2int (prev_acc) : 0;
-
- int num;
- if (a == p
- && !to_boolean (note->get_mus_property ("force-accidental"))
- && gh_number_p (prev_acc))
- num = 0;
- else if ( (abs (a)<abs (p) || p*a<0) && a != 0 )
- num = 2;
- else
- num = 1;
-
- return a == p ? num : -num;
-}
-
-static int
-number_accidentals (Music * note, Pitch *pitch, Translator_group * origin,
- SCM accidentals, SCM curbarnum)
-{
- int number = 0;
-
- bool diff = false;
- if (gh_pair_p (accidentals) && !gh_symbol_p (ly_car (accidentals)))
- warning (_f ("Accidental typesetting list must begin with context-name: %s",
- ly_scm2string (ly_car (accidentals)).to_str0 ()));
-
- while (gh_pair_p (accidentals) && origin)
- {
- // If pair then it is a new accidentals typesetting rule to be checked
- if (gh_pair_p (ly_car (accidentals)))
- {
- SCM type = gh_caar (accidentals);
- SCM lazyness = gh_cdar (accidentals);
- SCM localsig = origin->get_property ("localKeySignature");
-
- bool same_octave_b =
- gh_eq_p (ly_symbol2scm ("same-octave"), type);
- bool any_octave_b =
- gh_eq_p (ly_symbol2scm ("any-octave"), type);
-
- if (same_octave_b || any_octave_b)
- {
- int n = number_accidentals
- (localsig, note, pitch, curbarnum, lazyness, any_octave_b);
- diff = diff || (n < 0);
- number = max (number, abs (n));
- }
- else
- warning (_f ("unknown accidental typesetting: %s. Ignored",
- ly_symbol2string (type).to_str0 ()));
- }
-
-
- /*
- if symbol then it is a context name. Scan parent contexts to find it.
- */
- else if (gh_symbol_p (ly_car (accidentals)))
- {
- SCM context = ly_car (accidentals);
-
- while (origin && !origin->is_alias (context))
- origin = origin->daddy_trans_;
-
- if (!origin)
- warning (_f ("Symbol is not a parent context: %s. Ignored",
- ly_symbol2string (context).to_str0 ()));
- }
- else warning (_f ("Accidental typesetting must be pair or context-name: %s",
- ly_scm2string (ly_car (accidentals)).to_str0 ()));
-
- accidentals = ly_cdr (accidentals);
- }
- return diff ? -number : number;
-}
-
-
-/*
- Perhaps one should join the two functions into one function taking an
- argument (pass).
- OTOH even though code would be smaller, spaghetti-level would increase.
-*/
-void
-New_accidental_engraver::process_grobs_first_pass ()
-{
- SCM accidentals = get_property ("autoAccidentals");
- SCM cautionaries = get_property ("autoCautionaries");
- SCM barnum = get_property ("currentBarNumber");
-
- for (int i = 0; i < accidentals_.size (); i++)
- {
- if (accidentals_[i].pass_done_ >= 1)
- continue;
- accidentals_[i].pass_done_ = 1;
-
- Grob * support = accidentals_[i].head_;
- Music * note = accidentals_[i].melodic_;
- Translator_group * origin = accidentals_[i].origin_;
- Pitch * pitch = unsmob_pitch (note->get_mus_property ("pitch"));
-
- int num;
- num = number_accidentals (note, pitch, origin, accidentals, barnum);
- accidentals_[i].number_accidentals_ = abs(num);
- accidentals_[i].different_ = num<0;
-
- num = number_accidentals (note, pitch, origin, cautionaries, barnum);
- accidentals_[i].number_cautionaries_ = abs(num);
- accidentals_[i].different_ = accidentals_[i].different_ || num<0;
-
- bool tie_changes = false;
- for (int j = 0; j < ties_.size (); j++)
- if (support == Tie::head (ties_[j], RIGHT))
- tie_changes = accidentals_[i].different_;
- int n = pitch->get_notename ();
- int o = pitch->get_octave ();
- int a = pitch->get_alteration ();
- SCM o_s = gh_int2scm (o);
- SCM n_s = gh_int2scm (n);
- SCM on_s = gh_cons (o_s,n_s);
-
- while (origin)
- {
- SCM sigch = origin->get_property ("localKeySignatureChanges");
- SCM alt;
- if (tie_changes)
- /*
- Remember an alteration that is different both from
- that of the tied note and of the key signature.
- */
- alt = SCM_BOOL_T;
- else
- alt = gh_int2scm (a);
- bool other_alt_same_oct = false;
- bool other_alt_any_oct = false;
- for (SCM j = sigch; gh_pair_p(j); j = ly_cdr(j)) {
- SCM entry = ly_car(j);
- /* if same notename has a different alt already recorded: */
- if(gh_equal_p(ly_cdar(entry),n_s) && !gh_equal_p(ly_cadr(entry),alt))
- {
- /* if it is also in same octave */
- if(gh_equal_p(ly_caar(entry),o_s))
- other_alt_same_oct = true;
- else
- other_alt_any_oct = true;
- }
- }
- if(other_alt_same_oct)
- alt = SCM_BOOL_T;
- sigch = ly_assoc_front_x (sigch, on_s, gh_cons(alt,barnum));
- if(other_alt_any_oct && !other_alt_same_oct) {
- sigch = ly_assoc_front_x (sigch, on_s, gh_cons(SCM_BOOL_T,barnum));
- }
- origin->set_property ("localKeySignatureChanges", sigch);
- origin = origin->daddy_trans_;
- }
- }
-}
-
-void
-New_accidental_engraver::process_grobs_second_pass ()
-{
- SCM accidentals = get_property ("autoAccidentals");
- SCM cautionaries = get_property ("autoCautionaries");
- SCM barnum = get_property ("currentBarNumber");
-
- bool extra_natural_b = get_property ("extraNatural") == SCM_BOOL_T;
- for (int i = 0; i < accidentals_.size (); i++)
- {
- if (accidentals_[i].pass_done_ >= 2)
- continue;
- accidentals_[i].pass_done_ = 2;
- Grob * support = accidentals_[i].head_;
- Music * note = accidentals_[i].melodic_;
- Translator_group * origin = accidentals_[i].origin_;
-
- Pitch * pitch = unsmob_pitch (note->get_mus_property ("pitch"));
-
- int num;
- num = number_accidentals (note, pitch, origin, accidentals, barnum);
- accidentals_[i].number_accidentals_ =
- max (accidentals_[i].number_accidentals_, abs(num));
- accidentals_[i].different_ = accidentals_[i].different_ || num<0;
-
- num = number_accidentals (note, pitch, origin, cautionaries, barnum);
- accidentals_[i].number_cautionaries_ =
- max (accidentals_[i].number_cautionaries_, abs(num));
- accidentals_[i].different_ = accidentals_[i].different_ || num<0;
-
-
- bool cautionary = to_boolean (note->get_mus_property ("cautionary"));
-
- if (accidentals_[i].number_cautionaries_ >accidentals_[i].number_accidentals_ )
- {
- num = accidentals_[i].number_cautionaries_;
- cautionary = true;
- }
- else
- num = accidentals_[i].number_accidentals_;
-
- bool tie_changes = false;
- Grob *tie_break_reminder = 0;
- for (int j = 0; j < ties_.size (); j++)
- if (support == Tie::head (ties_[j], RIGHT))
- {
- tie_changes = accidentals_[i].different_;
- tie_break_reminder = ties_[j];
- }
-
- if (num)
- {
- Grob * a = make_item ("Accidental");
- a->set_parent (support, Y_AXIS);
-
- if (!accidental_placement_)
- {
- accidental_placement_ = make_item ("AccidentalPlacement");
- announce_grob (accidental_placement_, a->self_scm());
- }
-
- Accidental_placement::add_accidental (accidental_placement_, a);
- announce_grob (a, SCM_EOL);
-
-
- SCM accs = gh_cons (gh_int2scm (pitch->get_alteration ()), SCM_EOL);
- if (num == 2 && extra_natural_b)
- accs = gh_cons (gh_int2scm (0), accs);
-
- if (cautionary)
- {
- a->set_grob_property ("cautionary", SCM_BOOL_T);
- }
-
- if (tie_break_reminder)
- {
- a->set_grob_property ("tie", tie_break_reminder->self_scm());
- }
-
-
- support->set_grob_property ("accidental-grob", a->self_scm ());
-
- a->set_grob_property ("accidentals", accs);
- accidentals_[i].accidental_ = a;
- /*
- We add the accidentals to the support of the arpeggio, so it is
- put left of the accidentals.
- */
- for (int i = 0; i < arpeggios_.size (); i++)
- Side_position_interface::add_support (arpeggios_[i], a);
- }
- }
-}
-
-void
-New_accidental_engraver::process_acknowledged_grobs ()
-{
- if (accidentals_.size () && accidentals_.top().pass_done_ < 1)
- process_grobs_first_pass ();
-}
-
-void
-New_accidental_engraver::finalize ()
-{
-
-}
-
-void
-New_accidental_engraver::stop_translation_timestep ()
-{
- merge_property_on_family(daddy_trans_, "localKeySignatureChanges", "localKeySignature");
- if (accidentals_.size () && accidentals_.top().pass_done_ < 2)
- process_grobs_second_pass ();
-
- for (int i = 0; i < accidentals_.size(); i++)
- {
- Grob *a = accidentals_[i].accidental_;
- if (a)
- {
- typeset_grob (a);
- }
- }
-
- if (accidental_placement_)
- typeset_grob(accidental_placement_);
- accidental_placement_ = 00;
-
- set_property_on_family(daddy_trans_, "localKeySignatureChanges", SCM_EOL);
- accidentals_.clear();
- arpeggios_.clear ();
- ties_.clear ();
-}
-
-void
-New_accidental_engraver::acknowledge_grob (Grob_info info)
-{
- Music * note = info.music_cause ();
-
- if (note
- && note->is_mus_type ("note-event")
- && Rhythmic_head::has_interface (info.grob_))
- {
- New_accidental_entry entry ;
- entry.head_ = info.grob_;
- entry.origin_ = info.origin_trans_->daddy_trans_;
- entry.melodic_ = note;
-
- accidentals_.push (entry);
- }
- else if (Tie::has_interface (info.grob_))
- {
- ties_.push (info.grob_);
- }
- else if (Arpeggio::has_interface (info.grob_))
- {
- arpeggios_.push (info.grob_);
- }
-
-}
-
-void
-New_accidental_engraver::process_music ()
-{
- SCM sig = get_property ("keySignature");
-
- /* Detect key sig changes.
- Update all parents and children
- */
- if (last_keysig_ != sig)
- {
- set_property_on_family(daddy_trans_, "localKeySignature", sig);
- set_property_on_family(daddy_trans_, "localKeySignatureChanges", SCM_EOL); //This souldn't be neccesary
- last_keysig_ = sig;
- }
-}
-
-
-
-
-
-ENTER_DESCRIPTION (New_accidental_engraver,
-"Make accidentals. Catches note heads, ties and notices key-change "
-"events. Due to interaction with ties (which don't come together "
-"with note heads), this needs to be in a context higher than Tie_engraver.",
-
- "Accidental",
-/* accepts */ "",
- "rhythmic-head-interface tie-interface arpeggio-interface",
- "localKeySignature localKeySignatureChanges extraNatural autoAccidentals autoCautionaries",
- "localKeySignature localKeySignatureChanges");
Finger_tuple ft ;
Grob * g= make_item ("Script");
- make_script_from_event (g, &ft.description_, daddy_trans_,
+ make_script_from_event (g, &ft.description_, daddy_context_,
event->get_mus_property ("articulation-type"), 0);
if (g)
{
*/
-#include "translator-group.hh"
+#include "context.hh"
#include "lyric-combine-music.hh"
#include "event.hh"
#include "grob.hh"
virtual bool run_always ()const;
virtual bool ok () const;
virtual void derived_mark () const;
- virtual void derived_substitute (Translator_group*,Translator_group*);
+ virtual void derived_substitute (Context *,Context *);
private:
bool start_new_syllable () ;
void find_voice ();
bool made_association_;
- Translator_group * lyrics_context_;
- Translator_group* music_context_;
+ Context * lyrics_context_;
+ Context * music_context_;
Music_iterator * lyric_iter_;
};
}
void
-New_lyric_combine_music_iterator::derived_substitute (Translator_group*f, Translator_group*t)
+New_lyric_combine_music_iterator::derived_substitute (Context *f, Context *t)
{
if (lyric_iter_)
lyric_iter_->substitute_outlet (f,t);
music_context_ = t;
}
-/*
- ID == "" means accept any ID.
- */
-Translator_group *
-find_context_below (Translator_group * where,
- String type, String id)
-{
- if (where->is_alias (ly_symbol2scm (type.to_str0 ())))
- {
- if (id == "" || where->id_string_ == id)
- return where;
- }
-
- Translator_group * found = 0;
- for (SCM s = where->trans_group_list_;
- !found && gh_pair_p (s); s = gh_cdr (s))
- {
- Translator_group * tr = dynamic_cast<Translator_group*> (unsmob_translator (gh_car (s)));
-
- found = find_context_below (tr, type, id);
- }
-
- return found;
-}
-
-
void
New_lyric_combine_music_iterator::construct_children ()
if (gh_string_p (voice_name))
{
- Translator_group *t = get_outlet ();
- while (t && t->daddy_trans_)
- t = t->daddy_trans_;
+ Context *t = get_outlet ();
+ while (t && t->daddy_context_)
+ t = t->daddy_context_;
String name = ly_scm2string (voice_name);
- Translator_group *voice = find_context_below (t, "Voice", name);
+ Context *voice = find_context_below (t, "Voice", name);
if (!voice)
get_music ()->origin ()->warning (_f ("cannot find Voice: %s\n",
name.to_str0 ()));
if (!music_context_)
return ;
- if (!music_context_->daddy_trans_)
+ if (!music_context_->daddy_context_)
{
/*
The melody has died.
(c) 2004 Han-Wen Nienhuys
*/
-#include "translator-group.hh"
+#include "context.hh"
#include "event.hh"
#include "music-sequence.hh"
#include "lily-guile.hh"
DECLARE_SCHEME_CALLBACK(constructor, ());
protected:
- virtual void derived_substitute (Translator_group*f, Translator_group*t) ;
+ virtual void derived_substitute (Context *f, Context *t) ;
virtual void derived_mark () const;
New_pc_iterator (New_pc_iterator const &);
Interpretation_context_handle shared_;
Interpretation_context_handle solo_;
- void substitute_both (Translator_group * to1,
- Translator_group * to2);
+ void substitute_both (Context * to1,
+ Context * to2);
- void kill_mmrest (Translator_group*);
+ void kill_mmrest (Context *);
void chords_together ();
void solo1 ();
void solo2 ();
}
void
-New_pc_iterator::derived_substitute (Translator_group*f,
- Translator_group*t)
+New_pc_iterator::derived_substitute (Context *f,
+ Context *t)
{
if (first_iter_)
first_iter_->substitute_outlet (f,t);
void
-New_pc_iterator::kill_mmrest (Translator_group * tg)
+New_pc_iterator::kill_mmrest (Context * tg)
{
static Music * mmrest;
if (!mmrest)
}
void
-New_pc_iterator::substitute_both (Translator_group * to1,
- Translator_group * to2)
+New_pc_iterator::substitute_both (Context * to1,
+ Context * to2)
{
- Translator_group *tos[] = {to1,to2};
+ Context *tos[] = {to1,to2};
Music_iterator *mis[] = {first_iter_, second_iter_};
Interpretation_context_handle *hs[] = {
&null_,
for (int j = 0; hs[j]; j++)
{
- Translator_group* t = hs[j]->get_outlet ();
+ Context * t = hs[j]->get_outlet ();
if (t != to1 && t != to2)
kill_mmrest (t);
}
SCM_UNDEFINED);
- Translator_group *tr
- = get_outlet ()->find_create_translator (ly_symbol2scm ("Voice"),
+ Context *tr
+ = get_outlet ()->find_create_context (ly_symbol2scm ("Voice"),
"shared",props);
shared_.set_translator (tr);
*/
set_translator (tr);
- Translator_group *solo_tr
- = get_outlet ()->find_create_translator (ly_symbol2scm ("Voice"),
+ Context *solo_tr
+ = get_outlet ()->find_create_context (ly_symbol2scm ("Voice"),
"solo",props);
solo_ .set_translator (solo_tr);
- Translator_group *null
- = get_outlet ()->find_create_translator (ly_symbol2scm ("Devnull"),
+ Context *null
+ = get_outlet ()->find_create_context (ly_symbol2scm ("Devnull"),
"", SCM_EOL);
if (!null)
null_.set_translator (null);
- Translator_group *one = tr->find_create_translator (ly_symbol2scm ("Voice"),
+ Context *one = tr->find_create_context (ly_symbol2scm ("Voice"),
"one", props);
one_.set_translator (one);
first_iter_ = unsmob_iterator (get_iterator (unsmob_music (gh_car (lst))));
- Translator_group *two = tr->find_create_translator (ly_symbol2scm ("Voice"),
+ Context *two = tr->find_create_context (ly_symbol2scm ("Voice"),
"two", props);
two_.set_translator (two);
set_translator (two);
#include "rhythmic-head.hh"
#include "side-position-interface.hh"
#include "staff-symbol-referencer.hh"
-#include "translator-group.hh"
+#include "context.hh"
+
/**
Create line-spanner grobs for lines that connect note heads.
private:
Spanner* line_;
- Translator* last_staff_;
+ Context* last_staff_;
bool follow_;
Grob* head_;
Grob* last_head_;
head_ = info.grob_;
if (to_boolean (get_property ("followVoice")))
{
- Translator_group * tr = daddy_trans_;
+ Context * tr = daddy_context_;
while (tr && !tr->is_alias (ly_symbol2scm ( "Staff")))
- tr = tr->daddy_trans_ ;
+ tr = tr->daddy_context_ ;
- if (tr && tr->is_alias (ly_symbol2scm ("Staff")) && tr != last_staff_)
+ if (tr
+ && tr->is_alias (ly_symbol2scm ("Staff")) && tr != last_staff_)
{
if (last_head_)
follow_ = true;
#include "event.hh"
#include "audio-item.hh"
#include "audio-column.hh"
-#include "global-translator.hh"
+#include "global-context.hh"
#include "warn.hh"
/**
virtual void stop_translation_timestep ();
virtual void create_audio_elements ();
- Global_translator* get_global_translator ();
-
+
private:
Link_array<Music> note_evs_;
Link_array<Audio_note> notes_;
}
}
-Global_translator*
-Note_performer::get_global_translator ()
-{
- Translator *t = this;
- Global_translator *global =0;
- do
- {
- t = t->daddy_trans_ ;
- global = dynamic_cast<Global_translator*> (t);
- }
- while (!global);
-
- return global;
-}
-
void
Note_performer::stop_translation_timestep ()
{
-
// why don't grace notes show up here?
// --> grace notes effectively do not get delayed
- Global_translator* global = get_global_translator ();
+ Global_context * global = get_global_context ();
for (int i=0; i < notes_.size (); i++)
{
Audio_note* n = notes_[i];
ADD_INTERFACE (Note_spacing,"note-spacing-interface",
- "",
+ "This object calculates spacing wishes for individual voices.",
"left-items right-items stem-spacing-correction knee-spacing-correction");
#include "engraver.hh"
#include "grob.hh"
-#include "translator-group.hh"
+#include "context.hh"
+
class Output_property_engraver : public Engraver
{
}
else
{
- Translator_group * d =
- dynamic_cast<Translator_group*> (inf.origin_trans_);
+ Context * d =
+ dynamic_cast<Context *> (inf.origin_trans_);
if (!d)
- d = dynamic_cast<Translator_group*> (inf.origin_trans_->daddy_trans_);
+ d = dynamic_cast<Context *> (inf.origin_trans_->daddy_context_);
SCM proc = o->get_mus_property ("procedure");
scm_call_3 (proc,
inf.grob_->self_scm(),
d->self_scm(),
- daddy_trans_->self_scm());
+ daddy_context_->self_scm());
}
}
}
ADD_INTERFACE (Paper_column, "paper-column-interface",
- " Paper_columns form the top-most item parent. (The Paper_columns X\n"
-" parent is System, which is a spanner.)\n"
-"\n"
-" Paper_columns form the units for the spacing engine. They are\n"
-" numbered, the first (leftmost) is column 0. Numbering happens before\n"
-" line-breaking, and columns are not renumbered after line breaking.\n"
-"\n"
-" Since many columns go unused, you should only use the rank field to\n"
-" get ordering information. Two adjacent columns may have\n"
-" non-adjacent numbers.\n"
-"\n"
-" Don't be confused by right-items: each spacing wish can also contain\n"
-" a number of items, with which a spacing constraint may be kept. It's\n"
-" a little baroque, but it might come in handy later on?\n"
-"\n",
- "between-cols between-system-string when bounded-by-me shortest-playing-duration shortest-starter-duration");
-
+ "@code{Paper_column} objects form the top-most X-parents for items. "
+ " The are two types of columns: musical columns, where are attached to, and "
+ " non-musical columns, where bar-lines, clefs etc. are attached to. "
+ " The spacing engine determines the X-positions of these objects."
+ "\n\n"
+ "They are\n"
+ " numbered, the first (leftmost) is column 0. Numbering happens before\n"
+ " line-breaking, and columns are not renumbered after line breaking.\n"
+ " Since many columns go unused, you should only use the rank field to\n"
+ " get ordering information. Two adjacent columns may have\n"
+ " non-adjacent numbers.\n"
+ "\n"
+ ,
+ "between-cols between-system-string when bounded-by-me "
+ "shortest-playing-duration shortest-starter-duration");
void
Paper_column::do_break_processing ()
/*
Be sure to set breakability on first & last column.
*/
- {
+ { /* doubly, also done in Score_engraver */
Link_array<Grob> pc (system_->columns ());
pc[0]->set_grob_property ("breakable", SCM_BOOL_T);
| BAR STRING {
Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2);
- Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
- csm->set_mus_property ("element", t->self_scm ());
- scm_gc_unprotect_object (t->self_scm ());
-
- $$ = csm;
+ Music *csm = context_spec_music (ly_symbol2scm ("Timing"), SCM_UNDEFINED,
+ t, SCM_EOL);
+ $$ = context_spec_music (ly_symbol2scm ("Score"), SCM_UNDEFINED, csm, SCM_EOL);
$$->set_spot (THIS->here_input ());
-
- csm->set_mus_property ("context-type", ly_symbol2scm ("Timing"));
+ t->set_spot (THIS->here_input ());
}
| PARTIAL duration_length {
Moment m = - unsmob_duration ($2)->get_length ();
Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
-
- Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
- sp->set_mus_property ("element", p->self_scm ());
- scm_gc_unprotect_object (p->self_scm ());
-
- $$ =sp ;
- sp-> set_mus_property ("context-type", ly_symbol2scm ("Timing"));
+ p->set_spot (THIS->here_input ());
+ p = context_spec_music (ly_symbol2scm ("Timing"), SCM_UNDEFINED,
+ p, SCM_EOL);
+ p = context_spec_music (ly_symbol2scm ("Score"), SCM_UNDEFINED,
+ p, SCM_EOL);
+ $$ =p ;
}
| CLEF STRING {
static SCM proc ;
#include "engraver.hh"
#include "repeated-music.hh"
#include "engraver-group-engraver.hh"
-#include "global-translator.hh"
+#include "global-context.hh"
#include "warn.hh"
#include "misc.hh"
#include "spanner.hh"
#include "bar-line.hh"
#include "score-engraver.hh"
-#include "translator-group.hh"
+#include "context.hh"
+
/**
This acknowledges repeated music with "percent" style. It typesets
repeat_ = rp;
- Global_translator *global =top_engraver();
+ Global_context *global = get_global_context ();
for (int i = 0; i < count; i++)
global->add_moment_to_process (next_moment_ + Moment (i) * body_length_);
forbid breaks on a % line. Should forbid all breaks, really.
*/
- top_engraver()->forbid_breaks (); // guh. Use properties!
+ get_score_engraver ()->forbid_breaks (); // guh. Use properties!
}
next_moment_ = next_moment_ + body_length_;
- top_engraver()->add_moment_to_process (next_moment_);
+ get_global_context ()->add_moment_to_process (next_moment_);
}
}
}
void
-Percent_repeat_iterator::derived_substitute(Translator_group*f,Translator_group*t )
+Percent_repeat_iterator::derived_substitute(Context *f,Context *t )
{
if (child_iter_)
child_iter_->substitute_outlet (f,t);
*/
#include "performer-group-performer.hh"
-
+#include "context.hh"
#include "audio-element.hh"
#include "warn.hh"
Performer_group_performer::announce_element (Audio_element_info info)
{
announce_infos_.push (info);
- Performer::announce_element (info);
-}
-
-
+ Translator *t
+ = unsmob_translator (daddy_context_->daddy_context_->implementation_);
-void
-Performer_group_performer::create_audio_elements ()
-{
- for (SCM p = get_simple_trans_list (); gh_pair_p (p); p = ly_cdr (p))
- {
- Translator * t = unsmob_translator (ly_car (p));
- Performer * eng = dynamic_cast<Performer*> (t);
- if (eng)
- eng->create_audio_elements ();
- }
+ if (Performer_group_performer * eg = dynamic_cast<Performer_group_performer*> (t))
+ eg->announce_element (info);
}
void
void
Performer_group_performer::do_announces ()
{
- for (SCM p = trans_group_list_; gh_pair_p (p); p =ly_cdr (p))
+ while (1)
{
- Translator * t = unsmob_translator (ly_car (p));
- dynamic_cast<Performer_group_performer*> (t)->do_announces ();
- }
-
+ performer_each (get_simple_trans_list (),
+ &Performer::create_audio_elements);
- create_audio_elements ();
-
- while (announce_infos_.size ())
- {
+ if (!announce_infos_.size ())
+ break ;
+
acknowledge_audio_elements ();
announce_infos_.clear ();
- create_audio_elements ();
- }
-
- if (announce_infos_.size ())
- {
-#if 0 //printf? -> include <stdio.h>
- printf ("do_announces: elt: %s\n",
- classname (announce_infos_[0].elem_));
-#endif
- announce_infos_.clear ();
}
}
{
}
-/*
- C & P from Engraver.
-
- Should move into Translator ?
- */
+/* c&p engraver-group.cc */
void
-Performer_group_performer::process_music ()
+recurse_down_performers (Context * c, Performer_method ptr, bool context_first)
{
- for (SCM p = get_simple_trans_list (); gh_pair_p (p); p =ly_cdr (p))
+ Performer_group_performer * tg
+ = dynamic_cast<Performer_group_performer*> (unsmob_translator (c->implementation_));
+
+
+ if (!context_first)
{
- Translator * t = unsmob_translator (ly_car (p));
- Performer * eng = dynamic_cast<Performer*> (t);
+ performer_each (tg->get_simple_trans_list (),
+ ptr);
- if (eng)
- eng->process_music ();
+ (tg->*ptr) ();
}
- for (SCM p = trans_group_list_; gh_pair_p (p); p =ly_cdr (p))
+
+ for (SCM s = c->context_list_ ; gh_pair_p (s);
+ s =gh_cdr (s))
+ {
+ recurse_down_performers (unsmob_context (gh_car (s)), ptr, context_first);
+ }
+
+ if (context_first)
+ {
+ performer_each (tg->get_simple_trans_list (),
+ ptr);
+ (tg->*ptr) ();
+ }
+}
+
+
+void
+performer_each (SCM list, Performer_method method)
+{
+ for (SCM p = list; gh_pair_p (p); p = ly_cdr (p))
{
- Translator * t = unsmob_translator (ly_car (p));
- Performer*eng = dynamic_cast<Performer*> (t);
- if (eng)
- eng->process_music ();
+ Performer * e = dynamic_cast<Performer*>(unsmob_translator (ly_car (p)));
+ if (e)
+ (e->*method) ();
}
}
Jan Nieuwenhuizen <janneke@gnu.org>
*/
-
+#include "context.hh"
#include "performer-group-performer.hh"
#include "warn.hh"
+void
+Performer::do_announces ()
+{
+}
+
void
Performer::play_element (Audio_element* p)
{
- get_daddy_perf ()->play_element (p);
+ get_daddy_performer ()->play_element (p);
}
int
Performer::get_tempo () const
{
- return get_daddy_perf ()->get_tempo ();
+ return get_daddy_performer ()->get_tempo ();
}
Performer_group_performer*
-Performer::get_daddy_perf () const
+Performer::get_daddy_performer () const
{
- return (daddy_trans_)
- ?dynamic_cast<Performer_group_performer *> (daddy_trans_)
- : 0;
+ return
+ dynamic_cast<Performer_group_performer *> (get_daddy_translator ());
}
void
{
if (!i.origin_trans_)
i.origin_trans_= this;
- get_daddy_perf ()->announce_element (i);
+ get_daddy_performer ()->announce_element (i);
}
-
void
Performer::process_music ()
{
#include "slur.hh"
#include "warn.hh"
#include "note-column.hh"
-#include "translator-group.hh"
+#include "context.hh"
+
#include "engraver.hh"
#include "spanner.hh"
ADD_INTERFACE (Piano_pedal_bracket,"piano-pedal-bracket-interface",
- "The bracket of the piano pedal. It can be tuned through the regular bracket properties (bracket-flare, edge-height, shorten-pair).",
+ "The bracket of the piano pedal. It can be tuned through the regular "
+ "bracket properties.",
"edge-height shorten-pair bracket-flare pedal-text");
#include "staff-symbol-referencer.hh"
#include "item.hh"
#include "axis-group-interface.hh"
-#include "translator-group.hh"
+#include "context.hh"
+
#include "directional-element-interface.hh"
#include "note-column.hh"
#include "warn.hh"
*/
LY_DEFINE(make_pitch, "ly:make-pitch", 3, 0, 0,
- (SCM o, SCM n, SCM a),
+ (SCM octave, SCM note, SCM alter),
"@var{octave} is specified by an integer, zero for the octave containing "
"middle C. @var{note} is a number from 0 to 6, with 0 corresponding to C "
- "and 6 corresponding to B. The shift is zero for a natural, negative for "
+ "and 6 corresponding to B. The @var{alter} is zero for a natural, negative for "
"flats, or positive for sharps. ")
{
- SCM_ASSERT_TYPE(gh_number_p (o), o, SCM_ARG1, __FUNCTION__, "number");
- SCM_ASSERT_TYPE(gh_number_p (n), n, SCM_ARG2, __FUNCTION__, "number");
- SCM_ASSERT_TYPE(gh_number_p (a), a, SCM_ARG3, __FUNCTION__, "number");
+ SCM_ASSERT_TYPE(scm_integer_p (octave)== SCM_BOOL_T , octave, SCM_ARG1, __FUNCTION__, "integer");
+ SCM_ASSERT_TYPE(scm_integer_p (note)== SCM_BOOL_T, note, SCM_ARG2, __FUNCTION__, "integer");
+ SCM_ASSERT_TYPE(scm_integer_p (alter)== SCM_BOOL_T, alter, SCM_ARG3, __FUNCTION__, "integer");
- Pitch p (gh_scm2int (o), gh_scm2int (n), gh_scm2int (a));
+ Pitch p (gh_scm2int (octave), gh_scm2int (note), gh_scm2int (alter));
return p.smobbed_copy ();
}
LY_DEFINE(ly_pitch_diff, "ly:pitch-diff", 2 ,0 ,0,
(SCM pitch, SCM root),
- "Return pitch with value DELTA = PITCH - ROOT, ie, "
- "ROOT == (ly:pitch-transpose PITCH DELTA).")
+ "Return pitch @var{delta} such that @code{pitch} transposed by "
+ "@var{delta} equals @var{root}"
+ )
{
Pitch *p = unsmob_pitch (pitch);
Pitch *r = unsmob_pitch (root);
#include "property-iterator.hh"
#include "music.hh"
#include "context-def.hh"
-#include "translator-group.hh"
-#include "global-translator.hh"
-
+#include "global-context.hh"
bool check_grob(Music *mus, SCM sym);
Property_iterator::once_finalization(SCM translator, SCM music )
{
Music * m = unsmob_music (music);
- Translator_group * tg
- = dynamic_cast<Translator_group*> (unsmob_translator (translator));
+ Context * tg
+ = dynamic_cast<Context *> (unsmob_context (translator));
SCM sym = m->get_mus_property ("symbol");
tg->unset_property (sym);
SCM trans = get_outlet ()->self_scm();
SCM music = get_music()->self_scm();
- Global_translator * tg= get_outlet ()->top_translator ();
-
+ Global_context * tg = get_outlet ()->get_global_context ();
tg->add_finalization (scm_list_n (once_finalization_proc,
trans, music, SCM_UNDEFINED));
}
Push_property_iterator::once_finalization (SCM trans, SCM music)
{
Music * mus = unsmob_music (music);
- Translator_group * tg = dynamic_cast<Translator_group*> (unsmob_translator (trans));
+ Context * tg = dynamic_cast<Context *> (unsmob_context (trans));
SCM sym = mus->get_mus_property ("symbol");
if (check_grob (mus, sym))
SCM trans = get_outlet ()->self_scm();
SCM music = get_music ()->self_scm();
- Global_translator * tg= get_outlet ()->top_translator ();
+ Global_context * tg= get_outlet ()->get_global_context ();
tg->add_finalization (scm_list_n (once_finalization_proc,
trans, music, SCM_UNDEFINED));
}
bool
Recording_group_engraver::try_music (Music *m)
{
- bool here_success = Translator_group::try_music_on_nongroup_children (m);
- bool retval = here_success;
- if (!here_success && daddy_trans_)
- retval = daddy_trans_->try_music (m);
-
+ bool retval = Translator_group::try_music (m);
+
SCM seq = gh_cdar (accumulator_);
- seq = gh_cons (gh_cons (m->self_scm(), gh_bool2scm (here_success)),
+ seq = gh_cons (gh_cons (m->self_scm(), gh_bool2scm (retval)),
seq);
scm_set_cdr_x (gh_car (accumulator_), seq);
(c) 2000--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
+
#include "engraver.hh"
#include "translator-group.hh"
+#include "context.hh"
#include "repeated-music.hh"
void
Repeat_acknowledge_engraver::initialize ()
{
- daddy_trans_->set_property ("repeatCommands", SCM_EOL);
+ daddy_context_->set_property ("repeatCommands", SCM_EOL);
}
void
Repeat_acknowledge_engraver::start_translation_timestep ()
{
- Translator_group * tr = daddy_trans_->where_defined (ly_symbol2scm ("repeatCommands"));
+ Context * tr = daddy_context_->where_defined (ly_symbol2scm ("repeatCommands"));
if (!tr)
- tr = daddy_trans_;
+ tr = daddy_context_;
tr->set_property ("repeatCommands", SCM_EOL);
}
{
if (s != "" || (volta_found && !gh_string_p (wb)))
{
- daddy_trans_->set_property ("whichBar", scm_makfrom0str (s.to_str0 ()));
+ daddy_context_->set_property ("whichBar", scm_makfrom0str (s.to_str0 ()));
}
}
}
}
ADD_INTERFACE (Rest,"rest-interface",
- "a rest",
+ "A rest symbol.",
"style minimum-distance");
--- /dev/null
+/*
+score-context.cc -- implement
+
+source file of the GNU LilyPond music typesetter
+
+(c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ */
+
+
+#include "score-context.hh"
+#include "score-translator.hh"
+
+
+void
+Score_context::prepare (Moment w)
+{
+ Translator* t = unsmob_translator (implementation_);
+ Score_translator * s = dynamic_cast<Score_translator *> (t);
+
+ s->prepare (w);
+}
+
+void
+Score_context::finish ()
+{
+ Translator* t = unsmob_translator (implementation_);
+ Score_translator * s = dynamic_cast<Score_translator *> (t);
+
+ s->finish ();
+}
+
+void
+Score_context::one_time_step ()
+{
+ Translator* t = unsmob_translator (implementation_);
+ Score_translator * s = dynamic_cast<Score_translator *> (t);
+ s->one_time_step();
+}
+
+
+Music_output*
+Score_context::get_output ()
+{
+ Translator* t = unsmob_translator (implementation_);
+ Score_translator * s = dynamic_cast<Score_translator *> (t);
+ return s->get_output ();
+}
+
#include "score-engraver.hh"
#include "paper-score.hh"
#include "paper-column.hh"
-
#include "paper-def.hh"
#include "axis-group-interface.hh"
#include "context-def.hh"
-
#include "staff-spacing.hh"
#include "note-spacing.hh"
+#include "context.hh"
+#include "global-context.hh"
+
+
+
/*
TODO: the column creation logic is rather hairy. Revise it.
if (!command_column_)
{
SCM nmp
- = updated_grob_properties (this,
+ = updated_grob_properties (daddy_context_,
ly_symbol2scm ("NonMusicalPaperColumn"));
- SCM pc = updated_grob_properties (this,
+ SCM pc = updated_grob_properties (daddy_context_,
ly_symbol2scm ("PaperColumn"));
set_columns (new Paper_column (nmp), new Paper_column (pc));
-
- command_column_->set_grob_property ("breakable", SCM_BOOL_T);
-
Grob_info i1;
i1.grob_ = command_column_;
}
void
-Score_engraver::prepare (Moment w)
+Score_engraver::prepare (Moment m)
{
- Global_translator::prepare (w);
-
/*
TODO: don't make columns when skipTypesetting is true.
*/
make_columns ();
-
- command_column_->set_grob_property ("when", now_mom_.smobbed_copy ());
- musical_column_->set_grob_property ("when", now_mom_.smobbed_copy ());
+ SCM w = m.smobbed_copy ();
+ command_column_->set_grob_property ("when", w);
+ musical_column_->set_grob_property ("when", w);
- Translator_group::start_translation_timestep();
+ recurse_down_translators (daddy_context_, &Translator::start_translation_timestep, false);
}
void
{
if ((breaks_%8))
progress_indication ("[" + to_string (breaks_) + "]");
-
- check_removal ();
- finalize ();
+
+ recurse_down_translators (daddy_context_, &Translator::finalize, true);
}
/*
error (_f ("can't find `%s'", "feta20.afm")
+ "\n" +_ ("Fonts have not been installed properly. Aborting"));
- unsmob_context_def (definition_)->apply_default_property_operations (this);
- assert (!daddy_trans_);
pscore_ = new Paper_score;
pscore_->paper_ = dynamic_cast<Paper_def*> (get_output_def ());
- SCM props = updated_grob_properties (this, ly_symbol2scm ("System"));
+ SCM props = updated_grob_properties (daddy_context_, ly_symbol2scm ("System"));
pscore_->typeset_line (new System (props));
void
Score_engraver::finalize ()
{
- Engraver_group_engraver::finalize ();
+ Score_translator::finalize ();
Grob * cc
= unsmob_grob (get_property ("currentCommandColumn"));
typeset_all ();
}
+
void
Score_engraver::one_time_step ()
{
if (!to_boolean (get_property ("skipTypesetting")))
{
- process_music ();
- do_announces ();
+ recurse_down_engravers (daddy_context_, &Engraver::process_music, false);
+ recurse_down_engravers (daddy_context_, &Engraver::do_announces, true);
}
- stop_translation_timestep ();
-
- apply_finalizations ();
- check_removal ();
-
-
- for (int i = announce_infos_.size(); i--;)
- {
- Grob *g = announce_infos_[i].grob_;
- if (!dynamic_cast<Paper_column*> (g)) // ugh.
- {
- String msg= "Grob "
- + g->name()
- + " was created too late!";
- g->programming_error (msg);
- }
- }
- announce_infos_.clear ();
+ recurse_down_translators (daddy_context_, &Translator::stop_translation_timestep, true);
}
void
musical_column_ = new_musical;
if (new_command)
{
- set_property ("currentCommandColumn", new_command->self_scm ());
+ daddy_context_->set_property ("currentCommandColumn", new_command->self_scm ());
}
if (new_musical)
{
- set_property ("currentMusicalColumn", new_musical->self_scm ());
+ daddy_context_->set_property ("currentMusicalColumn", new_musical->self_scm ());
}
}
return gotcha;
}
-/*
- TODO: use property Score.breakForbidden = #t
- */
void
Score_engraver::forbid_breaks ()
{
- /*
- result is junked.
- */
if (command_column_)
command_column_->set_grob_property ("breakable", SCM_EOL);
}
Score_performer::announce_element (Audio_element_info info)
{
announce_infos_.push (info);
-
-
- /*
- huh?
- copied from score-engraver, but
- this way staff gets in list twice
- if (Audio_item* i = dynamic_cast<Audio_item*> (info.elem_))
- performance_->add_element (i);
- */
}
void
Score_performer::prepare (Moment m)
{
- Global_translator::prepare (m);
audio_column_ = new Audio_column (m);
play_element (audio_column_);
- start_translation_timestep ();
+ recurse_down_translators (daddy_context_, &Translator::start_translation_timestep, true);
}
void
Score_performer::one_time_step ()
{
- process_music ();
- do_announces ();
- stop_translation_timestep ();
- check_removal ();
-}
-
-void
-Score_performer::start ()
-{
+ recurse_down_performers (daddy_context_, &Performer::process_music, false);
+ recurse_down_performers (daddy_context_, &Performer::do_announces, true);
+ recurse_down_translators (daddy_context_, &Translator::stop_translation_timestep, false);
}
-
int
Score_performer::get_tempo () const
{
return performance_->midi_->get_tempo (Moment (Rational (1, 4)));
}
-void
-Score_performer::finish ()
-{
- check_removal ();
- finalize ();
-}
Music_output *
Score_performer::get_output ()
void
Score_performer::initialize ()
{
- unsmob_context_def (definition_)->apply_default_property_operations (this);
performance_ = new Performance;
performance_->midi_ = dynamic_cast<Midi_def*> (get_output_def ());
#include "music-output.hh"
#include "music-iterator.hh"
#include "music.hh"
-#include "global-translator.hh"
+#include "global-context.hh"
#include "scm-hash.hh"
#include "cpu-timer.hh"
#include "main.hh"
SCM_ASSERT_TYPE (odef, output_def, SCM_ARG2, __FUNCTION__, "Output definition");
Cpu_timer timer;
- Global_translator * trans = odef->get_global_translator ();
+
+ Global_context * trans = new Global_context (odef);
+
if (!trans)
{
programming_error ("no toplevel translator");
return SCM_BOOL_F; // todo: shoudl throw exception.
}
- trans->start ();
trans->run_iterator_on_me (iter);
iter->quit();
scm_remember_upto_here_1 (protected_iter);
"and dump the result to @var{out-filename}, using "
"@var{header} for the bibliographic information.")
{
- Translator *tr = unsmob_translator (context);
- Global_translator * gt = dynamic_cast<Global_translator*> (tr);
+ Global_context * gt = dynamic_cast<Global_context *> (unsmob_context (context));
SCM_ASSERT_TYPE(gt, context, SCM_ARG1, __FUNCTION__,
- "Score context");
+ "Global context");
SCM_ASSERT_TYPE(ly_module_p(header), header, SCM_ARG2, __FUNCTION__,
"module");
SCM_ASSERT_TYPE(gh_string_p (out_filename), out_filename, SCM_ARG3, __FUNCTION__,
{
SCM context = ly_run_translator (mus, outdef);
- if (unsmob_translator (context))
+ if (unsmob_context (context))
ly_render_output (context, head, outname);
}
+
{
Grob *sc = unsmob_grob (gh_car (s));
- if (!sc->has_offset_callback_b (Side_position_interface::aligned_side_proc, X_AXIS))
+ if (!sc->has_offset_callback (Side_position_interface::aligned_side_proc, X_AXIS))
staff_sided.push (sc);
}
#include "rhythmic-head.hh"
#include "engraver.hh"
#include "note-column.hh"
-#include "translator-group.hh"
+#include "context.hh"
+
#include "warn.hh"
struct Script_tuple
ScriptStaccato , ScriptMarcato, etc. )
*/
void make_script_from_event (Grob *p,
- SCM * descr, Translator_group*tg,
+ SCM * descr, Context *tg,
SCM art_type,
int index)
{
Grob * p = make_item ("Script");
- make_script_from_event (p, &scripts_[i].description_, daddy_trans_,
+ make_script_from_event (p, &scripts_[i].description_, daddy_context_,
l->get_mus_property ("articulation-type"),
i);
ADD_INTERFACE (Self_alignment_interface, "self-alignment-interface",
- "Position self using some alignment",
- "self-alignment-X self-alignment-Y");
+ "Position this object on itself and/or on its parent. To this end, the following functions "
+ " are provided: \n"
+ "@table @code \n"
+ "@item Self_alignment_interface::aligned_on_self\n"
+ " Align self on reference point, using @code{self-alignment-X} and "
+ "@code{self-alignment-Y}."
+ "@item Self_alignment_interface::aligned_on_parent\n"
+ "@item Self_alignment_interface::centered_on_parent\n"
+ " Shift the object so its own reference point is centered on the "
+ " extent of the parent \n"
+ "@item Self_alignment_interface::centered_on_other_axis_parent\n"
+ " For X-axis, center on the Y-parent, and vice versa.\n "
+ "@end table\n"
+ ,
+ "self-alignment-X self-alignment-Y");
#include "note-spacing.hh"
#include "group-interface.hh"
#include "accidental-placement.hh"
-#include "translator-group.hh"
+#include "context.hh"
+
struct Spacings
return;
if (it->get_parent (X_AXIS)
&& it->get_parent (X_AXIS)
- ->has_extent_callback_b(Axis_group_interface::group_extent_callback_proc, X_AXIS))
+ ->has_extent_callback(Axis_group_interface::group_extent_callback_proc, X_AXIS))
return;
if (ib)
{
p_ref_->set_grob_property ("breakable", SCM_BOOL_T);
- daddy_trans_->set_property ("breakableSeparationItem", p_ref_->self_scm ());
+ daddy_context_->set_property ("breakableSeparationItem", p_ref_->self_scm ());
}
announce_grob(p_ref_, SCM_EOL);
Separating_line_group_engraver::start_translation_timestep ()
{
if (break_item_)
- daddy_trans_->unset_property (ly_symbol2scm ("breakableSeparationItem"));
+ daddy_context_->unset_property (ly_symbol2scm ("breakableSeparationItem"));
break_item_ =0;
}
*/
#include "translator-group.hh"
-
+#include "context.hh"
#include "sequential-iterator.hh"
#include "music-list.hh"
void
-Sequential_iterator::derived_substitute (Translator_group*f,Translator_group*t)
+Sequential_iterator::derived_substitute (Context *f,Context *t)
{
if (iter_)
iter_->substitute_outlet (f,t);
void
Sequential_iterator::descend_to_child ()
{
- Translator_group * child_report = child_report = iter_->get_outlet ();
- Translator_group * me_report = get_outlet ();
+ Context * child_report = child_report = iter_->get_outlet ();
+ Context * me_report = get_outlet ();
- Translator_group * c = child_report;
+ Context * c = child_report;
while (c && c != me_report)
{
- c= c->daddy_trans_;
+ c= c->daddy_context_;
}
if (c == me_report)
(c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "translator-group.hh"
+#include "context.hh"
+
+
#include "warn.hh"
#include "sequential-music-iterator.hh"
#include "music-list.hh"
Axis
Side_position_interface::get_axis (Grob*me)
{
- if (me->has_offset_callback_b (Side_position_interface::aligned_side_proc, X_AXIS)
- || me->has_offset_callback_b (Side_position_interface::aligned_side_proc , X_AXIS))
+ if (me->has_offset_callback (Side_position_interface::aligned_side_proc, X_AXIS)
+ || me->has_offset_callback (Side_position_interface::aligned_side_proc , X_AXIS))
return X_AXIS;
(c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "translator-group.hh"
+#include "context.hh"
#include "warn.hh"
#include "simultaneous-music-iterator.hh"
#include "music-list.hh"
}
void
-Simultaneous_music_iterator::derived_substitute(Translator_group*f,Translator_group*t)
+Simultaneous_music_iterator::derived_substitute(Context *f,Context *t)
{
for (SCM s = children_list_; gh_pair_p (s); s = gh_cdr(s))
unsmob_iterator (gh_car (s))-> substitute_outlet (f,t);
number number as name */
SCM name = unsmob_context_def (get_outlet ()->definition_)->get_context_name ();
- Translator_group * t = (j && separate_contexts_b_)
- ? get_outlet ()->find_create_translator (name, to_string (j), SCM_EOL)
+ Context * t = (j && separate_contexts_b_)
+ ? get_outlet ()->find_create_context (name, to_string (j), SCM_EOL)
: get_outlet ();
if (!t)
#include "engraver.hh"
#include "repeated-music.hh"
#include "engraver-group-engraver.hh"
-#include "global-translator.hh"
+#include "global-context.hh"
#include "warn.hh"
#include "misc.hh"
#include "spanner.hh"
#include "bar-line.hh"
#include "score-engraver.hh"
-#include "translator-group.hh"
+#include "context.hh"
+
/**
This acknowledges repeated music with "percent" style. It typesets
else
return false;
- Global_translator *global =top_engraver();
+ Global_context *global =get_global_context ();
for (int i = 0; i < count; i++)
global->add_moment_to_process (next_moment_ + Moment (i) * body_length_);
announce_grob(beat_slash_, repeat_->self_scm());
next_moment_ = next_moment_ + body_length_;
- top_engraver()->add_moment_to_process (next_moment_);
+ get_global_context ()->add_moment_to_process (next_moment_);
}
}
#include "slur.hh"
#include "warn.hh"
#include "note-column.hh"
-#include "translator-group.hh"
+#include "context.hh"
+
#include "engraver.hh"
#include "spanner.hh"
void
Slur_engraver::set_melisma (bool m)
{
- daddy_trans_->set_property ("slurMelismaBusy", m ? SCM_BOOL_T :SCM_BOOL_F);
+ daddy_context_->set_property ("slurMelismaBusy", m ? SCM_BOOL_T :SCM_BOOL_F);
}
void
#include "event.hh"
#include "audio-item.hh"
#include "audio-column.hh"
-#include "global-translator.hh"
+#include "global-context.hh"
#include "warn.hh"
/*
void
Slur_performer::set_melisma (bool ml)
{
- daddy_trans_->set_property ("slurMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F);
+ daddy_context_->set_property ("slurMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F);
}
void
ADD_INTERFACE (Spaceable_grob,"spaceable-grob-interface",
- "A grob (a Paper_column) that takes part in the \n"
- "spacing problem. ",
- "measure-length spacing-wishes penalty minimum-distances ideal-distances "
-"left-neighbors right-neighbors");
+ "A layout object that takes part in the spacing problem. "
+ ,
+ "measure-length spacing-wishes penalty minimum-distances ideal-distances "
+ "left-neighbors right-neighbors");
void
Span_arpeggio_engraver::acknowledge_grob (Grob_info info)
{
- if (info.origin_transes (this).size ()
- && Arpeggio::has_interface (info.grob_))
+ if (Arpeggio::has_interface (info.grob_)
+ && info.origin_contexts (this).size ()) // huh? what's this test for?
{
arpeggios_.push (info.grob_);
}
void
Span_bar_engraver::acknowledge_grob (Grob_info i)
{
- int depth = i.origin_transes (this).size ();
- if (depth > 1
- && Bar_line::has_interface (i.grob_))
+ int depth = i.origin_contexts (this).size ();
+ if (depth && Bar_line::has_interface (i.grob_))
{
Item * it = dynamic_cast<Item*> (i.grob_);
bars_.push (it);
#include "staff-symbol.hh"
#include "engraver.hh"
#include "grob.hh"
-#include "translator-group.hh"
+#include "context.hh"
+
class Staff_collecting_engraver : public Engraver
{
SCM staffs = get_property ("stavesFound");
staffs = gh_cons (gi.grob_->self_scm (), staffs);
- daddy_trans_->set_property ("stavesFound", staffs);
+ daddy_context_->set_property ("stavesFound", staffs);
}
}
#include "audio-item.hh"
#include "audio-staff.hh"
#include "performer-group-performer.hh"
+#include "context.hh"
/** Perform a staff. Individual notes should have their instrument
(staff-wide) set, so we override play_element ()
audio_staff_ = new Audio_staff;
announce_element (Audio_element_info (audio_staff_, 0));
- name_ = new Audio_text (Audio_text::TRACK_NAME, id_string_);
+ name_ = new Audio_text (Audio_text::TRACK_NAME, daddy_context_->id_string_);
announce_element (Audio_element_info (name_, 0));
tempo_ = new Audio_tempo (get_tempo ());
}
- if (me->has_offset_callback_b (Staff_symbol_referencer::callback_proc, Y_AXIS))
+ if (me->has_offset_callback (Staff_symbol_referencer::callback_proc, Y_AXIS))
return ;
me->add_offset_callback (Staff_symbol_referencer::callback_proc, Y_AXIS);
}
ADD_INTERFACE (Staff_symbol_referencer,"staff-symbol-referencer-interface",
- "Object whose Y position is meant relative to a staff "
- "symbol. These objects usually have "
- "Staff_symbol_referencer::callback in their Y-offset-callback. "
+ "An object whose Y position is meant relative to a staff "
+ "symbol. These usually have "
+ "@code{Staff_symbol_referencer::callback} in their @code{Y-offset-callbacks}. "
,
"staff-position");
ADD_INTERFACE (Staff_symbol,"staff-symbol-interface",
"This spanner draws the lines of a staff. "
- "A staff symbol definines a vertical unit, the staff space "
+ "A staff symbol definines a vertical unit, the staff space. "
"Quantities that go by a half staff space are called positions "
"The center (i.e. middle line "
"or space) is position 0. The length of the symbol may be set by hand "
#include "misc.hh"
#include "stem-tremolo.hh"
#include "item.hh"
-#include "translator-group.hh"
+#include "context.hh"
+
#include "engraver.hh"
else
requested_type = 8;
else
- daddy_trans_->set_property ("tremoloFlags", gh_int2scm (requested_type));
+ daddy_context_->set_property ("tremoloFlags", gh_int2scm (requested_type));
int tremolo_flags = intlog2 (requested_type) - 2
- (duration_log > 2 ? duration_log - 2 : 0);
if (gh_number_p (prop))
{
Stem::set_beaming (stem_,gh_scm2int (prop),LEFT);
- daddy_trans_->unset_property (ly_symbol2scm ("stemLeftBeamCount"));
+ daddy_context_->unset_property (ly_symbol2scm ("stemLeftBeamCount"));
}
prop = get_property ("stemRightBeamCount");
if (gh_number_p (prop))
{
Stem::set_beaming (stem_,gh_scm2int (prop), RIGHT);
- daddy_trans_->unset_property (ly_symbol2scm ("stemRightBeamCount"));
+ daddy_context_->unset_property (ly_symbol2scm ("stemRightBeamCount"));
}
typeset_grob (stem_);
ADD_INTERFACE (Stem_tremolo,"stem-tremolo-interface",
- "",
+ "A beam slashing a stem to indicate a tremolo.",
"stem beam-width beam-thickness flag-count");
Stem::calc_stem_info (Grob *me)
{
Direction my_dir = get_grob_direction (me);
+
+ if (!my_dir)
+ {
+ programming_error ("No stem dir set?");
+ my_dir = UP;
+ }
+
Real staff_space = Staff_symbol_referencer::staff_space (me);
Grob *beam = get_beam (me);
Real beam_translation = Beam::get_beam_translation (beam);
LY_DEFINE(ly_stencil_set_extent_x,"ly:stencil-set-extent!", 3 , 0, 0,
(SCM mol, SCM axis, SCM np),
"Set the extent (@var{extent} must be a pair of numbers) of @var{mol} in \n"
-"@var{axis} direction (0 or 1 for x- and y-axis respectively).\n"
-"\n"
-"Note that an extent @code{(A . B)} is an interval and hence @code{A} is\n"
-"smaller than @code{B}, and is often negative.\n"
-)
+ "@var{axis} direction (0 or 1 for x- and y-axis respectively).\n"
+ )
{
Stencil* m = unsmob_stencil (mol);
SCM_ASSERT_TYPE (m, mol, SCM_ARG1, __FUNCTION__, "stencil");
LY_DEFINE(ly_make_stencil,
"ly:make-stencil", 3, 0, 0, (SCM expr, SCM xext, SCM yext),
" \n"
-"The objective of any typesetting system is to put ink on paper in the \n"
-"right places. For LilyPond, this final stage is left to the @TeX{} and \n"
-"the printer subsystem. For lily, the last stage in processing a score is \n"
-"outputting a description of what to put where. This description roughly \n"
-"looks like \n"
-"@example \n"
-" PUT glyph AT (x,y) \n"
-" PUT glyph AT (x,y) \n"
-" PUT glyph AT (x,y) \n"
-"@end example \n"
-"you merely have to look at the tex output of lily to see this. \n"
-"Internally these instructions are encoded in Stencils.@footnote{At some \n"
-"point LilyPond also contained Atom-objects, but they have been replaced \n"
-"by Scheme expressions, making the name outdated.} A stencil is \n"
-"what-to-print-where information that also contains dimension information \n"
-"(how large is this glyph?). \n"
-" \n"
-"Conceptually, Stencils can be constructed from Scheme code, by \n"
-"translating a Stencil and by combining two stencils. In BNF \n"
-"notation: \n"
-" \n"
-"@example \n"
-"Stencil :: COMBINE Stencil Stencil \n"
-" | TRANSLATE Offset Stencil \n"
-" | GLYPH-DESCRIPTION \n"
-" ; \n"
-"@end example \n"
-" \n"
-"If you are interested in seeing how this information is stored, you \n"
-"can run with the @code{-f scm} option. The scheme expressions are then \n"
-"dumped in the output file.")
+ "Stencils are a device independent output expressions."
+ "They carry two pieces of information: \n\n"
+ "1: a specification of how to print this object. "
+ "This specification is processed by the output backends, for example "
+ "@file{scm/output-tex.scm}.\n\n"
+ "2: the vertical and horizontal extents of the object.\n\n"
+
+ )
{
SCM_ASSERT_TYPE (is_number_pair (xext), xext, SCM_ARG2, __FUNCTION__, "number pair");
SCM_ASSERT_TYPE (is_number_pair (yext), yext, SCM_ARG3, __FUNCTION__, "number pair");
if (!delim_)
{
SCM delim_name =get_property ("systemStartDelimiter");
- delim_ = make_spanner_from_properties (daddy_trans_, delim_name);
+ delim_ = make_spanner_from_properties (daddy_context_, delim_name);
delim_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
announce_grob (delim_, SCM_EOL);
ADD_INTERFACE (System_start_delimiter,"system-start-delimiter-interface",
"The brace, bracket or bar in front of the system. "
- "It is implemented as a spanner"
+ "It is implemented as a spanner."
,
"collapse-height thickness "
"arch-height arch-angle arch-thick arch-width bracket-thick glyph");
/*
generate all stencils to trigger all font loads.
-
- (ugh. This is not very memory efficient.) */
-
+ */
SCM all = get_grob_property ("all-elements") ;
all = uniquify_list (all);
/*
- triger font loads first.
+ trigger font loads first.
This might seem inefficient, but Stencils are cached per grob
anyway.
}
ADD_INTERFACE (Text_item,"text-interface",
- "A scheme markup text, see @usermanref{Text markup}.",
+ "A scheme markup text, see @usermanref{Text-markup}.",
"text baseline-skip word-space");
#include "event.hh"
#include "tie.hh"
-#include "translator-group.hh"
+#include "context.hh"
+
#include "spanner.hh"
#include "tie-column.hh"
#include "engraver.hh"
Tie_engraver::process_music ()
{
if (event_)
- daddy_trans_->set_property ("tieMelismaBusy", SCM_BOOL_T);
+ daddy_context_->set_property ("tieMelismaBusy", SCM_BOOL_T);
}
void
void
Tie_engraver::start_translation_timestep ()
{
- daddy_trans_->set_property ("tieMelismaBusy",
+ daddy_context_->set_property ("tieMelismaBusy",
gh_bool2scm (heads_to_tie_.size ()));
}
*/
-#include "translator-group.hh"
+#include "context.hh"
#include "audio-item.hh"
#include "event.hh"
#include "pqueue.hh"
Tie_performer::process_music ()
{
if (event_)
- daddy_trans_->set_property ("tieMelismaBusy", SCM_BOOL_T);
+ daddy_context_->set_property ("tieMelismaBusy", SCM_BOOL_T);
}
#include "time-scaled-music-iterator.hh"
#include "time-scaled-music.hh"
#include "event.hh"
-#include "translator-group.hh"
-
+#include "context.hh"
void
Time_scaled_music_iterator::process (Moment m)
(c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "translator-group.hh"
-
+#include "context.hh"
#include "grob-info.hh"
#include "multi-measure-rest.hh"
#include "timing-translator.hh"
}
}
- daddy_trans_->set_property ("whichBar", which);
+ daddy_context_->set_property ("whichBar", which);
}
void
Timing_engraver::stop_translation_timestep ()
{
Timing_translator::stop_translation_timestep ();
- daddy_trans_->set_property ("whichBar", SCM_EOL);
+ daddy_context_->set_property ("whichBar", SCM_EOL);
last_moment_ = now_mom ();
}
#include "timing-translator.hh"
#include "translator-group.hh"
-#include "global-translator.hh"
+#include "global-context.hh"
#include "multi-measure-rest.hh"
void
Timing_translator::stop_translation_timestep ()
{
- Translator *t = this;
- Global_translator *global =0;
- do
- {
- t = t->daddy_trans_ ;
- global = dynamic_cast<Global_translator*> (t);
- }
- while (!global);
+ Global_context *global = get_global_context ();
/* allbars == ! skipbars */
SCM sb = get_property ("skipBars");
move this to engraver-init.ly?
*/
- daddy_trans_->set_property ("timing" , SCM_BOOL_T);
- daddy_trans_->set_property ("currentBarNumber" , gh_int2scm (1));
+ daddy_context_->set_property ("timing" , SCM_BOOL_T);
+ daddy_context_->set_property ("currentBarNumber" , gh_int2scm (1));
- daddy_trans_->set_property ("timeSignatureFraction",
+ daddy_context_->set_property ("timeSignatureFraction",
gh_cons (gh_int2scm (4), gh_int2scm (4)));
- daddy_trans_->set_property ("measurePosition", Moment (Rational (0)).smobbed_copy ());
- daddy_trans_->set_property ("measureLength", Moment (Rational (1)).smobbed_copy ());
- daddy_trans_->set_property ("beatLength", Moment (Rational (1,4)).smobbed_copy ());
+ daddy_context_->set_property ("measurePosition", Moment (Rational (0)).smobbed_copy ());
+ daddy_context_->set_property ("measureLength", Moment (Rational (1)).smobbed_copy ());
+ daddy_context_->set_property ("beatLength", Moment (Rational (1,4)).smobbed_copy ());
}
Rational
void
Timing_translator::start_translation_timestep ()
{
- Translator *t = this;
- Global_translator *global =0;
- do
- {
- t = t->daddy_trans_ ;
- global = dynamic_cast<Global_translator*> (t);
- }
- while (!global);
+ Global_context *global =get_global_context ();
Moment now = global->now_mom_;
Moment dt = now - global->prev_mom_;
else
{
measposp = now;
- daddy_trans_->set_property ("measurePosition", measposp.smobbed_copy ());
+ daddy_context_->set_property ("measurePosition", measposp.smobbed_copy ());
}
measposp += dt;
b ++;
}
- daddy_trans_->set_property ("currentBarNumber", gh_int2scm (b));
- daddy_trans_->set_property ("measurePosition", measposp.smobbed_copy ());
+ daddy_context_->set_property ("currentBarNumber", gh_int2scm (b));
+ daddy_context_->set_property ("measurePosition", measposp.smobbed_copy ());
}
ENTER_DESCRIPTION(Timing_translator,"","","","","","");
#include "moment.hh"
#include "scm-hash.hh"
#include "context-def.hh"
+#include "context.hh"
#include "main.hh"
#include "music.hh"
-Translator_group::Translator_group (Translator_group const&s)
- : Translator (s)
+Translator_group*
+Translator_group::get_daddy_translator () const
{
- iterator_count_ =0;
-
- Scheme_hash_table * tab = new Scheme_hash_table (*s.properties_dict ());
- properties_scm_ = tab->self_scm ();
- scm_gc_unprotect_object (tab->self_scm ());
-}
-
-Scheme_hash_table*
-Translator_group::properties_dict () const
-{
- return Scheme_hash_table::unsmob (properties_scm_);
-}
-
-Translator_group::~Translator_group ()
-{
-
- //assert (is_removable ());
-}
-
-
-Translator_group::Translator_group ()
-{
- iterator_count_ = 0;
- Scheme_hash_table *tab = new Scheme_hash_table ;
- properties_scm_ = tab->self_scm ();
-
- scm_gc_unprotect_object (tab->self_scm ());
-}
-
-void
-Translator_group::check_removal ()
-{
- SCM next = SCM_EOL;
- for (SCM p = trans_group_list_; gh_pair_p (p); p = next)
- {
- next = ly_cdr (p);
-
- Translator_group *trg = dynamic_cast<Translator_group*> (unsmob_translator (ly_car (p)));
-
- trg->check_removal ();
- if (trg->is_removable ())
- terminate_translator (trg);
- }
-}
-
-SCM
-Translator_group::add_translator (SCM list, Translator *t)
-{
- /*
- Must append, since list ordering must be preserved.
- */
- list = gh_append2 (list, gh_cons (t->self_scm (), SCM_EOL));
- t->daddy_trans_ = this;
- t->output_def_ = output_def_;
-
- return list;
-}
-
-
-void
-Translator_group::add_used_group_translator (Translator *t)
-{
- trans_group_list_ = add_translator (trans_group_list_,t);
+ Translator *t
+ = unsmob_translator (daddy_context_->daddy_context_->implementation_);
+ return dynamic_cast<Translator_group*> (t);
}
void
-Translator_group::add_fresh_group_translator (Translator*t)
-{
- Translator_group*tg = dynamic_cast<Translator_group*> (t);
- trans_group_list_ = add_translator (trans_group_list_,t);
- scm_gc_unprotect_object (t->self_scm ());
-
- Context_def * td = unsmob_context_def (tg->definition_);
-
- /*
- this can not move before add_translator(), because \override
- operations require that we are in the hierarchy.
- */
- td->apply_default_property_operations (tg);
-
- t->initialize ();
-}
-
-bool
-Translator_group::try_music (Music* m)
-{
- bool hebbes_b = try_music_on_nongroup_children (m);
-
- if (!hebbes_b && daddy_trans_)
- hebbes_b = daddy_trans_->try_music (m);
-
- return hebbes_b ;
-}
-
-void
-Translator_group::terminate_translator (Translator*r)
-{
- r->finalize ();
- /*
- Return value ignored. GC does the rest.
- */
- remove_translator (r);
-}
-
-
-/**
- Remove a translator from the hierarchy.
- */
-Translator *
-Translator_group::remove_translator (Translator*trans)
-{
- assert (trans);
-
- trans_group_list_ = scm_delq_x (trans->self_scm (), trans_group_list_);
- trans->daddy_trans_ = 0;
- return trans;
-}
-
-
-static void
-static_each (SCM list, Method_pointer method)
+translator_each (SCM list, Translator_method method)
{
for (SCM p = list; gh_pair_p (p); p = ly_cdr (p))
(unsmob_translator (ly_car (p))->*method) ();
-
-}
-
-void
-Translator_group::each (Method_pointer method)
-{
- static_each (get_simple_trans_list (), method);
- static_each (trans_group_list_, method);
}
-
-
-/*
- STUBS
-*/
-void
-Translator_group::stop_translation_timestep ()
-{
- each (&Translator::stop_translation_timestep);
-}
-
-void
-Translator_group::start_translation_timestep ()
-{
- each (&Translator::start_translation_timestep);
-}
-
-void
-Translator_group::do_announces ()
-{
- each (&Translator::do_announces);
-}
-
void
Translator_group::initialize ()
{
SCM tab = scm_make_vector (gh_int2scm (19), SCM_BOOL_F);
- set_property ("acceptHashTable", tab);
- each (&Translator::initialize);
+ daddy_context_->set_property ("acceptHashTable", tab);
}
-void
-Translator_group::finalize ()
-{
- each (&Translator::finalize);
-}
bool
translator_accepts_any_of (Translator*tr, SCM ifaces)
}
bool
-Translator_group::try_music_on_nongroup_children (Music *m )
+Translator_group::try_music (Music* m)
{
SCM tab = get_property ("acceptHashTable");
SCM name = scm_sloppy_assq (ly_symbol2scm ("name"),
}
SCM
-Translator_group::properties_as_alist () const
-{
- return properties_dict()->to_alist();
-}
-
-String
-Translator_group::context_name () const
-{
- Context_def * td = unsmob_context_def (definition_ );
- return ly_symbol2string (td->get_context_name ());
-}
-
-
-
-SCM
-names_to_translators (SCM namelist, Translator_group*tg)
+names_to_translators (SCM namelist, Context*tg)
{
SCM l = SCM_EOL;
for (SCM s = namelist; gh_pair_p (s) ; s = ly_cdr (s))
SCM str = tr->self_scm ();
l = gh_cons (str, l);
- tr->daddy_trans_ = tg;
- tr->output_def_ = tg->output_def_;
-
+ tr->daddy_context_ = tg;
scm_gc_unprotect_object (str);
}
}
return simple_trans_list_;
}
+
+void
+recurse_down_translators (Context * c, Translator_method ptr, bool context_first)
+{
+ Translator_group * tg
+ = dynamic_cast<Translator_group*> (unsmob_translator (c->implementation_));
+
+
+ if (!context_first)
+ {
+ translator_each (tg->get_simple_trans_list (),
+ ptr);
+
+ (tg->*ptr) ();
+ }
+
+ for (SCM s = c->context_list_ ; gh_pair_p (s);
+ s =gh_cdr (s))
+ {
+ recurse_down_translators (unsmob_context (gh_car (s)), ptr, context_first);
+ }
+
+ if (context_first)
+ {
+ translator_each (tg->get_simple_trans_list (),
+ ptr);
+
+ (tg->*ptr) ();
+ }
+}
*/
#include "main.hh"
-#include "translator-group.hh"
+#include "context.hh"
#include "warn.hh"
#include "item.hh"
#include "spanner.hh"
void
-execute_pushpop_property (Translator_group * trg,
+execute_pushpop_property (Context * trg,
SCM prop, SCM eltprop, SCM val)
{
if (gh_symbol_p (prop) && gh_symbol_p (eltprop))
if (val != SCM_UNDEFINED)
{
SCM prev = SCM_EOL;
- Translator_group * where = trg->where_defined (prop);
+ Context * where = trg->where_defined (prop);
/*
Don't mess with MIDI.
PRE_INIT_OPS is in the order specified, and hence must be reversed.
*/
void
-apply_property_operations (Translator_group*tg, SCM pre_init_ops)
+apply_property_operations (Context *tg, SCM pre_init_ops)
{
SCM correct_order = scm_reverse (pre_init_ops);
for (SCM s = correct_order; gh_pair_p (s); s = ly_cdr (s))
contexts has changed. The alist is updated if necessary.
*/
SCM
-updated_grob_properties (Translator_group* tg, SCM sym)
+updated_grob_properties (Context * tg, SCM sym)
{
assert (gh_symbol_p (sym));
tg = tg->where_defined (sym);
+ if (!tg)
+ return SCM_EOL;
+
SCM daddy_props
- = (tg->daddy_trans_)
- ? updated_grob_properties (tg->daddy_trans_, sym)
+ = (tg->daddy_context_)
+ ? updated_grob_properties (tg->daddy_context_, sym)
: SCM_EOL;
SCM props = tg->internal_get_property (sym);
}
Item*
-make_item_from_properties (Translator_group* tg, SCM x)
+make_item_from_properties (Context * tg, SCM x)
{
SCM props = updated_grob_properties (tg, x);
return new Item (props);
}
Spanner*
-make_spanner_from_properties (Translator_group *tg, SCM x)
+make_spanner_from_properties (Context *tg, SCM x)
{
SCM props = updated_grob_properties (tg, x);
return new Spanner (props);
#include "translator-group.hh"
#include "lily-guile.hh"
-LY_DEFINE(ly_get_context_property,
- "ly:get-context-property", 2, 0, 0,
- (SCM context, SCM name),
- "retrieve the value of @var{name} from context @var{context}")
-{
- Translator *t = unsmob_translator (context);
- Translator_group* tr= dynamic_cast<Translator_group*> (t);
- SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Translator group");
- SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol");
-
- return tr->internal_get_property (name);
-
-}
-
-LY_DEFINE(ly_set_context_property,
- "ly:set-context-property!", 3, 0, 0,
- (SCM context, SCM name, SCM val),
- "set value of property @var{name} in context @var{context} to @var{val}.")
-{
- Translator *t = unsmob_translator (context);
- Translator_group* tr= dynamic_cast<Translator_group*> (t);
-
- SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
- SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol");
-
- tr->internal_set_property (name, val);
-
- return SCM_UNSPECIFIED;
-}
-
-
-LY_DEFINE(ly_context_property_where_defined,
- "ly:context-property-where-defined", 2, 0, 0,
- (SCM context, SCM name),
- "Return the context above @var{context} where @var{name} is defined.")
-{
- Translator *t = unsmob_translator (context);
- Translator_group* tr = dynamic_cast<Translator_group*> (t);
- SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
- SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol");
-
-
- tr = tr->where_defined (name);
-
- if (tr)
- return tr->self_scm();
-
- return SCM_EOL;
-}
-
-LY_DEFINE(ly_unset_context_property,
- "ly:unset-context-property", 2, 0, 0,
- (SCM context, SCM name),
- "Unset value of property @var{name} in context @var{context}.")
-{
- Translator *t = unsmob_translator (context);
- Translator_group* tr = dynamic_cast<Translator_group*> (t);
- SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
- SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol");
-
- tr->unset_property (name);
-
- return SCM_UNSPECIFIED;
-}
-
-
-
-LY_DEFINE(ly_context_parent,
- "ly:context-parent", 1, 0, 0,
- (SCM context),
- "Return the parent of @var{context}, #f if none.")
-{
- Translator *t = unsmob_translator (context);
- Translator_group* tr= dynamic_cast<Translator_group*> (t);
-
- SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
-
- tr = tr->daddy_trans_ ;
- if (tr)
- return tr->self_scm();
- else
- return SCM_BOOL_F;
-}
-
-/*
- Todo: should support translator IDs, and creation?
- */
-LY_DEFINE(ly_translator_find,
- "ly:translator-find", 2, 0,0,
- (SCM context, SCM name),
- "Find a parent of @var{context} that has name or alias @var{name}. "
- "Return @code{#f} if not found." )
-{
- Translator_group* tr= dynamic_cast<Translator_group*> ( unsmob_translator (context));
-
- SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "context");
- SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol");
-
- while (tr)
- {
- if (tr->is_alias (name))
- return tr->self_scm();
- tr = tr->daddy_trans_ ;
- }
-
- return SCM_BOOL_F;
-}
-
-
-LY_DEFINE(ly_context_properties,
- "ly:context-properties", 1, 0, 0,
- (SCM context),
- "Return all properties of @var{context} in an alist.")
-{
- Translator *t = unsmob_translator (context);
- Translator_group* tr= dynamic_cast<Translator_group*> (t);
-
- SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
-
- return tr->properties_as_alist ();
-}
}
-LY_DEFINE(ly_context_id,
- "ly:context-id", 1,0,0, (SCM context),
- "Return the id string of @var{context}, i.e. for @code{\\context Voice "
-"= one .. } it will return the string @code{one}.")
-{
- Translator_group* tr = dynamic_cast<Translator_group*> (unsmob_translator (context));
- SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
-
- return scm_makfrom0str (tr->id_string_. to_str0 ());
-}
-
-
-LY_DEFINE(ly_context_name,
- "ly:context-name", 1,0,0, (SCM context),
- "Return the name of @var{context}, i.e. for @code{\\context Voice "
-"= one .. } it will return the symbol @code{Voice}.")
-{
- Translator_group* tr = dynamic_cast<Translator_group*> (unsmob_translator (context));
- SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
-
- return unsmob_context_def (tr->definition_)->get_context_name ();
-}
-
-
LY_DEFINE(ly_translator_description,
"ly:translator-description",
1,0,0, (SCM me),
}
-LY_DEFINE(ly_context_pushpop_property,
- "ly:context-pushpop-property", 3, 1, 0,
- (SCM context, SCM grob, SCM eltprop, SCM val),
- "Do a single @code{\\override} or @code{\\revert} operation "
- "in @var{context}. The grob definition @code{grob} is extended with "
- "@code{eltprop} (if @var{val} is specified) "
- "or reverted (if unspecified).")
-{
- Translator_group *tg = dynamic_cast<Translator_group*> (unsmob_translator (context));
-
- SCM_ASSERT_TYPE(tg, context, SCM_ARG1, __FUNCTION__, "context");
- SCM_ASSERT_TYPE(gh_symbol_p (grob), grob, SCM_ARG2, __FUNCTION__, "symbol");
- SCM_ASSERT_TYPE(gh_symbol_p (eltprop), eltprop, SCM_ARG3, __FUNCTION__, "symbol");
-
- execute_pushpop_property (tg, grob, eltprop, val);
-
- return SCM_UNDEFINED;
-}
-
-LY_DEFINE(ly_context_p,
- "ly:context?", 1, 0, 0,
- (SCM x),
- "Type predicate: is @var{x} a context?")
-{
- Translator_group *tg = dynamic_cast<Translator_group*> (unsmob_translator (x));
-
- return SCM_BOOL (tg);
-}
-
-
int
Translator::print_smob (SCM s, SCM port, scm_print_state *)
{
Translator *sc = (Translator *) ly_cdr (s);
scm_puts ("#<Translator ", port);
- if (Context_def *d=unsmob_context_def (sc->definition_))
- {
- scm_display (d->get_context_name (), port);
- }
- else
- scm_display (ly_translator_name (s), port);
-
- if (Translator_group *td=dynamic_cast<Translator_group*> (sc))
- {
- scm_puts ("=", port);
- scm_puts (td->id_string_.to_str0 (), port);
- }
-
- scm_display (sc->simple_trans_list_, port);
+ scm_puts (classname (sc), port);
/*
don't try to print properties, that is too much hassle.
#include "warn.hh"
#include "translator-group.hh"
#include "context-def.hh"
-
+#include "global-context.hh"
#include "moment.hh"
+#include "context.hh"
#include "ly-smobs.icc"
void
Translator::init ()
{
+ self_scm_ = SCM_EOL;
simple_trans_list_ = SCM_BOOL_F;
- trans_group_list_ = SCM_EOL;
- properties_scm_ = SCM_EOL;
- definition_ = SCM_EOL;
- daddy_trans_ =0;
- accepts_list_ = SCM_EOL;
+ daddy_context_ =0;
+ smobify_self ();
}
Translator::Translator ()
{
- self_scm_ = SCM_EOL;
init ();
- output_def_ = 0;
- smobify_self ();
}
-Translator::Translator (Translator const &s)
+Translator::Translator (Translator const &)
{
- self_scm_ = SCM_EOL;
init ();
- output_def_ = s.output_def_;
-
- smobify_self ();
}
-
bool
Translator::try_music (Music *)
{
Moment
Translator::now_mom () const
{
- return daddy_trans_->now_mom ();
+ return daddy_context_->now_mom ();
}
-void
-Translator::do_announces ()
+Music_output_def *
+Translator::get_output_def () const
{
+ return daddy_context_->get_output_def ();
}
-Music_output_def *
-Translator::get_output_def () const
+
+Translator_group*
+Translator::get_daddy_translator () const
{
- return
- (daddy_trans_)
- ? daddy_trans_->get_output_def ()
- : 0;
+ Translator *t
+ = unsmob_translator (daddy_context_->implementation_);
+ return dynamic_cast<Translator_group*> (t);
}
+
SCM
Translator::internal_get_property (SCM sym) const
{
- return daddy_trans_->internal_get_property (sym);
+ return daddy_context_->internal_get_property (sym);
}
void
Translator::mark_smob (SCM sm)
{
Translator * me = (Translator*) SCM_CELL_WORD_1 (sm);
- scm_gc_mark (me->simple_trans_list_);
- scm_gc_mark (me->trans_group_list_);
- scm_gc_mark (me->definition_);
- scm_gc_mark (me->properties_scm_);
- scm_gc_mark (me->accepts_list_);
-
- return me->properties_scm_;
+ return me->simple_trans_list_;
}
SCM
return SCM_EOL;
}
+
+Global_context *
+Translator::get_global_context () const
+{
+ return daddy_context_ ->get_global_context ();
+}
+
+
+Score_context *
+Translator::get_score_context () const
+{
+ return daddy_context_->get_score_context ();
+}
+
+
SCM
Translator::static_translator_description ()const
{
IMPLEMENT_SMOBS (Translator);
IMPLEMENT_DEFAULT_EQUAL_P (Translator);
IMPLEMENT_TYPE_P(Translator,"ly:translator?");
-
-SCM
-Translator::get_simple_trans_list()
-{
- return SCM_EOL;
-}
#include "music.hh"
#include "sequential-iterator.hh"
-#include "translator-group.hh"
+#include "context.hh"
class Unfolded_repeat_iterator : public Sequential_iterator
{
SCM reps = ly_symbol2scm ("repeatCommands");
SCM current_reps = get_outlet ()->internal_get_property (reps);
- Translator_group * where = get_outlet ()->where_defined (reps);
+ Context * where = get_outlet ()->where_defined (reps);
if (where
&& current_reps == SCM_EOL || gh_pair_p (current_reps))
{
(c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "translator-group.hh"
+#include "context.hh"
#include "paper-column.hh"
#include "align-interface.hh"
#include "span-bar.hh"
class Vertical_align_engraver : public Engraver
{
Spanner * valign_;
- bool qualifies_b (Grob_info) const;
+ bool qualifies (Grob_info) const;
public:
TRANSLATOR_DECLARATIONS(Vertical_align_engraver);
protected:
}
bool
-Vertical_align_engraver::qualifies_b (Grob_info i) const
+Vertical_align_engraver::qualifies (Grob_info i) const
{
- int sz = i.origin_transes ((Translator*)this).size () ;
+ int sz = i.origin_contexts ((Translator*)this).size () ;
- return sz > 1 && Axis_group_interface::has_interface (i.grob_)
+ return sz > 0 && Axis_group_interface::has_interface (i.grob_)
&& !i.grob_->get_parent (Y_AXIS) && Axis_group_interface::axis_b (i.grob_, Y_AXIS);
}
void
Vertical_align_engraver::acknowledge_grob (Grob_info i)
{
- if (qualifies_b (i))
+ if (qualifies (i))
{
Align_interface::add_element (valign_,i.grob_, get_property ("verticalAlignmentChildCallback"));
}
*/
#include "engraver.hh"
-#include "translator-group.hh"
+#include "context.hh"
#include "volta-bracket.hh"
#include "item.hh"
#include "note-column.hh"
\version "2.1.23"
+\translator {
+ \name Global
+
+ % nothing else needed -- tweaks are ignored anyway.
+ \accepts Score
+ }
%
% setup for Request->Element conversion. Guru-only
\name DrumVoice
\alias Voice
- \description " A voice on a percussion staff."
-
-
+ \description "A voice on a percussion staff."
\remove "Arpeggio_engraver"
\consists "Multi_measure_rest_engraver"
\consists "Text_spanner_engraver"
\consists "Key_performer"
\consists "Tempo_performer"
\consists "Time_signature_performer"
-
}
+\translator {
+ \name Global
+ \accepts Score
+ }
\translator {
\StaffContext
\name DrumStaff
(ly:add-interface
'multi-measure-interface
- "Multi measure rest, and friends (mmrest number, mmrest text)."
+ "Multi measure rest, and the text or number that is printed over it."
'())
(X-extent-callback ,procedure? "Procedure that calculates the
extent of this object. If this value is set to @code{#f}, the object
is empty in the X direction. The procedure takes a grob and axis
-argument, and returns a a number-pair.
+argument, and returns a number-pair.
")
(X-offset-callbacks ,list? "A list of functions determining this
(dependencies ,grob-list? "list of score-grob pointers that indicate who to compute first for certain global passes.")
(elements ,grob-list? "list of grobs, type depending on the Grob where this is set in.")
(heads ,grob-list? "List of note heads.")
- (items-worth-living ,grob-list? "list of interesting items. If empty in a particular system, clear that system.")
+ (items-worth-living ,grob-list? "A list of interesting items. If
+empty in a particular staff, then that staff is erased.")
(details ,list? "alist of parameters for detailed grob behavior.")
(note-heads ,grob-list? "List of note head grobs")
(side-support-elements ,grob-list? "the support, a list of grobs.")
(positioning-done ,boolean?
"Used to signal that a positioning element
-did it's job. This ensures that a positioning is only done once.")
+did its job. This ensures that a positioning is only done once.")
- (script-stencil ,pair? "Index code for script -- internal, see script.cc.")
+ (script-stencil ,pair? "Pair (@code{type} . @code{arg}), which
+acts as an index for looking up a Stencil object.")
(meta ,list? "Contains meta information. It is an alist with the
entries @code{name} and @code{interfaces}.")
(axes . (0))
(X-extent-callback . ,Axis_group_interface::group_extent_callback)
(before-line-breaking-callback . ,Paper_column::before_line_breaking)
+ (breakable . #t)
;; debugging stuff: print column number.
; (print-function . ,Paper_column::print) (font-name . "cmr8") (Y-extent-callback . #f)
TODO: consider making type into symbol")
(absolute-octave ,integer?
"The absolute octave for a octave check note.")
- (articulations ,music-list?
+ (articulations ,ly:music-list?
"Articulation events specifically for this note.")
(articulation-type ,string? "key for script definitions alist.
(tempo-unit ,ly:duration? "The unit for the metronome count.")
(tonic ,ly:pitch? "Base of the scale")
(element ,ly:music? "The single child of a Music_wrapper music object, or the body of a repeat.")
- (elements ,music-list? "A list of elements for sequential of simultaneous music, or the alternatives of repeated music. ")
+ (elements ,ly:music-list? "A list of elements for sequential of simultaneous music, or the alternatives of repeated music. ")
(force-accidental ,boolean? "If set, a cautionary accidental should always be printed on this note")
(grob-property ,symbol? "The symbol of the grob property to set. ")
(grob-value ,scheme? "The value of the grob property to set")
(,ly:duration? . "duration")
(,ly:grob? . "layout object")
(,ly:input-location? . "input location")
- (,ly:input-location? . "input location")
(,ly:moment? . "moment")
(,ly:music? . "music")
(,ly:pitch? . "pitch")
(,ly:font-metric? . "font metric")
(,markup-list? . "list of markups")
(,markup? . "markup")
- (,music-list? . "list of music")
+ (,ly:music-list? . "list of music")
(,number-or-grob? . "number or grob")
(,number-or-string? . "number or string")
(,number-pair? . "pair of numbers")
(basic (list set1 set2 set3 set4)))
(context-spec-music
- (make-sequential-music basic) 'Timing)))
+ (context-spec-music
+ (make-sequential-music basic) 'Timing) 'Score)))
(define-public (make-mark-set label)
"make the music for the \\mark command."
return str
conversions.append (((2,1,23), conv, """Property setting syntax in \\translator{ }"""))
+def conv (str):
+ str = re.sub (r'music-list\?', 'ly:music-list?', str)
+ return str
+
+conversions.append (((2,1,24), conv, """music-list? -> ly:music-list?"""))
################################