lilypond-devel
[Top][All Lists]
Advanced

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

Re: Adds Scheme function for spring constructor. (issue 5306050)


From: mtsolo
Subject: Re: Adds Scheme function for spring constructor. (issue 5306050)
Date: Sun, 23 Oct 2011 10:33:39 +0000

Reviewers: Bertrand Bordage, Neil Puttock, dak,

Message:
Hey all,

I've made all of the requested changes save Spring::equal_p, as I can't
see a clear consensus about what changes need to be made here.  As this
problem is outside the purview of this patch, it may be worth it to
propose another patch that treats this issue (and others like it in
other smobs if such issues exist) separately.

Cheers,
MS

Description:
Adds Scheme function for spring constructor.

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

Affected files:
  M lily/spring-smob.cc
  M scm/lily.scm


Index: lily/spring-smob.cc
diff --git a/lily/spring-smob.cc b/lily/spring-smob.cc
index 8e263d06944bd406b3bbff5a7a12165ce3f7a917..0f22f06778b199664ceaf81cca6e1a07403b4383 100644
--- a/lily/spring-smob.cc
+++ b/lily/spring-smob.cc
@@ -42,3 +42,41 @@ Spring::equal_p (SCM a, SCM b)
   return a == b ? SCM_BOOL_T : SCM_BOOL_F;
 }

+LY_DEFINE (ly_make_spring, "ly:make-spring",
+           2, 0, 0, (SCM ideal, SCM min_dist),
+           "Make a spring.  @var{ideal} is the ideal distance of the"
+           " spring, and @var{min-dist} is the minimum distance.")
+{
+  LY_ASSERT_TYPE (scm_is_number, ideal, 1);
+  LY_ASSERT_TYPE (scm_is_number, min_dist, 2);
+
+  Spring s (scm_to_double (ideal), scm_to_double (min_dist));
+
+  return s.smobbed_copy ();
+}
+
+LY_DEFINE (ly_spring_set_inverse_compress_strength_x, "ly:spring-set-inverse-compress-strength!",
+           2, 0, 0, (SCM spring, SCM strength),
+           "Set the inverse compress @var{strength} of @var{spring}.")
+{
+  LY_ASSERT_SMOB (Spring, spring, 1);
+  LY_ASSERT_TYPE (scm_is_number, strength, 2);
+
+  Spring *s = unsmob_spring (spring);
+  s->set_inverse_compress_strength (scm_to_double (strength));
+  return s->smobbed_copy ();
+}
+
+LY_DEFINE (ly_spring_set_inverse_stretch_strength_x, "ly:spring-set-inverse-stretch-strength!",
+           2, 0, 0, (SCM spring, SCM strength),
+           "Set the inverse stretch @var{strength} of @var{spring}.")
+{
+  LY_ASSERT_SMOB (Spring, spring, 1);
+  LY_ASSERT_TYPE (scm_is_number, strength, 2);
+
+  Spring *s = unsmob_spring (spring);
+  s->set_inverse_stretch_strength (scm_to_double (strength));
+  return s->smobbed_copy ();
+}
+
+IMPLEMENT_TYPE_P (Spring, "ly:spring?");
\ No newline at end of file
Index: scm/lily.scm
diff --git a/scm/lily.scm b/scm/lily.scm
index 88f1183b926dcf19e4cabcc9cc4f373a335a1e67..1e68b78a15e28b44fec1274a6580877a042d0763 100644
--- a/scm/lily.scm
+++ b/scm/lily.scm
@@ -575,6 +575,7 @@ LilyPond safe mode. The syntax is the same as `define*-public'."
     (,ly:skyline-pair? . "pair of skylines")
     (,ly:source-file? . "source file")
     (,ly:spanner? . "spanner")
+    (,ly:spring? . "spring")
     (,ly:stencil? . "stencil")
     (,ly:stream-event? . "stream event")
     (,ly:translator? . "translator")





reply via email to

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