]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/global-context.cc
Run `make grand-replace'.
[lilypond.git] / lily / global-context.cc
index 94f354763071d3d8700d5c432ef55f1ba2d9c18d..d1bd6a45475777ab6d946296247dbe0fa9b29e62 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 1997--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "global-context.hh"
@@ -14,18 +14,13 @@ using namespace std;
 #include "context-def.hh"
 #include "dispatcher.hh"
 #include "international.hh"
-#include "lilypond-key.hh"
 #include "music-iterator.hh"
 #include "music.hh"
 #include "output-def.hh"
-#include "score-context.hh"
-#include "stream-event.hh"
 #include "warn.hh"
 
-Global_context::Global_context (Output_def *o, Object_key *key)
-  : Context (new Lilypond_context_key (key,
-                                      Moment (0),
-                                      "Global", "", 0))
+Global_context::Global_context (Output_def *o)
+  : Context ()
 {
   output_def_ = o;
   definition_ = find_context_def (o, ly_symbol2scm ("Global"));
@@ -94,12 +89,6 @@ Global_context::prepare (SCM sev)
   else
     prev_mom_ = now_mom_;
   now_mom_ = *mom;
-  
-  clear_key_disambiguations ();
-
-  // should do nothing now
-  if (get_score_context ())
-    get_score_context ()->prepare (now_mom_);
 }
 
 Moment
@@ -108,31 +97,22 @@ Global_context::now_mom () const
   return now_mom_;
 }
 
-Score_context *
+Context *
 Global_context::get_score_context () const
 {
   return (scm_is_pair (context_list_))
-    ? dynamic_cast<Score_context *> (unsmob_context (scm_car (context_list_)))
+    ? unsmob_context (scm_car (context_list_))
     : 0;
 }
 
 SCM
 Global_context::get_output ()
 {
-  return get_score_context ()->get_output ();
-}
-
-void
-Global_context::one_time_step ()
-{
-  get_score_context ()->one_time_step ();
-}
-
-void
-Global_context::finish ()
-{
-  if (get_score_context ())
-    get_score_context ()->finish ();
+  Context * c = get_score_context ();
+  if (c)
+    return c->get_property ("output");
+  else
+    return SCM_EOL;
 }
 
 void
@@ -154,6 +134,13 @@ Global_context::run_iterator_on_me (Music_iterator *iter)
       if (w.main_part_.is_infinity () || w > final_mom)
        break;
 
+      if (w == prev_mom_)
+       {
+         programming_error ("Moment is not increasing. Aborting interpretation.");
+         break ;
+       }
+
+      
       if (first)
        {
          /*
@@ -169,23 +156,6 @@ Global_context::run_iterator_on_me (Music_iterator *iter)
       if (iter->ok ())
        iter->process (w);
 
-      if (!get_score_context ())
-       {
-         error ("ES TODO: no score context, this shouldn't happen");
-         SCM sym = ly_symbol2scm ("Score");
-         Context_def *t = unsmob_context_def (find_context_def (get_output_def (),
-                                                                sym));
-         if (!t)
-           error (_f ("can't find `%s' context", "Score"));
-
-         Object_key const *key = get_context_key ("Score", "");
-         Context *c = t->instantiate (SCM_EOL, key);
-         add_context (c);
-
-         Score_context *sc = dynamic_cast<Score_context *> (c);
-         sc->prepare (w);
-       }
-
       send_stream_event (this, "OneTimeStep", 0, 0);
       apply_finalizations ();
       check_removal ();
@@ -226,3 +196,9 @@ Global_context::get_default_interpreter ()
   else
     return Context::get_default_interpreter ();
 }
+
+Global_context *
+unsmob_global_context (SCM x)
+{
+  return dynamic_cast<Global_context *> (unsmob_context (x));
+}