On Tuesday 10 October 2006 17:58, Han-Wen Nienhuys wrote: > 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).
Should I remove the second unused arg of DECLARE_*SMOBS as well? > > I should also remove a couple of explicit set_spot calls from parser.yy. > > May I commit after that? > > Yes please. BTW, note that this does not affect \mark, which is a softcoded music function. IMHO we need a better convention for make-*-music, so we always can pass an optional origin parameter. > > +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. ok, done. I called it ly:camel-case->lisp-identifier, (camel case is the term that Wikipedia prefers). The function remains in music-scheme.cc, because it's only used for music so far, and I didn't find a spot for generic string-handling functions. > > +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. ok, done -- Erik _______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel