]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/output-def-scheme.cc
Merge remote-tracking branch 'origin/translation'
[lilypond.git] / lily / output-def-scheme.cc
index 73a8048bff0e5cc41978d8ad2cb7181bfa2a9a77..91a3adfb2df55a5cb3688439cb1e84e1f6cbc5fe 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--2014 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"
@@ -80,6 +91,8 @@ LY_DEFINE (ly_output_description, "ly:output-description",
           1, 0, 0, (SCM output_def),
           "Return the description of translators in @var{output-def}.")
 {
+  LY_ASSERT_SMOB (Output_def, output_def, 1);
+
   Output_def *id = unsmob_output_def (output_def);
 
   SCM al = ly_module_2_alist (id->scope_);
@@ -94,6 +107,31 @@ LY_DEFINE (ly_output_description, "ly:output-description",
   return ell;
 }
 
+LY_DEFINE (ly_output_find_context_def, "ly:output-find-context-def",
+          1, 1, 0, (SCM output_def, SCM context_name),
+          "Return an alist of all context defs (matching @var{context-name}"
+          "if given) in @var{output-def}.")
+{
+  LY_ASSERT_SMOB (Output_def, output_def, 1);
+  if (!SCM_UNBNDP (context_name))
+    LY_ASSERT_TYPE (ly_is_symbol, context_name, 2);
+
+  Output_def *id = unsmob_output_def (output_def);
+
+  SCM al = ly_module_2_alist (id->scope_);
+  SCM ell = SCM_EOL;
+  for (SCM s = al; scm_is_pair (s); s = scm_cdr (s))
+    {
+      SCM p = scm_car (s);
+      Context_def *td = unsmob_context_def (scm_cdr (p));
+      if (td && scm_is_eq (scm_car (p), td->get_context_name ())
+         && (SCM_UNBNDP (context_name) || td->is_alias (context_name)))
+       ell = scm_cons (p, ell);
+    }
+  return ell;
+}
+
+
 LY_DEFINE (ly_output_def_p, "ly:output-def?",
           1, 0, 0, (SCM def),
           "Is @var{def} an output definition?")