]> git.donarmstrong.com Git - lilypond.git/blob - lily/scope.cc
release: 1.3.93
[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   scm_unprotect_object (id_dict_->self_scm ());
18 }
19
20 Scope::Scope (Scope const&s)
21 {
22   id_dict_ =new Scheme_hash_table (*s.id_dict_);
23 }
24
25 Scope::Scope ()
26 {
27   id_dict_ = new Scheme_hash_table;
28 }
29
30 bool
31 Scope::elem_b (String s) const
32 {
33   return id_dict_->elem_b (ly_symbol2scm (s.ch_C()));
34 }
35
36
37 bool
38 Scope::elem_b (SCM s) const
39 {
40   return id_dict_->elem_b (s);
41 }
42 Identifier*
43 Scope::elem (SCM s)const
44 {
45   return unsmob_identifier  (id_dict_->get (s));
46 }
47
48 SCM
49 Scope::scm_elem (SCM s)const
50 {
51   return id_dict_->get (s);
52 }
53
54 SCM
55 Scope::scm_elem (String s) const
56 {
57  return scm_elem (ly_symbol2scm (s.ch_C()));
58 }
59
60 Identifier*
61 Scope::elem (String s)const
62 {
63   return elem (ly_symbol2scm (s.ch_C()));
64 }
65
66 void
67 Scope::set (String s, SCM id)
68 {
69   return id_dict_->set (ly_symbol2scm (s.ch_C()), id);
70 }
71
72 void
73 Scope::set (String s, Identifier * id) 
74 {
75   return id_dict_->set (ly_symbol2scm (s.ch_C()), id->self_scm ());
76 }
77
78 SCM
79 Scope::to_alist () const
80 {
81   return id_dict_->to_alist ();
82 }
83
84 bool
85 Scope::try_retrieve (SCM k , SCM *v)const
86 {
87   return id_dict_->try_retrieve (k, v);
88 }