]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/translator-group.cc
2003 -> 2004
[lilypond.git] / lily / translator-group.cc
index 503f2a7b47cb75f8ca7633daf2dc986be01b110d..ced34587173fcd15fcd8f55ba07dd40d121ae4dc 100644 (file)
@@ -3,7 +3,7 @@
 
   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"
@@ -12,7 +12,7 @@
 #include "warn.hh"
 #include "moment.hh"
 #include "scm-hash.hh"
-#include "translator-def.hh"
+#include "context-def.hh"
 #include "main.hh"
 #include "music.hh"
 
@@ -131,6 +131,10 @@ Translator_group::find_create_translator (SCM n, String id, SCM operations)
   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 ());
 
@@ -165,7 +169,8 @@ Translator_group::find_create_translator (SCM n, String id, SCM operations)
     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;
@@ -212,18 +217,32 @@ Translator_group::remove_translator (Translator*trans)
   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);
@@ -235,7 +254,7 @@ Translator_group::get_default_interpreter ()
       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;