]> git.donarmstrong.com Git - lilypond.git/blob - scm/c++.scm
Add '-dcrop' option to ps and svg backends
[lilypond.git] / scm / c++.scm
1 ;;;; This file is part of LilyPond, the GNU music typesetter.
2 ;;;;
3 ;;;; Copyright (C) 1998--2015 Jan Nieuwenhuizen <janneke@gnu.org>
4 ;;;;                 Han-Wen Nienhuys <hanwen@xs4all.nl>
5 ;;;;
6 ;;;; LilyPond is free software: you can redistribute it and/or modify
7 ;;;; it under the terms of the GNU General Public License as published by
8 ;;;; the Free Software Foundation, either version 3 of the License, or
9 ;;;; (at your option) any later version.
10 ;;;;
11 ;;;; LilyPond is distributed in the hope that it will be useful,
12 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ;;;; GNU General Public License for more details.
15 ;;;;
16 ;;;; You should have received a copy of the GNU General Public License
17 ;;;; along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18
19 ;;; Note: this file can't be used without LilyPond executable
20
21
22 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
23 ;; type predicates.
24 (define-public (number-pair? x)
25   (and (pair? x)
26        (number? (car x)) (number? (cdr x))))
27
28 (define-public (number-pair-list? x)
29   (and (list? x)
30        (every number-pair? x)))
31
32 (define-public (fraction? x)
33   (and (pair? x)
34        (index? (car x)) (index? (cdr x))))
35
36 (define-public (rational-or-procedure? x)
37   (or
38    (and (rational? x) (exact? x))
39    (procedure? x)))
40
41 (define-public (number-or-grob? x)
42   (or (ly:grob? x) (number? x)))
43
44 (define-public (grob-list? x)
45   (list? x))
46
47 (define-public (number-list? x)
48   (and (list? x) (every number? x)))
49
50 (define-public (index? x)
51   (and (integer? x) (>= x 0)))
52
53 (define-public (moment-pair? x)
54   (and (pair? x)
55        (ly:moment? (car x)) (ly:moment? (cdr x))))
56
57 (define-public (boolean-or-number? x)
58   (or (boolean? x) (number? x)))
59
60 (define-public (boolean-or-symbol? x)
61   (or (boolean? x) (symbol? x)))
62
63 (define-public (key? x)
64   (or (symbol? x) (index? x)))
65
66 (define-public (key-list? x)
67   (and (list? x) (every key? x)))
68
69 (define-public (key-list-or-music? x)
70   (if (list? x)
71       (every key? x)
72       (ly:music? x)))
73
74 (define-public (key-list-or-symbol? x)
75   (if (list? x)
76       (every key? x)
77       (symbol? x)))
78
79 (define-public (symbol-list? x)
80   (and (list? x) (every symbol? x)))
81
82 (define-public (symbol-list-or-music? x)
83   (if (list? x)
84       (every symbol? x)
85       (ly:music? x)))
86
87 (define-public (string-or-symbol? x)
88   (or (string? x) (symbol? x)))
89
90 (define-public (number-or-string? x)
91   (or (number? x) (string? x)))
92
93 (define-public (number-or-markup? x)
94   (or (number? x) (markup? x)))
95
96 (define-public (string-or-pair? x)
97   (or (string? x) (pair? x)))
98
99 (define-public (string-or-music? x)
100   (or (string? x) (ly:music? x)))
101
102 (define-public (number-or-pair? x)
103   (or (number? x) (pair? x)))
104
105 (define-public (cheap-list? x)
106   (or (pair? x) (null? x)))
107
108 (define-public (symbol-list-or-symbol? x)
109   (if (list? x)
110       (every symbol? x)
111       (symbol? x)))
112
113 (define-public (scheme? x) #t)
114
115
116 (define-public (void? x)
117   (unspecified? x))
118
119 ;; moved list to end of lily.scm: then all type-predicates are
120 ;; defined.
121 (define type-p-name-alist '())
122
123 (define (match-predicate obj alist)
124   (if (null? alist)
125       "Unknown type"
126       (if (apply (caar alist) obj)
127           (cdar alist)
128           (match-predicate obj (cdr alist)))))
129
130 (define-public (object-type obj)
131   (match-predicate obj type-p-name-alist))
132
133 (define-public (object-type-name obj)
134   (type-name (match-predicate obj type-p-name-alist)))
135
136 (define-public (type-name predicate)
137   (let ((entry (assoc predicate type-p-name-alist)))
138     (if (pair? entry) (cdr entry)
139         (string-trim-right
140          (symbol->string (procedure-name predicate))
141          #\?))))