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))))
14 (define (moment-pair? x)
16 (moment? (car x)) (moment? (cdr x))))
18 (define (boolean-or-symbol? x)
19 (or (boolean? x) (symbol? x)))
21 (define (number-or-boolean? x)
22 (or (number? x) (boolean? x)))
24 (define (number-or-string? x)
25 (or (number? x) (string? x)))
28 (or (string? x) (list? x)))
30 (define (scheme? x) #t)
32 (define type-p-name-alist
35 (,scheme? . "any type")
36 (,number-pair? . "pair of numbers")
37 (,ly-input-location? . "input location")
38 (,ly-grob? . "grob (GRaphical OBject)")
39 (,duration? . "duration")
41 (,integer? . "integer")
45 (,boolean? . "boolean")
47 (,ly-input-location? . "input location")
51 (,input-port? . "input port")
52 (,output-port? . "output port")
54 (,procedure? . "procedure")
55 (,boolean-or-symbol? . "boolean or symbol")
56 (,number-or-string? . "number or string")
57 (,number-or-boolean? . "number or boolean")
58 (,markup? . "markup (list or string)")
62 (define (match-predicate obj alist)
65 (if (apply (caar alist) obj)
67 (match-predicate obj (cdr alist))
71 (define (object-type obj)
72 (match-predicate obj type-p-name-alist))
74 (define (type-name predicate)
75 (let ((entry (assoc predicate type-p-name-alist)))
76 (if (pair? entry) (cdr entry)
80 (define (uniqued-alist alist acc)
82 (if (assoc (caar alist) acc)
83 (uniqued-alist (cdr alist) acc)
84 (uniqued-alist (cdr alist) (cons (car alist) acc)))))
87 ;; used in denneboom.ly
88 (define (cons-map f x)
89 (cons (f (car x)) (f (cdr x))))
92 ;;(define (reduce operator list)
93 ;; (if (null? (cdr list)) (car list)
94 ;; (operator (car list) (reduce operator (cdr list)))))
98 ; Make a function that checks score element for being of a specific type.
99 (define (make-type-checker symbol)
102 ;;(eq? #t (ly-get-grob-property elt symbol))
103 (not (eq? #f (memq symbol (ly-get-grob-property elt 'interfaces))))))
106 (define (index-cell cell dir)
111 (define (repeat-name-to-ctor name)
114 `(("volta" . ((iterator-ctor . ,Volta_repeat_iterator::constructor)
115 (length . ,Repeated_music::volta_music_length)))
116 ("unfold" . ((iterator-ctor . ,Unfolded_repeat_iterator::constructor)
117 (length . ,Repeated_music::unfolded_music_length)))
118 ("fold" . ((iterator-ctor . ,Folded_repeat_iterator::constructor)
119 (length . ,Repeated_music::folded_music_length)))
120 ("percent" . ((iterator-ctor . ,Percent_repeat_iterator::constructor)
121 (length . ,Repeated_music::unfolded_music_length)))
122 ("tremolo" . ((iterator-ctor . ,Chord_tremolo_iterator::constructor)
123 (length . ,Repeated_music::unfolded_music_length)))))
125 (handle (assoc name supported-reps)))
131 (string-append "Unknown repeat type `" name "'\nSee scm/c++.scm for supported repeats"))
132 '(type . 'repeated-music)))))