]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/output-def-scheme.cc
Imported Upstream version 2.14.2
[lilypond.git] / lily / output-def-scheme.cc
index f3b7a1cf0a1b36543072d5a5a5331a1353612b22..d1ee31083792d90ac3958e71e87b0bfd8d1b0e13 100644 (file)
@@ -1,9 +1,20 @@
 /*
-  output-def-scheme.cc -- implement Output_def bindings
+  This file is part of LilyPond, the GNU music typesetter.
 
-  source file of the GNU LilyPond music typesetter
+  Copyright (C) 2005--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
-  (c) 2005--2009 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 "output-def.hh"
 #include "lily-parser.hh"
 
 LY_DEFINE (ly_output_def_lookup, "ly:output-def-lookup",
-          2, 1, 0, (SCM pap, SCM sym, SCM def),
-          "Look up @var{sym} in the @var{pap} output definition"
-          " (e.g., @code{\\paper}).  Return the value or @var{def}"
-          " (which defaults to @code{'()}) if undefined.")
+          2, 1, 0, (SCM def, SCM sym, SCM val),
+          "Return the value of @var{sym} in output definition @var{def}"
+          " (e.g., @code{\\paper}).  If no value is found, return"
+          " @var{val} or @code{'()} if @var{val} is undefined.")
 {
-  LY_ASSERT_SMOB (Output_def, pap, 1);
-  Output_def *op = unsmob_output_def (pap);
+  LY_ASSERT_SMOB (Output_def, def, 1);
+  Output_def *op = unsmob_output_def (def);
   LY_ASSERT_TYPE (ly_is_symbol, sym, 2);
 
   SCM answer = op->lookup_variable (sym);
   if (answer == SCM_UNDEFINED)
     {
-      if (def == SCM_UNDEFINED)
-       def = SCM_EOL;
+      if (val == SCM_UNDEFINED)
+       val = SCM_EOL;
 
-      answer = def;
+      answer = val;
     }
 
   return answer;
@@ -38,7 +49,7 @@ LY_DEFINE (ly_output_def_lookup, "ly:output-def-lookup",
 
 LY_DEFINE (ly_output_def_scope, "ly:output-def-scope",
           1, 0, 0, (SCM def),
-          "Get the variable scope inside @var{def}.")
+          "Return the variable scope inside @var{def}.")
 {
   LY_ASSERT_SMOB (Output_def, def, 1);
   Output_def *op = unsmob_output_def (def);
@@ -47,7 +58,7 @@ LY_DEFINE (ly_output_def_scope, "ly:output-def-scope",
 
 LY_DEFINE (ly_output_def_parent, "ly:output-def-parent",
           1, 0, 0, (SCM def),
-          "Get the parent output definition of @var{def}.")
+          "Return the parent output definition of @var{def}.")
 {
   LY_ASSERT_SMOB (Output_def, def, 1);
   Output_def *op = unsmob_output_def (def);
@@ -96,17 +107,17 @@ LY_DEFINE (ly_output_description, "ly:output-description",
 
 LY_DEFINE (ly_output_def_p, "ly:output-def?",
           1, 0, 0, (SCM def),
-          "Is @var{def} a layout definition?")
+          "Is @var{def} an output definition?")
 {
   return ly_bool2scm (unsmob_output_def (def));
 }
 
 LY_DEFINE (ly_paper_outputscale, "ly:paper-outputscale",
-          1, 0, 0, (SCM bp),
-          "Get output-scale for @var{bp}.")
+          1, 0, 0, (SCM def),
+          "Return the output-scale for output definition @var{def}.")
 {
-  LY_ASSERT_SMOB (Output_def, bp, 1);
-  Output_def *b = unsmob_output_def (bp);
+  LY_ASSERT_SMOB (Output_def, def, 1);
+  Output_def *b = unsmob_output_def (def);
   return scm_from_double (output_scale (b));
 }
 
@@ -118,35 +129,37 @@ LY_DEFINE (ly_make_output_def, "ly:make-output-def",
   return bp->unprotect ();
 }
 
-LY_DEFINE (ly_paper_get_font, "ly:paper-get-font", 2, 0, 0,
-          (SCM paper_smob, SCM chain),
-          "Return a font metric satisfying the font-qualifiers"
-          " in the alist chain @var{chain}.  (An alist chain is a"
-          " list of alists, containing grob properties.)")
+LY_DEFINE (ly_paper_get_font, "ly:paper-get-font",
+          2, 0, 0, (SCM def, SCM chain),
+          "Find a font metric in output definition @var{def} satisfying"
+          " the font-qualifiers in alist chain @var{chain}, and return"
+          " it.  (An alist chain is a list of alists, containing grob"
+          " properties.)")
 {
-  LY_ASSERT_SMOB (Output_def, paper_smob, 1);
+  LY_ASSERT_SMOB (Output_def, def, 1);
 
-  Output_def *paper = unsmob_output_def (paper_smob);
+  Output_def *paper = unsmob_output_def (def);
   Font_metric *fm = select_font (paper, chain);
   return fm->self_scm ();
 }
 
-LY_DEFINE (ly_paper_get_number, "ly:paper-get-number", 2, 0, 0,
-          (SCM layout_smob, SCM name),
-          "Return the layout variable @var{name}.")
+LY_DEFINE (ly_paper_get_number, "ly:paper-get-number",
+          2, 0, 0, (SCM def, SCM sym),
+          "Return the value of variable @var{sym} in output definition"
+          " @var{def} as a double.")
 {
-  LY_ASSERT_SMOB (Output_def, layout_smob, 1);
-  Output_def *layout = unsmob_output_def (layout_smob);
-  return scm_from_double (layout->get_dimension (name));
+  LY_ASSERT_SMOB (Output_def, def, 1);
+  Output_def *layout = unsmob_output_def (def);
+  return scm_from_double (layout->get_dimension (sym));
 }
 
 LY_DEFINE (ly_paper_fonts, "ly:paper-fonts",
-          1, 0, 0,
-          (SCM bp),
-          "Return fonts from the @code{\\paper} block @var{bp}.")
+          1, 0, 0, (SCM def),
+          "Return a list containing the fonts from output definition"
+          " @var{def} (e.g., @code{\\paper}).")
 {
-  LY_ASSERT_SMOB (Output_def, bp, 1);
-  Output_def *b = unsmob_output_def (bp);
+  LY_ASSERT_SMOB (Output_def, def, 1);
+  Output_def *b = unsmob_output_def (def);
 
   SCM tab1 = b->lookup_variable (ly_symbol2scm ("scaled-fonts"));
   SCM tab2 = b->lookup_variable (ly_symbol2scm ("pango-fonts"));