]> git.donarmstrong.com Git - lilypond.git/commitdiff
Don't use SCM_UNSPECIFIED as a magic return value for callbacks.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 4 Jan 2007 19:26:08 +0000 (20:26 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 4 Jan 2007 19:26:08 +0000 (20:26 +0100)
lily/beam-concave.cc
lily/include/tie.hh
lily/melody-spanner.cc
lily/semi-tie-column.cc
lily/semi-tie.cc
lily/tie-column.cc
lily/tie.cc

index a37005c17ca35e57d9a59e4cc9f2b73e5aebc9e3..2b88e0807ac55a13af98475e17f29028188560e3 100644 (file)
@@ -106,7 +106,7 @@ Beam::calc_concaveness (SCM smob)
     }
 
   if (stems.size () <= 2)
-    return SCM_UNSPECIFIED;
+    return scm_from_int (0);
 
   vector<int> close_positions;
   vector<int> far_positions;
index 35d3d9596cb54767190fa8c4ec2ef7e85c530836..b68d73d24ba8229d0c6ce58f54f95bf8bcb029d0 100644 (file)
@@ -25,10 +25,10 @@ public:
   static int get_column_rank (Grob *, Direction);
   static int get_position (Grob *);
   static Direction get_default_dir (Grob *);  
-  static void set_control_points (Grob *, Grob *,
-                                 Tie_configuration const&,
-                                 Tie_details const&);
-  static void set_default_control_points (Grob *);
+  static SCM get_control_points (Grob *, Grob *,
+                                Tie_configuration const&,
+                                Tie_details const&);
+  static SCM get_default_control_points (Grob *);
   DECLARE_SCHEME_CALLBACK (print, (SCM));
   DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
index d4901f2c9b1a12a9958132fdc7b133e0af3ef928..103a5c642744658ee6ad84d114605ebafc1ab69b 100644 (file)
@@ -27,7 +27,7 @@ Melody_spanner::calc_neutral_stem_direction (SCM smob)
   Grob *stem = unsmob_grob (smob);
   Grob *me =  unsmob_grob (stem->get_object ("melody-spanner"));
   if (!me || !me->is_live ())
-    return SCM_UNSPECIFIED;
+    return scm_from_int (DOWN);
   
   extract_grob_set (me, "stems", stems);
 
@@ -41,6 +41,7 @@ Melody_spanner::calc_neutral_stem_direction (SCM smob)
         &&  !dirs[next_nonneutral])
     next_nonneutral++;
 
+  SCM retval = SCM_EOL;
   while (last_nonneutral == VPOS || last_nonneutral < dirs.size () - 1) 
     {
       Direction d1 = CENTER;
@@ -61,8 +62,12 @@ Melody_spanner::calc_neutral_stem_direction (SCM smob)
        total = to_dir (me->get_property ("neutral-direction"));
       
       for (vsize i = last_nonneutral + 1; i <  next_nonneutral; i++)
-       stems[i]->set_property ("neutral-direction", scm_from_int (total));
-
+       {
+         if (stems[i] == stem)
+           retval = scm_from_int (total);
+         else
+           stems[i]->set_property ("neutral-direction", scm_from_int (total));
+       }
 
       last_nonneutral = next_nonneutral;
       while (last_nonneutral < dirs.size ()
@@ -76,8 +81,7 @@ Melody_spanner::calc_neutral_stem_direction (SCM smob)
        next_nonneutral++;
     }
 
-  me->suicide ();
-  return SCM_UNSPECIFIED;
+  return retval;
 }
 
 void
index 7a02ac578b6b3ba14e57fd6c203f5f1378cd9b09..7b3ff58f89e3d77ea92ef79e5fa6fbe1797015c9 100644 (file)
@@ -58,8 +58,10 @@ Semi_tie_column::calc_positioning_done (SCM smob)
   Ties_configuration base = problem.generate_optimal_chord_configuration ();
   for (vsize i = 0; i < lv_ties.size(); i++)
     {
-      Tie::set_control_points (lv_ties[i], problem.common_x_refpoint (), base[i],
-                              problem.details_);
+      SCM cp = Tie::get_control_points (lv_ties[i], problem.common_x_refpoint (), base[i],
+                                       problem.details_);
+
+      lv_ties[i]->set_property ("control-points", cp);
       set_grob_direction (lv_ties[i], base[i].dir_);
     }
 
