]> git.donarmstrong.com Git - lilypond.git/commitdiff
Get rid off the markup-command-signatures hash: only use object
authorNicolas Sceaux <nicolas.sceaux@free.fr>
Mon, 1 Jan 2007 17:06:54 +0000 (18:06 +0100)
committerNicolas Sceaux <nicolas.sceaux@free.fr>
Mon, 1 Jan 2007 17:06:54 +0000 (18:06 +0100)
properties for storing markup command signatures (accessors
accordingly rewritten).

input/regression/markup-scheme.ly
scm/markup.scm

index af1b4f912185e211a76db2c3fcc89d9c491c3050..e4589d4a9bd9302a855a179c56de59de0998e752 100644 (file)
@@ -51,7 +51,7 @@ For maintenance reasons, we don't excercise the entire markup command set.
     \dynamic sfzp
     \huge { "A" \smaller "A" \smaller \smaller "A"
            \smaller \smaller \smaller "A" }
-    \sub "alike"
+    \larger \sub "alike"
   }    
   \break
   f'1-#(markup* 
@@ -74,5 +74,5 @@ For maintenance reasons, we don't excercise the entire markup command set.
        #:dynamic "sfzp"
        #:huge #:line ("A" #:smaller "A" #:smaller #:smaller "A" 
                       #:smaller #:smaller #:smaller "A")
-       #:sub "alike")
+       #:larger #:sub "alike")
 }
index f1e32402366a50b5cfa05aebcf71efb469f6c099..c786c16890f1b64bbf7c80d3d9d7a131165a31b5 100644 (file)
@@ -112,7 +112,7 @@ against SIGNATURE, reporting MAKE-NAME as the user-invoked function.
   "The `markup' macro provides a lilypond-like syntax for building markups.
 
  - #:COMMAND is used instead of \\COMMAND
- - #:line ( ... ) is used instead of \line { ... }
+ - #:line ( ... ) is used instead of \\line { ... }
  - etc.
 
 Example:
@@ -239,44 +239,28 @@ Use `markup*' in a \\notemode context."
 ;;; (markup-command-keyword raise-markup) ==> "scheme0-markup1"
 ;;; 
 
-(define markup-command-signatures (make-hash-table 50))
+(define-public (markup-command-keyword markup-command)
+  "Return markup-command's argument keyword, ie a string describing the command
+  arguments, eg. \"scheme0markup1\""
+  (object-property markup-command 'markup-keyword))
 
-(define (markup-command-signature-ref markup-command)
-  "Return markup-command's signature, e.g. (number? markup?).
-markup-command may be a procedure."
-  (let ((sig-key (hashq-ref markup-command-signatures
-                            markup-command)))
-    (if sig-key (car sig-key) #f)))
+(define-public (markup-command-signature-ref markup-command)
+  "Return markup-command's signature (the 'markup-signature object property)"
+  (object-property markup-command 'markup-signature))
 
-(define-public (markup-command-keyword markup-command)
-  "Return markup-command's keyword, e.g. \"scheme0markup1\".
-markup-command may be a procedure."
-  (let ((sig-key (hashq-ref markup-command-signatures
-                            markup-command)))
-    (if sig-key (cdr sig-key) #f)))
-
-(define (markup-command-signatureset! markup-command signature)
-  "Set markup-command's signature. markup-command must be a named procedure.
-Also set markup-signature and markup-keyword object properties."
-  (hashq-set! markup-command-signatures
-              markup-command
-              (cons signature (markup-signature-to-keyword signature)))
-  ;; these object properties are still in use somewhere
+(define-public (markup-command-signature-set! markup-command signature)
+  "Set markup-command's signature and keyword (as object properties)"
   (set-object-property! markup-command 'markup-signature signature)
-  (set-object-property! markup-command 'markup-keyword (markup-signature-to-keyword signature)))
-  
-(define-public markup-command-signature
-  (make-procedure-with-setter markup-command-signature-ref markup-command-signatureset!))
+  (set-object-property! markup-command 'markup-keyword 
+                        (markup-signature-to-keyword signature))
+  signature)
 
-(define (markup-symbol-to-proc markup-sym)
-  "Return the markup command procedure which name is `markup-sym', if any."
-  (hash-fold (lambda (key val prev)
-               (or prev
-                   (if (eqv? (procedure-name key) markup-sym) key #f)))
-             #f
-             markup-command-signatures))
+(define-public markup-command-signature
+  (make-procedure-with-setter markup-command-signature-ref
+                              markup-command-signature-set!))
 
-(define-public markup-function-list '())
+;; For documentation purposes
+(define-public markup-function-list (list))
 
 (define-public (markup-signature-to-keyword sig)
   " (A B C) -> a0-b1-c2 "
@@ -299,8 +283,13 @@ Also set markup-signature and markup-keyword object properties."
                          "-"))))
 
 (define-public (lookup-markup-command code)
-  (let ((proc (markup-symbol-to-proc (string->symbol (string-append code "-markup")))))
-    (and proc (cons proc (markup-command-keyword proc)))))
+  (let ((proc (catch 'misc-error
+                (lambda ()
+                  (module-ref (current-module)
+                              (string->symbol (format #f "~a-markup" code))))
+                (lambda (key . args) #f))))
+    (and (procedure? proc)
+         (cons proc (markup-command-keyword proc)))))
 
 ;;;;;;;;;;;;;;;;;;;;;;
 ;;; used in parser.yy to map a list of markup commands on markup arguments