]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/context.cc
news: ugh, another typo in date
[lilypond.git] / lily / context.cc
index 3454ab1f1735fcc257ec58a46c46d0adc21c1e3f..4d949e8379c0a02f34003794b7f5e62bf3ec0b80 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2004--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 2004--2012 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
@@ -35,7 +35,7 @@
 bool
 Context::is_removable () const
 {
-  return context_list_ == SCM_EOL && ! iterator_count_
+  return context_list_ == SCM_EOL && ! client_count_
          && !dynamic_cast<Global_context const *> (daddy_context_);
 }
 
@@ -82,7 +82,7 @@ Context::Context ()
 {
   daddy_context_ = 0;
   aliases_ = SCM_EOL;
-  iterator_count_ = 0;
+  client_count_ = 0;
   implementation_ = 0;
   properties_scm_ = SCM_EOL;
   accepts_list_ = SCM_EOL;
@@ -91,6 +91,7 @@ Context::Context ()
   definition_mods_ = SCM_EOL;
   event_source_ = 0;
   events_below_ = 0;
+  ancestor_lookup_ = SCM_UNDEFINED;
 
   smobify_self ();
 
@@ -265,7 +266,7 @@ Context::create_context_from_event (SCM sev)
 
   if (path.size () != 1)
     {
-      programming_error (_f ("Invalid CreateContext event: Cannot create %s context", type.c_str ()));
+      programming_error (to_string ("Invalid CreateContext event: Cannot create %s context", type.c_str ()));
       return;
     }
   Context_def *cdef = path[0];
@@ -318,7 +319,7 @@ Context::path_to_acceptable_context (SCM name) const
   // The 'accepts elements in definition_mods_ is a list of ('accepts string),
   // but the Context_def expects to see elements of the form ('accepts symbol).
   SCM accepts = SCM_EOL;
-  for (SCM s = scm_reverse (definition_mods_); scm_is_pair (s); s = scm_cdr (s))
+  for (SCM s = definition_mods_; scm_is_pair (s); s = scm_cdr (s))
     if (scm_caar (s) == ly_symbol2scm ("accepts"))
       {
         SCM elt = scm_list_2 (scm_caar (s), scm_string_to_symbol (scm_cadar (s)));
@@ -327,7 +328,7 @@ Context::path_to_acceptable_context (SCM name) const
 
   return unsmob_context_def (definition_)->path_to_acceptable_context (name,
          get_output_def (),
-         accepts);
+         scm_reverse_x (accepts, SCM_EOL));
 
 }
 
@@ -452,7 +453,7 @@ be called from any other place than the send_stream_event macro.
 void
 Context::internal_send_stream_event (SCM type, Input *origin, SCM props[])
 {
-  Stream_event *e = new Stream_event (type, origin);
+  Stream_event *e = new Stream_event (make_event_class (type), origin);
   for (int i = 0; props[i]; i += 2)
     {
       e->set_property (props[i], props[i + 1]);
@@ -593,6 +594,14 @@ Context::get_score_context () const
     return 0;
 }
 
+SCM
+Context::make_event_class (SCM event_type)
+{
+  if (SCM_UNBNDP (ancestor_lookup_))
+    ancestor_lookup_ = get_global_context ()->ancestor_lookup_;
+  return scm_hashq_ref (ancestor_lookup_, event_type, SCM_EOL);
+}
+
 Output_def *
 Context::get_output_def () const
 {
@@ -661,6 +670,8 @@ Context::mark_smob (SCM sm)
   if (me->events_below_)
     scm_gc_mark (me->events_below_->self_scm ());
 
+  scm_gc_mark (me->ancestor_lookup_);
+
   return me->properties_scm_;
 }