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

Side by Side Diff: lily/context-def.cc

Issue 346080043: Issue 5344: Avoid repeated calculation of accepted contexts (Closed)
Patch Set: Created 6 years, 9 months 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
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) 2000--2015 Han-Wen Nienhuys <hanwen@xs4all.nl> 4 Copyright (C) 2000--2015 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
(...skipping 26 matching lines...) Expand all
37 // We can instantiate any context with a definition, but if there were any 37 // We can instantiate any context with a definition, but if there were any
38 // properties of the definition that could prevent instantiatation, we would 38 // properties of the definition that could prevent instantiatation, we would
39 // also want to check them here. 39 // also want to check them here.
40 return c; 40 return c;
41 } 41 }
42 42
43 Context_def::Context_def () 43 Context_def::Context_def ()
44 { 44 {
45 context_aliases_ = SCM_EOL; 45 context_aliases_ = SCM_EOL;
46 translator_group_type_ = SCM_EOL; 46 translator_group_type_ = SCM_EOL;
47 accept_mods_ = SCM_EOL;
48 translator_mods_ = SCM_EOL; 47 translator_mods_ = SCM_EOL;
49 property_ops_ = SCM_EOL; 48 property_ops_ = SCM_EOL;
50 context_name_ = SCM_EOL; 49 context_name_ = SCM_EOL;
51 default_child_ = SCM_EOL;
52 description_ = SCM_EOL; 50 description_ = SCM_EOL;
53 input_location_ = SCM_EOL; 51 input_location_ = SCM_EOL;
54 52
55 smobify_self (); 53 smobify_self ();
56 54
57 input_location_ = Input ().smobbed_copy (); 55 input_location_ = Input ().smobbed_copy ();
58 context_name_ = ly_symbol2scm (""); 56 context_name_ = ly_symbol2scm ("");
59 } 57 }
60 58
61 Input * 59 Input *
62 Context_def::origin () const 60 Context_def::origin () const
63 { 61 {
64 return unsmob<Input> (input_location_); 62 return unsmob<Input> (input_location_);
65 } 63 }
66 64
67 Context_def::Context_def (Context_def const &s) 65 Context_def::Context_def (Context_def const &s)
68 : Smob<Context_def> () 66 : Smob<Context_def> ()
69 { 67 {
70 context_aliases_ = SCM_EOL; 68 context_aliases_ = SCM_EOL;
71 translator_group_type_ = SCM_EOL; 69 translator_group_type_ = SCM_EOL;
72 accept_mods_ = SCM_EOL;
73 translator_mods_ = SCM_EOL; 70 translator_mods_ = SCM_EOL;
74 property_ops_ = SCM_EOL; 71 property_ops_ = SCM_EOL;
75 context_name_ = SCM_EOL; 72 context_name_ = SCM_EOL;
76 description_ = SCM_EOL; 73 description_ = SCM_EOL;
77 default_child_ = SCM_EOL;
78 input_location_ = SCM_EOL; 74 input_location_ = SCM_EOL;
79 smobify_self (); 75 smobify_self ();
80 76
81 description_ = s.description_; 77 description_ = s.description_;
82 input_location_ = s.origin ()->smobbed_copy (); 78 input_location_ = s.origin ()->smobbed_copy ();
83 default_child_ = s.default_child_; 79 acceptance_ = s.acceptance_;
84 accept_mods_ = s.accept_mods_;
85 property_ops_ = s.property_ops_; 80 property_ops_ = s.property_ops_;
86 translator_mods_ = s.translator_mods_; 81 translator_mods_ = s.translator_mods_;
87 context_aliases_ = s.context_aliases_; 82 context_aliases_ = s.context_aliases_;
88 translator_group_type_ = s.translator_group_type_; 83 translator_group_type_ = s.translator_group_type_;
89 context_name_ = s.context_name_; 84 context_name_ = s.context_name_;
90 } 85 }
91 86
92 Context_def::~Context_def () 87 Context_def::~Context_def ()
93 { 88 {
94 } 89 }
(...skipping 12 matching lines...) Expand all
107 return 1; 102 return 1;
108 } 103 }
109 104
110 SCM 105 SCM
111 Context_def::mark_smob () const 106 Context_def::mark_smob () const
112 { 107 {
113 ASSERT_LIVE_IS_ALLOWED (self_scm ()); 108 ASSERT_LIVE_IS_ALLOWED (self_scm ());
114 109
115 scm_gc_mark (description_); 110 scm_gc_mark (description_);
116 scm_gc_mark (context_aliases_); 111 scm_gc_mark (context_aliases_);
117 scm_gc_mark (accept_mods_); 112 acceptance_.gc_mark ();
118 scm_gc_mark (translator_mods_); 113 scm_gc_mark (translator_mods_);
119 scm_gc_mark (property_ops_); 114 scm_gc_mark (property_ops_);
120 scm_gc_mark (translator_group_type_); 115 scm_gc_mark (translator_group_type_);
121 scm_gc_mark (default_child_);
122 scm_gc_mark (input_location_); 116 scm_gc_mark (input_location_);
123 117
124 return context_name_; 118 return context_name_;
125 } 119 }
126 120
127 void 121 void
128 Context_def::add_context_mod (SCM mod) 122 Context_def::add_context_mod (SCM mod)
129 { 123 {
130 SCM tag = scm_car (mod); 124 SCM tag = scm_car (mod);
131 if (scm_is_eq (tag, ly_symbol2scm ("description"))) 125 if (scm_is_eq (tag, ly_symbol2scm ("description")))
132 { 126 {
133 description_ = scm_cadr (mod); 127 description_ = scm_cadr (mod);
134 return; 128 return;
135 } 129 }
136 130
137 /* 131 /*
138 other modifiers take symbols as argument. 132 other modifiers take symbols as argument.
139 */ 133 */
140 SCM sym = scm_cadr (mod); 134 SCM sym = scm_cadr (mod);
141 if (scm_is_string (sym)) 135 if (scm_is_string (sym))
142 sym = scm_string_to_symbol (sym); 136 sym = scm_string_to_symbol (sym);
143 137
144 if (scm_is_eq (tag, ly_symbol2scm ("default-child"))) 138 if (scm_is_eq (tag, ly_symbol2scm ("default-child")))
145 default_child_ = sym; 139 acceptance_.accept_default (sym);
146 else if (scm_is_eq (tag, ly_symbol2scm ("consists")) 140 else if (scm_is_eq (tag, ly_symbol2scm ("consists"))
147 || scm_is_eq (tag, ly_symbol2scm ("remove"))) 141 || scm_is_eq (tag, ly_symbol2scm ("remove")))
148 { 142 {
149 translator_mods_ = scm_cons (scm_list_2 (tag, sym), translator_mods_); 143 translator_mods_ = scm_cons (scm_list_2 (tag, sym), translator_mods_);
150 } 144 }
151 else if (scm_is_eq (tag, ly_symbol2scm ("accepts"))) 145 else if (scm_is_eq (tag, ly_symbol2scm ("accepts")))
152 accept_mods_ = scm_cons (scm_list_2 (tag, sym), accept_mods_); 146 acceptance_.accept (sym);
153 else if (scm_is_eq (tag, ly_symbol2scm ("denies"))) 147 else if (scm_is_eq (tag, ly_symbol2scm ("denies")))
154 { 148 acceptance_.deny (sym);
155 accept_mods_ = scm_cons (scm_list_2 (tag, sym), accept_mods_);
156 if (scm_is_eq (sym, default_child_))
157 default_child_ = SCM_EOL;
158 }
159 else if (scm_is_eq (tag, ly_symbol2scm ("pop")) 149 else if (scm_is_eq (tag, ly_symbol2scm ("pop"))
160 || scm_is_eq (tag, ly_symbol2scm ("push")) 150 || scm_is_eq (tag, ly_symbol2scm ("push"))
161 || scm_is_eq (tag, ly_symbol2scm ("assign")) 151 || scm_is_eq (tag, ly_symbol2scm ("assign"))
162 || scm_is_eq (tag, ly_symbol2scm ("unset")) 152 || scm_is_eq (tag, ly_symbol2scm ("unset"))
163 || scm_is_eq (tag, ly_symbol2scm ("apply"))) 153 || scm_is_eq (tag, ly_symbol2scm ("apply")))
164 property_ops_ = scm_cons (mod, property_ops_); 154 property_ops_ = scm_cons (mod, property_ops_);
165 else if (scm_is_eq (tag, ly_symbol2scm ("alias"))) 155 else if (scm_is_eq (tag, ly_symbol2scm ("alias")))
166 context_aliases_ = scm_cons (sym, context_aliases_); 156 context_aliases_ = scm_cons (sym, context_aliases_);
167 else if (scm_is_eq (tag, ly_symbol2scm ("translator-type"))) 157 else if (scm_is_eq (tag, ly_symbol2scm ("translator-type")))
168 translator_group_type_ = sym; 158 translator_group_type_ = sym;
169 else if (scm_is_eq (tag, ly_symbol2scm ("context-name"))) 159 else if (scm_is_eq (tag, ly_symbol2scm ("context-name")))
170 context_name_ = sym; 160 context_name_ = sym;
171 else 161 else
172 programming_error ("unknown context mod tag"); 162 programming_error ("unknown context mod tag");
173 } 163 }
174 164
175 SCM
176 Context_def::get_accepted (SCM user_mod) const
177 {
178 SCM mods = scm_reverse_x (scm_list_copy (accept_mods_), user_mod);
179 SCM acc = SCM_EOL;
180 for (SCM s = mods; scm_is_pair (s); s = scm_cdr (s))
181 {
182 SCM tag = scm_caar (s);
183 SCM sym = scm_cadar (s);
184 if (scm_is_eq (tag, ly_symbol2scm ("accepts")))
185 acc = scm_cons (sym, acc);
186 else if (scm_is_eq (tag, ly_symbol2scm ("denies")))
187 acc = scm_delete_x (sym, acc);
188 }
189
190 SCM def = get_default_child (user_mod);
191 if (scm_is_symbol (def))
192 {
193 acc = scm_delete_x (def, acc);
194 acc = scm_cons (def, acc);
195 }
196
197 return acc;
198 }
199
200 SCM
201 Context_def::get_default_child (SCM user_mod) const
202 {
203 SCM name = default_child_;
204 for (SCM s = user_mod; scm_is_pair (s); s = scm_cdr (s))
205 {
206 SCM entry = scm_car (s);
207 SCM tag = scm_car (entry);
208 if (scm_is_eq (tag, ly_symbol2scm ("denies")))
209 {
210 if (scm_is_eq (scm_cadr (entry), name))
211 name = SCM_EOL;
212 }
213 else if (scm_is_eq (tag, ly_symbol2scm ("default-child")))
214 name = scm_cadr (entry);
215 }
216
217 return name;
218 }
219
220 /* 165 /*
221 Given a name of a context that we want to create, finds a list of context 166 Given a name of a context that we want to create, finds a list of context
222 definitions such that: 167 definitions such that:
223 - the first element in the list defines a context that is a valid child of 168 - the first element in the list defines a context that is a valid child of
224 the context defined by this Context_def 169 the context defined by this Context_def
225 - each subsequent element in the list defines a context that is a valid child 170 - each subsequent element in the list defines a context that is a valid child
226 of the context defined by the preceding element in the list 171 of the context defined by the preceding element in the list
227 - the last element in the list defines a context with the given name 172 - the last element in the list defines a context with the given name
228 173
229 The ADDITIONAL_ACCEPTS parameter is a list of additional contexts that this 174 The ACCEPTED parameter is the list of contexts that the caller accepts. (The
230 specific context def (but not any of the child context defs) should accept. 175 caller is a Context instantiated from this Context_def, but its acceptance
176 list may have been modified from the defined default.)
231 */ 177 */
232 vector<Context_def *> 178 vector<Context_def *>
233 Context_def::path_to_acceptable_context (SCM type_sym, 179 Context_def::path_to_acceptable_context (SCM type_sym,
234 Output_def *odef, 180 Output_def *odef,
235 SCM additional_accepts) const 181 SCM accepted) const
236 { 182 {
237 set<const Context_def *> seen; 183 set<const Context_def *> seen;
238 Context_def *t = unsmob<Context_def> (find_context_def (odef, type_sym)); 184 Context_def *t = unsmob<Context_def> (find_context_def (odef, type_sym));
239 return internal_path_to_acceptable_context (type_sym, is_instantiable (t), 185 return internal_path_to_acceptable_context (type_sym, is_instantiable (t),
240 odef, additional_accepts, &seen); 186 odef, accepted, &seen);
241 } 187 }
242 188
243 /* 189 /*
244 The SEEN parameter is a set which keeps track of visited contexts, allowing 190 The SEEN parameter is a set which keeps track of visited contexts, allowing
245 contexts of the same type to be nested. 191 contexts of the same type to be nested.
246 192
247 When the leaf is instantiable (the usual), we ignore aliases and thereby use 193 When the leaf is instantiable (the usual), we ignore aliases and thereby use
248 the requested context or nothing. Example: If the caller requests a Staff, we 194 the requested context or nothing. Example: If the caller requests a Staff, we
249 do not substitute a RhythmicStaff. 195 do not substitute a RhythmicStaff.
250 196
251 When the leaf is not instantiable, since there would otherwise be nothing worth 197 When the leaf is not instantiable, since there would otherwise be nothing worth
252 doing, we allow substituting an instantiable context that aliases the requested 198 doing, we allow substituting an instantiable context that aliases the requested
253 context. Example: The caller requests a Timing and the current context would 199 context. Example: The caller requests a Timing and the current context would
254 accept a Score, for which Timing is an alias, so substitute a Score. 200 accept a Score, for which Timing is an alias, so substitute a Score.
255 */ 201 */
256 vector<Context_def *> 202 vector<Context_def *>
257 Context_def::internal_path_to_acceptable_context (SCM type_sym, 203 Context_def::internal_path_to_acceptable_context (SCM type_sym,
258 bool instantiable, 204 bool instantiable,
259 Output_def *odef, 205 Output_def *odef,
260 SCM additional_accepts, 206 SCM accepted,
261 set<const Context_def *> *seen ) const 207 set<const Context_def *> *seen ) const
262 { 208 {
263 assert (scm_is_symbol (type_sym)); 209 assert (scm_is_symbol (type_sym));
264 210
265 SCM accepted = get_accepted (additional_accepts);
266
267 vector<Context_def *> accepteds; 211 vector<Context_def *> accepteds;
268 for (SCM s = accepted; scm_is_pair (s); s = scm_cdr (s)) 212 for (SCM s = accepted; scm_is_pair (s); s = scm_cdr (s))
269 { 213 {
270 Context_def *t = unsmob<Context_def> (find_context_def (odef, 214 Context_def *t = unsmob<Context_def> (find_context_def (odef,
271 scm_car (s))); 215 scm_car (s)));
272 if (is_instantiable (t)) 216 if (is_instantiable (t))
273 accepteds.push_back (t); 217 accepteds.push_back (t);
274 } 218 }
275 219
276 vector<Context_def *> best_result; 220 vector<Context_def *> best_result;
277 for (vsize i = 0; i < accepteds.size (); i++) 221 for (vsize i = 0; i < accepteds.size (); i++)
278 { 222 {
279 bool valid = instantiable 223 bool valid = instantiable
280 ? ly_is_equal (accepteds[i]->get_context_name (), type_sym) 224 ? ly_is_equal (accepteds[i]->get_context_name (), type_sym)
281 : accepteds[i]->is_alias (type_sym); 225 : accepteds[i]->is_alias (type_sym);
282 if (valid) 226 if (valid)
283 { 227 {
284 best_result.push_back (accepteds[i]); 228 best_result.push_back (accepteds[i]);
285 return best_result; 229 return best_result;
286 } 230 }
287 } 231 }
288 232
289 seen->insert (this); 233 seen->insert (this);
290 vsize best_depth = INT_MAX; 234 vsize best_depth = INT_MAX;
291 for (vsize i = 0; i < accepteds.size (); i++) 235 for (vsize i = 0; (best_depth > 1) && (i < accepteds.size ()); i++)
292 { 236 {
293 Context_def *g = accepteds[i]; 237 Context_def *g = accepteds[i];
294 238
295 if (!seen->count (g)) 239 if (!seen->count (g))
296 { 240 {
241 SCM acc = g->acceptance_.get_list ();
297 vector<Context_def *> result 242 vector<Context_def *> result
298 = g->internal_path_to_acceptable_context (type_sym, instantiable, 243 = g->internal_path_to_acceptable_context (type_sym, instantiable,
299 odef, SCM_EOL, seen); 244 odef, acc, seen);
300 if (result.size () && result.size () < best_depth) 245 if (result.size () && result.size () < best_depth)
301 { 246 {
302 best_depth = result.size (); 247 best_depth = result.size ();
303 result.insert (result.begin (), g); 248 result.insert (result.begin (), g);
304 best_result = result; 249 best_result = result;
305 } 250 }
306 } 251 }
307 } 252 }
308 seen->erase (this); 253 seen->erase (this);
309 254
(...skipping 27 matching lines...) Expand all
337 } 282 }
338 283
339 if (std::find (path->begin (), path->end (), t) != path->end ()) 284 if (std::find (path->begin (), path->end (), t) != path->end ())
340 { 285 {
341 warning (_f ("default child context begins a cycle: `%s'", 286 warning (_f ("default child context begins a cycle: `%s'",
342 ly_symbol2string (next_type_sym).c_str ())); 287 ly_symbol2string (next_type_sym).c_str ()));
343 return false; 288 return false;
344 } 289 }
345 290
346 path->push_back (t); 291 path->push_back (t);
347 return internal_path_to_bottom_context (odef, path, t->default_child_); 292 return internal_path_to_bottom_context (odef, path,
293 t->acceptance_.get_default ());
348 } 294 }
349 295
350 SCM 296 SCM
351 Context_def::get_translator_names (SCM user_mod) const 297 Context_def::get_translator_names (SCM user_mod) const
352 { 298 {
353 SCM l1 = SCM_EOL; 299 SCM l1 = SCM_EOL;
354 300
355 SCM mods = scm_reverse_x (scm_list_copy (translator_mods_), user_mod); 301 SCM mods = scm_reverse_x (scm_list_copy (translator_mods_), user_mod);
356 302
357 for (SCM s = mods; scm_is_pair (s); s = scm_cdr (s)) 303 for (SCM s = mods; scm_is_pair (s); s = scm_cdr (s))
(...skipping 14 matching lines...) Expand all
372 } 318 }
373 319
374 Context * 320 Context *
375 Context_def::instantiate (SCM ops) 321 Context_def::instantiate (SCM ops)
376 { 322 {
377 Context *context = new Context (); 323 Context *context = new Context ();
378 324
379 context->definition_ = self_scm (); 325 context->definition_ = self_scm ();
380 context->definition_mods_ = ops; 326 context->definition_mods_ = ops;
381 context->aliases_ = context_aliases_; 327 context->aliases_ = context_aliases_;
382 context->accepts_list_ = get_accepted (ops); 328 context->acceptance_ = acceptance_;
383 context->default_child_ = get_default_child (ops); 329
330 Acceptance_set& acc = context->acceptance_;
dak 2018/06/14 22:53:58 This is a bloody mess. You take the original list
Dan Eble 2018/06/15 02:36:40 context->acceptance_ = acceptance_ (line 328) copi
331 for (SCM s = ops; scm_is_pair (s); s = scm_cdr (s))
332 {
333 SCM tag = scm_caar (s);
334 if (scm_is_eq (tag, ly_symbol2scm ("accepts")))
335 acc.accept (scm_string_to_symbol (scm_cadar (s)));
336 else if (scm_is_eq (tag, ly_symbol2scm ("denies")))
337 acc.deny (scm_string_to_symbol (scm_cadar (s)));
338 else if (scm_is_eq (tag, ly_symbol2scm ("default-child")))
339 acc.accept_default (scm_string_to_symbol (scm_cadar (s)));
340 }
384 341
385 return context; 342 return context;
386 } 343 }
387 344
388 SCM 345 SCM
389 Context_def::make_scm () 346 Context_def::make_scm ()
390 { 347 {
391 Context_def *t = new Context_def; 348 Context_def *t = new Context_def;
392 return t->unprotect (); 349 return t->unprotect ();
393 } 350 }
394 351
395 void 352 void
396 Context_def::apply_default_property_operations (Context *tg) 353 Context_def::apply_default_property_operations (Context *tg)
397 { 354 {
398 apply_property_operations (tg, scm_reverse (property_ops_)); 355 apply_property_operations (tg, scm_reverse (property_ops_));
399 } 356 }
400 357
401 SCM 358 SCM
402 Context_def::to_alist () const 359 Context_def::to_alist () const
403 { 360 {
404 SCM ell = SCM_EOL; 361 SCM ell = SCM_EOL;
405 362
406 ell = scm_cons (scm_cons (ly_symbol2scm ("consists"), 363 ell = scm_cons (scm_cons (ly_symbol2scm ("consists"),
407 get_translator_names (SCM_EOL)), ell); 364 get_translator_names (SCM_EOL)), ell);
408 ell = scm_cons (scm_cons (ly_symbol2scm ("description"), description_), ell); 365 ell = scm_cons (scm_cons (ly_symbol2scm ("description"), description_), ell);
409 ell = scm_cons (scm_cons (ly_symbol2scm ("aliases"), context_aliases_), ell); 366 ell = scm_cons (scm_cons (ly_symbol2scm ("aliases"), context_aliases_), ell);
410 ell = scm_cons (scm_cons (ly_symbol2scm ("accepts"), get_accepted (SCM_EOL)), 367 ell = scm_cons (scm_cons (ly_symbol2scm ("accepts"), acceptance_.get_list ()),
411 ell); 368 ell);
412 if (scm_is_symbol (default_child_)) 369 if (acceptance_.has_default ())
413 ell = scm_acons (ly_symbol2scm ("default-child"), default_child_, ell); 370 {
414 ell = scm_cons (scm_cons (ly_symbol2scm ("accepts"), get_accepted (SCM_EOL)), 371 ell = scm_acons (ly_symbol2scm ("default-child"),
415 ell); 372 acceptance_.get_default (), ell);
373 }
416 ell = scm_cons (scm_cons (ly_symbol2scm ("property-ops"), property_ops_), 374 ell = scm_cons (scm_cons (ly_symbol2scm ("property-ops"), property_ops_),
417 ell); 375 ell);
418 ell = scm_cons (scm_cons (ly_symbol2scm ("context-name"), context_name_), 376 ell = scm_cons (scm_cons (ly_symbol2scm ("context-name"), context_name_),
419 ell); 377 ell);
420 378
421 if (scm_is_symbol (translator_group_type_)) 379 if (scm_is_symbol (translator_group_type_))
422 ell = scm_cons (scm_cons (ly_symbol2scm ("group-type"), 380 ell = scm_cons (scm_cons (ly_symbol2scm ("group-type"),
423 translator_group_type_), ell); 381 translator_group_type_), ell);
424 return ell; 382 return ell;
425 } 383 }
426 384
427 SCM 385 SCM
428 Context_def::lookup (SCM sym) const 386 Context_def::lookup (SCM sym) const
429 { 387 {
430 if (scm_is_eq (ly_symbol2scm ("default-child"), sym)) 388 if (scm_is_eq (ly_symbol2scm ("default-child"), sym))
431 return default_child_; 389 return acceptance_.get_default ();
432 else if (scm_is_eq (ly_symbol2scm ("consists"), sym)) 390 else if (scm_is_eq (ly_symbol2scm ("consists"), sym))
433 return get_translator_names (SCM_EOL); 391 return get_translator_names (SCM_EOL);
434 else if (scm_is_eq (ly_symbol2scm ("description"), sym)) 392 else if (scm_is_eq (ly_symbol2scm ("description"), sym))
435 return description_; 393 return description_;
436 else if (scm_is_eq (ly_symbol2scm ("aliases"), sym)) 394 else if (scm_is_eq (ly_symbol2scm ("aliases"), sym))
437 return context_aliases_; 395 return context_aliases_;
438 else if (scm_is_eq (ly_symbol2scm ("accepts"), sym)) 396 else if (scm_is_eq (ly_symbol2scm ("accepts"), sym))
439 return get_accepted (SCM_EOL); 397 return acceptance_.get_list ();
440 else if (scm_is_eq (ly_symbol2scm ("property-ops"), sym)) 398 else if (scm_is_eq (ly_symbol2scm ("property-ops"), sym))
441 return property_ops_; 399 return property_ops_;
442 else if (scm_is_eq (ly_symbol2scm ("context-name"), sym)) 400 else if (scm_is_eq (ly_symbol2scm ("context-name"), sym))
443 return context_name_; 401 return context_name_;
444 else if (scm_is_eq (ly_symbol2scm ("group-type"), sym)) 402 else if (scm_is_eq (ly_symbol2scm ("group-type"), sym))
445 return translator_group_type_; 403 return translator_group_type_;
446 return SCM_UNDEFINED; 404 return SCM_UNDEFINED;
447 } 405 }
448 406
449 bool 407 bool
450 Context_def::is_alias (SCM sym) const 408 Context_def::is_alias (SCM sym) const
451 { 409 {
452 if (scm_is_eq (sym, ly_symbol2scm ("Bottom"))) 410 if (scm_is_eq (sym, ly_symbol2scm ("Bottom")))
453 return !scm_is_symbol (get_default_child (SCM_EOL)); 411 return !acceptance_.has_default ();
454 412
455 if (scm_is_eq (sym, get_context_name ())) 413 if (scm_is_eq (sym, get_context_name ()))
456 return true; 414 return true;
457 415
458 return scm_is_true (scm_c_memq (sym, context_aliases_)); 416 return scm_is_true (scm_c_memq (sym, context_aliases_));
459 } 417 }
460 418
461 LY_DEFINE (ly_context_def_lookup, "ly:context-def-lookup", 419 LY_DEFINE (ly_context_def_lookup, "ly:context-def-lookup",
462 2, 1, 0, (SCM def, SCM sym, SCM val), 420 2, 1, 0, (SCM def, SCM sym, SCM val),
463 "Return the value of @var{sym} in context definition @var{def}" 421 "Return the value of @var{sym} in context definition @var{def}"
(...skipping 30 matching lines...) Expand all
494 452
495 Context_def *cd = unsmob<Context_def> (def)->clone (); 453 Context_def *cd = unsmob<Context_def> (def)->clone ();
496 454
497 for (SCM s = unsmob<Context_mod> (mod)->get_mods (); 455 for (SCM s = unsmob<Context_mod> (mod)->get_mods ();
498 scm_is_pair (s); 456 scm_is_pair (s);
499 s = scm_cdr (s)) 457 s = scm_cdr (s))
500 cd->add_context_mod (scm_car (s)); 458 cd->add_context_mod (scm_car (s));
501 459
502 return cd->unprotect (); 460 return cd->unprotect ();
503 } 461 }
OLDNEW
« lily/acceptance-set.cc ('K') | « lily/context.cc ('k') | lily/global-context.cc » ('j') | no next file with comments »

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