Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(822)

Side by Side Diff: lily/output-def-scheme.cc

Issue 549480043: Run scripts/auxiliar/fixcc.py (Closed)
Patch Set: Created 5 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lily/output-def.cc ('k') | lily/output-property-engraver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 This file is part of LilyPond, the GNU music typesetter. 2 This file is part of LilyPond, the GNU music typesetter.
3 3
4 Copyright (C) 2005--2020 Han-Wen Nienhuys <hanwen@xs4all.nl> 4 Copyright (C) 2005--2020 Han-Wen Nienhuys <hanwen@xs4all.nl>
5 5
6 LilyPond is free software: you can redistribute it and/or modify 6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or 8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 LilyPond is distributed in the hope that it will be useful, 11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>. 17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
18 */ 18 */
19 19
20 #include "output-def.hh" 20 #include "output-def.hh"
21 21
22 #include "pango-font.hh" 22 #include "pango-font.hh"
23 #include "modified-font-metric.hh" 23 #include "modified-font-metric.hh"
24 #include "ly-module.hh" 24 #include "ly-module.hh"
25 #include "context-def.hh" 25 #include "context-def.hh"
26 #include "lily-parser.hh" 26 #include "lily-parser.hh"
27 27
28 LY_DEFINE (ly_output_def_lookup, "ly:output-def-lookup", 28 LY_DEFINE (ly_output_def_lookup, "ly:output-def-lookup",
29 » 2, 1, 0, (SCM def, SCM sym, SCM val), 29 2, 1, 0, (SCM def, SCM sym, SCM val),
30 » "Return the value of @var{sym} in output definition @var{def}" 30 "Return the value of @var{sym} in output definition @var{def}"
31 » " (e.g., @code{\\paper}). If no value is found, return" 31 " (e.g., @code{\\paper}). If no value is found, return"
32 » " @var{val} or @code{'()} if @var{val} is undefined.") 32 " @var{val} or @code{'()} if @var{val} is undefined.")
33 { 33 {
34 LY_ASSERT_SMOB (Output_def, def, 1); 34 LY_ASSERT_SMOB (Output_def, def, 1);
35 Output_def *op = unsmob<Output_def> (def); 35 Output_def *op = unsmob<Output_def> (def);
36 LY_ASSERT_TYPE (ly_is_symbol, sym, 2); 36 LY_ASSERT_TYPE (ly_is_symbol, sym, 2);
37 37
38 SCM answer = op->lookup_variable (sym); 38 SCM answer = op->lookup_variable (sym);
39 if (SCM_UNBNDP (answer)) 39 if (SCM_UNBNDP (answer))
40 { 40 {
41 if (SCM_UNBNDP (val)) 41 if (SCM_UNBNDP (val))
42 » val = SCM_EOL; 42 val = SCM_EOL;
43 43
44 answer = val; 44 answer = val;
45 } 45 }
46 46
47 return answer; 47 return answer;
48 } 48 }
49 49
50 LY_DEFINE (ly_output_def_scope, "ly:output-def-scope", 50 LY_DEFINE (ly_output_def_scope, "ly:output-def-scope",
51 » 1, 0, 0, (SCM def), 51 1, 0, 0, (SCM def),
52 » "Return the variable scope inside @var{def}.") 52 "Return the variable scope inside @var{def}.")
53 { 53 {
54 LY_ASSERT_SMOB (Output_def, def, 1); 54 LY_ASSERT_SMOB (Output_def, def, 1);
55 Output_def *op = unsmob<Output_def> (def); 55 Output_def *op = unsmob<Output_def> (def);
56 return op->scope_; 56 return op->scope_;
57 } 57 }
58 58
59 LY_DEFINE (ly_output_def_parent, "ly:output-def-parent", 59 LY_DEFINE (ly_output_def_parent, "ly:output-def-parent",
60 » 1, 0, 0, (SCM def), 60 1, 0, 0, (SCM def),
61 » "Return the parent output definition of @var{def}.") 61 "Return the parent output definition of @var{def}.")
62 { 62 {
63 LY_ASSERT_SMOB (Output_def, def, 1); 63 LY_ASSERT_SMOB (Output_def, def, 1);
64 Output_def *op = unsmob<Output_def> (def); 64 Output_def *op = unsmob<Output_def> (def);
65 return op->parent_ ? op->parent_->self_scm () : SCM_EOL; 65 return op->parent_ ? op->parent_->self_scm () : SCM_EOL;
66 } 66 }
67 67
68 LY_DEFINE (ly_output_def_set_variable_x, "ly:output-def-set-variable!", 68 LY_DEFINE (ly_output_def_set_variable_x, "ly:output-def-set-variable!",
69 3, 0, 0, (SCM def, SCM sym, SCM val), 69 3, 0, 0, (SCM def, SCM sym, SCM val),
70 "Set an output definition @var{def} variable @var{sym} to @var{val}." ) 70 "Set an output definition @var{def} variable @var{sym} to @var{val}." )
71 { 71 {
72 LY_ASSERT_SMOB (Output_def, def, 1); 72 LY_ASSERT_SMOB (Output_def, def, 1);
73 Output_def *output_def = unsmob<Output_def> (def); 73 Output_def *output_def = unsmob<Output_def> (def);
74 LY_ASSERT_TYPE (ly_is_symbol, sym, 2); 74 LY_ASSERT_TYPE (ly_is_symbol, sym, 2);
75 output_def->set_variable (sym, val); 75 output_def->set_variable (sym, val);
76 return SCM_UNSPECIFIED; 76 return SCM_UNSPECIFIED;
77 } 77 }
78 78
79 LY_DEFINE (ly_output_def_clone, "ly:output-def-clone", 79 LY_DEFINE (ly_output_def_clone, "ly:output-def-clone",
80 » 1, 0, 0, (SCM def), 80 1, 0, 0, (SCM def),
81 » "Clone output definition @var{def}.") 81 "Clone output definition @var{def}.")
82 { 82 {
83 LY_ASSERT_SMOB (Output_def, def, 1); 83 LY_ASSERT_SMOB (Output_def, def, 1);
84 Output_def *op = unsmob<Output_def> (def); 84 Output_def *op = unsmob<Output_def> (def);
85 85
86 Output_def *clone = op->clone (); 86 Output_def *clone = op->clone ();
87 return clone->unprotect (); 87 return clone->unprotect ();
88 } 88 }
89 89
90 LY_DEFINE (ly_output_description, "ly:output-description", 90 LY_DEFINE (ly_output_description, "ly:output-description",
91 » 1, 0, 0, (SCM output_def), 91 1, 0, 0, (SCM output_def),
92 » "Return the description of translators in @var{output-def}.") 92 "Return the description of translators in @var{output-def}.")
93 { 93 {
94 LY_ASSERT_SMOB (Output_def, output_def, 1); 94 LY_ASSERT_SMOB (Output_def, output_def, 1);
95 95
96 Output_def *id = unsmob<Output_def> (output_def); 96 Output_def *id = unsmob<Output_def> (output_def);
97 97
98 SCM al = ly_module_2_alist (id->scope_); 98 SCM al = ly_module_2_alist (id->scope_);
99 SCM ell = SCM_EOL; 99 SCM ell = SCM_EOL;
100 for (SCM s = al; scm_is_pair (s); s = scm_cdr (s)) 100 for (SCM s = al; scm_is_pair (s); s = scm_cdr (s))
101 { 101 {
102 Context_def *td = unsmob<Context_def> (scm_cdar (s)); 102 Context_def *td = unsmob<Context_def> (scm_cdar (s));
103 SCM key = scm_caar (s); 103 SCM key = scm_caar (s);
104 if (td && scm_is_eq (key, td->get_context_name ())) 104 if (td && scm_is_eq (key, td->get_context_name ()))
105 ell = scm_cons (scm_cons (key, td->to_alist ()), ell); 105 ell = scm_cons (scm_cons (key, td->to_alist ()), ell);
106 } 106 }
107 return ell; 107 return ell;
108 } 108 }
109 109
110 LY_DEFINE (ly_output_find_context_def, "ly:output-find-context-def", 110 LY_DEFINE (ly_output_find_context_def, "ly:output-find-context-def",
111 » 1, 1, 0, (SCM output_def, SCM context_name), 111 1, 1, 0, (SCM output_def, SCM context_name),
112 » "Return an alist of all context defs (matching @var{context-name}" 112 "Return an alist of all context defs (matching @var{context-name}"
113 » " if given) in @var{output-def}.") 113 " if given) in @var{output-def}.")
114 { 114 {
115 LY_ASSERT_SMOB (Output_def, output_def, 1); 115 LY_ASSERT_SMOB (Output_def, output_def, 1);
116 if (!SCM_UNBNDP (context_name)) 116 if (!SCM_UNBNDP (context_name))
117 LY_ASSERT_TYPE (ly_is_symbol, context_name, 2); 117 LY_ASSERT_TYPE (ly_is_symbol, context_name, 2);
118 118
119 Output_def *id = unsmob<Output_def> (output_def); 119 Output_def *id = unsmob<Output_def> (output_def);
120 120
121 SCM al = ly_module_2_alist (id->scope_); 121 SCM al = ly_module_2_alist (id->scope_);
122 SCM ell = SCM_EOL; 122 SCM ell = SCM_EOL;
123 for (SCM s = al; scm_is_pair (s); s = scm_cdr (s)) 123 for (SCM s = al; scm_is_pair (s); s = scm_cdr (s))
124 { 124 {
125 SCM p = scm_car (s); 125 SCM p = scm_car (s);
126 Context_def *td = unsmob<Context_def> (scm_cdr (p)); 126 Context_def *td = unsmob<Context_def> (scm_cdr (p));
127 if (td && scm_is_eq (scm_car (p), td->get_context_name ()) 127 if (td && scm_is_eq (scm_car (p), td->get_context_name ())
128 » && (SCM_UNBNDP (context_name) || td->is_alias (context_name))) 128 && (SCM_UNBNDP (context_name) || td->is_alias (context_name)))
129 » ell = scm_cons (p, ell); 129 ell = scm_cons (p, ell);
130 } 130 }
131 return ell; 131 return ell;
132 } 132 }
133 133
134 const char 134 const char
135 * const Output_def::type_p_name_ = "ly:output-def?"; 135 *const Output_def::type_p_name_ = "ly:output-def?";
136 136
137 LY_DEFINE (ly_paper_outputscale, "ly:paper-outputscale", 137 LY_DEFINE (ly_paper_outputscale, "ly:paper-outputscale",
138 » 1, 0, 0, (SCM def), 138 1, 0, 0, (SCM def),
139 » "Return the output-scale for output definition @var{def}.") 139 "Return the output-scale for output definition @var{def}.")
140 { 140 {
141 LY_ASSERT_SMOB (Output_def, def, 1); 141 LY_ASSERT_SMOB (Output_def, def, 1);
142 Output_def *b = unsmob<Output_def> (def); 142 Output_def *b = unsmob<Output_def> (def);
143 return scm_from_double (output_scale (b)); 143 return scm_from_double (output_scale (b));
144 } 144 }
145 145
146 LY_DEFINE (ly_make_output_def, "ly:make-output-def", 146 LY_DEFINE (ly_make_output_def, "ly:make-output-def",
147 » 0, 0, 0, (), 147 0, 0, 0, (),
148 » "Make an output definition.") 148 "Make an output definition.")
149 { 149 {
150 Output_def *bp = new Output_def; 150 Output_def *bp = new Output_def;
151 return bp->unprotect (); 151 return bp->unprotect ();
152 } 152 }
153 153
154 LY_DEFINE (ly_paper_get_font, "ly:paper-get-font", 154 LY_DEFINE (ly_paper_get_font, "ly:paper-get-font",
155 » 2, 0, 0, (SCM def, SCM chain), 155 2, 0, 0, (SCM def, SCM chain),
156 » "Find a font metric in output definition @var{def} satisfying" 156 "Find a font metric in output definition @var{def} satisfying"
157 » " the font-qualifiers in alist chain @var{chain}, and return" 157 " the font-qualifiers in alist chain @var{chain}, and return"
158 » " it. (An alist chain is a list of alists, containing grob" 158 " it. (An alist chain is a list of alists, containing grob"
159 » " properties.)") 159 " properties.)")
160 { 160 {
161 LY_ASSERT_SMOB (Output_def, def, 1); 161 LY_ASSERT_SMOB (Output_def, def, 1);
162 162
163 Output_def *paper = unsmob<Output_def> (def); 163 Output_def *paper = unsmob<Output_def> (def);
164 Font_metric *fm = select_font (paper, chain); 164 Font_metric *fm = select_font (paper, chain);
165 return fm->self_scm (); 165 return fm->self_scm ();
166 } 166 }
167 167
168 LY_DEFINE (ly_paper_get_number, "ly:paper-get-number", 168 LY_DEFINE (ly_paper_get_number, "ly:paper-get-number",
169 » 2, 0, 0, (SCM def, SCM sym), 169 2, 0, 0, (SCM def, SCM sym),
170 » "Return the value of variable @var{sym} in output definition" 170 "Return the value of variable @var{sym} in output definition"
171 » " @var{def} as a double.") 171 " @var{def} as a double.")
172 { 172 {
173 LY_ASSERT_SMOB (Output_def, def, 1); 173 LY_ASSERT_SMOB (Output_def, def, 1);
174 Output_def *layout = unsmob<Output_def> (def); 174 Output_def *layout = unsmob<Output_def> (def);
175 return scm_from_double (layout->get_dimension (sym)); 175 return scm_from_double (layout->get_dimension (sym));
176 } 176 }
177 177
178 LY_DEFINE (ly_paper_fonts, "ly:paper-fonts", 178 LY_DEFINE (ly_paper_fonts, "ly:paper-fonts",
179 » 1, 0, 0, (SCM def), 179 1, 0, 0, (SCM def),
180 » "Return a list containing the fonts from output definition" 180 "Return a list containing the fonts from output definition"
181 » " @var{def} (e.g., @code{\\paper}).") 181 " @var{def} (e.g., @code{\\paper}).")
182 { 182 {
183 LY_ASSERT_SMOB (Output_def, def, 1); 183 LY_ASSERT_SMOB (Output_def, def, 1);
184 Output_def *b = unsmob<Output_def> (def); 184 Output_def *b = unsmob<Output_def> (def);
185 185
186 SCM tab1 = b->lookup_variable (ly_symbol2scm ("scaled-fonts")); 186 SCM tab1 = b->lookup_variable (ly_symbol2scm ("scaled-fonts"));
187 SCM tab2 = b->lookup_variable (ly_symbol2scm ("pango-fonts")); 187 SCM tab2 = b->lookup_variable (ly_symbol2scm ("pango-fonts"));
188 188
189 SCM alist1 = SCM_EOL; 189 SCM alist1 = SCM_EOL;
190 if (to_boolean (scm_hash_table_p (tab1))) 190 if (to_boolean (scm_hash_table_p (tab1)))
191 { 191 {
(...skipping 14 matching lines...) Expand all
206 206
207 SCM alist = scm_append (scm_list_2 (alist1, alist2)); 207 SCM alist = scm_append (scm_list_2 (alist1, alist2));
208 SCM font_list = SCM_EOL; 208 SCM font_list = SCM_EOL;
209 for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s)) 209 for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s))
210 { 210 {
211 SCM entry = scm_car (s); 211 SCM entry = scm_car (s);
212 212
213 Font_metric *fm = unsmob<Font_metric> (entry); 213 Font_metric *fm = unsmob<Font_metric> (entry);
214 214
215 if (dynamic_cast<Modified_font_metric *> (fm) 215 if (dynamic_cast<Modified_font_metric *> (fm)
216 » || dynamic_cast<Pango_font *> (fm)) 216 || dynamic_cast<Pango_font *> (fm))
217 » font_list = scm_cons (fm->self_scm (), font_list); 217 font_list = scm_cons (fm->self_scm (), font_list);
218 } 218 }
219 219
220 return font_list; 220 return font_list;
221 } 221 }
OLDNEW
« no previous file with comments | « lily/output-def.cc ('k') | lily/output-property-engraver.cc » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b