]> git.donarmstrong.com Git - lilypond.git/blob - lily/scope.cc
patch::: 1.3.59.uu2.jcn1
[lilypond.git] / lily / scope.cc
1 /*   
2   scope.cc --  implement Scope
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1998--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include "scope.hh"
11 #include "identifier.hh"
12 #include "scm-hash.hh"
13
14
15 Scope::~Scope ()
16 {
17   delete id_dict_;
18 }
19
20 Scope::Scope (Scope const&s)
21   : id_dict_ (new Scheme_hash_table (*s.id_dict_))
22 {
23   /*
24     cloning not necessary.
25
26   id_dict_ = new Hash_table<Protected_scm,Identifier*> (*s.id_dict_);
27   for (Scope_iter ai (s); ai.ok(); ai++)
28     {
29       id_dict_->elem (ai.scm_key ()) = ai.val ()->clone ();
30     }
31   */
32 }
33
34 Scope::Scope ()
35 {
36   id_dict_ = new Scheme_hash_table;
37 }
38
39 bool
40 Scope::elem_b (String s) const
41 {
42   return id_dict_->elem_b (ly_symbol2scm (s.ch_C()));
43 }
44
45
46 bool
47 Scope::elem_b (SCM s) const
48 {
49   return id_dict_->elem_b (s);
50 }
51 Identifier*
52 Scope::elem (SCM s)const
53 {
54   return unsmob_identifier  (id_dict_->get (s));
55 }
56 Identifier*
57 Scope::elem (String s)const
58 {
59   return elem (ly_symbol2scm (s.ch_C()));
60 }
61
62 void
63 Scope::set (String s, Identifier * id) 
64 {
65   return id_dict_->set (ly_symbol2scm (s.ch_C()), smobify (id));
66 }
67
68 SCM
69 Scope::to_alist () const
70 {
71   return id_dict_->to_alist ();
72 }