]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/context.cc
* scm/define-context-properties.scm (Module): change definition of
[lilypond.git] / lily / context.cc
index fc7a17ff1f4636c3a30178d69e8a8e8ea3c9cc92..75b378c8f3126926416c119d82e49ff04b09a648 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,16 +21,15 @@ 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_; ly_c_pair_p (p); p = ly_cdr (p))
+  for (SCM p = context_list_; scm_is_pair (p); p = scm_cdr (p))
     {
-      Context *trg =  unsmob_context (ly_car (p));
+      Context *trg =  unsmob_context (scm_car (p));
 
       trg->check_removal ();
       if (trg->is_removable ())
@@ -175,8 +174,8 @@ Context::find_create_context (SCM n, String id,
 SCM
 Context::default_child_context_name () const
 {
-  return ly_c_pair_p (accepts_list_)
-    ? ly_car (scm_last_pair (accepts_list_))
+  return scm_is_pair (accepts_list_)
+    ? scm_car (scm_last_pair (accepts_list_))
     : SCM_EOL;
 }
 
@@ -184,7 +183,7 @@ Context::default_child_context_name () const
 bool
 Context::is_bottom_context () const
 {
-  return !ly_c_symbol_p (default_child_context_name ());
+  return !scm_is_symbol (default_child_context_name ());
 }
 
 Context*
@@ -193,7 +192,7 @@ Context::get_default_interpreter ()
   if (!is_bottom_context ())
     {
       SCM nm = default_child_context_name ();
-      SCM st = get_output_def ()->find_context_def (nm);
+      SCM st = find_context_def (get_output_def (), nm);
 
       Context_def *t = unsmob_context_def (st);
       if (!t)
@@ -245,7 +244,7 @@ bool
 Context::is_alias (SCM sym) const
 {
   if (sym == ly_symbol2scm ("Bottom")
-      && !ly_c_pair_p (accepts_list_))
+      && !scm_is_pair (accepts_list_))
     return true;
   if (sym == unsmob_context_def (definition_)->get_context_name ())
     return true;
@@ -303,15 +302,15 @@ find_context_below (Context * where,
 {
   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->children_contexts ();
-       !found && ly_c_pair_p (s); s = ly_cdr (s))
+       !found && scm_is_pair (s); s = scm_cdr (s))
     {
-      Context * tr = unsmob_context (ly_car (s));
+      Context * tr = unsmob_context (scm_car (s));
 
       found = find_context_below (tr, type, id);
     }
@@ -325,26 +324,32 @@ Context::properties_as_alist () const
   return properties_dict ()->to_alist ();
 }
 
-String
-Context::context_name () const
+SCM
+Context::context_name_symbol () const
 {
   Context_def * td = unsmob_context_def (definition_ );
-  return ly_symbol2string (td->get_context_name ());
+  return td->get_context_name ();
 }
 
+String
+Context::context_name () const
+{
+  return  ly_symbol2string (context_name_symbol ());
+}
 
 Score_context*
 Context::get_score_context () const
 {
-  if (Score_context *sc =dynamic_cast<Score_context*> ((Context*)this))
+  if (Score_context *sc =dynamic_cast<Score_context*> ((Context*) this))
     return sc;
+  
   else if (daddy_context_)
     return daddy_context_->get_score_context ();
   else
     return 0;
 }
 
-Music_output_def *
+Output_def *
 Context::get_output_def () const
 {
   return  (daddy_context_)
@@ -365,7 +370,7 @@ Context::now_mom () const
 int
 Context::print_smob (SCM s, SCM port, scm_print_state *)
 {
-  Context *sc = (Context *) ly_cdr (s);
+  Context *sc = (Context *) SCM_CELL_WORD_1 (s);
      
   scm_puts ("#<", port);
   scm_puts (classname (sc), port);
@@ -412,7 +417,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;
   
@@ -442,3 +447,9 @@ Context::get_parent_context () const
 {
   return daddy_context_;
 }
+
+Translator_group*
+Context::implementation () const
+{
+  return dynamic_cast<Translator_group*> (unsmob_translator (implementation_));
+}