]> git.donarmstrong.com Git - lilypond.git/blob - lily/grob-info.cc
(protect_smob): experiment: O(1) GC (un)protection.
[lilypond.git] / lily / grob-info.cc
1 /*
2   grob-info.cc -- implement Grob_info
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "grob-info.hh"
10 #include "grob.hh"
11 #include "music.hh"
12 #include "translator-group.hh"
13 #include "context.hh"
14 #include "spanner.hh"
15 #include "item.hh"
16
17
18 Grob_info::Grob_info (Translator *t, Grob *g)
19 {
20   origin_trans_ = t;
21   grob_ = g;
22 }
23
24 Grob_info::Grob_info ()
25 {
26   grob_ = 0;
27   origin_trans_ = 0;
28 }
29
30 Music *
31 Grob_info::music_cause ()
32 {
33   SCM cause = grob_->get_property ("cause");
34   return unsmob_music (cause);
35 }
36
37 Link_array<Context>
38 Grob_info::origin_contexts (Translator *end) const
39 {
40   Context *t = origin_trans_->context ();
41   Link_array<Context> r;
42   do
43     {
44       r.push (t);
45       t = t->get_parent_context ();
46     }
47   while (t && t != end->context ());
48
49   return r;
50 }
51
52
53 Context*
54 Grob_info::context () const
55 {
56   return origin_trans_->context ();
57 }
58
59 Spanner*
60 Grob_info::spanner () const
61 {
62   return dynamic_cast<Spanner*> (grob_);
63 }
64
65 Item*
66 Grob_info::item () const
67 {
68   return dynamic_cast<Item*> (grob_);
69 }