]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/translator-group.cc
Issue 5167/6: Changes: show \markup xxx = ... \etc assignments
[lilypond.git] / lily / translator-group.cc
index 6e47a85ad9a863d965ab87a47915cc1d40aace5e..538a1d7b05cdc13df399a60f9e61814a5ec7a868 100644 (file)
@@ -162,48 +162,32 @@ Translator_group::create_child_translator (SCM sev)
 
   for (SCM s = trans_names; scm_is_pair (s); s = scm_cdr (s))
     {
-      SCM definition = scm_car (s);
-      bool is_scheme = false;
-
-      Translator *type = 0;
-      if (ly_is_symbol (definition))
-        type = get_translator (definition);
-      else if (ly_is_pair (definition))
-        {
-          is_scheme = true;
-        }
-      else if (ly_is_procedure (definition))
+      SCM trans = scm_car (s);
+
+      if (ly_is_symbol (trans))
+        trans = get_translator_creator (trans);
+      if (ly_is_procedure (trans))
+        trans = scm_call_1 (trans, cs);
+      if (ly_cheap_is_list (trans))
+        trans = (new Scheme_engraver (trans, new_context))->unprotect ();
+      Translator *instance = unsmob<Translator> (trans);
+      if (!instance)
         {
-          // `definition' is a procedure, which takes the context as
-          // an argument and evaluates to an a-list scheme engraver
-          // definition.
-          definition = scm_call_1 (definition, cs);
-          is_scheme = true;
+          warning (_f ("cannot find: `%s'", ly_scm_write_string (trans).c_str ()));
+          continue;
         }
 
-      if (!is_scheme && !type)
-        warning (_f ("cannot find: `%s'", ly_symbol2string (scm_car (s)).c_str ()));
-      else
+      if (instance->must_be_last ())
         {
-          Translator *instance = is_scheme ? new Scheme_engraver (definition)
-            : type->clone ();
-
-          SCM str = instance->self_scm ();
-
-          if (instance->must_be_last ())
-            {
-              SCM cons = scm_cons (str, SCM_EOL);
-              if (scm_is_pair (trans_list))
-                scm_set_cdr_x (scm_last_pair (trans_list), cons);
-              else
-                trans_list = cons;
-            }
+          SCM cons = scm_cons (trans, SCM_EOL);
+          if (scm_is_pair (trans_list))
+            scm_set_cdr_x (scm_last_pair (trans_list), cons);
           else
-            trans_list = scm_cons (str, trans_list);
-
-          instance->daddy_context_ = new_context;
-          instance->unprotect ();
+            trans_list = cons;
         }
+      else
+        trans_list = scm_cons (trans, trans_list);
+
     }
 
   /* Filter unwanted translator types. Required to make
@@ -241,7 +225,6 @@ precomputed_recurse_over_translators (Context *c, Translator_precompute_index id
   if (tg && dir == DOWN)
     {
       tg->precomputed_translator_foreach (idx);
-      tg->call_precomputed_self_method (idx);
     }
 
   for (SCM s = c->children_contexts (); scm_is_pair (s);
@@ -251,7 +234,6 @@ precomputed_recurse_over_translators (Context *c, Translator_precompute_index id
   if (tg && dir == UP)
     {
       tg->precomputed_translator_foreach (idx);
-      tg->call_precomputed_self_method (idx);
     }
 }
 
@@ -311,7 +293,6 @@ Translator_group::precompute_method_bindings ()
         }
     }
 
-  fetch_precomputable_methods (precomputed_self_method_bindings_);
 }
 
 void
@@ -322,26 +303,12 @@ Translator_group::precomputed_translator_foreach (Translator_precompute_index id
     bindings[i]();
 }
 
-void
-Translator_group::fetch_precomputable_methods (SCM ptrs[])
-{
-  for (int i = 0; i < TRANSLATOR_METHOD_PRECOMPUTE_COUNT; i++)
-    ptrs[i] = SCM_UNDEFINED;
-}
-
-void
-Translator_group::call_precomputed_self_method (Translator_precompute_index idx)
-{
-  if (!SCM_UNBNDP (precomputed_self_method_bindings_[idx]))
-    scm_call_1 (precomputed_self_method_bindings_[idx], self_scm ());
-}
-
 Translator_group::~Translator_group ()
 {
 }
 
 
-const char Translator_group::type_p_name_[] = "ly:translator-group?";
+const char * const Translator_group::type_p_name_ = "ly:translator-group?";
 
 int
 Translator_group::print_smob (SCM port, scm_print_state *) const