]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/paper-book.cc
Issue 4357/5: Remove Scheme listeners as they are just callbacks now.
[lilypond.git] / lily / paper-book.cc
index 3a6d4b1074079b5d555551a3d65ed67364f02111..fbaccb3babeb7be5e5e028ccbc343359323cdcd8 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2004--2014 Jan Nieuwenhuizen <janneke@gnu.org>
+  Copyright (C) 2004--2015 Jan Nieuwenhuizen <janneke@gnu.org>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -54,29 +54,19 @@ Paper_book::~Paper_book ()
 const char Paper_book::type_p_name_[] = "ly:paper-book?";
 
 SCM
-Paper_book::mark_smob (SCM smob)
+Paper_book::mark_smob ()
 {
-  Paper_book *b = (Paper_book *) SCM_CELL_WORD_1 (smob);
-  if (b->paper_)
-    scm_gc_mark (b->paper_->self_scm ());
-  if (b->parent_)
-    scm_gc_mark (b->parent_->self_scm ());
-  scm_gc_mark (b->header_);
-  scm_gc_mark (b->header_0_);
-  scm_gc_mark (b->pages_);
-  scm_gc_mark (b->performances_);
-  scm_gc_mark (b->scores_);
-  scm_gc_mark (b->bookparts_);
-  return b->systems_;
-}
-
-int
-Paper_book::print_smob (SCM smob, SCM port, scm_print_state *)
-{
-  Paper_book *b = (Paper_book *) SCM_CELL_WORD_1 (smob);
-  (void)b;
-  scm_puts ("#<Paper_book>", port);
-  return 1;
+  if (paper_)
+    scm_gc_mark (paper_->self_scm ());
+  if (parent_)
+    scm_gc_mark (parent_->self_scm ());
+  scm_gc_mark (header_);
+  scm_gc_mark (header_0_);
+  scm_gc_mark (pages_);
+  scm_gc_mark (performances_);
+  scm_gc_mark (scores_);
+  scm_gc_mark (bookparts_);
+  return systems_;
 }
 
 Output_def *
@@ -149,7 +139,7 @@ Paper_book::output_aux (SCM output_channel,
     }
   else
     {
-      if (scores_ == SCM_EOL)
+      if (scm_is_null (scores_))
         return 0;
       paper_->set_variable (ly_symbol2scm ("first-page-number"),
                             scm_from_long (*first_page_number));
@@ -175,7 +165,7 @@ Paper_book::output (SCM output_channel)
      with different line-widths) and why we need it at all.
   */
 
-  if (paper_->c_variable ("line-width") == SCM_UNDEFINED)
+  if (SCM_UNBNDP (paper_->c_variable ("line-width")))
     paper_->set_variable (ly_symbol2scm ("line-width"),
                           paper_->c_variable ("paper-width"));
 
@@ -198,7 +188,7 @@ Paper_book::output (SCM output_channel)
       SCM framework = ly_module_lookup (mod,
                                         ly_symbol2scm ("output-framework"));
 
-      if (framework != SCM_BOOL_F)
+      if (scm_is_true (framework))
         {
           SCM func = scm_variable_ref (framework);
           scm_call_4 (func,
@@ -217,7 +207,7 @@ Paper_book::output (SCM output_channel)
       SCM framework
         = ly_module_lookup (mod, ly_symbol2scm ("output-preview-framework"));
 
-      if (framework != SCM_BOOL_F)
+      if (scm_is_true (framework))
         {
           SCM func = scm_variable_ref (framework);
           scm_call_4 (func,
@@ -295,7 +285,7 @@ Paper_book::book_title ()
                       paper_->self_scm (),
                       scopes);
 
-  if (Stencil::unsmob (tit))
+  if (Stencil::is_smob (tit))
     title = *Stencil::unsmob (tit);
 
   if (!title.is_empty ())
@@ -324,7 +314,7 @@ Paper_book::score_title (SCM header)
                       paper_->self_scm (),
                       scopes);
 
-  if (Stencil::unsmob (tit))
+  if (Stencil::is_smob (tit))
     title = *Stencil::unsmob (tit);
 
   if (!title.is_empty ())
@@ -336,7 +326,7 @@ Paper_book::score_title (SCM header)
 void
 set_page_permission (SCM sys, SCM symbol, SCM permission)
 {
-  if (Paper_score *ps = dynamic_cast<Paper_score *> (Music_output::unsmob (sys)))
+  if (Paper_score *ps = Paper_score::unsmob (sys))
     {
       vector<Grob *> cols = ps->get_columns ();
       if (cols.size ())
@@ -380,7 +370,7 @@ set_system_penalty (SCM sys, SCM header)
 void
 set_labels (SCM sys, SCM labels)
 {
-  if (Paper_score *ps = dynamic_cast<Paper_score *> (Music_output::unsmob (sys)))
+  if (Paper_score *ps = Paper_score::unsmob (sys))
     {
       vector<Grob *> cols = ps->get_columns ();
       if (cols.size ())
@@ -454,7 +444,7 @@ Paper_book::get_system_specs ()
       if (ly_is_module (scm_car (s)))
         {
           header = scm_car (s);
-          if (header_0_ == SCM_EOL)
+          if (scm_is_null (header_0_))
             header_0_ = header;
         }
       else if (Page_marker *page_marker = Page_marker::unsmob (scm_car (s)))
@@ -484,7 +474,7 @@ Paper_book::get_system_specs ()
               if (scm_is_pair (system_specs))
                 set_system_penalty (scm_car (system_specs), header);
 
-              if (Prob::unsmob (title))
+              if (Prob::is_smob (title))
                 {
                   system_specs = scm_cons (title, system_specs);
                   Prob::unsmob (title)->unprotect ();
@@ -570,7 +560,7 @@ Paper_book::get_system_specs ()
 SCM
 Paper_book::systems ()
 {
-  if (systems_ != SCM_BOOL_F)
+  if (scm_is_true (systems_))
     return systems_;
 
   systems_ = SCM_EOL;
@@ -588,7 +578,7 @@ Paper_book::systems ()
       for (SCM s = specs; scm_is_pair (s); s = scm_cdr (s))
         {
           if (Paper_score * pscore
-              = dynamic_cast<Paper_score *> (Music_output::unsmob (scm_car (s))))
+              = Paper_score::unsmob (scm_car (s)))
             {
               SCM system_list
                 = scm_vector_to_list (pscore->get_paper_systems ());
@@ -620,9 +610,9 @@ Paper_book::systems ()
             {
               SCM perm = ps->get_property ("page-break-permission");
               Prob *next = Prob::unsmob (scm_cadr (s));
-              if (perm == SCM_EOL)
+              if (scm_is_null (perm))
                 next->set_property ("penalty", scm_from_int (10001));
-              else if (perm == ly_symbol2scm ("force"))
+              else if (scm_is_eq (perm, ly_symbol2scm ("force")))
                 next->set_property ("penalty", scm_from_int (-10001));
             }
         }
@@ -634,7 +624,7 @@ Paper_book::systems ()
 SCM
 Paper_book::pages ()
 {
-  if (SCM_BOOL_F != pages_)
+  if (scm_is_true (pages_))
     return pages_;
 
   pages_ = SCM_EOL;
@@ -663,7 +653,7 @@ Paper_book::pages ()
         scm_call_2 (post_process, paper_->self_scm (), pages_);
 
       /* set systems_ from the pages */
-      if (systems_ == SCM_BOOL_F)
+      if (scm_is_false (systems_))
         {
           systems_ = SCM_EOL;
           for (SCM p = pages_; scm_is_pair (p); p = scm_cdr (p))