source file of the GNU LilyPond music typesetter
- (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "music-output-def.hh"
#include "warn.hh"
#include "moment.hh"
#include "scm-hash.hh"
-#include "translator-def.hh"
+#include "context-def.hh"
#include "main.hh"
#include "music.hh"
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);
-
- Translator_def * td = unsmob_translator_def (tg->definition_);
+ Context_def * td = unsmob_context_def (tg->definition_);
/*
this can not move before add_translator(), because \override
t->initialize ();
}
-
bool
Translator_group::is_removable () const
{
{
Translator * t = unsmob_translator (ly_car (p));
- r = dynamic_cast<Translator_group*> (t)->find_existing_translator (n, id);
- }
+ r = dynamic_cast<Translator_group*> (t)->find_existing_translator (n, id); }
return r;
}
if (existing)
return existing;
- Link_array<Translator_def> path
- = unsmob_translator_def (definition_)->path_to_acceptable_translator (n, get_output_def ());
+
+ /*
+ TODO: use accepts_list_.
+ */
+ Link_array<Context_def> path
+ = unsmob_context_def (definition_)->path_to_acceptable_translator (n, get_output_def ());
if (path.size ())
{
ret = daddy_trans_->find_create_translator (n, id, operations);
else
{
- warning (_f ("can't find or create `%s' called `%s'", ly_symbol2string (n).to_str0 (), id));
+ warning (_f ("Cannot find or create `%s' called `%s'",
+ ly_symbol2string (n).to_str0 (), id));
ret =0;
}
return ret;
return (daddy_trans_) ? daddy_trans_->get_depth () + 1 : 0;
}
-Translator_group*
-Translator_group::get_ancestor (int level)
-{
- if (!level || !daddy_trans_)
- return this;
-
- return daddy_trans_->get_ancestor (level-1);
-}
-
void
Translator_group::terminate_translator (Translator*r)
{
return trans;
}
+
+/*
+ Default child context as a SCM string, or something else if there is
+ none.
+*/
+SCM
+default_child_context_name (Translator_group const *tg)
+{
+ return gh_pair_p (tg->accepts_list_)
+ ? ly_car (scm_last_pair (tg->accepts_list_))
+ : SCM_EOL;
+}
+
+
bool
-Translator_group::is_bottom_translator_b () const
+Translator_group::is_bottom_context () const
{
- return !gh_symbol_p (unsmob_translator_def (definition_)->default_child_context_name ());
+ return !gh_symbol_p (default_child_context_name (this));
}
Translator_group*
Translator_group::get_default_interpreter ()
{
- if (!is_bottom_translator_b ())
+ if (!is_bottom_context ())
{
- SCM nm = unsmob_translator_def (definition_)->default_child_context_name ();
+ SCM nm = default_child_context_name (this);
SCM st = get_output_def ()->find_translator (nm);
- Translator_def *t = unsmob_translator_def (st);
+ Context_def *t = unsmob_context_def (st);
if (!t)
{
warning (_f ("can't find or create: `%s'", ly_symbol2string (nm).to_str0 ()));
- t = unsmob_translator_def (this->definition_);
+ t = unsmob_context_def (this->definition_);
}
Translator_group *tg = t->instantiate (output_def_, SCM_EOL);
add_fresh_group_translator (tg);
- if (!tg->is_bottom_translator_b ())
+ if (!tg->is_bottom_context ())
return tg->get_default_interpreter ();
else
return tg;
{
SCM tab = scm_make_vector (gh_int2scm (19), SCM_BOOL_F);
set_property ("acceptHashTable", tab);
- static_each (trans_group_list_, &Translator::initialize);
+ each (&Translator::initialize);
}
void
String
Translator_group::context_name () const
{
- Translator_def * td = unsmob_translator_def (definition_ );
+ Context_def * td = unsmob_context_def (definition_ );
return ly_symbol2string (td->get_context_name ());
}
}
+SCM
+Translator_group::get_simple_trans_list ()
+{
+ return simple_trans_list_;
+
+}
+
+
+
+#if 0
SCM
Translator_group::get_simple_trans_list ()
{
if (simple_trans_list_ != SCM_BOOL_F)
return simple_trans_list_;
- Translator_def * td = unsmob_translator_def (definition_);
+ Context_def * td = unsmob_context_def (definition_);
/*
The following cannot work, since start_translation_timestep ()
\property Voice.Voice =#'()
*/
+ trans_names = td->get_translator_names (SCM_EOL);
+
SCM trans_names = internal_get_property (td->get_context_name ());
if (!gh_pair_p (trans_names))
{
- trans_names = td->get_translator_names (SCM_EOL);
}
simple_trans_list_ = names_to_translators (trans_names, this);
static_each (simple_trans_list_, &Translator::initialize);
return simple_trans_list_;
}
+#endif