]> git.donarmstrong.com Git - lilypond.git/blob - scm/c++.scm
Issue 3313: Add the command \offset
[lilypond.git] / scm / c++.scm
1 ;;;; This file is part of LilyPond, the GNU music typesetter.
2 ;;;;
3 ;;;; Copyright (C) 1998--2012 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 (number-or-grob? x)
37   (or (ly:grob? x) (number? x)))
38
39 (define-public (grob-list? x)
40   (list? x))
41
42 (define-public (number-list? x)
43   (and (list? x) (every number? x)))
44
45 (define-public (index? x)
46   (and (integer? x) (>= x 0)))
47
48 (define-public (moment-pair? x)
49   (and (pair? x)
50        (ly:moment? (car x)) (ly:moment? (cdr x))))
51
52 (define-public (boolean-or-symbol? x)
53   (or (boolean? x) (symbol? x)))
54
55 (define-public (symbol-list? x)
56   (and (list? x) (every symbol? x)))
57
58 (define-public (symbol-list-or-music? x)
59   (if (list? x)
60       (every symbol? x)
61       (ly:music? x)))
62
63 (define-public (string-or-symbol? x)
64   (or (string? x) (symbol? x)))
65
66 (define-public (number-or-string? x)
67   (or (number? x) (string? x)))
68
69 (define-public (number-or-markup? x)
70   (or (number? x) (markup? x)))
71
72 (define-public (string-or-pair? x)
73   (or (string? x) (pair? x)))
74
75 (define-public (string-or-music? x)
76   (or (string? x) (ly:music? x)))
77
78 (define-public (number-or-pair? x)
79   (or (number? x) (pair? x)))
80
81 (define-public (cheap-list? x)
82   (or (pair? x) (null? x)))
83
84 (define-public (symbol-list-or-symbol? x)
85   (if (list? x)
86       (every symbol? x)
87       (symbol? x)))
88
89 (define-public (scheme? x) #t)
90
91 (define-public (symbol-or-boolean? x)
92   (or (symbol? x) (boolean? x)))
93
94 (define-public (void? x)
95   (unspecified? x))
96
97 ;; moved list to end of lily.scm: then all type-predicates are
98 ;; defined.
99 (define type-p-name-alist '())
100
101 (define (match-predicate obj alist)
102   (if (null? alist)
103       "Unknown type"
104       (if (apply (caar alist) obj)
105           (cdar alist)
106           (match-predicate obj (cdr alist)))))
107
108 (define-public (object-type obj)
109   (match-predicate obj type-p-name-alist))
110
111 (define-public (object-type-name obj)
112   (type-name (match-predicate obj type-p-name-alist)))
113
114 (define-public (type-name predicate)
115   (let ((entry (assoc predicate type-p-name-alist)))
116     (if (pair? entry) (cdr entry)
117         (string-trim-right
118          (symbol->string (procedure-name predicate))
119          #\?))))