]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/context-selector.cc
* lily/context-selector.cc (set_tweaks): New function.
[lilypond.git] / lily / context-selector.cc
index 6bfc0c9e844c6effc91f9343510e0d84048772ca..2a90b8d3d8629654e70e10c2d701ff05377c5dcc 100644 (file)
@@ -15,31 +15,27 @@ Scheme_hash_table *Context_selector::contexts_ = 0;
 void
 Context_selector::register_context (Context *context)
 {
-  if (!contexts_)
-    contexts_ = new Scheme_hash_table ();
   int count = 0;
   if (Context *first = retrieve_context (identify_context (context, 0)))
     {
-      count = robust_scm2int (first->get_property ("max"), 0);
+      count = robust_scm2int (first->get_property ("tweakCount"), 0);
       count++;
       SCM s = scm_int2num (count);
-      first->set_property ("max", s);
-      context->set_property ("count", s);
+      first->set_property ("tweakCount", s);
+      context->set_property ("tweakRank", s);
   }
-  /* FIXME: must alway set count, for get_property () not to segfault.  */
-  context->set_property ("count", scm_int2num (count));
-  contexts_->set (identify_context (context, count), context->self_scm ());
+  /* FIXME: must alway set rank, for get_property () not to segfault.  */
+  context->set_property ("tweakRank", scm_int2num (count));
+  store_context (identify_context (context, count), context);
 }
 
 SCM
 Context_selector::identify_context (Context *context, int count)
 {
   /* TODO: start time, parent-context-at-start */
-  return ly_symbol2scm ((context->context_name ()
-                        + ","
-                        + context->id_string ()
-                        + ","
-                        + to_string (count)).to_str0 ());
+  return scm_list_3 (scm_makfrom0str (context->context_name ().to_str0 ()),
+                    scm_makfrom0str (context->id_string ().to_str0 ()),
+                    scm_int2num (count));
 }
 
 SCM
@@ -47,11 +43,26 @@ Context_selector::identify_context (Context *context)
 {
   return
     identify_context (context,
-                     robust_scm2int (context->get_property ("count"), 0));
+                     robust_scm2int (context->get_property ("tweakRank"), 0));
+}
+
+void
+Context_selector::store_context (SCM context_id, Context *context)
+{
+  contexts_->set (ly_to_symbol (context_id), context->self_scm ());
 }
 
 Context *
-Context_selector::retrieve_context (SCM key)
+Context_selector::retrieve_context (SCM context_id)
 {
-  return unsmob_context (contexts_->get (key));
+  return unsmob_context (contexts_->get (ly_to_symbol (context_id)));
 }
+
+void
+Context_selector::set_tweaks (SCM tweaks)
+{
+  (void) tweaks;
+  contexts_ = new Scheme_hash_table ();
+  //tweaks_ = tweaks;
+}
+