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 - [EMAIL PROTECTED] - http://www.xs4all.nl/~hanwen
LilyPond Software Design
-- Code for Music Notation
http://www.lilypond-design.com
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel