]> git.donarmstrong.com Git - lilypond.git/blob - scm/c++.scm
* Another grand 2003 update.
[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--2003 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;; Han-Wen Nienhuys <hanwen@cs.uu.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 (define-public (number-or-grob? x)
17   (or (ly:grob? x) (number? x))
18   )
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 (number-or-string? x)
31   (or (number? x) (string? x)))
32
33 (define-public (scheme? x) #t)
34
35
36
37 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
38 ;;
39
40
41 ;; moved list to end of lily.scm: then all type-predicates are
42 ;; defined.
43 (define type-p-name-alist '()) 
44
45 (define (match-predicate obj alist)
46   (if (null? alist)
47       "Unknown type"
48       (if (apply (caar alist) obj)
49           (cdar alist)
50           (match-predicate obj (cdr alist))
51           )
52       ))
53
54 (define-public (object-type obj)
55   (match-predicate obj type-p-name-alist))
56
57 (define-public (type-name  predicate)
58   (let ((entry (assoc predicate type-p-name-alist)))
59     (if (pair? entry) (cdr entry)
60         "unknown"
61         )))