lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

add ly:book-set-header! (issue 5720062)


From: janek . lilypond
Subject: add ly:book-set-header! (issue 5720062)
Date: Sat, 03 Mar 2012 00:42:25 +0000

Reviewers: ,

Message:
From Jan-Peter Voigt, please review:

Hello list,

sorry for resending this, it might get lost, because I simply answered
to another thread with another subject.

now, we have a book-predicate and we are dealing with books in scheme.
Then we might want to set a header after creating a book.
There is a function ly:score-set-header!, which I copied and adapted for
the Book-class.
This patch compiled and works with the following snippet.

--snip--
\version "2.15.32"

bk = \book {
 \score {
   \relative c' {
     c4 e g b
   }
 }
}

#(let ((bh (eval-string "(define-module (a b))")))
    (eval '(define title "Hallo") bh)
    (ly:book-set-header! bk bh))

\book { \bk }
--snip--

Is this helpful for lily-devel?
And is there another (better) way of creating a module (for header
generation) on the fly in scheme?


Description:
add ly:book-set-header!

Add a scheme function ly:book-set-header! like ly:score-set-header!

Function is copied from score-scheme.cc to book-scheme.cc,
setting public member var header_ in class Book.

Please review this at http://codereview.appspot.com/5720062/

Affected files:
  M lily/book-scheme.cc


Index: lily/book-scheme.cc
diff --git a/lily/book-scheme.cc b/lily/book-scheme.cc
index 7f1026a3e79239c83a95c6144c47427adda4f5f1..ae505af3184b422f4c34ff9308f984b35acc4f19 100644
--- a/lily/book-scheme.cc
+++ b/lily/book-scheme.cc
@@ -156,6 +156,19 @@ LY_DEFINE (ly_book_header, "ly:book-header",
   return b->header_ ? b->header_ : SCM_BOOL_F;
 }

+LY_DEFINE (ly_book_set_header_x, "ly:book-set-header!",
+           2, 0, 0, (SCM book, SCM module),
+           "Set the book header.")
+{
+  LY_ASSERT_SMOB (Book, book, 1);
+  SCM_ASSERT_TYPE (ly_is_module (module), module, SCM_ARG2, __FUNCTION__,
+                   "module");
+
+  Book *b = unsmob_book (book);
+  b->header_ = (module);
+  return SCM_UNSPECIFIED;
+}
+
 LY_DEFINE (ly_book_scores, "ly:book-scores",
            1, 0, 0, (SCM book),
            "Return scores in @var{book}.")





reply via email to

[Prev in Thread] Current Thread [Next in Thread]