]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/context.cc
Run grand-replace (issue 3765)
[lilypond.git] / lily / context.cc
index 3453284cd8c75455787aebcb47252e4ea94b6779..a27db01865b92414d07d37752b407df85d26755a 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2004--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 2004--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -105,7 +105,7 @@ Context::Context ()
 
 /* TODO:  this shares code with find_create_context ().  */
 Context *
-Context::create_unique_context (SCM name, string id, SCM operations)
+Context::create_unique_context (SCM name, const string &id, SCM operations)
 {
   /*
     Don't create multiple score contexts.
@@ -154,7 +154,7 @@ Context::create_unique_context (SCM name, string id, SCM operations)
 }
 
 Context *
-Context::find_create_context (SCM n, string id, SCM operations)
+Context::find_create_context (SCM n, const string &id, SCM operations)
 {
   /*
     Don't create multiple score contexts.
@@ -256,8 +256,8 @@ Context::set_property_from_event (SCM sev)
       }
           
       bool ok = true;
-      if (val != SCM_EOL)
-        ok = type_check_assignment (sym, val, ly_symbol2scm ("translation-type?"));
+      ok = type_check_assignment (sym, val, ly_symbol2scm ("translation-type?"));
+
       if (ok)
         set_property (sym, val);
     }
@@ -361,7 +361,7 @@ Context::path_to_acceptable_context (SCM name) const
 
 Context *
 Context::create_context (Context_def *cdef,
-                         string id,
+                         const string &id,
                          SCM ops)
 {
   infant_event_ = 0;
@@ -411,7 +411,7 @@ Context::is_bottom_context () const
 }
 
 Context *
-Context::get_default_interpreter (string context_id)
+Context::get_default_interpreter (const string &context_id)
 {
   if (!is_bottom_context ())
     {
@@ -425,9 +425,19 @@ Context::get_default_interpreter (string context_id)
           warning (_f ("cannot find or create: `%s'", name.c_str ()));
           t = unsmob_context_def (this->definition_);
         }
-
-      Context *tg = create_context (t, context_id, SCM_EOL);
-      return tg->get_default_interpreter (context_id);
+      if (scm_is_symbol (t->get_default_child (SCM_EOL)))
+        {
+          Context *tg = create_context (t, "\\new", SCM_EOL);
+          return tg->get_default_interpreter (context_id);
+        }
+      return create_context (t, context_id, SCM_EOL);
+    }
+  else if (!context_id.empty () && context_id != id_string ())
+    {
+      if (daddy_context_ && !dynamic_cast<Global_context *> (daddy_context_))
+        return daddy_context_->get_default_interpreter (context_id);
+      warning (_f ("cannot find or create new Bottom = \"%s\"",
+                   context_id.c_str ()));
     }
   return this;
 }
@@ -572,7 +582,7 @@ Context::disconnect_from_parent ()
 */
 Context *
 find_context_below (Context *where,
-                    SCM type, string id)
+                    SCM type, const string &id)
 {
   if (where->is_alias (type))
     {