1 ;;;; stream-event-classes.scm -- define the tree of stream-event classes.
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2005-2006 Erik Sandberg <mandolaerik@gmail.com>
8 (use-modules (srfi srfi-1))
10 ;; Event class hierarchy. Each line is on the form ((List of children) . Parent)
12 '(((StreamEvent) . '())
13 ((RemoveContext ChangeParent Override Revert UnsetProperty SetProperty
14 MusicEvent CreateContext Prepare OneTimeStep Finish) . StreamEvent)
17 ;; Each class will be defined as
18 ;; (class parent grandparent .. )
19 ;; so that (eq? (cdr class) parent) holds.
24 (primitive-eval `(define ,type (cons ',type ,(cdr rel)))))
28 ;; TODO: Allow entering more complex classes, by taking unions.
29 (define-public (ly:make-event-class leaf)
30 (primitive-eval leaf))
32 (defmacro-public make-stream-event (expr)
33 (Stream_event::undump (primitive-eval (list 'quasiquote expr))))
37 ;; Special case for lists reduces stack consumption.
38 ((list? e) (map simplify e))
39 ((pair? e) (cons (simplify (car e))
42 (list 'unquote `(make-stream-event ,(simplify (Stream_event::dump e)))))
44 (list 'unquote (music->make-music e)))
46 (list 'unquote `(ly:make-moment
47 ,(ly:moment-main-numerator e)
48 ,(ly:moment-main-denominator e)
49 . ,(if (eq? 0 (ly:moment-grace-numerator e))
51 (list (ly:moment-grace-numerator e)
52 (ly:moment-grace-denominator e))))))
54 (list 'unquote `(ly:make-duration
56 ,(ly:duration-dot-count e)
57 ,(car (ly:duration-factor e))
58 ,(cdr (ly:duration-factor e)))))
60 (list 'unquote `(ly:make-pitch
62 ,(ly:pitch-notename e)
63 ,(ly:pitch-alteration e))))
64 ((ly:input-location? e)
65 (list 'unquote '(ly:dummy-input-location)))
68 (define-public (ly:simplify-scheme e)
69 (list 'quasiquote (simplify e))
72 ; used by lily/dispatcher.cc
73 (define-public (car< a b) (< (car a) (car b)))