]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/scope.cc
release: 1.5.4
[lilypond.git] / lily / scope.cc
index e2923fcb80bfa68ca954be7c6a01235d483ffb5f..f578433a800d1e39ec5d8e71a96e6adfde95a3b3 100644 (file)
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1998--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1998--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
 
 #include "scope.hh"
-#include "dictionary-iter.hh"
-#include "debug.hh"
-#include "identifier.hh"
-#include "dictionary.hh"
-#include "protected-scm.hh"
+#include "string.hh"
+#include "scm-hash.hh"
 
-void
-Scope::print () const
-{
-#ifndef NPRINT
-  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 ();
-       }
-    }
-#endif
-}
-
-Scope::~Scope ()
-{
-  for (Scope_iter ai (*this); ai.ok(); ai++)
-    {
-      DEBUG_OUT << "deleting: " << ai.key() << '\n';
-      delete ai.val ();
-    }
-  delete id_dict_;
-}
-
-Scope::Scope (Scope const&s)
-{
-  id_dict_ = new Hash_table<Protected_scm,Identifier*> (*s.id_dict_);
-  for (Scope_iter ai (s); ai.ok(); ai++)
-    {
-      id_dict_->elem (ai.scm_key ()) = ai.val ()->clone ();
-    }
-}
-
-unsigned int ly_pscm_hash (Protected_scm s)
-{
-  return ly_scm_hash (s);
-}
-
-
-Scope::Scope ()
+Scope::Scope (Scheme_hash_table * st)
 {
-  id_dict_ = new Hash_table<Protected_scm,Identifier*>;
-  id_dict_->hash_func_ = ly_pscm_hash;
+  assert (st);
+  id_dict_ =st;
 }
 
 bool
 Scope::elem_b (String s) const
 {
-  return id_dict_->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 id_dict_->elem (ly_symbol2scm (s.ch_C()));
+  return id_dict_->elem_b (s);
 }
 
 
-Scope_iter::Scope_iter (Scope const &s)
+SCM
+Scope::scm_elem (SCM s)const
 {
-  iter_ = new Hash_table_iter<Protected_scm,Identifier*>(*s.id_dict_);
+  return id_dict_->get (s);
 }
 
-String
-Scope_iter::key () const
+SCM
+Scope::scm_elem (String s) const
 {
-  SCM s= iter_->key ();
-  return ly_symbol2string (s);
+ return scm_elem (ly_symbol2scm (s.ch_C ()));
 }
 
-bool
-Scope::elem_b (SCM s) const
-{
-  return id_dict_->elem_b (s);
-}
 
-Identifier* &
-Scope::elem (SCM s)
+void
+Scope::set (String s, SCM id)
 {
-  return id_dict_->elem (s);
+  return id_dict_->set (ly_symbol2scm (s.ch_C ()), id);
 }
 
 SCM
-Scope_iter::scm_key () const
+Scope::to_alist () const
 {
-  return iter_->key ();
+  return id_dict_->to_alist ();
 }
 
 bool
-Scope_iter::ok () const
-{
-  return iter_->ok();
-}
-
-void
-Scope_iter::operator ++(int)
+Scope::try_retrieve (SCM k , SCM *v)const
 {
-  (*iter_) ++;
+  return id_dict_->try_retrieve (k, v);
 }
 
-Identifier*
-Scope_iter::val ()const
-{
-  return iter_->val ();
-}