lilypond-devel
[Top][All Lists]
Advanced

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

Add scheme procedure that gets paper column rank (issue 281020043 by add


From: paulwmorris
Subject: Add scheme procedure that gets paper column rank (issue 281020043 by address@hidden)
Date: Tue, 15 Dec 2015 22:05:16 +0000

Reviewers: ,

Message:
Please review.

There is already a Paper_column::get_rank for C++ use, so I created a
Scheme version alongside it, but I'm not sure if this is the best
approach.  I named the Scheme one "get_rank_number" to differentiate the
two.  Any suggestions are welcome.

Background: I was working on a Scheme rewrite of
ly:ledger-line-spanner::print, to allow for some local customizations,
but it uses the rank of paper columns and currently there seems to be no
way to access rank from scheme.

Description:
Add scheme procedure that gets paper column rank

Please review this at https://codereview.appspot.com/281020043/

Affected files (+12, -0 lines):
  M lily/include/paper-column.hh
  M lily/paper-column.cc


Index: lily/include/paper-column.hh
diff --git a/lily/include/paper-column.hh b/lily/include/paper-column.hh
index f1cb01e740685bcf11f9463e82a42466501d01f0..d4e68edc656438953c30633689aecab14bed41c4 100644
--- a/lily/include/paper-column.hh
+++ b/lily/include/paper-column.hh
@@ -49,6 +49,7 @@ public:

   DECLARE_SCHEME_CALLBACK (print, (SCM));
   DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM));
+  DECLARE_SCHEME_CALLBACK (get_rank_number, (SCM));

   static int get_rank (Grob const *);
   static bool is_musical (Grob *);
Index: lily/paper-column.cc
diff --git a/lily/paper-column.cc b/lily/paper-column.cc
index da3807c31d6f4ddb33fb75edf69c24ec3baf8175..f0b991780f81f1d5934642de1ab123f092f0bbdd 100644
--- a/lily/paper-column.cc
+++ b/lily/paper-column.cc
@@ -57,6 +57,17 @@ Paper_column::get_rank (Grob const *me)
   return dynamic_cast<Paper_column const *> (me)->rank_;
 }

+MAKE_DOCUMENTED_SCHEME_CALLBACK (Paper_column, get_rank_number, 1,
+                                 "Get the @code{rank number} of a"
+                                 " @code{PaperColumn} or"
+                                 " @code{NonMusicalPaperColumn}.");
+SCM
+Paper_column::get_rank_number (SCM grob)
+{
+  Grob *me = unsmob<Grob> (grob);
+  return scm_from_int (Paper_column::get_rank (me));
+}
+
 void
 Paper_column::set_rank (int rank)
 {





reply via email to

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