]> git.donarmstrong.com Git - lilypond.git/blob - lily/grob.cc
release: 1.5.31
[lilypond.git] / lily / grob.cc
1 /*
2   grob.cc -- implement Grob
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #include <string.h>
11 #include <math.h>
12
13 #include "main.hh"
14 #include "input-smob.hh"
15
16 #include "group-interface.hh"
17 #include "misc.hh"
18 #include "paper-score.hh"
19 #include "paper-def.hh"
20 #include "molecule.hh"
21 #include "grob.hh"
22 #include "debug.hh"
23 #include "spanner.hh"
24 #include "line-of-score.hh"
25 #include "item.hh"
26 #include "paper-column.hh"
27 #include "molecule.hh"
28 #include "misc.hh"
29 #include "paper-outputter.hh"
30 #include "music.hh"
31 #include "item.hh"
32
33 #include "ly-smobs.icc"
34
35 /*
36 TODO:
37
38 remove dynamic_cast<Spanner,Item> and put this code into respective
39   subclass.
40 */
41
42
43 #define INFINITY_MSG "Infinity or NaN encountered"
44
45 Grob::Grob (SCM basicprops)
46 {
47   /*
48     fixme: default should be no callback.
49    */
50
51   pscore_l_=0;
52   status_c_ = 0;
53   original_l_ = 0;
54   immutable_property_alist_ =  basicprops;
55   mutable_property_alist_ = SCM_EOL;
56
57   smobify_self ();
58
59   /*
60     TODO:
61
62     destill this into a function, so we can re-init the immutable
63     properties with a new BASICPROPS value after creation. Convenient
64     eg. when using \override with StaffSymbol.  */
65   
66   char const*onames[] = {"X-offset-callbacks", "Y-offset-callbacks"};
67   char const*enames[] = {"X-extent-callback", "Y-extent-callback"};
68   
69   for (int a = X_AXIS; a <= Y_AXIS; a++)
70     {
71       SCM l = get_grob_property (onames[a]);
72
73       if (scm_ilength (l) >=0)
74         {
75           dim_cache_[a].offset_callbacks_ = l;
76           dim_cache_[a].offsets_left_ = scm_ilength (l);
77         }
78       else
79         {
80           programming_error ("[XY]-offset-callbacks must be a list");
81         }
82
83       SCM cb = get_grob_property (enames[a]);
84
85       /*
86         Should change default to be empty? 
87       */
88       if (cb != SCM_BOOL_F && !gh_procedure_p (cb) && !gh_pair_p (cb))
89         cb = molecule_extent_proc;
90     
91       dim_cache_[a].dimension_ = cb;
92     }
93
94   SCM meta = get_grob_property ("meta");
95   if (gh_pair_p (meta))
96     {
97       SCM ifs = scm_assoc (ly_symbol2scm ("interfaces"), meta);
98   
99       set_grob_property ("interfaces",ly_cdr (ifs));
100     }
101 }
102
103 Grob::Grob (Grob const&s)
104    : dim_cache_ (s.dim_cache_)
105 {
106   original_l_ = (Grob*) &s;
107   immutable_property_alist_ = s.immutable_property_alist_;
108   mutable_property_alist_ = SCM_EOL;
109   
110   status_c_ = s.status_c_;
111   pscore_l_ = s.pscore_l_;
112
113   smobify_self ();
114 }
115
116 Grob::~Grob ()
117 {
118   /*
119     do nothing scm-ish and no unprotecting here.
120    */
121 }
122
123
124 SCM
125 Grob::internal_get_grob_property (SCM sym) const
126 {
127   SCM s = scm_sloppy_assq (sym, mutable_property_alist_);
128   if (s != SCM_BOOL_F)
129     return ly_cdr (s);
130
131   s = scm_sloppy_assq (sym, immutable_property_alist_);
132   return (s == SCM_BOOL_F) ? SCM_EOL : ly_cdr (s); 
133 }
134
135 /*
136   Remove the value associated with KEY, and return it. The result is
137   that a next call will yield SCM_EOL (and not the underlying
138   `basic' property.
139 */
140 SCM
141 Grob::remove_grob_property (const char* key)
142 {
143   SCM val = get_grob_property (key);
144   if (val != SCM_EOL)
145     set_grob_property (key, SCM_EOL);
146   return val;
147 }
148
149
150 #if 0
151 /*
152   Puts the k, v in the immutable_property_alist_, which is convenient for
153   storing variables that are needed during the breaking process. (eg.
154   Line_of_score::rank : int)
155  */
156 void
157 Grob::set_immutable_grob_property (const char*k, SCM v)
158 {
159   SCM s = ly_symbol2scm (k);
160   set_immutable_grob_property (s, v);
161 }
162
163 void
164 Grob::set_immutable_grob_property (SCM s, SCM v)
165 {
166   immutable_property_alist_ = gh_cons (gh_cons (s,v), mutable_property_alist_);
167   mutable_property_alist_ = scm_assq_remove_x (mutable_property_alist_, s);
168 }
169 #endif
170
171
172 void
173 Grob::internal_set_grob_property (SCM s, SCM v)
174 {
175   mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, s, v);
176 }
177
178
179 MAKE_SCHEME_CALLBACK (Grob,molecule_extent,2);
180 SCM
181 Grob::molecule_extent (SCM element_smob, SCM scm_axis)
182 {
183   Grob *s = unsmob_grob (element_smob);
184   Axis a = (Axis) gh_scm2int (scm_axis);
185
186   Molecule *m = s->get_molecule ();
187   Interval e ;
188   if (m)
189     e = m->extent (a);
190   return ly_interval2scm (e);
191 }
192
193 MAKE_SCHEME_CALLBACK (Grob,preset_extent,2);
194
195 SCM
196 Grob::preset_extent (SCM element_smob, SCM scm_axis)
197 {
198   Grob *s = unsmob_grob (element_smob);
199   Axis a = (Axis) gh_scm2int (scm_axis);
200
201   SCM ext = s->get_grob_property ((a == X_AXIS)
202                                  ? "extent-X"
203                                  : "extent-Y");
204   
205   if (gh_pair_p (ext))
206     {
207       Real l = gh_scm2double (ly_car (ext));
208       Real r = gh_scm2double (ly_cdr (ext));
209       return ly_interval2scm (Interval (l, r));
210     }
211   
212   return ly_interval2scm (Interval ());
213 }
214
215
216
217 Paper_def*
218 Grob::paper_l ()  const
219 {
220  return pscore_l_ ? pscore_l_->paper_l_ : 0;
221 }
222
223 void
224 Grob::calculate_dependencies (int final, int busy, SCM funcname)
225 {
226   if (status_c_ >= final)
227     return;
228
229   if (status_c_== busy)
230     {
231       programming_error ("Element is busy, come back later");
232       return;
233     }
234   
235   status_c_= busy;
236
237   for (SCM d=  get_grob_property ("dependencies"); gh_pair_p (d); d = ly_cdr (d))
238     {
239       unsmob_grob (ly_car (d))
240         ->calculate_dependencies (final, busy, funcname);
241     }
242
243   // ughugh.
244   String s = ly_symbol2string (funcname);
245   SCM proc = get_grob_property (s.ch_C ());
246   if (gh_procedure_p (proc))
247     gh_call1 (proc, this->self_scm ());
248   
249   status_c_= final;
250
251 }
252
253 Molecule *
254 Grob::get_molecule ()  const
255 {
256   SCM mol = get_grob_property ("molecule");
257   if (unsmob_molecule (mol))
258     return unsmob_molecule (mol);
259
260   mol =  get_uncached_molecule ();
261   
262   Grob *me = (Grob*)this;
263   me->set_grob_property ("molecule", mol);
264   
265   return unsmob_molecule (mol);  
266 }
267 SCM
268 Grob::get_uncached_molecule ()const
269 {
270   SCM proc = get_grob_property ("molecule-callback");
271
272   SCM  mol = SCM_EOL;
273   if (gh_procedure_p (proc)) 
274     mol = gh_apply (proc, scm_list_n (this->self_scm (), SCM_UNDEFINED));
275
276   
277   Molecule *m = unsmob_molecule (mol);
278   
279   if (unsmob_molecule (mol))
280     {
281       SCM origin =      ly_symbol2scm ("no-origin");
282       
283       if (store_locations_global_b){
284         SCM cause = get_grob_property ("cause");
285         if (Music*m = unsmob_music (cause))
286           {
287             SCM music_origin = m->get_mus_property ("origin");
288             if (unsmob_input (music_origin))
289               origin = music_origin;
290           }
291       }
292
293       // ugr.
294       
295       mol = Molecule (m->extent_box (),
296                       scm_list_n (origin, m->get_expr (), SCM_UNDEFINED)
297                       ). smobbed_copy ();
298
299       m = unsmob_molecule (mol);
300     }
301   
302   /*
303     transparent retains dimensions of element.
304    */
305   if (m && to_boolean (get_grob_property ("transparent")))
306     mol = Molecule (m->extent_box (), SCM_EOL).smobbed_copy ();
307
308   return mol;
309 }
310
311 /*
312   
313   VIRTUAL STUBS
314
315  */
316 void
317 Grob::do_break_processing ()
318 {
319 }
320
321
322
323
324
325
326 Line_of_score *
327 Grob::line_l () const
328 {
329   return 0;
330 }
331
332 void
333 Grob::add_dependency (Grob*e)
334 {
335   if (e)
336     {
337       Pointer_group_interface::add_grob (this, ly_symbol2scm ("dependencies"),e);
338     }
339   else
340     programming_error ("Null dependency added");
341 }
342
343
344
345
346 /**
347       Do break substitution in S, using CRITERION. Return new value.
348       CRITERION is either a SMOB pointer to the desired line, or a number
349       representing the break direction. Do not modify SRC.
350
351       It is rather tightly coded, since it takes a lot of time; it is
352       one of the top functions in the profile.
353
354 */
355 SCM
356 Grob::handle_broken_grobs (SCM src, SCM criterion)
357 {
358  again:
359   Grob *sc = unsmob_grob (src);
360   if (sc)
361     {
362       if (SCM_INUMP (criterion))
363         {
364           Item * i = dynamic_cast<Item*> (sc);
365           Direction d = to_dir (criterion);
366           if (i && i->break_status_dir () != d)
367             {
368               Item *br = i->find_prebroken_piece (d);
369               return (br) ? br->self_scm () : SCM_UNDEFINED;
370             }
371         }
372       else
373         {
374           Line_of_score * line
375             = dynamic_cast<Line_of_score*> (unsmob_grob (criterion));
376           if (sc->line_l () != line)
377             {
378               sc = sc->find_broken_piece (line);
379
380             }
381
382           /* now: !sc || (sc && sc->line_l () == line) */
383           if (!sc)
384             return SCM_UNDEFINED;
385
386           /* now: sc && sc->line_l () == line */
387           if (!line)
388             return sc->self_scm();
389               /*
390                 This was introduced in 1.3.49 as a measure to prevent
391                 programming errors. It looks expensive (?). TODO:
392                 benchmark , document when (what kind of programming
393                 errors) this happens.
394                */
395           if (sc->common_refpoint (line, X_AXIS)
396                && sc->common_refpoint (line, Y_AXIS))
397             {
398               return sc->self_scm ();
399             }
400           return SCM_UNDEFINED;
401         }
402     }
403   else if (ly_pair_p (src)) // SCM_CONSP (src))  // huh?
404     {
405       SCM oldcar =ly_car (src);
406       /*
407         UGH! breaks on circular lists.
408       */
409       SCM newcar = handle_broken_grobs (oldcar, criterion);
410       SCM oldcdr = ly_cdr (src);
411       
412       if (newcar == SCM_UNDEFINED
413           && (gh_pair_p (oldcdr) || oldcdr == SCM_EOL))
414         {
415           /*
416             This is tail-recursion, ie. 
417             
418             return handle_broken_grobs (cdr, criterion);
419
420             We don't want to rely on the compiler to do this.  Without
421             tail-recursion, this easily crashes with a stack overflow.  */
422           src =  oldcdr;
423           goto again;
424         }
425
426       SCM newcdr = handle_broken_grobs (oldcdr, criterion);
427       return scm_cons (newcar, newcdr);
428     }
429   else
430     return src;
431
432   return src;
433 }
434
435 void
436 Grob::handle_broken_dependencies ()
437 {
438   Spanner * s= dynamic_cast<Spanner*> (this);
439   if (original_l_ && s)
440     return;
441
442   if (s)
443     {
444       for (int i = 0;  i< s->broken_into_l_arr_ .size (); i++)
445         {
446           Grob * sc = s->broken_into_l_arr_[i];
447           Line_of_score * l = sc->line_l ();
448           sc->mutable_property_alist_ =
449             handle_broken_grobs (mutable_property_alist_,
450                                  l ? l->self_scm () : SCM_UNDEFINED);
451         }
452     }
453
454
455   Line_of_score *line = line_l ();
456
457   if (line && common_refpoint (line, X_AXIS) && common_refpoint (line, Y_AXIS))
458     {
459       mutable_property_alist_
460         = handle_broken_grobs (mutable_property_alist_,
461                                line ? line->self_scm () : SCM_UNDEFINED);
462     }
463   else if (dynamic_cast <Line_of_score*> (this))
464     {
465       mutable_property_alist_ = handle_broken_grobs (mutable_property_alist_,
466                                             SCM_UNDEFINED);
467     }
468   else
469     {
470       /*
471         This element is `invalid'; it has been removed from all
472         dependencies, so let's junk the element itself.
473
474         do not do this for Line_of_score, since that would remove
475         references to the originals of score-elts, which get then GC'd
476  (a bad thing.)
477       */
478       suicide ();
479     }
480 }
481
482 /*
483  Note that we still want references to this element to be
484  rearranged, and not silently thrown away, so we keep pointers
485  like {broken_into_{drul,array}, original}
486 */
487 void
488 Grob::suicide ()
489 {
490   mutable_property_alist_ = SCM_EOL;
491   immutable_property_alist_ = SCM_EOL;
492
493   set_extent_callback (SCM_EOL, Y_AXIS);
494   set_extent_callback (SCM_EOL, X_AXIS);
495
496   for (int a= X_AXIS; a <= Y_AXIS; a++)
497     {
498       dim_cache_[a].offset_callbacks_ = SCM_EOL;
499       dim_cache_[a].offsets_left_ = 0;
500     }
501 }
502
503 void
504 Grob::handle_prebroken_dependencies ()
505 {
506 }
507
508 Grob*
509 Grob::find_broken_piece (Line_of_score*) const
510 {
511   return 0;
512 }
513
514 void
515 Grob::translate_axis (Real y, Axis a)
516 {
517   if (isinf (y) || isnan (y))
518     programming_error (_ (INFINITY_MSG));
519   else
520     {
521       dim_cache_[a].offset_ += y;
522     }
523 }  
524
525 Real
526 Grob::relative_coordinate (Grob const*refp, Axis a) const
527 {
528   if (refp == this)
529     return 0.0;
530
531   /*
532     We catch PARENT_L_ == nil case with this, but we crash if we did
533     not ask for the absolute coordinate (ie. REFP == nil.)
534     
535    */
536   if (refp == dim_cache_[a].parent_l_)
537     return get_offset (a);
538   else
539     return get_offset (a) + dim_cache_[a].parent_l_->relative_coordinate (refp, a);
540 }
541
542 Real
543 Grob::get_offset (Axis a) const
544 {
545   Grob *me = (Grob*) this;
546   while (dim_cache_[a].offsets_left_)
547     {
548       int l = --me->dim_cache_[a].offsets_left_;
549       SCM cb = scm_list_ref (dim_cache_[a].offset_callbacks_,  gh_int2scm (l));
550       SCM retval = gh_call2 (cb, self_scm (), gh_int2scm (a));
551
552       Real r =  gh_scm2double (retval);
553       if (isinf (r) || isnan (r))
554         {
555           programming_error (INFINITY_MSG);
556           r = 0.0;
557         }
558       me->dim_cache_[a].offset_ +=r;
559     }
560   return dim_cache_[a].offset_;
561 }
562
563
564 MAKE_SCHEME_CALLBACK (Grob,point_dimension_callback,2);
565 SCM
566 Grob::point_dimension_callback (SCM , SCM)
567 {
568   return ly_interval2scm (Interval (0,0));
569 }
570
571 bool
572 Grob::empty_b (Axis a)const
573 {
574   return ! (gh_pair_p (dim_cache_[a].dimension_) ||
575             gh_procedure_p (dim_cache_[a].dimension_));
576 }
577
578 /*
579   TODO: add
580
581     Grob *refpoint
582
583   to arguments?
584  */
585 Interval
586 Grob::extent (Grob * refp, Axis a) const
587 {
588   Real x = relative_coordinate (refp, a);
589
590   
591   Dimension_cache * d = (Dimension_cache *)&dim_cache_[a];
592   Interval ext ;   
593   if (gh_pair_p (d->dimension_))
594     ;
595   else if (gh_procedure_p (d->dimension_))
596     {
597       /*
598         FIXME: add doco on types, and should typecheck maybe? 
599        */
600       d->dimension_= gh_call2 (d->dimension_, self_scm (), gh_int2scm (a));
601     }
602   else
603     return ext;
604
605   if (!gh_pair_p (d->dimension_))
606     return ext;
607   
608   ext = ly_scm2interval (d->dimension_);
609
610   SCM extra = get_grob_property (a == X_AXIS
611                                 ? "extra-extent-X"
612                                 : "extra-extent-Y");
613
614   /*
615     signs ?
616    */
617   if (gh_pair_p (extra))
618     {
619       ext[BIGGER] +=  gh_scm2double (ly_cdr (extra));
620       ext[SMALLER] +=   gh_scm2double (ly_car (extra));
621     }
622   
623   extra = get_grob_property (a == X_AXIS
624                                 ? "minimum-extent-X"
625                                 : "minimum-extent-Y");
626   if (gh_pair_p (extra))
627     {
628       ext.unite (Interval (gh_scm2double (ly_car (extra)),
629                            gh_scm2double (ly_cdr (extra))));
630     }
631
632   ext.translate (x);
633   
634   return ext;
635 }
636
637 Grob * 
638 Grob::common_refpoint (Grob const* s, Axis a) const
639 {
640   /*
641     I don't like the quadratic aspect of this code, but I see no other
642     way. The largest chain of parents might be 10 high or so, so
643     it shouldn't be a real issue. */
644   for (Grob const *c = this; c; c = c->dim_cache_[a].parent_l_)
645     for (Grob const * d = s; d; d = d->dim_cache_[a].parent_l_)
646       if (d == c)
647         return (Grob*)d;
648
649   return 0;
650 }
651
652
653 Grob *
654 Grob::common_refpoint (SCM elist, Axis a) const
655 {
656   Grob * common = (Grob*) this;
657   for (; gh_pair_p (elist); elist = ly_cdr (elist))
658     {
659       Grob * s = unsmob_grob (ly_car (elist));
660       if (s)
661         common = common->common_refpoint (s, a);
662     }
663
664   return common;
665 }
666
667 String
668 Grob::name () const
669 {
670   SCM meta = get_grob_property ("meta");
671   SCM nm = scm_assoc (ly_symbol2scm ("name"), meta);
672   nm = (gh_pair_p (nm)) ? ly_cdr (nm) : SCM_EOL;
673   return  gh_symbol_p (nm) ? ly_symbol2string (nm) :  classname (this);  
674 }
675
676 void
677 Grob::add_offset_callback (SCM cb, Axis a)
678 {
679   if (!has_offset_callback_b (cb, a))
680   {
681     dim_cache_[a].offset_callbacks_ = gh_cons (cb, dim_cache_[a].offset_callbacks_);
682     dim_cache_[a].offsets_left_ ++;
683   }
684 }
685
686 bool
687 Grob::has_extent_callback_b (SCM cb, Axis a)const
688 {
689   return scm_equal_p (cb, dim_cache_[a].dimension_) == SCM_BOOL_T;
690 }
691
692
693 bool
694 Grob::has_extent_callback_b (Axis a) const
695 {
696   return gh_procedure_p (dim_cache_[a].dimension_);
697 }
698
699 bool
700 Grob::has_offset_callback_b (SCM cb, Axis a)const
701 {
702   return scm_memq (cb, dim_cache_[a].offset_callbacks_) != SCM_BOOL_F;
703 }
704
705 void
706 Grob::set_extent_callback (SCM dc, Axis a)
707 {
708   dim_cache_[a].dimension_ =dc;
709 }
710
711 void
712 Grob::set_parent (Grob *g, Axis a)
713 {
714   dim_cache_[a].parent_l_ = g;
715 }
716
717 MAKE_SCHEME_CALLBACK (Grob,fixup_refpoint,1);
718 SCM
719 Grob::fixup_refpoint (SCM smob)
720 {
721   Grob *me = unsmob_grob (smob);
722   for (int a = X_AXIS; a < NO_AXES; a ++)
723     {
724       Axis ax = (Axis)a;
725       Grob * parent = me->get_parent (ax);
726
727       if (!parent)
728         continue;
729       
730       if (parent->line_l () != me->line_l () && me->line_l ())
731         {
732           Grob * newparent = parent->find_broken_piece (me->line_l ());
733           me->set_parent (newparent, ax);
734         }
735
736       if (Item * i  = dynamic_cast<Item*> (me))
737         {
738           Item *parenti = dynamic_cast<Item*> (parent);
739
740           if (parenti && i)
741             {
742               Direction  my_dir = i->break_status_dir () ;
743               if (my_dir!= parenti->break_status_dir ())
744                 {
745                   Item *newparent =  parenti->find_prebroken_piece (my_dir);
746                   me->set_parent (newparent, ax);
747                 }
748             }
749         }
750     }
751   return smob;
752 }
753
754
755
756 /****************************************************
757   SMOB funcs
758  ****************************************************/
759
760
761
762 IMPLEMENT_SMOBS (Grob);
763 IMPLEMENT_DEFAULT_EQUAL_P (Grob);
764
765 SCM
766 Grob::mark_smob (SCM ses)
767 {
768   Grob * s = (Grob*) SCM_CELL_WORD_1 (ses);
769   scm_gc_mark (s->immutable_property_alist_);
770   scm_gc_mark (s->mutable_property_alist_);
771
772   for (int a =0 ; a < 2; a++)
773     {
774       scm_gc_mark (s->dim_cache_[a].offset_callbacks_);
775       scm_gc_mark (s->dim_cache_[a].dimension_);
776       Grob *p = s->get_parent (Y_AXIS);
777       if (p)
778         scm_gc_mark (p->self_scm ());
779     }
780   
781   if (s->original_l_)
782     scm_gc_mark (s->original_l_->self_scm ());
783
784   return s->do_derived_mark ();
785 }
786
787 int
788 Grob::print_smob (SCM s, SCM port, scm_print_state *)
789 {
790   Grob *sc = (Grob *) ly_cdr (s);
791      
792   scm_puts ("#<Grob ", port);
793   scm_puts ((char *)sc->name ().ch_C (), port);
794
795   /*
796     don't try to print properties, that is too much hassle.
797    */
798   scm_puts (" >", port);
799   return 1;
800 }
801
802 SCM
803 Grob::do_derived_mark ()
804 {
805   return SCM_EOL;
806 }
807
808
809 SCM
810 ly_set_grob_property (SCM elt, SCM sym, SCM val)
811 {
812   Grob * sc = unsmob_grob (elt);
813
814   if (!gh_symbol_p (sym))
815     {
816       error ("Not a symbol");
817       ly_display_scm (sym);
818       return SCM_UNSPECIFIED;
819     }
820
821   if (sc)
822     {
823       sc->internal_set_grob_property (sym, val);
824     }
825   else
826     {
827       error ("Not a score element");
828       ly_display_scm (elt);
829     }
830
831   return SCM_UNSPECIFIED;
832 }
833
834
835 SCM
836 ly_get_grob_property (SCM elt, SCM sym)
837 {
838   Grob * sc = unsmob_grob (elt);
839   
840   if (sc)
841     {
842       return sc->internal_get_grob_property (sym);
843     }
844   else
845     {
846       error ("Not a score element");
847       ly_display_scm (elt);
848     }
849   return SCM_UNSPECIFIED;
850 }
851
852
853 void
854 Grob::discretionary_processing ()
855 {
856 }
857
858
859
860 SCM
861 spanner_get_bound (SCM slur, SCM dir)
862 {
863   return dynamic_cast<Spanner*> (unsmob_grob (slur))->get_bound (to_dir (dir))->self_scm ();
864 }
865
866
867
868
869 static void
870 init_functions ()
871 {
872   scm_c_define_gsubr ("ly-get-grob-property", 2, 0, 0,
873                       (Scheme_function_unknown)ly_get_grob_property);
874   scm_c_define_gsubr ("ly-set-grob-property", 3, 0, 0,
875                       (Scheme_function_unknown)ly_set_grob_property);
876   scm_c_define_gsubr ("ly-get-spanner-bound", 2 , 0, 0,
877                       (Scheme_function_unknown) spanner_get_bound);
878 }
879
880 bool
881 Grob::has_interface (SCM k)
882 {
883   SCM ifs = get_grob_property ("interfaces");
884
885   return scm_memq (k, ifs) != SCM_BOOL_F;
886 }
887
888 void
889 Grob::set_interface (SCM k)
890 {
891   if (has_interface (k))
892     return ;
893   else
894     {
895       set_grob_property ("interfaces",
896                          gh_cons (k, get_grob_property ("interfaces")));
897     }
898 }
899
900
901 ADD_SCM_INIT_FUNC (scoreelt, init_functions);
902 IMPLEMENT_TYPE_P (Grob, "ly-grob?");