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-public (number-pair? x)
12 (number? (car x)) (number? (cdr x))))
13 (define-public (number-or-grob? x)
14 (or (ly-grob? x) (number? x))
17 (define-public (grob-list? x)
20 (define-public (moment-pair? x)
22 (moment? (car x)) (moment? (cdr x))))
24 (define-public (boolean-or-symbol? x)
25 (or (boolean? x) (symbol? x)))
27 (define-public (number-or-string? x)
28 (or (number? x) (string? x)))
30 (define-public (markup? x)
31 (or (string? x) (list? x)))
33 (define-public (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 (,grob-list? . "list of grobs")
43 (,duration? . "duration")
45 (,integer? . "integer")
49 (,boolean? . "boolean")
51 (,ly-input-location? . "input location")
52 (,music-list? . "list of music")
56 (,input-port? . "input port")
57 (,output-port? . "output port")
59 (,procedure? . "procedure")
60 (,boolean-or-symbol? . "boolean or symbol")
61 (,number-or-string? . "number or string")
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-public (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-public (repeat-name-to-ctor name)
138 `(("volta" . ((iterator-ctor . ,Volta_repeat_iterator::constructor)
139 (start-moment-function . ,Repeated_music::first_start)
140 (length . ,Repeated_music::volta_music_length)))
142 ("unfold" . ((iterator-ctor . ,Unfolded_repeat_iterator::constructor)
143 (start-moment-function . ,Repeated_music::first_start)
144 (length . ,Repeated_music::unfolded_music_length)))
145 ("fold" . ((iterator-ctor . ,Folded_repeat_iterator::constructor)
146 (start-moment-function . ,Repeated_music::minimum_start)
147 (length . ,Repeated_music::folded_music_length)))
148 ("percent" . ((iterator-ctor . ,Percent_repeat_iterator::constructor)
149 (start-moment-function . ,Repeated_music::first_start)
150 (length . ,Repeated_music::unfolded_music_length)))
151 ("tremolo" . ((iterator-ctor . ,Chord_tremolo_iterator::constructor)
152 (start-moment-function . ,Repeated_music::first_start)
154 ;; the length of the repeat is handled by shifting the note logs
155 (length . ,Repeated_music::folded_music_length)))))
157 (handle (assoc name supported-reps)))
163 (string-append "Unknown repeat type `" name "'\nSee scm/c++.scm for supported repeats"))
164 '(type . 'repeated-music)))))