]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/define-event-classes.scm
Doc: NR 2.1 Vocal: Switching to an alternative melody
[lilypond.git] / scm / define-event-classes.scm
index e1f3b4aa33b3122aff4d30b256c079c83bc6b8fc..f631bcddc0b9f8365eb3d8bf8688e10f810fccf2 100644 (file)
     (cdr rel)))
  event-classes)
 
+(define-public (define-event-class leaf heritage)
+  (cond
+   ((not (eq? leaf (car heritage)))
+    (ly:warning (_ "All classes must be the last in their matrilineal line.")))
+   ((not (equal? (cdr heritage)
+                 (list-head (hashq-ref ancestor-lookup (cadr heritage) '())
+                            (length (cdr heritage)))))
+    (ly:warning (_ "All classes must have a well-defined pedigree in the existing class hierarchy.")))
+   (else (hashq-set! ancestor-lookup
+                     leaf
+                     (cons leaf
+                           (hashq-ref ancestor-lookup
+                                      (cadr heritage)
+                                      '()))))))
+
 ;; TODO: Allow entering more complex classes, by taking unions.
 (define-public (ly:make-event-class leaf)
  (hashq-ref ancestor-lookup leaf))