source file of the GNU LilyPond music typesetter
- (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1998--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "scope.hh"
-#include "dictionary-iter.hh"
-#include "debug.hh"
#include "identifier.hh"
+#include "scm-hash.hh"
-void
-Scope::print () const
-{
- bool init_b = false; // ugh
- for (Scope_iter ai (*this); ai.ok(); ai++)
- {
- if (ai.val()->init_b_ == init_b)
- {
- DEBUG_OUT << ai.key() << "=";
- ai.val()->print ();
- }
- }
-}
Scope::~Scope ()
{
- for (Scope_iter ai (*this); ai.ok(); ai++)
- {
- DEBUG_OUT << "deleting: " << ai.key() << '\n';
- delete ai.val ();
- }
+ scm_unprotect_object (id_dict_->self_scm ());
}
Scope::Scope (Scope const&s)
- : Hash_table<Protected_scm,Identifier*> (s)
{
- for (Scope_iter ai (s); ai.ok(); ai++)
- {
- (*this)[ai.scm_key ()] = ai.val ()->clone ();
- }
+ id_dict_ =new Scheme_hash_table (*s.id_dict_);
}
-unsigned int ly_pscm_hash (Protected_scm s)
-{
- return ly_scm_hash (s);
-}
-
-
Scope::Scope ()
{
- hash_func_ = ly_pscm_hash;
+ id_dict_ = new Scheme_hash_table;
}
bool
Scope::elem_b (String s) const
{
- return elem_b (ly_symbol2scm (s.ch_C()));
+ return id_dict_->elem_b (ly_symbol2scm (s.ch_C()));
}
-Identifier *&
-Scope::elem (String s)
+bool
+Scope::elem_b (SCM s) const
{
- return elem (ly_symbol2scm (s.ch_C()));
+ return id_dict_->elem_b (s);
+}
+Identifier*
+Scope::elem (SCM s)const
+{
+ return unsmob_identifier (id_dict_->get (s));
}
+SCM
+Scope::scm_elem (SCM s)const
+{
+ return id_dict_->get (s);
+}
-Scope_iter::Scope_iter (Scope const &s)
- : Hash_table_iter<Protected_scm,Identifier*>(s)
+SCM
+Scope::scm_elem (String s) const
{
+ return scm_elem (ly_symbol2scm (s.ch_C()));
}
-String
-Scope_iter::key () const
+Identifier*
+Scope::elem (String s)const
{
- SCM s= Hash_table_iter<Protected_scm,Identifier*>::key ();
- return ly_symbol2string (s);
+ return elem (ly_symbol2scm (s.ch_C()));
}
-bool
-Scope::elem_b (SCM s) const
+void
+Scope::set (String s, SCM id)
{
- return Hash_table<Protected_scm,Identifier*> ::elem_b (s);
+ return id_dict_->set (ly_symbol2scm (s.ch_C()), id);
}
-Identifier* &
-Scope::elem (SCM s)
+void
+Scope::set (String s, Identifier * id)
{
- return Hash_table<Protected_scm,Identifier*> ::elem (s);
+ return id_dict_->set (ly_symbol2scm (s.ch_C()), id->self_scm ());
}
SCM
-Scope_iter::scm_key () const
+Scope::to_alist () const
+{
+ return id_dict_->to_alist ();
+}
+
+bool
+Scope::try_retrieve (SCM k , SCM *v)const
{
- return Hash_table_iter<Protected_scm,Identifier*>::key ();
+ return id_dict_->try_retrieve (k, v);
}
+