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