X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Foutput-def-scheme.cc;h=a2e1e345134bae7d56926e29ff98136c1ff817bd;hb=c838ee8dfd128890fe06537e3e81f47a0e725267;hp=6f1982cc982a7c247e06512c9177723f09b16b25;hpb=bc95f4434f760d41191341ab4508b2064eb19025;p=lilypond.git diff --git a/lily/output-def-scheme.cc b/lily/output-def-scheme.cc index 6f1982cc98..a2e1e34513 100644 --- a/lily/output-def-scheme.cc +++ b/lily/output-def-scheme.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2005--2010 Han-Wen Nienhuys + Copyright (C) 2005--2012 Han-Wen Nienhuys LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -91,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_); @@ -105,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?")