#include "lily-guile.hh"
SCM ly_make_music_function (SCM, SCM);
+SCM make_music_function (SCM, SCM);
+
SCM get_music_function_transform (SCM);
bool is_music_function (SCM);
--- /dev/null
+#include "music-function.hh"
+
+LY_DEFINE (ly_music_function_p, "ly:music-function?", 1, 0, 0,
+ (SCM x),
+ "Is @var{x} an @code{music-function}?")
+{
+ return is_music_function (x) ? SCM_BOOL_T : SCM_BOOL_F;
+}
+
+LY_DEFINE (ly_music_function_extract, "ly:music-function-extract", 1, 0, 0,
+ (SCM x),
+ "Return the Scheme function inside @var{x}")
+{
+ SCM_ASSERT_TYPE(is_music_function (x), x, SCM_ARG1, __FUNCTION__,
+ "music function");
+
+ return SCM_CELL_OBJECT_1(x);
+}
+
+LY_DEFINE (ly_make_music_function, "ly:make-music-function", 2, 0, 0,
+ (SCM signature, SCM func),
+ "Make a function to process music, to be used for the "
+ "parser. @code{func} is the function, and @code{signature} describes "
+ "Its arguments. @code{signature} is a list containing either "
+ "@code{ly:music?} predicates or other type predicates.")
+{
+ SCM_ASSERT_TYPE(ly_is_procedure (func), func, SCM_ARG1, __FUNCTION__, "function");
+ return make_music_function (signature, func);
+}
+
return 1;
}
-LY_DEFINE (ly_make_music_function, "ly:make-music-function", 2, 0, 0,
- (SCM signature, SCM func),
- "Make a function to process music, to be used for the "
- "parser. @code{func} is the function, and @code{signature} describes "
- "Its arguments. @code{signature} is a list containing either "
- "@code{ly:music?} predicates or other type predicates.")
-{
- scm_set_object_property_x (func, ly_symbol2scm ("music-function-signature"),
- signature);
-
- SCM_RETURN_NEWSMOB (music_function_tag, func);
-}
-
bool
is_music_function (SCM music_function)
{
scm_set_smob_print (music_function_tag, print_music_function);
}
+SCM
+make_music_function (SCM signature, SCM func)
+{
+ scm_set_object_property_x (func, ly_symbol2scm ("music-function-signature"),
+ signature);
+
+ SCM_RETURN_NEWSMOB (music_function_tag, func);
+}
+
ADD_SCM_INIT_FUNC (music_function_tag, init_music_function);
+
(define-public (object-type obj)
(match-predicate obj type-p-name-alist))
+
(define-public (object-type-name obj)
(type-name (match-predicate obj type-p-name-alist)))
+
(define-public (type-name predicate)
(let ((entry (assoc predicate type-p-name-alist)))
(if (pair? entry) (cdr entry)
--- /dev/null
+(use-modules (ice-9 format))
+
+(define (document-music-function music-func-pair)
+ (let*
+ ((name-sym (car music-func-pair))
+ (music-func (cdr music-func-pair))
+ (func (ly:music-function-extract music-func))
+ (arg-names
+ (map symbol->string
+ (cddr (cadr (procedure-source func)))))
+ (doc (procedure-documentation func))
+ (sign (object-property func 'music-function-signature))
+ (type-names (map type-name sign))
+
+ ;; C&P
+ (signature (zip arg-names arg-names type-names))
+ (signature-str
+ (string-join
+ (map (lambda (x) (format "@var{~a} (~a)"
+ (car x)
+ (cadr x)))
+
+ (zip arg-names type-names)))))
+
+ (format
+
+ "\n
+@item @code{~a} - ~a\n
+@findex ~a
+
+~a\n\n"
+
+ name-sym signature-str
+ name-sym
+ (if doc doc "(undocumented; fixme)"))))
+
+
+
+(define (document-object obj-pair)
+ (cond
+ ((ly:music-function? (cdr obj-pair)) (document-music-function obj-pair))
+ (else
+ #f)))
+
+(define-public (identifiers-doc-string)
+ (format
+ "@table @asis
+~a
+@end table
+"
+ (string-join
+ (filter
+ identity
+ (map
+ document-object
+ (ly:module->alist (current-module)))))))
(cddr (cadr (procedure-source func)))))
(sig-type-names (map type-name sig))
- (signature (zip arg-names sig-type-names))
(signature-str
(string-join
(map (lambda (x) (string-append
"document-functions.scm"
"document-translation.scm"
"document-music.scm"
+ "document-identifiers.scm"
"document-backend.scm"
"document-markup.scm"))
(markup-doc-string)
(open-output-file "markup-commands.tely"))
+(display
+ (identifiers-doc-string)
+ (open-output-file "identifiers.tely"))
+
(display
(backend-properties-doc-string all-user-grob-properties)
(if (ly:get-option 'verbose)
(ly:progress "[~A" file-name))
(if (not file-name)
- (ly:error (_ "Can't find ~A" x)))
+ (ly:error (_ "Can't find ~A") x))
(primitive-load file-name)
(if (ly:get-option 'verbose)
(ly:progress "]"))))