]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/scope.cc
release: 1.3.114
[lilypond.git] / lily / scope.cc
index 88056b9b8b7e41f852ba06d129c3d3890410d281..5fd04e4257c5e02f36ae54fd6d21f79dfeceb385 100644 (file)
 
 Scope::~Scope ()
 {
-  delete id_dict_;
+  scm_unprotect_object (id_dict_->self_scm ());
 }
 
 Scope::Scope (Scope const&s)
-  : id_dict_ (new Scheme_hash_table (*s.id_dict_))
 {
-  /*
-    cloning not necessary.
-
-  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 ();
-    }
-  */
+  id_dict_ =new Scheme_hash_table (*s.id_dict_);
 }
 
 Scope::Scope ()
@@ -53,17 +44,35 @@ 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->smobify_self());
+  return id_dict_->set (ly_symbol2scm (s.ch_C()), id->self_scm ());
 }
 
 SCM
@@ -71,3 +80,10 @@ 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);
+}
+