]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/context.cc
release commit
[lilypond.git] / lily / context.cc
index d891aac163880ce72c92e3cef74edf9fa90be975..6b539519e1629af16abbb30e92071835a17ba6e0 100644 (file)
@@ -11,7 +11,7 @@
 #include "context-def.hh"
 #include "context.hh"
 #include "warn.hh"
-#include "music-output-def.hh"
+#include "output-def.hh"
 #include "scm-hash.hh"
 #include "main.hh"
 #include "ly-smobs.icc"
@@ -21,14 +21,13 @@ bool
 Context::is_removable () const
 {
   return context_list_ == SCM_EOL && ! iterator_count_ &&
-         !dynamic_cast<Score_context const*> (this)
-    ;
+         !dynamic_cast<Score_context const*> (this);
 }
 
 void
 Context::check_removal ()
 {
-  for (SCM p = context_list_; gh_pair_p (p); p = gh_cdr (p))
+  for (SCM p = context_list_; scm_is_pair (p); p = ly_cdr (p))
     {
       Context *trg =  unsmob_context (ly_car (p));
 
@@ -56,8 +55,8 @@ void
 Context::add_context (Context*t)
 {
   SCM ts = t->self_scm ();
-  context_list_ = gh_append2 (context_list_,
-                             gh_cons (ts, SCM_EOL));
+  context_list_ = ly_append2 (context_list_,
+                             scm_cons (ts, SCM_EOL));
   
   t->daddy_context_ = this;
   if (!t->init_)
@@ -95,22 +94,6 @@ Context::Context ()
   scm_gc_unprotect_object (properties_scm_);
 }
 
-Context *
-Context::find_context_below (SCM n, String id)
-{
-  if ((is_alias (n) && (id_string_ == id || id.is_empty ())))
-    return this;
-
-  Context* r = 0;
-  for (SCM p = context_list_; !r && gh_pair_p (p); p = ly_cdr (p))
-    {
-      Context *  t = unsmob_context (ly_car (p));
-      
-      r = dynamic_cast<Context*> (t)->find_context_below (n, id);
-    }
-
-  return r;
-}
 
 
 Context*
@@ -125,7 +108,7 @@ Context::find_create_context (SCM n, String id,
     return get_score_context ()->find_create_context (n, id, operations);
     
   
-  Context * existing = find_context_below (n,id);
+  Context * existing = find_context_below (this, n,id);
   if (existing)
     return existing;
 
@@ -189,10 +172,10 @@ Context::find_create_context (SCM n, String id,
   none.
 */
 SCM
-default_child_context_name (Context const *tg)
+Context::default_child_context_name () const
 {
-  return gh_pair_p (tg->accepts_list_)
-    ? ly_car (scm_last_pair (tg->accepts_list_))
+  return scm_is_pair (accepts_list_)
+    ? ly_car (scm_last_pair (accepts_list_))
     : SCM_EOL;
 }
 
@@ -200,7 +183,7 @@ default_child_context_name (Context const *tg)
 bool
 Context::is_bottom_context () const
 {
-  return !gh_symbol_p (default_child_context_name (this));
+  return !scm_is_symbol (default_child_context_name ());
 }
 
 Context*
@@ -208,8 +191,8 @@ Context::get_default_interpreter ()
 {
   if (!is_bottom_context ())
     {
-      SCM nm = default_child_context_name (this);
-      SCM st = get_output_def ()->find_context_def (nm);
+      SCM nm = default_child_context_name ();
+      SCM st = find_context_def (get_output_def (), nm);
 
       Context_def *t = unsmob_context_def (st);
       if (!t)
@@ -261,7 +244,7 @@ bool
 Context::is_alias (SCM sym) const
 {
   if (sym == ly_symbol2scm ("Bottom")
-      && !gh_pair_p (accepts_list_))
+      && !scm_is_pair (accepts_list_))
     return true;
   if (sym == unsmob_context_def (definition_)->get_context_name ())
     return true;
@@ -315,19 +298,19 @@ Context::remove_context (Context*trans)
  */
 Context *
 find_context_below (Context * where,
-                   String type, String id)
+                   SCM type, String id)
 {
-  if (where->is_alias (ly_symbol2scm (type.to_str0 ())))
+  if (where->is_alias (type))
     {
-      if (id == "" || where->id_string_ == id)
+      if (id == "" || where->id_string () == id)
        return where;
     }
   
   Context * found = 0;
-  for (SCM s = where->context_list_;
-       !found && gh_pair_p (s); s = gh_cdr (s))
+  for (SCM s = where->children_contexts ();
+       !found && scm_is_pair (s); s = ly_cdr (s))
     {
-      Context * tr = unsmob_context (gh_car (s));
+      Context * tr = unsmob_context (ly_car (s));
 
       found = find_context_below (tr, type, id);
     }
@@ -360,7 +343,7 @@ Context::get_score_context () const
     return 0;
 }
 
-Music_output_def *
+Output_def *
 Context::get_output_def () const
 {
   return  (daddy_context_)
@@ -428,7 +411,7 @@ IMPLEMENT_TYPE_P (Context,"ly:context?");
 bool
 Context::try_music (Music* m)
 {
-  Translator*  t = unsmob_translator (implementation_);
+  Translator*  t = implementation ();
   if (!t)
     return false;
   
@@ -452,3 +435,15 @@ Context::get_global_context () const
   programming_error ("No Global context!");
   return 0;
 }
+
+Context*
+Context::get_parent_context () const
+{
+  return daddy_context_;
+}
+
+Translator_group*
+Context::implementation () const
+{
+  return dynamic_cast<Translator_group*> (unsmob_translator (implementation_));
+}