]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/break-substitution.cc
* lily/modified-font-metric.cc (text_dimension): try
[lilypond.git] / lily / break-substitution.cc
index f19cece1d5b9e4bb94bd847250283f9b8286250a..29298fe15aab2ed123b02c92a8b8eb6eb5c60d42 100644 (file)
@@ -1,10 +1,8 @@
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdio>
+#include <cstdlib>
 
-#include  "grob.hh"
 #include "item.hh"
-#include  "spanner.hh"
-#include  "system.hh"
+#include "system.hh"
 
 static SCM break_criterion; 
 void
@@ -19,7 +17,7 @@ set_break_subsititution (SCM criterion)
 SCM
 substitute_grob (Grob *sc)
 {
-  if (SCM_INUMP (break_criterion))
+  if (scm_is_integer (break_criterion))
     {
       Item * i = dynamic_cast<Item*> (sc);
       Direction d = to_dir (break_criterion);
@@ -91,7 +89,7 @@ do_break_substitution (SCM src)
  
   if (unsmob_grob (src))
     return substitute_grob (unsmob_grob (src));
-  else if (is_vector (src))
+  else if (ly_c_vector_p (src))
     {
       int len = SCM_VECTOR_LENGTH (src);
       SCM nv = scm_c_make_vector (len, SCM_UNDEFINED);
@@ -102,16 +100,16 @@ do_break_substitution (SCM src)
                            do_break_substitution (scm_vector_ref (src, si))); 
        }
     }
-  else if (is_pair (src)) 
+  else if (scm_is_pair (src)) 
     {
       /*
        UGH! breaks on circular lists.
       */
-      SCM newcar = do_break_substitution (ly_car (src));
-      SCM oldcdr = ly_cdr (src);
+      SCM newcar = do_break_substitution (scm_car (src));
+      SCM oldcdr = scm_cdr (src);
       
       if (newcar == SCM_UNDEFINED
-         && (is_pair (oldcdr) || oldcdr == SCM_EOL))
+         && (scm_is_pair (oldcdr) || oldcdr == SCM_EOL))
        {
          /*
            This is tail-recursion, ie. 
@@ -142,9 +140,9 @@ substitute_grob_list (SCM grob_list)
   SCM l = SCM_EOL;
   SCM * tail = &l;
 
-  for (SCM s = grob_list; is_pair (s); s =  ly_cdr (s))
+  for (SCM s = grob_list; scm_is_pair (s); s =  scm_cdr (s))
     {
-      SCM n= substitute_grob (unsmob_grob (ly_car (s)));
+      SCM n = substitute_grob (unsmob_grob (scm_car (s)));
 
       if (n != SCM_UNDEFINED)
        {
@@ -230,7 +228,7 @@ spanner_system_range (Spanner* sp)
 Slice
 item_system_range (Item* it)
 {
-  if (System*st= it->get_system ())
+  if (System*st = it->get_system ())
     return Slice (st->rank_, st->rank_);
 
   Slice sr;
@@ -241,7 +239,7 @@ item_system_range (Item* it)
       if (bi && bi->get_system ())
        sr.add_point (bi->get_system ()->rank_);
     }
-  while (flip (&d)!=LEFT);
+  while (flip (&d)!= LEFT);
   
   return sr;
 }
@@ -287,7 +285,7 @@ struct Substitution_entry
   }
   Substitution_entry ()
   {
-    grob_ =0;
+    grob_ = 0;
     left_ = right_ = -2;
   }
   
@@ -350,9 +348,9 @@ Spanner::fast_fubstitute_grob_list (SCM sym,
   
   int sp_index = len;
   int it_index = 0;
-  for (SCM s = grob_list; is_pair (s); s = ly_cdr (s))
+  for (SCM s = grob_list; scm_is_pair (s); s = scm_cdr (s))
     {
-      Grob * g = unsmob_grob (ly_car (s));
+      Grob * g = unsmob_grob (scm_car (s));
 
       Slice sr = grob_system_range (g);
       sr.intersect (system_range);
@@ -409,7 +407,7 @@ Spanner::fast_fubstitute_grob_list (SCM sym,
      for (int k = 0; k < 2;k++)
        for (int j = (*arrs[k])[i][LEFT]; j <= (*arrs[k])[i][RIGHT]; j++)
          {
-           SCM subs =substitute_grob (vec[j].grob_);
+           SCM subs = substitute_grob (vec[j].grob_);
            if (subs!= SCM_UNDEFINED)
              {
                *tail = scm_cons (subs, SCM_EOL);
@@ -426,7 +424,7 @@ Spanner::fast_fubstitute_grob_list (SCM sym,
              sp_indices[i].length () , len -sp_index);
              
       {
-       SCM l1 =substitute_grob_list (grob_list);
+       SCM l1 = substitute_grob_list (grob_list);
        assert (scm_ilength (l1) == scm_ilength (newval));
       }
 #endif
@@ -463,14 +461,14 @@ Spanner::fast_fubstitute_grob_list (SCM sym,
 SCM
 substitute_mutable_property_alist (SCM alist)
 {
-  SCM grob_list_p = ly_scheme_function ("grob-list?");
+  SCM grob_list_p = ly_lily_module_constant ("grob-list?");
 
   SCM l = SCM_EOL;
   SCM *tail = &l;
-  for (SCM s = alist; is_pair (s); s = ly_cdr (s))
+  for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s))
     {
-      SCM sym = ly_caar (s);
-      SCM val = ly_cdar (s);
+      SCM sym = scm_caar (s);
+      SCM val = scm_cdar (s);
       SCM type = scm_object_property (sym, ly_symbol2scm ("backend-type?"));
 
       if (type == grob_list_p)
@@ -478,10 +476,17 @@ substitute_mutable_property_alist (SCM alist)
       else
        val = do_break_substitution (val);
 
-      *tail = scm_cons (scm_cons (sym, val), SCM_EOL);
-      tail = SCM_CDRLOC (*tail);
-    }
 
+      if (val != SCM_UNDEFINED)
+       {
+         /*
+           for ly:grob? properties, SCM_UNDEFINED could leak out
+           through ly:grob-property
+          */
+         *tail = scm_cons (scm_cons (sym, val), SCM_EOL);
+         tail = SCM_CDRLOC (*tail);
+       }
+    }
   return l;
 }
 
@@ -494,7 +499,7 @@ Spanner::substitute_one_mutable_property (SCM sym,
   Spanner*s = this;
   
   bool fast_done = false;
-  SCM grob_list_p = ly_scheme_function ("grob-list?");
+  SCM grob_list_p = ly_lily_module_constant ("grob-list?");
   if (type == grob_list_p)
     fast_done = s->fast_fubstitute_grob_list (sym, val);