]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/context-def.cc
* lily/simple-spacer.cc (add_columns): use binary search for
[lilypond.git] / lily / context-def.cc
index ba9f5fec1756f34c3ff018b3e113e9915232311b..82b32ef4b7774b090fd44f84c3231cdf6c8b38b6 100644 (file)
@@ -10,8 +10,8 @@
    a single list of context modifications?  */
 
 #include "context-def.hh"
+
 #include "engraver.hh"
-#include "lily-proto.hh"
 #include "output-def.hh"
 #include "performer.hh"
 #include "score-context.hh"
@@ -92,15 +92,15 @@ Context_def::mark_smob (SCM smob)
 void
 Context_def::add_context_mod (SCM mod)
 {
-  SCM tag = ly_car (mod);
+  SCM tag = scm_car (mod);
   if (ly_symbol2scm ("description") == tag)
     {
-      description_ = ly_cadr (mod);
+      description_ = scm_cadr (mod);
       return;
     }
 
-  SCM sym = ly_cadr (mod);
-  if (ly_c_string_p (sym))
+  SCM sym = scm_cadr (mod);
+  if (scm_is_string (sym))
     sym = scm_string_to_symbol (sym);
   
   if (ly_symbol2scm ("consists") == tag
@@ -143,10 +143,10 @@ Context_def::get_accepted (SCM user_mod) const
 {
   SCM mods = scm_reverse_x (scm_list_copy (accept_mods_), user_mod);
   SCM acc = SCM_EOL;
-  for (SCM s = mods; ly_c_pair_p (s); s = ly_cdr (s))
+  for (SCM s = mods; scm_is_pair (s); s = scm_cdr (s))
     {
-      SCM tag = ly_caar (s);
-      SCM sym = ly_cadar (s);
+      SCM tag = scm_caar (s);
+      SCM sym = scm_cadar (s);
       if (tag == ly_symbol2scm ("accepts"))
        acc = scm_cons (sym, acc);
       else if (tag == ly_symbol2scm ("denies"))
@@ -158,14 +158,14 @@ Context_def::get_accepted (SCM user_mod) const
 Link_array<Context_def>
 Context_def::path_to_acceptable_context (SCM type_sym, Output_def *odef) const
 {
-  assert (ly_c_symbol_p (type_sym));
+  assert (scm_is_symbol (type_sym));
   
   SCM accepted = get_accepted (SCM_EOL);
 
   Link_array<Context_def> accepteds;
-  for (SCM s = accepted; ly_c_pair_p (s); s = ly_cdr (s))
+  for (SCM s = accepted; scm_is_pair (s); s = scm_cdr (s))
     if (Context_def *t = unsmob_context_def (find_context_def (odef,
-                                                              ly_car (s))))
+                                                              scm_car (s))))
       accepteds.push (t);
 
   Link_array<Context_def> best_result;
@@ -208,12 +208,12 @@ Context_def::get_translator_names (SCM user_mod) const
 
   SCM mods = scm_reverse_x (scm_list_copy (translator_mods_), user_mod);
   
-  for (SCM s = mods; ly_c_pair_p (s); s = ly_cdr (s))
+  for (SCM s = mods; scm_is_pair (s); s = scm_cdr (s))
     {
-      SCM tag = ly_caar (s);
-      SCM arg = ly_cadar (s);
+      SCM tag = scm_caar (s);
+      SCM arg = scm_cadar (s);
 
-      if (ly_c_string_p (arg))
+      if (scm_is_string (arg))
        arg = scm_string_to_symbol (arg);
       
       if (ly_symbol2scm ("consists") == tag)
@@ -230,12 +230,12 @@ Context_def::get_translator_names (SCM user_mod) const
 SCM
 filter_performers (SCM ell)
 {
-  for (SCM *tail = &ell; ly_c_pair_p (*tail); tail = SCM_CDRLOC (*tail))
+  for (SCM *tail = &ell; scm_is_pair (*tail); tail = SCM_CDRLOC (*tail))
     {
-      if (dynamic_cast<Performer*> (unsmob_translator (ly_car (*tail))))
+      if (dynamic_cast<Performer*> (unsmob_translator (scm_car (*tail))))
        {
-         *tail = ly_cdr (*tail);
-         if (!ly_c_pair_p (*tail))
+         *tail = scm_cdr (*tail);
+         if (!scm_is_pair (*tail))
            break ;
        }
     }
@@ -246,12 +246,12 @@ SCM
 filter_engravers (SCM ell)
 {
   SCM *tail = &ell;  
-  for (; ly_c_pair_p (*tail) ; tail = SCM_CDRLOC (*tail))
+  for (; scm_is_pair (*tail) ; tail = SCM_CDRLOC (*tail))
     {
-      if (dynamic_cast<Engraver*> (unsmob_translator (ly_car (*tail))))
+      if (dynamic_cast<Engraver*> (unsmob_translator (scm_car (*tail))))
        {
-         *tail = ly_cdr (*tail);
-         if (!ly_c_pair_p (*tail))
+         *tail = scm_cdr (*tail);
+         if (!scm_is_pair (*tail))
            break ;
        }
     }
@@ -260,27 +260,28 @@ filter_engravers (SCM ell)
 
 
 Context *
-Context_def::instantiate (SCM ops)
+Context_def::instantiate (SCM ops, Object_key const *key)
 {
   Context *tg =  0;
 
   if (context_name_ == ly_symbol2scm ("Score"))
-    tg = new Score_context ();
+    tg = new Score_context (key);
   else
-    tg = new Context ();
+    tg = new Context (key);
 
   tg->definition_ = self_scm ();
 
   SCM trans_names = get_translator_names (ops); 
 
-  Translator *g = get_translator (translator_group_type_);
-  g = g->clone ();
+  Translator_group *g = dynamic_cast<Translator_group*>
+    (get_translator (translator_group_type_));
+  g = dynamic_cast<Translator_group*> (g->clone ());
 
   SCM trans_list = SCM_EOL;
   
-  for (SCM s = trans_names; ly_c_pair_p (s) ; s = ly_cdr (s))
+  for (SCM s = trans_names; scm_is_pair (s) ; s = scm_cdr (s))
     {
-      Translator *t = get_translator (ly_car (s));
+      Translator *t = get_translator (scm_car (s));
       if (!t)
        warning (_f ("can't find: `%s'", s));
       else
@@ -291,9 +292,10 @@ Context_def::instantiate (SCM ops)
          if (tr->must_be_last ())
            {
              SCM cons = scm_cons (str, SCM_EOL);
-             trans_list = ly_c_pair_p (trans_list)
-               ? scm_set_cdr_x (scm_last_pair (trans_list), cons)
-               : cons;
+             if (scm_is_pair (trans_list))
+               scm_set_cdr_x (scm_last_pair (trans_list), cons);
+             else
+               trans_list= cons;
            }
          else
            {
@@ -318,15 +320,15 @@ Context_def::instantiate (SCM ops)
   
   scm_gc_unprotect_object (g->self_scm ());
   
-  tg->accepts_list_ = get_accepted  (ops);
-  
+  tg->accepts_list_ = get_accepted (ops);
+
   return tg;
 }
 
 SCM
 Context_def::clone_scm () const
 {
-  Context_def * t = new Context_def (*this);
+  Context_def *t = new Context_def (*this);
   SCM x = t->self_scm ();
   scm_gc_unprotect_object (x);
   return x;
@@ -335,7 +337,7 @@ Context_def::clone_scm () const
 SCM
 Context_def::make_scm ()
 {
-  Context_deft = new Context_def;
+  Context_def *t = new Context_def;
   SCM x = t->self_scm ();
   scm_gc_unprotect_object (x);
   return x;
@@ -363,7 +365,7 @@ Context_def::to_alist () const
   ell = scm_cons (scm_cons (ly_symbol2scm ("context-name"), context_name_),
                  ell);
 
-  if (ly_c_symbol_p (translator_group_type_))
+  if (scm_is_symbol (translator_group_type_))
     ell = scm_cons (scm_cons (ly_symbol2scm ("group-type"),
                              translator_group_type_), ell);    
   return ell;