index 77b266e6c43aeea6704dcaeccd5b3a4738a3d12c..96d4a07219ac88906d15f596b51b2711de9a2bab 100644 (file)
@@ -43,8 +43,8 @@ Semi_tie::calc_control_points (SCM smob)
       programming_error ("lv tie without Semi_tie_column. Killing lv tie."); 
       me->suicide (); 
     }
-  
-  return SCM_UNSPECIFIED;
+
+  return me->get_property_data ("control-points");
 }
 
 int
index 39c51fefc36ae0731c7d91a830bead7bf97a1258..2121d318ce0edc54108aa612467db9c2662dabb4 100644 (file)
@@ -100,9 +100,11 @@ Tie_column::calc_positioning_done (SCM smob)
 
   for (vsize i = 0; i < base.size(); i++)
     {
-      Tie::set_control_points (ties[i], problem.common_x_refpoint (),
-                              base[i],
-                              problem.details_);
+      SCM cp = Tie::get_control_points (ties[i], problem.common_x_refpoint (),
+                                       base[i],
+                                       problem.details_);
+
+      ties[i]->set_property ("control-points", cp);
       set_grob_direction (ties[i],
                          base[i].dir_);
 
index 50519bc4f55ab4ae5da1f4e25a59e593d2c4d7a3..1e94638f3981e5ad3551d94d2df8dc1704f15fa0 100644 (file)
@@ -152,16 +152,16 @@ Tie::calc_direction (SCM smob)
     {
       /* trigger positioning. */
       (void) yparent->get_property ("positioning-done");
+
+      return me->get_property_data ("direction");
     }
   else
-    set_grob_direction (me, Tie::get_default_dir (me));
-
-  return SCM_UNSPECIFIED;
+    return scm_from_int (Tie::get_default_dir (me));
 }
 
 
-void
-Tie::set_default_control_points (Grob *me_grob)
+SCM
+Tie::get_default_control_points (Grob *me_grob)
 {
   Spanner *me = dynamic_cast<Spanner*> (me_grob);
   Grob *common  = me;
@@ -174,17 +174,18 @@ Tie::set_default_control_points (Grob *me_grob)
   spec.has_manual_dir_ = true;
   spec.manual_dir_ = get_grob_direction (me);
 
-  if (me->is_live ())
-    {
-      Tie_configuration conf
-       = problem.find_optimal_tie_configuration (spec);
+  if (!me->is_live ())
+    return SCM_EOL;
+
+  Tie_configuration conf
+    = problem.find_optimal_tie_configuration (spec);
   
-      set_control_points (me, problem.common_x_refpoint (),
-                         conf, problem.details_);
-    }
+  return get_control_points (me, problem.common_x_refpoint (),
+                            conf, problem.details_);
 }
-void
-Tie::set_control_points (Grob *me,
+
+SCM
+Tie::get_control_points (Grob *me,
                         Grob *common,
                         Tie_configuration const &conf,
                         Tie_details const &details
@@ -200,9 +201,10 @@ Tie::set_control_points (Grob *me,
        programming_error ("Insane offset");
       controls = scm_cons (ly_offset2scm (b.control_[i]), controls);
     }
-  me->set_property ("control-points", controls);
+  return controls;
 }
 
+
 MAKE_SCHEME_CALLBACK(Tie, calc_control_points, 1);
 SCM
 Tie::calc_control_points (SCM smob)
@@ -222,12 +224,13 @@ Tie::calc_control_points (SCM smob)
       (void) yparent->get_property ("positioning-done");
     }
 
-  if (!scm_is_pair (me->get_property_data ("control-points")))
+  SCM cp = me->get_property_data ("control-points");
+  if (!scm_is_pair (cp))
     {
-      set_default_control_points (me);
+      cp = get_default_control_points (me);
     }
 
-  return SCM_UNSPECIFIED;
+  return cp;
 }
 
 /*