]> git.donarmstrong.com Git - lilypond.git/blob - scm/c++.scm
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond into...
[lilypond.git] / scm / c++.scm
1 ;;;; c++.scm -- implement Scheme frontends to C++ functions
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;;
5 ;;;; (c) 1998--2009 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;;                 Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8 ;;; Note: this file can't be used without LilyPond executable
9
10
11 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12 ;; type predicates.
13 (define-public (number-pair? x)
14   (and (pair? x)
15        (number? (car x)) (number? (cdr x))))
16
17 (define-public (number-or-grob? x)
18   (or (ly:grob? x) (number? x)))
19
20 (define-public (grob-list? x)
21   (list? x))
22
23 (define-public (moment-pair? x)
24   (and (pair? x)
25        (ly:moment? (car x)) (ly:moment? (cdr x))))
26
27 (define-public (boolean-or-symbol? x)
28   (or (boolean? x) (symbol? x)))
29
30 (define-public (string-or-symbol? x)
31   (or (string? x) (symbol? x)))
32
33 (define-public (number-or-string? x)
34   (or (number? x) (string? x)))
35
36 (define-public (string-or-pair? x)
37   (or (string? x) (pair? x)))
38
39 (define-public (cheap-list? x)
40   (or (pair? x) (null? x)))
41
42 (define-public (list-or-symbol? x)
43   (or (cheap-list? x) (symbol? x)))
44
45 (define-public (scheme? x) #t)
46
47
48 ;; moved list to end of lily.scm: then all type-predicates are
49 ;; defined.
50 (define type-p-name-alist '())
51
52 (define (match-predicate obj alist)
53   (if (null? alist)
54       "Unknown type"
55       (if (apply (caar alist) obj)
56           (cdar alist)
57           (match-predicate obj (cdr alist)))))
58
59 (define-public (object-type obj)
60   (match-predicate obj type-p-name-alist))
61
62 (define-public (object-type-name obj)
63   (type-name (match-predicate obj type-p-name-alist)))
64
65 (define-public (type-name predicate)
66   (assoc-get predicate type-p-name-alist "unknown"))