]> git.donarmstrong.com Git - lilypond.git/blob - lily/context.cc
Merge branch 'master' of /home/jcharles/GIT/Lily/. into translation
[lilypond.git] / lily / context.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2004--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "context.hh"
21
22 #include "context-def.hh"
23 #include "dispatcher.hh"
24 #include "global-context.hh"
25 #include "international.hh"
26 #include "ly-smobs.icc"
27 #include "main.hh"
28 #include "output-def.hh"
29 #include "profile.hh"
30 #include "program-option.hh"
31 #include "scm-hash.hh"
32 #include "translator-group.hh"
33 #include "warn.hh"
34
35 bool
36 Context::is_removable () const
37 {
38   return context_list_ == SCM_EOL && ! client_count_
39          && !dynamic_cast<Global_context const *> (daddy_context_);
40 }
41
42 void
43 Context::check_removal ()
44 {
45   for (SCM p = context_list_; scm_is_pair (p); p = scm_cdr (p))
46     {
47       Context *ctx = Context::unsmob (scm_car (p));
48
49       ctx->check_removal ();
50       if (ctx->is_removable ())
51         {
52           recurse_over_translators (ctx, &Translator::finalize,
53                                     &Translator_group::finalize,
54                                     UP);
55           send_stream_event (ctx, "RemoveContext", 0, 0);
56         }
57     }
58 }
59
60 Context::Context (Context const & /* src */)
61 {
62   assert (false);
63 }
64
65 Scheme_hash_table *
66 Context::properties_dict () const
67 {
68   return Scheme_hash_table::unsmob (properties_scm_);
69 }
70
71 void
72 Context::add_context (Context *child)
73 {
74   context_list_ = ly_append2 (context_list_,
75                               scm_cons (child->self_scm (), SCM_EOL));
76
77   child->daddy_context_ = this;
78   this->events_below_->register_as_listener (child->events_below_);
79 }
80
81 Context::Context ()
82 {
83   daddy_context_ = 0;
84   aliases_ = SCM_EOL;
85   client_count_ = 0;
86   implementation_ = 0;
87   properties_scm_ = SCM_EOL;
88   accepts_list_ = SCM_EOL;
89   default_child_ = SCM_EOL;
90   context_list_ = SCM_EOL;
91   definition_ = SCM_EOL;
92   definition_mods_ = SCM_EOL;
93   event_source_ = 0;
94   events_below_ = 0;
95
96   smobify_self ();
97
98   Scheme_hash_table *tab = new Scheme_hash_table;
99   properties_scm_ = tab->unprotect ();
100   event_source_ = new Dispatcher ();
101   event_source_->unprotect ();
102   events_below_ = new Dispatcher ();
103   events_below_->unprotect ();
104 }
105
106 /* TODO:  this shares code with find_create_context ().  */
107 Context *
108 Context::create_unique_context (SCM name, const string &id, SCM operations)
109 {
110   /*
111     Don't create multiple score contexts.
112   */
113   Global_context *gthis = dynamic_cast<Global_context *> (this);
114   if (gthis && gthis->get_score_context ())
115     return gthis->get_score_context ()->create_unique_context (name, id, operations);
116
117   vector<Context_def *> path = path_to_acceptable_context (name);
118   if (path.size ())
119     {
120       Context *current = this;
121
122       // Iterate through the path and create all of the implicit contexts.
123       for (vsize i = 0; i < path.size (); i++)
124         {
125           SCM ops = SCM_EOL;
126           string id_str = "\\new";
127           if (i == path.size () - 1)
128             {
129               ops = operations;
130               id_str = id;
131             }
132           current = current->create_context (path[i],
133                                              id_str,
134                                              ops);
135         }
136
137       return current;
138     }
139
140   /*
141     Don't go up to Global_context, because global goes down to the
142     Score context
143   */
144   Context *ret = 0;
145   if (daddy_context_ && !dynamic_cast<Global_context *> (daddy_context_))
146     ret = daddy_context_->create_unique_context (name, id, operations);
147   else
148     {
149       warning (_f ("cannot find or create new `%s'",
150                    ly_symbol2string (name).c_str ()));
151       ret = 0;
152     }
153   return ret;
154 }
155
156 Context *
157 Context::find_create_context (SCM n, const string &id, SCM operations)
158 {
159   /*
160     Don't create multiple score contexts.
161   */
162   Global_context *gthis = dynamic_cast<Global_context *> (this);
163   if (gthis)
164     {
165       if (gthis->get_score_context ())
166         return gthis->get_score_context ()->find_create_context (n, id, operations);
167
168       // Special case: If we use \set Timing.xxx = whatever before
169       // Score is established, the alias of Score to Timing will not
170       // be taken into account.  We check for this particular case
171       // here.  Aliases apart from Score-level ones don't warrant
172       // context creation as they could create unwanted contexts, like
173       // RhythmicVoice instead of Voice.  Creating a Score context,
174       // however, can't really do anything wrong.
175
176       SCM score_name = default_child_context_name ();
177       SCM score_def = find_context_def (get_output_def (), score_name);
178
179       if (Context_def *cd = Context_def::unsmob (score_def))
180         {
181           if (cd->is_alias (n))
182             return create_context (cd, id, operations);
183         }
184     }
185
186
187   if (Context *existing = find_context_below (this, n, id))
188     return existing;
189
190   if (n == ly_symbol2scm ("Bottom"))
191     {
192       Context *tg = get_default_interpreter (id);
193       return tg;
194     }
195
196   vector<Context_def *> path = path_to_acceptable_context (n);
197
198   if (path.size ())
199     {
200       Context *current = this;
201
202       // start at 1.  The first one (index 0) will be us.
203       for (vsize i = 0; i < path.size (); i++)
204         {
205           SCM ops = (i == path.size () - 1) ? operations : SCM_EOL;
206
207           string this_id = "";
208           if (i == path.size () - 1)
209             this_id = id;
210
211           current = current->create_context (path[i],
212                                              this_id,
213                                              ops);
214         }
215
216       return current;
217     }
218
219   /*
220     Don't go up to Global_context, because global goes down to the
221     Score context
222   */
223   Context *ret = 0;
224   if (daddy_context_ && !dynamic_cast<Global_context *> (daddy_context_))
225     ret = daddy_context_->find_create_context (n, id, operations);
226   else
227     {
228       warning (_f ("cannot find or create `%s' called `%s'",
229                    ly_symbol2string (n).c_str (), id));
230       ret = 0;
231     }
232   return ret;
233 }
234
235 IMPLEMENT_LISTENER (Context, acknowledge_infant);
236 void
237 Context::acknowledge_infant (SCM sev)
238 {
239   infant_event_ = Stream_event::unsmob (sev);
240 }
241
242 IMPLEMENT_LISTENER (Context, set_property_from_event);
243 void
244 Context::set_property_from_event (SCM sev)
245 {
246   Stream_event *ev = Stream_event::unsmob (sev);
247
248   SCM sym = ev->get_property ("symbol");
249   if (scm_is_symbol (sym))
250     {
251       SCM val = ev->get_property ("value");
252
253       if (SCM_UNBNDP (val)) {
254         unset_property (sym);
255         return;
256       }
257           
258       bool ok = true;
259       ok = type_check_assignment (sym, val, ly_symbol2scm ("translation-type?"));
260
261       if (ok)
262         set_property (sym, val);
263     }
264 }
265
266 IMPLEMENT_LISTENER (Context, unset_property_from_event);
267 void
268 Context::unset_property_from_event (SCM sev)
269 {
270   Stream_event *ev = Stream_event::unsmob (sev);
271
272   SCM sym = ev->get_property ("symbol");
273   type_check_assignment (sym, SCM_EOL, ly_symbol2scm ("translation-type?"));
274   unset_property (sym);
275 }
276
277 /*
278   Creates a new context from a CreateContext event, and sends an
279   AnnounceNewContext event to this context.
280 */
281 IMPLEMENT_LISTENER (Context, create_context_from_event);
282 void
283 Context::create_context_from_event (SCM sev)
284 {
285   Stream_event *ev = Stream_event::unsmob (sev);
286
287   string id = ly_scm2string (ev->get_property ("id"));
288   SCM ops = ev->get_property ("ops");
289   SCM type_scm = ev->get_property ("type");
290   string type = ly_symbol2string (type_scm);
291
292   vector<Context_def *> path = path_to_acceptable_context (type_scm);
293
294   if (path.size () != 1)
295     {
296       programming_error (to_string ("Invalid CreateContext event: Cannot create %s context", type.c_str ()));
297       return;
298     }
299   Context_def *cdef = path[0];
300
301   Context *new_context = cdef->instantiate (ops);
302
303   new_context->id_string_ = id;
304
305   /* Register various listeners:
306       - Make the new context hear events that universally affect contexts
307       - connect events_below etc. properly */
308   /* We want to be the first ones to hear our own events. Therefore, wait
309      before registering events_below_ */
310   new_context->event_source ()->
311   add_listener (GET_LISTENER (new_context->create_context_from_event),
312                 ly_symbol2scm ("CreateContext"));
313   new_context->event_source ()->
314   add_listener (GET_LISTENER (new_context->remove_context),
315                 ly_symbol2scm ("RemoveContext"));
316   new_context->event_source ()->
317   add_listener (GET_LISTENER (new_context->change_parent),
318                 ly_symbol2scm ("ChangeParent"));
319   new_context->event_source ()->
320   add_listener (GET_LISTENER (new_context->set_property_from_event),
321                 ly_symbol2scm ("SetProperty"));
322   new_context->event_source ()->
323   add_listener (GET_LISTENER (new_context->unset_property_from_event),
324                 ly_symbol2scm ("UnsetProperty"));
325
326   new_context->events_below_->register_as_listener (new_context->event_source_);
327   this->add_context (new_context);
328
329   new_context->unprotect ();
330
331   Context_def *td = Context_def::unsmob (new_context->definition_);
332
333   /* This cannot move before add_context (), because \override
334      operations require that we are in the hierarchy.  */
335   td->apply_default_property_operations (new_context);
336   apply_property_operations (new_context, ops);
337
338   send_stream_event (this, "AnnounceNewContext", 0,
339                      ly_symbol2scm ("context"), new_context->self_scm (),
340                      ly_symbol2scm ("creator"), sev);
341 }
342
343 vector<Context_def *>
344 Context::path_to_acceptable_context (SCM name) const
345 {
346   // The 'accepts elements in definition_mods_ is a list of ('accepts string),
347   // but the Context_def expects to see elements of the form ('accepts symbol).
348   SCM accepts = SCM_EOL;
349   for (SCM s = definition_mods_; scm_is_pair (s); s = scm_cdr (s))
350     if (scm_caar (s) == ly_symbol2scm ("accepts"))
351       {
352         SCM elt = scm_list_2 (scm_caar (s), scm_string_to_symbol (scm_cadar (s)));
353         accepts = scm_cons (elt, accepts);
354       }
355
356   return Context_def::unsmob (definition_)->path_to_acceptable_context (name,
357          get_output_def (),
358          scm_reverse_x (accepts, SCM_EOL));
359
360 }
361
362 Context *
363 Context::create_context (Context_def *cdef,
364                          const string &id,
365                          SCM ops)
366 {
367   infant_event_ = 0;
368   /* TODO: This is fairly misplaced. We can fix this when we have taken out all
369      iterator specific stuff from the Context class */
370   event_source_->
371   add_listener (GET_LISTENER (acknowledge_infant),
372                 ly_symbol2scm ("AnnounceNewContext"));
373   /* The CreateContext creates a new context, and sends an announcement of the
374      new context through another event. That event will be stored in
375      infant_event_ to create a return value. */
376   send_stream_event (this, "CreateContext", 0,
377                      ly_symbol2scm ("ops"), ops,
378                      ly_symbol2scm ("type"), cdef->get_context_name (),
379                      ly_symbol2scm ("id"), ly_string2scm (id));
380   event_source_->
381   remove_listener (GET_LISTENER (acknowledge_infant),
382                    ly_symbol2scm ("AnnounceNewContext"));
383
384   assert (infant_event_);
385   SCM infant_scm = infant_event_->get_property ("context");
386   Context *infant = Context::unsmob (infant_scm);
387
388   if (!infant || infant->get_parent_context () != this)
389     {
390       programming_error ("create_context: can't locate newly created context");
391       return 0;
392     }
393
394   return infant;
395 }
396
397 /*
398   Default child context as a SCM string, or something else if there is
399   none.
400 */
401 SCM
402 Context::default_child_context_name () const
403 {
404   return default_child_;
405 }
406
407 bool
408 Context::is_bottom_context () const
409 {
410   return !scm_is_symbol (default_child_context_name ());
411 }
412
413 Context *
414 Context::get_default_interpreter (const string &context_id)
415 {
416   if (!is_bottom_context ())
417     {
418       SCM nm = default_child_context_name ();
419       SCM st = find_context_def (get_output_def (), nm);
420
421       string name = ly_symbol2string (nm);
422       Context_def *t = Context_def::unsmob (st);
423       if (!t)
424         {
425           warning (_f ("cannot find or create: `%s'", name.c_str ()));
426           t = Context_def::unsmob (this->definition_);
427         }
428       if (scm_is_symbol (t->get_default_child (SCM_EOL)))
429         {
430           Context *tg = create_context (t, "\\new", SCM_EOL);
431           return tg->get_default_interpreter (context_id);
432         }
433       return create_context (t, context_id, SCM_EOL);
434     }
435   else if (!context_id.empty () && context_id != id_string ())
436     {
437       if (daddy_context_ && !dynamic_cast<Global_context *> (daddy_context_))
438         return daddy_context_->get_default_interpreter (context_id);
439       warning (_f ("cannot find or create new Bottom = \"%s\"",
440                    context_id.c_str ()));
441     }
442   return this;
443 }
444
445 /*
446   PROPERTIES
447 */
448 Context *
449 Context::where_defined (SCM sym, SCM *value) const
450 {
451 #ifndef NDEBUG
452   if (profile_property_accesses)
453     note_property_access (&context_property_lookup_table, sym);
454 #endif
455
456   if (properties_dict ()->try_retrieve (sym, value))
457     return (Context *)this;
458
459   return (daddy_context_) ? daddy_context_->where_defined (sym, value) : 0;
460 }
461
462 /* Quick variant of where_defined.  Checks only the context itself. */
463
464 bool
465 Context::here_defined (SCM sym, SCM *value) const
466 {
467 #ifndef NDEBUG
468   if (profile_property_accesses)
469     note_property_access (&context_property_lookup_table, sym);
470 #endif
471
472   return properties_dict ()->try_retrieve (sym, value);
473 }
474
475 /*
476   return SCM_EOL when not found.
477 */
478 SCM
479 Context::internal_get_property (SCM sym) const
480 {
481 #ifndef NDEBUG
482   if (profile_property_accesses)
483     note_property_access (&context_property_lookup_table, sym);
484 #endif
485
486   SCM val = SCM_EOL;
487   if (properties_dict ()->try_retrieve (sym, &val))
488     return val;
489
490   if (daddy_context_)
491     return daddy_context_->internal_get_property (sym);
492
493   return val;
494 }
495
496 /*
497 Called by the send_stream_event macro. props is a 0-terminated array of
498 properties and corresponding values, interleaved. This method should not
499 be called from any other place than the send_stream_event macro.
500 */
501 void
502 Context::internal_send_stream_event (SCM type, Input *origin, SCM props[])
503 {
504   Stream_event *e = new Stream_event
505     (scm_call_1 (ly_lily_module_constant ("ly:make-event-class"), type),
506      origin);
507   for (int i = 0; props[i]; i += 2)
508     {
509       e->set_property (props[i], props[i + 1]);
510     }
511   event_source_->broadcast (e);
512   e->unprotect ();
513 }
514
515 bool
516 Context::is_alias (SCM sym) const
517 {
518   if (scm_is_eq (sym, ly_symbol2scm ("Bottom")))
519     return is_bottom_context ();
520   if (scm_is_eq (sym, context_name_symbol ()))
521     return true;
522
523   return scm_c_memq (sym, aliases_) != SCM_BOOL_F;
524 }
525
526 void
527 Context::add_alias (SCM sym)
528 {
529   aliases_ = scm_cons (sym, aliases_);
530 }
531
532 /* we don't (yet) instrument context properties */
533 void
534 Context::instrumented_set_property (SCM sym, SCM val, const char *, int, const char *)
535 {
536   internal_set_property (sym, val);
537 }
538
539 void
540 Context::internal_set_property (SCM sym, SCM val)
541 {
542   bool type_check_ok = type_check_assignment (sym, val, ly_symbol2scm ("translation-type?"));
543
544   if (do_internal_type_checking_global)
545     assert (type_check_ok);
546
547   if (type_check_ok)
548     properties_dict ()->set (sym, val);
549 }
550
551 /*
552   TODO: look up to check whether we have inherited var?
553 */
554 void
555 Context::unset_property (SCM sym)
556 {
557   properties_dict ()->remove (sym);
558 }
559
560 IMPLEMENT_LISTENER (Context, change_parent);
561 void
562 Context::change_parent (SCM sev)
563 {
564   Stream_event *ev = Stream_event::unsmob (sev);
565   Context *to = Context::unsmob (ev->get_property ("context"));
566
567   disconnect_from_parent ();
568   to->add_context (this);
569 }
570
571 /*
572   Die. The next GC sweep should take care of the actual death.
573  */
574 IMPLEMENT_LISTENER (Context, remove_context);
575 void
576 Context::remove_context (SCM)
577 {
578   /* ugh, the translator group should listen to RemoveContext events by itself */
579   Translator_group *impl = implementation ();
580   if (impl)
581     impl->disconnect_from_context ();
582   disconnect_from_parent ();
583 }
584
585 void
586 Context::disconnect_from_parent ()
587 {
588   daddy_context_->events_below_->unregister_as_listener (this->events_below_);
589   daddy_context_->context_list_ = scm_delq_x (this->self_scm (), daddy_context_->context_list_);
590   daddy_context_ = 0;
591 }
592
593 /*
594   ID == "" means accept any ID.
595 */
596 Context *
597 find_context_below (Context *where,
598                     SCM type, const string &id)
599 {
600   if (where->is_alias (type))
601     {
602       if (id == "" || where->id_string () == id)
603         return where;
604     }
605
606   Context *found = 0;
607   for (SCM s = where->children_contexts ();
608        !found && scm_is_pair (s); s = scm_cdr (s))
609     {
610       Context *tr = Context::unsmob (scm_car (s));
611
612       found = find_context_below (tr, type, id);
613     }
614
615   return found;
616 }
617
618 SCM
619 Context::properties_as_alist () const
620 {
621   return properties_dict ()->to_alist ();
622 }
623
624 SCM
625 Context::context_name_symbol () const
626 {
627   Context_def *td = Context_def::unsmob (definition_);
628   return td->get_context_name ();
629 }
630
631 string
632 Context::context_name () const
633 {
634   return ly_symbol2string (context_name_symbol ());
635 }
636
637 Context *
638 Context::get_score_context () const
639 {
640   if (daddy_context_)
641     return daddy_context_->get_score_context ();
642   else
643     return 0;
644 }
645
646 Output_def *
647 Context::get_output_def () const
648 {
649   return daddy_context_ ? daddy_context_->get_output_def () : 0;
650 }
651
652 Context::~Context ()
653 {
654 }
655
656 Moment
657 Context::now_mom () const
658 {
659   Context const *p = this;
660   while (p->daddy_context_)
661     p = p->daddy_context_;
662
663   return p->now_mom ();
664 }
665
666 int
667 Context::print_smob (SCM s, SCM port, scm_print_state *)
668 {
669   Context *sc = (Context *) SCM_CELL_WORD_1 (s);
670
671   scm_puts ("#<", port);
672   scm_puts (sc->class_name (), port);
673   if (Context_def *d = Context_def::unsmob (sc->definition_))
674     {
675       scm_puts (" ", port);
676       scm_display (d->get_context_name (), port);
677     }
678
679   if (!sc->id_string_.empty ())
680     {
681       scm_puts ("=", port);
682       scm_puts (sc->id_string_.c_str (), port);
683     }
684
685   scm_puts (" ", port);
686
687   scm_display (sc->context_list_, port);
688   scm_puts (" >", port);
689
690   return 1;
691 }
692
693 SCM
694 Context::mark_smob (SCM sm)
695 {
696   Context *me = (Context *) SCM_CELL_WORD_1 (sm);
697
698   scm_gc_mark (me->context_list_);
699   scm_gc_mark (me->aliases_);
700   scm_gc_mark (me->definition_);
701   scm_gc_mark (me->definition_mods_);
702   scm_gc_mark (me->properties_scm_);
703   scm_gc_mark (me->accepts_list_);
704   scm_gc_mark (me->default_child_);
705
706   if (me->implementation_)
707     scm_gc_mark (me->implementation_->self_scm ());
708
709   if (me->event_source_)
710     scm_gc_mark (me->event_source_->self_scm ());
711
712   if (me->events_below_)
713     scm_gc_mark (me->events_below_->self_scm ());
714
715   return me->properties_scm_;
716 }
717
718 IMPLEMENT_SMOBS (Context);
719 IMPLEMENT_DEFAULT_EQUAL_P (Context);
720 IMPLEMENT_TYPE_P (Context, "ly:context?");
721
722 Global_context *
723 Context::get_global_context () const
724 {
725   if (dynamic_cast<Global_context *> ((Context *) this))
726     return dynamic_cast<Global_context *> ((Context *) this);
727
728   if (daddy_context_)
729     return daddy_context_->get_global_context ();
730
731   programming_error ("no Global context");
732   return 0;
733 }
734
735 Context *
736 Context::get_parent_context () const
737 {
738   return daddy_context_;
739 }
740
741 /*
742   Ugh. Where to put this?
743 */
744 Rational
745 measure_length (Context const *context)
746 {
747   SCM l = context->get_property ("measureLength");
748   Rational length (1);
749   if (Moment::unsmob (l))
750     length = Moment::unsmob (l)->main_part_;
751   return length;
752 }
753
754 Moment
755 measure_position (Context const *context)
756 {
757   SCM sm = context->get_property ("measurePosition");
758
759   Moment m = 0;
760   if (Moment::unsmob (sm))
761     {
762       m = *Moment::unsmob (sm);
763
764       if (m.main_part_ < Rational (0))
765         {
766           Rational length (measure_length (context));
767           while (m.main_part_ < Rational (0))
768             m.main_part_ += length;
769         }
770     }
771
772   return m;
773 }
774
775 /* Finds the measure position after a note of length DUR that
776    begins at the current measure position. */
777 Moment
778 measure_position (Context const *context, Duration const *dur)
779 {
780   Moment pos = measure_position (context);
781   Rational dur_length = dur ? dur->get_length () : Rational (0);
782
783   Moment end_pos = pos.grace_part_ < Rational (0)
784                    ? Moment (pos.main_part_, pos.grace_part_ + dur_length)
785                    : Moment (pos.main_part_ + dur_length, 0);
786
787   return end_pos;
788 }
789
790 int
791 measure_number (Context const *context)
792 {
793   SCM barnum = context->get_property ("internalBarNumber");
794   SCM smp = context->get_property ("measurePosition");
795
796   int bn = robust_scm2int (barnum, 0);
797   Moment mp = robust_scm2moment (smp, Moment (0));
798   if (mp.main_part_ < Rational (0))
799     bn--;
800
801   return bn;
802 }
803
804 void
805 set_context_property_on_children (Context *trans, SCM sym, SCM val)
806 {
807   trans->set_property (sym, ly_deep_copy (val));
808   for (SCM p = trans->children_contexts (); scm_is_pair (p); p = scm_cdr (p))
809     {
810       Context *trg = Context::unsmob (scm_car (p));
811       set_context_property_on_children (trg, sym, ly_deep_copy (val));
812     }
813 }
814
815 bool
816 melisma_busy (Context *tr)
817 {
818   SCM melisma_properties = tr->get_property ("melismaBusyProperties");
819   bool busy = false;
820
821   for (; !busy && scm_is_pair (melisma_properties);
822        melisma_properties = scm_cdr (melisma_properties))
823     busy = busy || to_boolean (tr->internal_get_property (scm_car (melisma_properties)));
824
825   return busy;
826 }
827
828 bool
829 check_repeat_count_visibility (Context const *context, SCM count)
830 {
831   SCM proc = context->get_property ("repeatCountVisibility");
832   return (ly_is_procedure (proc)
833           && to_boolean (scm_call_2 (proc,
834                                      count,
835                                      context->self_scm ())));
836 }