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"
if (existing)
return existing;
+
+ /*
+ TODO: use accepts_list_.
+ */
Link_array<Context_def> path
= unsmob_context_def (definition_)->path_to_acceptable_translator (n, get_output_def ());
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_context_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_context_def (definition_)->default_child_context_name ();
+ SCM nm = default_child_context_name (this);
SCM st = get_output_def ()->find_translator (nm);
Context_def *t = unsmob_context_def (st);
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;