X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Foutput-def-scheme.cc;h=0b85c133a8cf6cd32b1522fd7e590592ab7e0dd6;hb=47db9a3883d726ca53e2133a3b2298f78dd6a32e;hp=73a8048bff0e5cc41978d8ad2cb7181bfa2a9a77;hpb=794dcbdb52faf4292036cd1b0270a956cf4316a3;p=lilypond.git diff --git a/lily/output-def-scheme.cc b/lily/output-def-scheme.cc index 73a8048bff..0b85c133a8 100644 --- a/lily/output-def-scheme.cc +++ b/lily/output-def-scheme.cc @@ -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--2015 Han-Wen Nienhuys - (c) 2005--2009 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 + 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 . */ #include "output-def.hh" @@ -21,7 +32,7 @@ LY_DEFINE (ly_output_def_lookup, "ly:output-def-lookup", " @var{val} or @code{'()} if @var{val} is undefined.") { LY_ASSERT_SMOB (Output_def, def, 1); - Output_def *op = unsmob_output_def (def); + Output_def *op = Output_def::unsmob (def); LY_ASSERT_TYPE (ly_is_symbol, sym, 2); SCM answer = op->lookup_variable (sym); @@ -41,7 +52,7 @@ LY_DEFINE (ly_output_def_scope, "ly:output-def-scope", "Return the variable scope inside @var{def}.") { LY_ASSERT_SMOB (Output_def, def, 1); - Output_def *op = unsmob_output_def (def); + Output_def *op = Output_def::unsmob (def); return op->scope_; } @@ -50,7 +61,7 @@ LY_DEFINE (ly_output_def_parent, "ly:output-def-parent", "Return the parent output definition of @var{def}.") { LY_ASSERT_SMOB (Output_def, def, 1); - Output_def *op = unsmob_output_def (def); + Output_def *op = Output_def::unsmob (def); return op->parent_ ? op->parent_->self_scm () : SCM_EOL; } @@ -59,7 +70,7 @@ LY_DEFINE (ly_output_def_set_variable_x, "ly:output-def-set-variable!", "Set an output definition @var{def} variable @var{sym} to @var{val}.") { LY_ASSERT_SMOB (Output_def, def, 1); - Output_def *output_def = unsmob_output_def (def); + Output_def *output_def = Output_def::unsmob (def); LY_ASSERT_TYPE (ly_is_symbol, sym, 2); output_def->set_variable (sym, val); return SCM_UNSPECIFIED; @@ -70,7 +81,7 @@ LY_DEFINE (ly_output_def_clone, "ly:output-def-clone", "Clone output definition @var{def}.") { LY_ASSERT_SMOB (Output_def, def, 1); - Output_def *op = unsmob_output_def (def); + Output_def *op = Output_def::unsmob (def); Output_def *clone = op->clone (); return clone->unprotect (); @@ -80,13 +91,15 @@ LY_DEFINE (ly_output_description, "ly:output-description", 1, 0, 0, (SCM output_def), "Return the description of translators in @var{output-def}.") { - Output_def *id = unsmob_output_def (output_def); + LY_ASSERT_SMOB (Output_def, output_def, 1); + + Output_def *id = Output_def::unsmob (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)) { - Context_def *td = unsmob_context_def (scm_cdar (s)); + Context_def *td = Context_def::unsmob (scm_cdar (s)); SCM key = scm_caar (s); if (td && key == td->get_context_name ()) ell = scm_cons (scm_cons (key, td->to_alist ()), ell); @@ -94,19 +107,39 @@ LY_DEFINE (ly_output_description, "ly:output-description", return ell; } -LY_DEFINE (ly_output_def_p, "ly:output-def?", - 1, 0, 0, (SCM def), - "Is @var{def} an output definition?") +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}.") { - return ly_bool2scm (unsmob_output_def (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 = Output_def::unsmob (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 = Context_def::unsmob (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; } +const char +Output_def::type_p_name_[] = "ly:output-def?"; + LY_DEFINE (ly_paper_outputscale, "ly:paper-outputscale", 1, 0, 0, (SCM def), "Return the output-scale for output definition @var{def}.") { LY_ASSERT_SMOB (Output_def, def, 1); - Output_def *b = unsmob_output_def (def); + Output_def *b = Output_def::unsmob (def); return scm_from_double (output_scale (b)); } @@ -127,7 +160,7 @@ LY_DEFINE (ly_paper_get_font, "ly:paper-get-font", { LY_ASSERT_SMOB (Output_def, def, 1); - Output_def *paper = unsmob_output_def (def); + Output_def *paper = Output_def::unsmob (def); Font_metric *fm = select_font (paper, chain); return fm->self_scm (); } @@ -138,7 +171,7 @@ LY_DEFINE (ly_paper_get_number, "ly:paper-get-number", " @var{def} as a double.") { LY_ASSERT_SMOB (Output_def, def, 1); - Output_def *layout = unsmob_output_def (def); + Output_def *layout = Output_def::unsmob (def); return scm_from_double (layout->get_dimension (sym)); } @@ -148,7 +181,7 @@ LY_DEFINE (ly_paper_fonts, "ly:paper-fonts", " @var{def} (e.g., @code{\\paper}).") { LY_ASSERT_SMOB (Output_def, def, 1); - Output_def *b = unsmob_output_def (def); + Output_def *b = Output_def::unsmob (def); SCM tab1 = b->lookup_variable (ly_symbol2scm ("scaled-fonts")); SCM tab2 = b->lookup_variable (ly_symbol2scm ("pango-fonts")); @@ -177,7 +210,7 @@ LY_DEFINE (ly_paper_fonts, "ly:paper-fonts", { SCM entry = scm_car (s); - Font_metric *fm = unsmob_metrics (entry); + Font_metric *fm = Font_metric::unsmob (entry); if (dynamic_cast (fm) || dynamic_cast (fm))