inline void
Dispatcher::internal_add_listener (SCM callback, SCM ev_class, int priority)
{
- SCM list = scm_hashq_ref (listeners_, ev_class, SCM_EOL);
+ SCM handle = scm_hashq_create_handle_x (listeners_, ev_class, SCM_EOL);
+ SCM list = scm_cdr (handle);
// if ev_class is not yet listened to, we go through our list of
// source dispatchers and register ourselves there with the priority
// we have reserved for this dispatcher. The priority system
}
SCM entry = scm_cons (scm_from_int (priority), callback);
list = scm_merge (list, scm_list_1 (entry), ly_lily_module_constant ("car<"));
- scm_hashq_set_x (listeners_, ev_class, list);
+ scm_set_cdr_x (handle, list);
}
void
Dispatcher::remove_listener (Listener l, SCM ev_class)
{
- SCM list = scm_hashq_ref (listeners_, ev_class, SCM_EOL);
+ SCM handle = scm_hashq_get_handle (listeners_, ev_class);
- if (scm_is_null (list))
+ if (scm_is_false (handle))
{
programming_error ("remove_listener called with incorrect class.");
return;
}
+ SCM list = scm_cdr (handle);
// We just remove the listener once.
bool first = true;
else
e = scm_cdr (e);
list = scm_cdr (dummy);
- scm_hashq_set_x (listeners_, ev_class, list);
+ scm_set_cdr_x (handle, list);
if (first)
warning (_ ("Attempting to remove nonexisting listener."));
else
continue;
- SCM acklist = scm_hashq_ref (acknowledge_hash_table_drul_[info.start_end ()],
- nm, SCM_BOOL_F);
+ SCM ackhandle = scm_hashq_create_handle_x (acknowledge_hash_table_drul_[info.start_end ()],
+ nm, SCM_BOOL_F);
- Engraver_dispatch_list *dispatch
- = Engraver_dispatch_list::unsmob (acklist);
+ SCM acklist = scm_cdr (ackhandle);
if (scm_is_false (acklist))
{
acklist = Engraver_dispatch_list::create (get_simple_trans_list (),
ifaces, info.start_end ());
- dispatch
- = Engraver_dispatch_list::unsmob (acklist);
-
- scm_hashq_set_x (acknowledge_hash_table_drul_[info.start_end ()], nm, acklist);
+ scm_set_cdr_x (ackhandle, acklist);
}
+ Engraver_dispatch_list *dispatch
+ = Engraver_dispatch_list::unsmob (acklist);
+
if (dispatch)
dispatch->apply (info);
}
Ugh. This is slightly expensive. We could/should cache the value of
the group count?
*/
-int
-Engraver_group::pending_grob_count () const
+bool
+Engraver_group::pending_grobs () const
{
- int count = announce_infos_.size ();
+ if (!announce_infos_.empty ())
+ return true;
for (SCM s = context_->children_contexts ();
scm_is_pair (s); s = scm_cdr (s))
{
Engraver_group *group
= dynamic_cast<Engraver_group *> (c->implementation ());
- if (group)
- count += group->pending_grob_count ();
+ if (group && group->pending_grobs ())
+ return true;
}
- return count;
+ return false;
}
void
announce_infos_.clear ();
}
}
- while (pending_grob_count () > 0);
+ while (pending_grobs ());
}
Engraver_group::Engraver_group ()
virtual void connect_to_context (Context *c);
virtual void disconnect_from_context ();
virtual void announce_grob (Grob_info);
- int pending_grob_count () const;
+ bool pending_grobs () const;
private:
virtual void acknowledge_grobs ();
};