]> git.donarmstrong.com Git - lilypond.git/commitdiff
Allow spanner bounds to be set in scheme.
authorNeil Puttock <n.puttock@gmail.com>
Mon, 26 Jul 2010 22:22:08 +0000 (23:22 +0100)
committerNeil Puttock <n.puttock@gmail.com>
Mon, 26 Jul 2010 22:22:08 +0000 (23:22 +0100)
* lily/spanner-scheme (ly_spanner_bound/ly_spanner_set_bound_x):

  only return spanner bound if it exists, otherwise return '(): if we want
  to set bounds, we may need to test whether a bound already exists

  add new exported function ly:spanner-set-bound!

lily/spanner-scheme.cc

index d733996430778378bf2c3a9d136ca65b85f527ff..60fe032cda6ce23315756a871ccd1f7f2580cff1 100644 (file)
@@ -28,8 +28,21 @@ LY_DEFINE (ly_spanner_bound, "ly:spanner-bound",
 {
   LY_ASSERT_TYPE (unsmob_spanner, spanner, 1);
   LY_ASSERT_TYPE (is_direction, dir, 2);
-  
-  return unsmob_spanner (spanner)->get_bound (to_dir (dir))->self_scm ();
+  Item *bound = unsmob_spanner (spanner)->get_bound (to_dir (dir));
+  return bound ? bound->self_scm () : SCM_EOL;
+}
+
+LY_DEFINE (ly_spanner_set_bound_x, "ly:spanner-set-bound!",
+          3, 0, 0, (SCM spanner, SCM dir, SCM item),
+          "Set grob @var{item} as bound in direction @var{dir} for"
+          " @var{spanner}.")
+{
+  LY_ASSERT_TYPE (unsmob_spanner, spanner, 1);
+  LY_ASSERT_TYPE (is_direction, dir, 2);
+  LY_ASSERT_TYPE (unsmob_item, item, 3);
+
+  unsmob_spanner (spanner)->set_bound (to_dir (dir), unsmob_item (item));
+  return SCM_UNSPECIFIED;
 }
 
 /* TODO: maybe we should return a vector -- random access is more