]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tweak-registration.cc
* lily/sequential-music.cc: remove file.
[lilypond.git] / lily / tweak-registration.cc
index 7f929b0a1058b3c5f4996bf2de87a2cb89f8f586..4984922f2b272dc80658e84c5e32cd0bdcacea6a 100644 (file)
@@ -7,15 +7,13 @@
 
 */
 
+#include "tweak-registration.hh"
 
 #include "object-key-undumper.hh"
-#include "tweak-registration.hh"
-#include "object-key.hh"
 #include "grob.hh"
 
 #include "ly-smobs.icc"
 
-
 void
 Tweak_registry::clear ()
 {
@@ -25,7 +23,7 @@ Tweak_registry::clear ()
 }
 
 void
-Tweak_registry::insert_tweak (SCM tweak)
+Tweak_registry::insert_tweak_from_file (SCM tweak)
 {
   SCM skey = scm_car (tweak);
 
@@ -41,6 +39,20 @@ Tweak_registry::insert_tweak (SCM tweak)
   tweaks_[key] = scm_cons (scm_cdr (tweak), tweaks_[key]);
 }
 
+
+void
+Tweak_registry::insert_grob_tweak (Grob *g, SCM tweak)
+{
+  Object_key const * key =  g->get_key ();
+  if (tweaks_.find (key) == tweaks_.end())
+    {
+      tweaks_[key] = SCM_EOL;
+    }
+
+  tweaks_[key] = scm_cons (tweak, tweaks_[key]);
+}
+
+
 SCM
 Tweak_registry::get_tweaks (Grob *g) 
 {
@@ -75,7 +87,7 @@ Tweak_registry::list_tweaks ()
       const Object_key *  key = (*i).first;
       for (SCM t = (*i).second; scm_is_pair (t); t = scm_cdr (t))
        {
-         retval = scm_cons (key->self_scm(), scm_car (t));
+         retval = scm_cons (scm_cons (key->self_scm(), scm_car (t)), retval);
        }
     }
 
@@ -95,13 +107,16 @@ Tweak_registry::mark_smob (SCM smob)
       scm_gc_mark ((*i).second);
     }
 
-  return me->undumper_ ? me->undumper_->self_scm() : SCM_EOL;
+  if (me->undumper_)
+    scm_gc_mark (me->undumper_->self_scm());
+                     
+  return SCM_EOL;
 }
 
-
 int
 Tweak_registry::print_smob (SCM smob, SCM port, scm_print_state*)
 {
+  (void) smob;                 // smother warning.
   scm_puts ("#<Tweak_registry>", port); 
   return 1;
 }
@@ -121,38 +136,5 @@ Tweak_registry  * global_registry_;
 void
 init_global_tweak_registry()
 {
-  //  global_registry_ = new Tweak_registry();
-}
-
-ADD_SCM_INIT_FUNC(init_global_tweak_registry,init_global_tweak_registry);
-
-LY_DEFINE(ly_clear_tweak_registry, "ly:clear-tweak-registry",
-         0,0,0,(),
-         "Clear global tweak registry"
-         )
-{
-  global_registry_->clear ();
-  return SCM_UNSPECIFIED;
-}
-
-
-LY_DEFINE(ly_tweak_read_keys, "ly:tweak-read-keys",
-         1,0,0,(SCM keys),
-         "Read keys"
-         )
-{
-  global_registry_->undumper ()->parse_contents (keys); 
-  return SCM_UNSPECIFIED;
-}
-
-LY_DEFINE(ly_tweak_read_tweaks, "ly:tweak-read-tweaks",
-         1,0,0,(SCM tweaks),
-         "Read  tweaks"
-         )
-{
-  for (SCM s = tweaks; scm_is_pair (s); s = scm_cdr (s))
-    {
-      global_registry_->insert_tweak (scm_car (s));
-    }
-  return SCM_UNSPECIFIED;
+  global_registry_ = new Tweak_registry();
 }