lilypond-devel
[Top][All Lists]
Advanced

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

Re: Using \global - Lilypond 2.9.20 Windows


From: Han-Wen Nienhuys
Subject: Re: Using \global - Lilypond 2.9.20 Windows
Date: Tue, 10 Oct 2006 17:58:22 +0200
User-agent: Thunderbird 1.5.0.7 (X11/20061004)

Erik Sandberg schreef:
Yes, I think that's a good idea.

The attached patch fixes this and various other fixes:
- add equal_p for Input and Prob
- ASSIGN_EVENT_ONCE checks for inequality before warning.
- musics generated by parser always have their origin set.
- document-music.scm uses the auto-generated event classes
- small cleanup in translator's macro trickery


The 'types music property is now only used by music functions AFAIK; perhaps we should deprecate it soon.

Yes, while you're at it, the accepted argument of the ADD_TRANSLATOR macro should also go (global search & replace patch).

I should also remove a couple of explicit set_spot calls from parser.yy. May I commit after that?

Yes please.

+LY_DEFINE (ly_music_name_to_event_class, "ly:music-name->event-class",
+          1, 0, 0, (SCM name_sym),
+          "Convert music name to corresponding event class name.")
+{
+  /* UGH. There should be a better way. */
+  const string in = ly_symbol2string (name_sym);
+  /* this should be sufficient */
+  char out[in.size() * 2 + 2];
+  /* don't add '-' before first character */
+  out[0] = tolower (in[0]);
+  size_t outpos = 1;
+  for (size_t inpos = 1; inpos < in.size (); inpos++)
+    {
+      if (isupper (in[inpos]))
+       out[outpos++] = '-';
+ out[outpos++] = tolower (in[inpos]); + }
+  out[outpos] = 0;
+
+  return ly_symbol2scm (out);
+}

I think it's better to name it as a library function:

 ly:studly-caps->lisp-identifier

taking strings, and use that.

+SCM
+Prob::equal_p (SCM sa, SCM sb)
+{
+  /* This comparison function is only designed to make the copy
+     constructor preserve equality.
+
+     Perhaps it would be better to use a more strict definition of
+     equality; e.g. that that two probs are equal iff they can be
+     distinguished by calls to ly:prob-property.
+  */
+  Prob *pa = unsmob_prob (sa);
+  Prob *pb = unsmob_prob (sb);
+
+  /* Compare mutable and immutable lists, element by element. */
+  for (int iter = 0; iter < 2; iter++)
+    {
+      SCM aprop, bprop;
+      if (iter == 0)
+       {
+         aprop = pa->immutable_property_alist_;
+         bprop = pb->immutable_property_alist_;
+       }
+      else
+       {
+         aprop = pa->mutable_property_alist_;
+         bprop = pb->mutable_property_alist_;
+       }

slightly cleaner:

  Prob *probs[2] = {pa,pb}
  SCM prop_lists [2][2];

and then init prop_list with a loop.

however, as you note this isn't completely fool proof, as changing the ordering should not change the result of equal_p()

--

Han-Wen Nienhuys - address@hidden - http://www.xs4all.nl/~hanwen

LilyPond Software Design
 -- Code for Music Notation
http://www.lilypond-design.com





reply via email to

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