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 (grob-list? x)
20 (define (moment-pair? x)
22 (moment? (car x)) (moment? (cdr x))))
24 (define (boolean-or-symbol? x)
25 (or (boolean? x) (symbol? x)))
27 (define (number-or-boolean? x)
28 (or (number? x) (boolean? x)))
30 (define (number-or-string? x)
31 (or (number? x) (string? x)))
34 (or (string? x) (list? x)))
36 (define (scheme? x) #t)
38 (define type-p-name-alist
41 (,scheme? . "any type")
42 (,number-pair? . "pair of numbers")
43 (,ly-input-location? . "input location")
44 (,ly-grob? . "grob (GRaphical OBject)")
45 (,grob-list? . "list of grobs")
46 (,duration? . "duration")
48 (,integer? . "integer")
52 (,boolean? . "boolean")
54 (,ly-input-location? . "input location")
55 (,music-list? . "list of music")
59 (,input-port? . "input port")
60 (,output-port? . "output port")
62 (,procedure? . "procedure")
63 (,boolean-or-symbol? . "boolean or symbol")
64 (,number-or-string? . "number or string")
65 (,number-or-boolean? . "number or boolean")
66 (,markup? . "markup (list or string)")
67 (,number-or-grob? . "number or grob")
71 (define (match-predicate obj alist)
74 (if (apply (caar alist) obj)
76 (match-predicate obj (cdr alist))
80 (define (object-type obj)
81 (match-predicate obj type-p-name-alist))
83 (define (type-name predicate)
84 (let ((entry (assoc predicate type-p-name-alist)))
85 (if (pair? entry) (cdr entry)
89 (define (uniqued-alist alist acc)
91 (if (assoc (caar alist) acc)
92 (uniqued-alist (cdr alist) acc)
93 (uniqued-alist (cdr alist) (cons (car alist) acc)))))
96 ;; used in denneboom.ly
97 (define (cons-map f x)
98 (cons (f (car x)) (f (cdr x))))
101 (define (reduce operator list)
102 "reduce OP [A, B, C, D, ... ] =
105 (if (null? (cdr list)) (car list)
106 (operator (car list) (reduce operator (cdr list)))))
110 (define (take-from-list-until todo gathered crit?)
111 "return (G, T), where (reverse G) + T = GATHERED + TODO, and the last of G
112 is the first to satisfy CRIT "
115 (if (crit? (car todo))
116 (cons (cons (car todo) gathered) (cdr todo))
117 (take-from-list-until (cdr todo) (cons (car todo) gathered) crit?)
121 ; (take-from-list-until '(1 2 3 4 5) '() (lambda (x) (eq? x 3)))
126 ; Make a function that checks score element for being of a specific type.
127 (define (make-type-checker symbol)
130 ;;(eq? #t (ly-get-grob-property elt symbol))
131 (not (eq? #f (memq symbol (ly-get-grob-property elt 'interfaces))))))
134 (define (index-cell cell dir)
139 (define (repeat-name-to-ctor name)
142 `(("volta" . ((iterator-ctor . ,Volta_repeat_iterator::constructor)
143 (start-moment-function . ,Repeated_music::first_start)
144 (length . ,Repeated_music::volta_music_length)))
145 ("unfold" . ((iterator-ctor . ,Unfolded_repeat_iterator::constructor)
146 (start-moment-function . ,Repeated_music::first_start)
147 (length . ,Repeated_music::unfolded_music_length)))
148 ("fold" . ((iterator-ctor . ,Folded_repeat_iterator::constructor)
149 (start-moment-function . ,Repeated_music::minimum_start)
150 (length . ,Repeated_music::folded_music_length)))
151 ("percent" . ((iterator-ctor . ,Percent_repeat_iterator::constructor)
152 (start-moment-function . ,Repeated_music::first_start)
153 (length . ,Repeated_music::unfolded_music_length)))
154 ("tremolo" . ((iterator-ctor . ,Chord_tremolo_iterator::constructor)
155 (start-moment-function . ,Repeated_music::first_start)
156 (length . ,Repeated_music::unfolded_music_length)))))
158 (handle (assoc name supported-reps)))
164 (string-append "Unknown repeat type `" name "'\nSee scm/c++.scm for supported repeats"))
165 '(type . 'repeated-music)))))