]> git.donarmstrong.com Git - lilypond.git/blob - scm/c++.scm
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--2002 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 (markup? x)
34   (or (string? x) (list? x)
35       (new-markup? x)))
36
37 (define-public (scheme? x) #t)
38
39 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
40 ;;
41 (define type-p-name-alist
42   `(
43    (,ly:dir? . "direction")
44    (,scheme? . "any type")
45    (,number-pair? . "pair of numbers")
46    (,ly:input-location? . "input location")   
47    (,ly:grob? . "grob (GRaphical OBject)")
48    (,grob-list? . "list of grobs")
49    (,ly:duration? . "duration")
50    (,pair? . "pair")
51    (,integer? . "integer")
52    (,list? . "list")
53    (,symbol? . "symbol")
54    (,string? . "string")
55    (,boolean? . "boolean")
56    (,ly:moment? . "moment")
57    (,ly:input-location? . "input location")
58    (,music-list? . "list of music")
59    (,ly:music? . "music")
60    (,number? . "number")
61    (,char? . "char")
62    (,input-port? . "input port")
63    (,output-port? . "output port")   
64    (,vector? . "vector")
65    (,procedure? . "procedure") 
66    (,boolean-or-symbol? . "boolean or symbol")
67    (,number-or-string? . "number or string")
68    (,markup? . "markup (list or string)")
69    (,number-or-grob? . "number or grob")
70    ))
71
72
73
74 (define (match-predicate obj alist)
75   (if (null? alist)
76       "Unknown type"
77       (if (apply (caar alist) obj)
78           (cdar alist)
79           (match-predicate obj (cdr alist))
80           )
81       ))
82
83 (define-public (object-type obj)
84   (match-predicate obj type-p-name-alist))
85
86 (define-public (type-name  predicate)
87   (let ((entry (assoc predicate type-p-name-alist)))
88     (if (pair? entry) (cdr entry)
89         "unknown"
90         )))