]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/scope.cc
release: 1.1.24
[lilypond.git] / lily / scope.cc
index 7ff133cc285076329bf9b73364fef02fe928c488..39e91b3065d23539eb61b6daa40a5623ba3156a5 100644 (file)
@@ -16,7 +16,7 @@ void
 Scope::print () const
 {
   bool init_b = false;         // ugh
-  for (Dictionary_iter<Identifier*> ai (*this);  ai.ok(); ai++)
+  for (Scope_iter ai (*this);  ai.ok(); ai++)
     {
       if (ai.val()->init_b_ == init_b)
        {
@@ -28,7 +28,7 @@ Scope::print () const
 
 Scope::~Scope ()
 {
-  for (Dictionary_iter<Identifier*>     ai (*this); ai.ok(); ai++)
+  for (Scope_iter       ai (*this); ai.ok(); ai++)
     {
       DOUT << "deleting: " << ai.key() << '\n';
       delete ai.val ();
@@ -36,15 +36,64 @@ Scope::~Scope ()
 }
 
 Scope::Scope (Scope const&s)
-  : Dictionary<Identifier*> (s)
+  : Hash_table<Protected_scm,Identifier*> (s)
 {
-  for (Dictionary_iter<Identifier*> ai (s); ai.ok(); ai++)
+  for (Scope_iter ai (s); ai.ok(); ai++)
     {
-      (*this)[ai.key ()] = ai.val ()->clone ();
+      (*this)[ai.scm_key ()] = ai.val ()->clone ();
     }
 }
 
+unsigned int scm_hash (Protected_scm s)
+{
+  return scm_ihashv (s, ~1u);
+}
+
 Scope::Scope ()
-{}
+{
+  hash_func_ = scm_hash;
+}
+
+bool
+Scope::elem_b (String s) const
+{
+  return elem_b (ly_symbol (s.ch_C()));
+}
+
+
+Identifier *&
+Scope::elem (String s) 
+{
+  return elem (ly_symbol (s.ch_C()));
+}
+
 
+Scope_iter::Scope_iter (Scope const &s)
+  : Hash_table_iter<Protected_scm,Identifier*>(s)
+{
+}
 
+String
+Scope_iter::key () const
+{
+  SCM s= Hash_table_iter<Protected_scm,Identifier*>::key ();
+  return symbol_to_string (s);
+}
+
+bool
+Scope::elem_b (SCM s) const
+{
+  return Hash_table<Protected_scm,Identifier*> ::elem_b (s);
+}
+
+Identifier* &
+Scope::elem (SCM s)
+{
+  return Hash_table<Protected_scm,Identifier*> ::elem (s);
+}
+
+SCM
+Scope_iter::scm_key () const
+{
+  return Hash_table_iter<Protected_scm,Identifier*>::key ();
+}