-number_accidentals (SCM localsig, SCM lazysig, Note_req * note_l, SCM accidentals_l) {
- int number=0;
- int diff=0;
- if(gh_memq(ly_symbol2scm("same-octave"),accidentals_l)!=SCM_BOOL_F) {
- int n = number_accidentals(localsig,note_l,false);
- diff |= n<0;
- number = max(number,abs(n));
- }
- if(gh_memq(ly_symbol2scm("lazy-same-octave"),accidentals_l)!=SCM_BOOL_F) {
- int n = number_accidentals(lazysig,note_l,false);
- diff |= n<0;
- number = max(number,abs(n));
- }
- if(gh_memq(ly_symbol2scm("any-octave"),accidentals_l)!=SCM_BOOL_F) {
- int n = number_accidentals(localsig,note_l,true);
- diff |= n<0;
- number = max(number,abs(n));
- }
- if(gh_memq(ly_symbol2scm("lazy-any-octave"),accidentals_l)!=SCM_BOOL_F) {
- int n = number_accidentals(lazysig,note_l,true);
- diff |= n<0;
- number = max(number,abs(n));
- }
+number_accidentals (Music * note, Pitch *pitch, Translator_group * origin,
+ SCM accidentals, SCM curbarnum)
+{
+ int number = 0;
+
+ bool diff = false;
+ if (gh_pair_p (accidentals) && !gh_symbol_p (ly_car (accidentals)))
+ warning (_f ("Accidental typesetting list must begin with context-name: %s",
+ ly_scm2string (ly_car (accidentals)).to_str0 ()));
+
+ while (gh_pair_p (accidentals) && origin)
+ {
+ // If pair then it is a new accidentals typesetting rule to be checked
+ if (gh_pair_p (ly_car (accidentals)))
+ {
+ SCM type = gh_caar (accidentals);
+ SCM lazyness = gh_cdar (accidentals);
+ SCM localsig = origin->get_property ("localKeySignature");
+
+ bool same_octave_b =
+ gh_eq_p (ly_symbol2scm ("same-octave"), type);
+ bool any_octave_b =
+ gh_eq_p (ly_symbol2scm ("any-octave"), type);
+
+ if (same_octave_b || any_octave_b)
+ {
+ int n = number_accidentals
+ (localsig, note, pitch, curbarnum, lazyness, any_octave_b);
+ diff = diff || (n < 0);
+ number = max (number, abs (n));
+ }
+ else
+ warning (_f ("unknown accidental typesetting: %s. Ignored",
+ ly_symbol2string (type).to_str0 ()));
+ }
+
+
+ /*
+ if symbol then it is a context name. Scan parent contexts to find it.
+ */
+ else if (gh_symbol_p (ly_car (accidentals)))
+ {
+ String context = ly_symbol2string (ly_car (accidentals));
+
+ while (origin && !origin->is_alias_b (context))
+ origin = origin->daddy_trans_;
+
+ if (!origin)
+ warning (_f ("Symbol is not a parent context: %s. Ignored",
+ context.to_str0 ()));
+ }
+ else warning (_f ("Accidental typesetting must be pair or context-name: %s",
+ ly_scm2string (ly_car (accidentals)).to_str0 ()));
+
+ accidentals = ly_cdr (accidentals);
+ }