Re: Adds Scheme function for spring constructor. (issue 5306050)
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") ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Adds Scheme function for spring constructor. (issue 5306050)
On 21 October 2011 12:39, wrote: > For me, this function is totally useless. If we want to check whether > they are equal, we use scm_equal_p, if we want to see whether they are > the same object, we use scm_eqv_p. > > Besides, I can't find any use for this function with git grep. I think Guile requires it. The documentation in lily/include/smobs.hh says all smobs should implement an equal_p () function. Cheers, Neil ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Adds Scheme function for spring constructor. (issue 5306050)
On 2011/10/21 11:39:41, Bertrand Bordage wrote: http://codereview.appspot.com/5306050/diff/2001/lily/spring-smob.cc File lily/spring-smob.cc (left): http://codereview.appspot.com/5306050/diff/2001/lily/spring-smob.cc#oldcode42 lily/spring-smob.cc:42: return a == b ? SCM_BOOL_T : SCM_BOOL_F; On 2011/10/21 11:27:35, dak wrote: > scm_is_true (scm_is_eqv (a, b)) You mean scm_is_true(scm_eqv_p (a, b))? :) Yes. For me, this function is totally useless. If we want to check whether they are equal, we use scm_equal_p, if we want to see whether they are the same object, we use scm_eqv_p. Cough, cough. Besides, I can't find any use for this function with git grep. Then it may be saner to just remove it instead of thinking about what we would like it to do if we wanted it to do something. http://codereview.appspot.com/5306050/ ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Adds Scheme function for spring constructor. (issue 5306050)
http://codereview.appspot.com/5306050/diff/2001/lily/spring-smob.cc File lily/spring-smob.cc (left): http://codereview.appspot.com/5306050/diff/2001/lily/spring-smob.cc#oldcode42 lily/spring-smob.cc:42: return a == b ? SCM_BOOL_T : SCM_BOOL_F; On 2011/10/21 11:27:35, dak wrote: scm_is_true (scm_is_eqv (a, b)) You mean scm_is_true(scm_eqv_p (a, b))? :) For me, this function is totally useless. If we want to check whether they are equal, we use scm_equal_p, if we want to see whether they are the same object, we use scm_eqv_p. Besides, I can't find any use for this function with git grep. http://codereview.appspot.com/5306050/ ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Adds Scheme function for spring constructor. (issue 5306050)
On 2011/10/21 11:27:34, dak wrote: http://codereview.appspot.com/5306050/diff/2001/lily/spring-smob.cc File lily/spring-smob.cc (left): http://codereview.appspot.com/5306050/diff/2001/lily/spring-smob.cc#oldcode42 lily/spring-smob.cc:42: return a == b ? SCM_BOOL_T : SCM_BOOL_F; On 2011/10/21 11:18:06, Neil Puttock wrote: > Not sure why this doesn't use the DEFAULT_EQUAL_P macro. I'd use scm_is_eq which is less obscure. However, I have no idea whether this should not rather be scm_is_true (scm_is_eqv (a, b)) since otherwise we'll just compare for object identity rather than equal values. Is object identity sufficient here? Make that scm_is_true (scm_eqv_p (... http://codereview.appspot.com/5306050/ ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Adds Scheme function for spring constructor. (issue 5306050)
http://codereview.appspot.com/5306050/diff/2001/lily/spring-smob.cc File lily/spring-smob.cc (left): http://codereview.appspot.com/5306050/diff/2001/lily/spring-smob.cc#oldcode42 lily/spring-smob.cc:42: return a == b ? SCM_BOOL_T : SCM_BOOL_F; On 2011/10/21 11:18:06, Neil Puttock wrote: Not sure why this doesn't use the DEFAULT_EQUAL_P macro. I'd use scm_is_eq which is less obscure. However, I have no idea whether this should not rather be scm_is_true (scm_is_eqv (a, b)) since otherwise we'll just compare for object identity rather than equal values. Is object identity sufficient here? http://codereview.appspot.com/5306050/ ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Adds Scheme function for spring constructor. (issue 5306050)
http://codereview.appspot.com/5306050/diff/1/lily/spring-smob.cc File lily/spring-smob.cc (right): http://codereview.appspot.com/5306050/diff/1/lily/spring-smob.cc#newcode48 lily/spring-smob.cc:48: "spring, and @code{min-dist} is the minimum distance.") @var{min-dist} http://codereview.appspot.com/5306050/diff/2001/lily/spring-smob.cc File lily/spring-smob.cc (left): http://codereview.appspot.com/5306050/diff/2001/lily/spring-smob.cc#oldcode42 lily/spring-smob.cc:42: return a == b ? SCM_BOOL_T : SCM_BOOL_F; Not sure why this doesn't use the DEFAULT_EQUAL_P macro. Also should have IMPLEMENT_TYPE_P for ly:spring? (+ entry in lily.scm) http://codereview.appspot.com/5306050/diff/2001/lily/spring-smob.cc File lily/spring-smob.cc (right): http://codereview.appspot.com/5306050/diff/2001/lily/spring-smob.cc#newcode47 lily/spring-smob.cc:47: "Make a spring. @code{ideal} is the ideal distance of the " @var{ideal} move space to start of next line http://codereview.appspot.com/5306050/diff/2001/lily/spring-smob.cc#newcode48 lily/spring-smob.cc:48: "spring, and @code{min-dist} is the minimum distance.") @var{min-dist} http://codereview.appspot.com/5306050/diff/2001/lily/spring-smob.cc#newcode60 lily/spring-smob.cc:60: "Set the inverse compress @code{strength} of @code{spring}.") @var{strength} @var{spring} http://codereview.appspot.com/5306050/diff/2001/lily/spring-smob.cc#newcode72 lily/spring-smob.cc:72: "Set the inverse stretch @code{strength} of @code{spring}.") @var{strength} @var{spring} http://codereview.appspot.com/5306050/ ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Adds Scheme function for spring constructor. (issue 5306050)
LGTM. http://codereview.appspot.com/5306050/ ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel