]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/grob-scheme.cc
Run grand-replace for 2010.
[lilypond.git] / lily / grob-scheme.cc
index 4d6ed8f69b1524236b81b8f32291382cf75846db..bfe79da7c0bdf43c563d8e9b45c9c2f2e05bfe79 100644 (file)
@@ -1,10 +1,21 @@
 /*
-  grob-scheme.cc -- Scheme entry points for the grob datatype
+  This file is part of LilyPond, the GNU music typesetter.
 
-  source file of the GNU LilyPond music typesetter
-
-  (c) 1998--2008 Jan Nieuwenhuizen <janneke@gnu.org>
+  Copyright (C) 1998--2010 Jan Nieuwenhuizen <janneke@gnu.org>
   Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+  LilyPond is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  LilyPond is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "warn.hh"             // error ()
@@ -17,7 +28,8 @@
 
 LY_DEFINE (ly_grob_property_data, "ly:grob-property-data",
           2, 0, 0, (SCM grob, SCM sym),
-          "Retrieve @var{sym} for @var{grob} but don't process callbacks.")
+          "Return the value for property @var{sym} of @var{grob},"
+          " but do not process callbacks.")
 {
   Grob *sc = unsmob_grob (grob);
 
@@ -44,23 +56,43 @@ LY_DEFINE (ly_grob_set_property_x, "ly:grob-set-property!",
   return SCM_UNSPECIFIED;
 }
 
+LY_DEFINE (ly_grob_set_nested_property_x, "ly:grob-set-nested-property!",
+          3, 0, 0, (SCM grob, SCM symlist, SCM val),
+          "Set nested property @var{symlist} in grob @var{grob} to value @var{val}.")
+{
+  Grob *sc = unsmob_grob (grob);
+
+  LY_ASSERT_SMOB (Grob, grob, 1);
+
+  bool type_ok = ly_cheap_is_list (symlist);
+
+  if (type_ok)
+    for (SCM s = symlist; scm_is_pair (s) && type_ok; s = scm_cdr (s))
+      type_ok &= ly_is_symbol (scm_car (s));
+
+  SCM_ASSERT_TYPE (type_ok, symlist, SCM_ARG2, __FUNCTION__, "list of symbols");
+
+  set_nested_property (sc, symlist, val);
+  return SCM_UNSPECIFIED;
+}
+
+
 LY_DEFINE (ly_grob_property, "ly:grob-property",
-          2, 1, 0, (SCM grob, SCM sym, SCM deflt),
-          "Return the value of a value in grob@tie{}@var{g} of property"
-          " @var{sym}.  It returns @code{'()} (end-of-list) or"
-          " @var{deflt} (if specified) if @var{sym} is undefined"
-          " in@tie{}@var{g}.")
+          2, 1, 0, (SCM grob, SCM sym, SCM val),
+          "Return the value for property @var{sym} of @var{grob}."
+          "  If no value is found, return @var{val} or @code{'()}"
+          " if @var{val} is not specified.")
 {
   Grob *sc = unsmob_grob (grob);
-   
+
   LY_ASSERT_SMOB (Grob, grob, 1);
   LY_ASSERT_TYPE (ly_is_symbol, sym, 2);
-  if (deflt == SCM_UNDEFINED)
-    deflt = SCM_EOL;
+  if (val == SCM_UNDEFINED)
+    val = SCM_EOL;
 
   SCM retval = sc->internal_get_property (sym);
   if (retval == SCM_EOL)
-    retval = deflt;
+    retval = val;
   
   return retval;
 }