1 ;;;; c++.scm -- implement Scheme frontends to C++ functions
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 1998--2001 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 ;;; Note: this file can't be used without LilyPond executable
10 (define (number-pair? x)
12 (number? (car x)) (number? (cdr x))))
13 (define (number-or-grob? x)
14 (or (ly-grob? x) (number? x))
17 (define (moment-pair? x)
19 (moment? (car x)) (moment? (cdr x))))
21 (define (boolean-or-symbol? x)
22 (or (boolean? x) (symbol? x)))
24 (define (number-or-boolean? x)
25 (or (number? x) (boolean? x)))
27 (define (number-or-string? x)
28 (or (number? x) (string? x)))
31 (or (string? x) (list? x)))
33 (define (scheme? x) #t)
35 (define type-p-name-alist
38 (,scheme? . "any type")
39 (,number-pair? . "pair of numbers")
40 (,ly-input-location? . "input location")
41 (,ly-grob? . "grob (GRaphical OBject)")
42 (,duration? . "duration")
44 (,integer? . "integer")
48 (,boolean? . "boolean")
50 (,ly-input-location? . "input location")
51 (,music-list? . "list of music")
55 (,input-port? . "input port")
56 (,output-port? . "output port")
58 (,procedure? . "procedure")
59 (,boolean-or-symbol? . "boolean or symbol")
60 (,number-or-string? . "number or string")
61 (,number-or-boolean? . "number or boolean")
62 (,markup? . "markup (list or string)")
63 (,number-or-grob? . "number or grob")
67 (define (match-predicate obj alist)
70 (if (apply (caar alist) obj)
72 (match-predicate obj (cdr alist))
76 (define (object-type obj)
77 (match-predicate obj type-p-name-alist))
79 (define (type-name predicate)
80 (let ((entry (assoc predicate type-p-name-alist)))
81 (if (pair? entry) (cdr entry)
85 (define (uniqued-alist alist acc)
87 (if (assoc (caar alist) acc)
88 (uniqued-alist (cdr alist) acc)
89 (uniqued-alist (cdr alist) (cons (car alist) acc)))))
92 ;; used in denneboom.ly
93 (define (cons-map f x)
94 (cons (f (car x)) (f (cdr x))))
97 (define (reduce operator list)
98 "reduce OP [A, B, C, D, ... ] =
101 (if (null? (cdr list)) (car list)
102 (operator (car list) (reduce operator (cdr list)))))
106 (define (take-from-list-until todo gathered crit?)
107 "return (G, T), where (reverse G) + T = GATHERED + TODO, and the last of G
108 is the first to satisfy CRIT "
111 (if (crit? (car todo))
112 (cons (cons (car todo) gathered) (cdr todo))
113 (take-from-list-until (cdr todo) (cons (car todo) gathered) crit?)
117 ; (take-from-list-until '(1 2 3 4 5) '() (lambda (x) (eq? x 3)))
122 ; Make a function that checks score element for being of a specific type.
123 (define (make-type-checker symbol)
126 ;;(eq? #t (ly-get-grob-property elt symbol))
127 (not (eq? #f (memq symbol (ly-get-grob-property elt 'interfaces))))))
130 (define (index-cell cell dir)
135 (define (repeat-name-to-ctor name)
138 `(("volta" . ((iterator-ctor . ,Volta_repeat_iterator::constructor)
139 (length . ,Repeated_music::volta_music_length)))
140 ("unfold" . ((iterator-ctor . ,Unfolded_repeat_iterator::constructor)
141 (length . ,Repeated_music::unfolded_music_length)))
142 ("fold" . ((iterator-ctor . ,Folded_repeat_iterator::constructor)
143 (length . ,Repeated_music::folded_music_length)))
144 ("percent" . ((iterator-ctor . ,Percent_repeat_iterator::constructor)
145 (length . ,Repeated_music::unfolded_music_length)))
146 ("tremolo" . ((iterator-ctor . ,Chord_tremolo_iterator::constructor)
147 (length . ,Repeated_music::unfolded_music_length)))))
149 (handle (assoc name supported-reps)))
155 (string-append "Unknown repeat type `" name "'\nSee scm/c++.scm for supported repeats"))
156 '(type . 'repeated-music)))))