2002-09-28 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ * 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.
}
#(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)))
}
#(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)))
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))
--- /dev/null
+
+
+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
+}
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.")
{
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);
}
+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;
}
(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 '()))