From fddf7362622bf78f00c3abc6306076cbe244a35b Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 28 Sep 2002 15:51:09 +0000 Subject: [PATCH] *** empty log message *** --- ChangeLog | 5 +++++ input/test/add-staccato.ly | 4 ++-- input/test/add-text-script.ly | 4 ++-- input/test/music-creation.ly | 4 ---- input/test/to-xml.ly | 27 +++++++++++++++++++++++++++ lily/music.cc | 15 +++++++++++++++ lily/parse-scm.cc | 15 +++++++++++++-- scm/music-types.scm | 2 +- 8 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 input/test/to-xml.ly diff --git a/ChangeLog b/ChangeLog index 64a4fd9a93..70cc1d1fd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2002-09-28 Han-Wen Nienhuys + * scm/to-xml.scm: new file. + + * input/test/to-xml.ly (fooBar): demo of what is possible with the + new Input representation: dump music as XML. + * scm/engraver-documentation-lib.scm (engraver-accepts-music-types?): add links from music to engraver, from music-type to engraver. diff --git a/input/test/add-staccato.ly b/input/test/add-staccato.ly index 19abe00052..15268357b4 100644 --- a/input/test/add-staccato.ly +++ b/input/test/add-staccato.ly @@ -8,12 +8,12 @@ one would not use scm constructs. See separate-staccato.ly first." } #(define (make-script x) - (let ((m (make-music-by-name "Articulation_req"))) + (let ((m (make-music-by-name 'ArticulationEvent))) (ly-set-mus-property! m 'articulation-type x) m)) #(define (add-script m x) - (if (equal? (make-music-by-name m) "Request_chord") + (if (equal? (ly-get-mus-property m 'name) 'RequestChord) (ly-set-mus-property! m 'elements (cons (make-script x) (ly-get-mus-property m 'elements))) diff --git a/input/test/add-text-script.ly b/input/test/add-text-script.ly index b800ad259a..bec0a15910 100644 --- a/input/test/add-text-script.ly +++ b/input/test/add-text-script.ly @@ -9,13 +9,13 @@ create, then write a function that will build the structure for you." } #(define (make-text-script x) - (let ((m (make-music-by-name "Text_script_req"))) + (let ((m (make-music-by-name 'TextScriptEvent))) (ly-set-mus-property! m 'text-type 'finger) (ly-set-mus-property! m 'text x) m)) #(define (add-text-script m x) - (if (equal? (ly-music-name m) "Request_chord") + (if (equal? (ly-music-name m) 'RequestChord) (ly-set-mus-property! m 'elements (cons (make-text-script x) (ly-get-mus-property m 'elements))) diff --git a/input/test/music-creation.ly b/input/test/music-creation.ly index 00e12dd2ce..647005b7db 100644 --- a/input/test/music-creation.ly +++ b/input/test/music-creation.ly @@ -15,15 +15,11 @@ ml)) #(define (make-note elts) - ;; huh? lily-guile: Could not find music type `Request_chord' - ;;(let* ((ml (make-music-by-name "Request_chord"))) (let* ((ml (make-music-by-name 'RequestChord))) (ly-set-mus-property! ml 'elements elts) ml)) #(define (seq-music-list elts) - ;; huh? lily-guile: Could not find music type `Sequential_music' - ;;(let* ((ml (make-music-by-name "Sequential_music"))) (let* ((ml (make-music-by-name 'SequentialMusic))) (ly-set-mus-property! ml 'elements elts) ml)) diff --git a/input/test/to-xml.ly b/input/test/to-xml.ly new file mode 100644 index 0000000000..04938d83fe --- /dev/null +++ b/input/test/to-xml.ly @@ -0,0 +1,27 @@ + + +fooBar = \notes { < c''4 \\ g'4 > } + +#(ly-set-parse-protect #f) +#(load-from-path "to-xml.scm") + +#(music-to-xml fooBar (current-output-port)) + +\header { + texidoc = + + #(string-append + "The input representation is very generic. It + should not be hard to convert it to XML or a similar format:\n\n" + + "@example\n" + (call-with-output-string + (lambda (p) (music-to-xml fooBar p)) + ) + "@end example" ) +} + + +\score { +\fooBar +} diff --git a/lily/music.cc b/lily/music.cc index d95603ad81..f72290d546 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -270,6 +270,21 @@ WARNING: deprecated; use make-music-by-name. return s; } +// to do property args +LY_DEFINE(ly_get_mutable_properties, + "ly-get-mutable-properties", 1, 0, 0, (SCM mus), + " +Return an alist signifying the mutable properties of @var{mus}. +The immutable properties are not available; they should be initialized +by the functions make-music-by-name function. + ") +{ + Music *m = unsmob_music (mus); + SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__, "music"); + + return m->get_property_alist (true); +} + LY_DEFINE(ly_music_list_p,"music-list?", 1, 0, 0, (SCM l),"Type predicate: return true if @var{l} is a list of music objects.") { diff --git a/lily/parse-scm.cc b/lily/parse-scm.cc index 9c49be4b5e..694872a335 100644 --- a/lily/parse-scm.cc +++ b/lily/parse-scm.cc @@ -21,7 +21,6 @@ internal_ly_parse_scm (Parse_start * ps) int off = ps->start_location_.defined_str0_ - sf->to_str0(); - scm_seek (port, scm_long2num (off), scm_long2num (SEEK_SET)); SCM from = scm_ftell (port); @@ -114,14 +113,26 @@ protected_ly_parse_scm (Parse_start *ps) } +static bool protect = true; + +LY_DEFINE(set_parse_protect, "ly-set-parse-protect", + 1,0,0, (SCM t), + "If protection is switched on, errors in inline scheme are caught.") +{ + protect = (t == SCM_BOOL_T); + return SCM_UNSPECIFIED; +} + SCM ly_parse_scm (char const* s, int *n, Input i) { + Parse_start ps ; ps.str = s; ps.start_location_ = i; - SCM ans = protected_ly_parse_scm (&ps); + SCM ans = protect ? protected_ly_parse_scm (&ps) + : internal_ly_parse_scm (&ps); *n = ps.nchars; return ans; } diff --git a/scm/music-types.scm b/scm/music-types.scm index 3e5ca4a78b..a33ad0934c 100644 --- a/scm/music-types.scm +++ b/scm/music-types.scm @@ -483,7 +483,7 @@ (define-public (make-music-by-name x) (if (not (symbol? x)) - (misc-error "Not a symbol: ~s" x)) + (error (format "Not a symbol: ~a" x))) (let* ( (props (hashq-ref music-name-to-property-table x '())) -- 2.39.5