]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/translator-group.cc
Pass a list of design sizes into add-music-fonts function.
[lilypond.git] / lily / translator-group.cc
index 83bfdfa0b7be9eeb0839a056a0a20b8103c6eea9..dc2b772428f681e935d6e089f7fbffe16610bb87 100644 (file)
@@ -1,10 +1,21 @@
 /*
-  translator-group.cc -- implement Translator_group
+  This file is part of LilyPond, the GNU music typesetter.
 
-  source file of the GNU LilyPond music typesetter
-
-  (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>,
+  Copyright (C) 1997--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>,
                  Erik Sandberg <mandolaerik@gmail.com>
+
+  LilyPond is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  LilyPond is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "translator-group.hh"
 #include "music.hh"
 #include "output-def.hh"
 #include "performer-group.hh"
+#include "scheme-engraver.hh"
 #include "scm-hash.hh"
 #include "warn.hh"
 
-
 void
 translator_each (SCM list, Translator_method method)
 {
@@ -141,15 +152,39 @@ Translator_group::create_child_translator (SCM sev)
 
   for (SCM s = trans_names; scm_is_pair (s); s = scm_cdr (s))
     {
-      Translator *type = get_translator (scm_car (s));
+      SCM definition = scm_car (s);
+
+      Translator *type = 0;
+      Translator *instance = type;
+      if (ly_is_symbol (definition))
+       {
+         type = get_translator (definition);
+         instance = type->clone ();
+       }
+      else if (ly_is_pair (definition))
+       {
+         type = get_translator (ly_symbol2scm ("Scheme_engraver"));
+         instance = type->clone ();
+         dynamic_cast<Scheme_engraver*> (instance)->init_from_scheme (definition);
+       }
+      else if (ly_is_procedure (definition))
+       {
+         // `definition' is a procedure, which takes the context as
+         // an argument and evaluates to an a-list scheme engraver
+         // definition.
+         SCM def = scm_call_1 (definition, cs);
+         type = get_translator (ly_symbol2scm ("Scheme_engraver"));
+         instance = type->clone ();
+         dynamic_cast<Scheme_engraver*> (instance)->init_from_scheme (def);
+       }
+        
       if (!type)
        warning (_f ("cannot find: `%s'", ly_symbol2string (scm_car (s)).c_str ()));
       else
        {
-         Translator *tr = type->clone ();
-         SCM str = tr->self_scm ();
+         SCM str = instance->self_scm ();
 
-         if (tr->must_be_last ())
+         if (instance->must_be_last ())
            {
              SCM cons = scm_cons (str, SCM_EOL);
              if (scm_is_pair (trans_list))
@@ -160,13 +195,13 @@ Translator_group::create_child_translator (SCM sev)
          else
            trans_list = scm_cons (str, trans_list);
 
-         tr->daddy_context_ = new_context;
-         tr->unprotect ();
+         instance->daddy_context_ = new_context;
+         instance->unprotect ();
        }
     }
 
   /* Filter unwanted translator types. Required to make
-     \with {\consists "..."} work. */
+     \with { \consists "..." } work. */
   if (dynamic_cast<Engraver_group *> (g))
     g->simple_trans_list_ = filter_performers (trans_list);
   else if (dynamic_cast<Performer_group *> (g))
@@ -214,7 +249,8 @@ precomputed_recurse_over_translators (Context *c, Translator_precompute_index id
 }
 
 void
-recurse_over_translators (Context *c, Translator_method ptr, Translator_group_method tg_ptr, Direction dir)
+recurse_over_translators (Context *c, Translator_method ptr,
+                         Translator_group_method tg_ptr, Direction dir)
 {
   Translator_group *tg
     = dynamic_cast<Translator_group *> (c->implementation ());