]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/scope.cc
release: 1.3.93
[lilypond.git] / lily / scope.cc
index 7ff133cc285076329bf9b73364fef02fe928c488..ba18c1f44c707362c82048ec295597da4f4e5be4 100644 (file)
@@ -3,48 +3,86 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1998 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 (Dictionary_iter<Identifier*> ai (*this);  ai.ok(); ai++)
-    {
-      if (ai.val()->init_b_ == init_b)
-       {
-         DOUT << ai.key() << "=";
-         ai.val()->print ();
-       }
-    }
-}
 
 Scope::~Scope ()
 {
-  for (Dictionary_iter<Identifier*>     ai (*this); ai.ok(); ai++)
-    {
-      DOUT << "deleting: " << ai.key() << '\n';
-      delete ai.val ();
-    }
+  scm_unprotect_object (id_dict_->self_scm ());
 }
 
 Scope::Scope (Scope const&s)
-  : Dictionary<Identifier*> (s)
 {
-  for (Dictionary_iter<Identifier*> ai (s); ai.ok(); ai++)
-    {
-      (*this)[ai.key ()] = ai.val ()->clone ();
-    }
+  id_dict_ =new Scheme_hash_table (*s.id_dict_);
 }
 
 Scope::Scope ()
-{}
+{
+  id_dict_ = new Scheme_hash_table;
+}
+
+bool
+Scope::elem_b (String s) const
+{
+  return id_dict_->elem_b (ly_symbol2scm (s.ch_C()));
+}
+
 
+bool
+Scope::elem_b (SCM s) const
+{
+  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);
+}
+
+SCM
+Scope::scm_elem (String s) const
+{
+ return scm_elem (ly_symbol2scm (s.ch_C()));
+}
+
+Identifier*
+Scope::elem (String s)const
+{
+  return elem (ly_symbol2scm (s.ch_C()));
+}
+
+void
+Scope::set (String s, SCM id)
+{
+  return id_dict_->set (ly_symbol2scm (s.ch_C()), id);
+}
+
+void
+Scope::set (String s, Identifier * id) 
+{
+  return id_dict_->set (ly_symbol2scm (s.ch_C()), id->self_scm ());
+}
+
+SCM
+Scope::to_alist () const
+{
+  return id_dict_->to_alist ();
+}
+
+bool
+Scope::try_retrieve (SCM k , SCM *v)const
+{
+  return id_dict_->try_retrieve (k, v);
+}