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