]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/dispatcher.cc
Web: tweak the second-level navigation bar first button
[lilypond.git] / lily / dispatcher.cc
index 9ba5fc2fc7d36b0ff254594020194b35a616e710..e5efff922dd9eb264018142efe8d908e1e9402d0 100644 (file)
@@ -1,20 +1,30 @@
 /*
-  dispatcher.cc -- implement Dispatcher
+  This file is part of LilyPond, the GNU music typesetter.
 
-  source file of the GNU LilyPond music typesetter
+  Copyright (C) 2005-2006 Erik Sandberg  <mandolaerik@gmail.com>
 
-  (c) 2005-2006 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 "dispatcher.hh"
 #include "input.hh"
 #include "international.hh"
 #include "ly-smobs.icc"
-#include "stream-event.hh"
 #include "warn.hh"
 
 IMPLEMENT_SMOBS (Dispatcher);
-IMPLEMENT_TYPE_P (Dispatcher, "dispatcher");
+IMPLEMENT_TYPE_P (Dispatcher, "ly:dispatcher?");
 IMPLEMENT_DEFAULT_EQUAL_P (Dispatcher);
 
 Dispatcher::~Dispatcher ()
@@ -69,15 +79,14 @@ Dispatcher::dispatch (SCM sev)
   SCM class_symbol = ev->get_property ("class");
   if (!scm_symbol_p (class_symbol))
     {
-      warning (_f ("Event class should be a symbol"));
+      warning (_ ("Event class should be a symbol"));
       return;
     }
 
   SCM class_list = scm_call_1 (ly_lily_module_constant ("ly:make-event-class"), class_symbol);
   if (!scm_is_pair (class_list))
     {
-      // TODO: Re-enable this warning when the translator cleanup is finished
-      //ev->origin ()->warning (_f ("Unknown event class %s", ly_symbol2string (class_symbol).c_str ()));
+      ev->origin ()->warning (_f ("Unknown event class %s", ly_symbol2string (class_symbol).c_str ()));
       return;
     }
   bool sent = false;
@@ -102,10 +111,10 @@ Dispatcher::dispatch (SCM sev)
   */
   struct { int prio; SCM list; } lists[num_classes+1];
   int i = 0;
-  for (SCM cl = class_list; scm_is_pair(cl); cl = scm_cdr (cl))
+  for (SCM cl = class_list; scm_is_pair (cl); cl = scm_cdr (cl))
     {
       SCM list = scm_hashq_ref (listeners_, scm_car (cl), SCM_EOL);
-      if (!scm_is_pair(list))
+      if (!scm_is_pair (list))
        num_classes--;
       else
        {
@@ -143,9 +152,9 @@ Dispatcher::dispatch (SCM sev)
         }
       // go to the next listener; bubble-sort the class list.
       SCM next = scm_cdr (lists[0].list);
-      if (!scm_is_pair(next))
+      if (!scm_is_pair (next))
         num_classes--;
-      int prio = (scm_is_pair(next)) ? scm_to_int (scm_caar (next)) : INT_MAX;
+      int prio = (scm_is_pair (next)) ? scm_to_int (scm_caar (next)) : INT_MAX;
       for (i = 0; prio > lists[i+1].prio; i++)
         lists[i] = lists[i+1];
       lists[i].prio = prio;
@@ -178,7 +187,7 @@ Dispatcher::internal_add_listener (Listener l, SCM ev_class, int priority)
     {
       /* Tell all dispatchers that we listen to, that we want to hear ev_class 
          events */
-      for (SCM disp = dispatchers_; scm_is_pair(disp); disp = scm_cdr (disp))
+      for (SCM disp = dispatchers_; scm_is_pair (disp); disp = scm_cdr (disp))
        {
          int priority = scm_to_int (scm_cdar (disp));
          Dispatcher *d = unsmob_dispatcher (scm_caar (disp));
@@ -207,10 +216,10 @@ Dispatcher::remove_listener (Listener l, SCM ev_class)
 
   SCM dummy = scm_cons (SCM_EOL, list);
   SCM e = dummy;
-  while (scm_is_pair(scm_cdr (e)))
+  while (scm_is_pair (scm_cdr (e)))
     if (*unsmob_listener (scm_cdadr (e)) == l && first)
       {
-       scm_set_cdr_x (e, scm_cddr(e));
+       scm_set_cdr_x (e, scm_cddr (e));
        first = false;
        break;
       }
@@ -224,7 +233,7 @@ Dispatcher::remove_listener (Listener l, SCM ev_class)
   else if (!scm_is_pair (list))
     {
       /* Unregister with all dispatchers. */
-      for (SCM disp = dispatchers_; disp != SCM_EOL; disp = scm_cdr (disp))
+      for (SCM disp = dispatchers_; scm_is_pair (disp); disp = scm_cdr (disp))
        {
          Dispatcher *d = unsmob_dispatcher (scm_caar (disp));
          d->remove_listener (GET_LISTENER (dispatch), ev_class);
@@ -249,7 +258,7 @@ Dispatcher::register_as_listener (Dispatcher *disp)
   dispatchers_ = scm_acons (disp->self_scm (), scm_int2num (priority), dispatchers_);
 
   Listener list = GET_LISTENER (dispatch);
-  for (SCM cl = listen_classes_; cl != SCM_EOL; cl = scm_cdr (cl))
+  for (SCM cl = listen_classes_; scm_is_pair (cl); cl = scm_cdr (cl))
     {
       disp->internal_add_listener (list, scm_car (cl), priority);
     }