On Thursday 05 October 2006 14:24, Han-Wen Nienhuys wrote:
> Erik Sandberg schreef:
> > On Wednesday 04 October 2006 10:33, Han-Wen Nienhuys wrote:
> >> It would be better if there were a check if the new event is equal to
> >> the old one, and only warn if they're different.
> >
> > Hm, then I'll define a new equal_p for probs. I'd say that two events are
> > equal if all event properties are 'equal?'. This
> > includes 'origin, so there will be a warning in cases like:

> >> Also, the definition
> >> location seems to be missing. Erik?
> >
> > My work-in-progress macro-capable parser contains a generic fix for this,
> > where I added a mandatory location parameter to MY_MAKE_MUSIC. Should I
> > try to backport this before 2.10?
>
> 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.

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

-- 
Erik
? .cvs-checksum
? .cvsup-timestamp
? .sconf_temp
? build-stamp
? context-unique.diff
? cvsdiff
? def-rel-music-funciton.diff
? delay-music-functions.diff
? exjobb.diff3
? fonts
? foo-1.signature
? foo-systems.texi
? grob-name.diff
? lib
? lilypond-internals.texi
? lilypond.kdevelop
? lilypond.kdevelop.pcs
? lilypond.kdevses
? optimized
? os
? parser.diff
? ref1.diff
? ref2.diff
? repeat.diff
? scons.cache
? web-err
? web-out
? Documentation/out
? Documentation/out-www
? Documentation/bibliography/out
? Documentation/bibliography/out-www
? Documentation/misc/out
? Documentation/misc/out-www
? Documentation/pictures/out
? Documentation/pictures/out-www
? Documentation/topdocs/out
? Documentation/topdocs/out-www
? Documentation/user/out
? Documentation/user/out-www
? buildscripts/out
? buildscripts/out-www
? cygwin/out
? cygwin/out-www
? debian/out
? elisp/out
? elisp/out-www
? flower/out
? flower/out-scons
? flower/out-www
? flower/include/.sconsign
? flower/include/out
? flower/include/out-www
? input/Diagram1.dia.autosave
? input/les-nereides.pdf
? input/les-nereides.ps
? input/out
? input/out-www
? input/manual/out
? input/manual/out-www
? input/mutopia/out
? input/mutopia/out-www
? input/mutopia/E.Satie/out
? input/mutopia/E.Satie/out-www
? input/mutopia/F.Schubert/morgenlied.midi
? input/mutopia/F.Schubert/morgenlied.pdf
? input/mutopia/F.Schubert/morgenlied.ps
? input/mutopia/F.Schubert/out
? input/mutopia/F.Schubert/out-www
? input/mutopia/J.S.Bach/out
? input/mutopia/J.S.Bach/out-www
? input/mutopia/R.Schumann/out
? input/mutopia/R.Schumann/out-www
? input/mutopia/W.A.Mozart/mozart-hrn-3-1.midi
? input/mutopia/W.A.Mozart/mozart-hrn-3-2.midi
? input/mutopia/W.A.Mozart/mozart-hrn-3.midi
? input/mutopia/W.A.Mozart/mozart-hrn-3.pdf
? input/mutopia/W.A.Mozart/mozart-hrn-3.ps
? input/mutopia/W.A.Mozart/out
? input/mutopia/W.A.Mozart/out-www
? input/no-notation/out
? input/no-notation/out-www
? input/no-notation/to-xml.pdf
? input/no-notation/to-xml.ps
? input/regression/chord-tremolo.pdf
? input/regression/chord-tremolo.ps
? input/regression/out
? input/regression/out-www
? input/template/out
? input/test/new
? input/test/out
? input/test/out-www
? input/tutorial/out
? input/tutorial/out-www
? kpath-guile/out
? kpath-guile/out-scons
? lily/On
? lily/busy-playing-listener.cc
? lily/foo
? lily/foo.pdf
? lily/foo.ps
? lily/lilypond
? lily/lilypond.gdt
? lily/lilypond.gpr
? lily/out
? lily/out-scons
? lily/out-www
? lily/include/.new.cf-string
? lily/include/.sconsign
? lily/include/busy-playing-listener.hh
? lily/include/out
? lily/include/out-www
? ly/out
? ly/out-www
? make/out
? make/out-www
? mf/feta-alphabet11.600pk
? mf/feta-alphabet13.600pk
? mf/feta-alphabet14.600pk
? mf/feta-alphabet16.600pk
? mf/feta-alphabet18.600pk
? mf/feta-alphabet20.600pk
? mf/feta-alphabet23.600pk
? mf/feta-alphabet26.600pk
? mf/feta-braces-a.600pk
? mf/feta-braces-b.600pk
? mf/feta-braces-c.600pk
? mf/feta-braces-d.600pk
? mf/feta-braces-e.600pk
? mf/feta-braces-f.600pk
? mf/feta-braces-g.600pk
? mf/feta-braces-h.600pk
? mf/feta-braces-i.600pk
? mf/feta11.600pk
? mf/feta11.tfm
? mf/feta13.600pk
? mf/feta13.tfm
? mf/feta14.600pk
? mf/feta14.tfm
? mf/feta16.600pk
? mf/feta16.tfm
? mf/feta18.600pk
? mf/feta18.tfm
? mf/feta20.600pk
? mf/feta20.tfm
? mf/feta23.600pk
? mf/feta23.tfm
? mf/feta26.600pk
? mf/feta26.tfm
? mf/out
? mf/out-scons
? mf/out-www
? mf/parmesan11.600pk
? mf/parmesan13.600pk
? mf/parmesan14.600pk
? mf/parmesan16.600pk
? mf/parmesan18.600pk
? mf/parmesan20.600pk
? mf/parmesan23.600pk
? mf/parmesan26.600pk
? po/out
? po/out-www
? ps/out
? ps/out-www
? python/convertrules.pyc
? python/fontextract.pyc
? python/lilylib.pyc
? python/out
? python/out-www
? scm/out
? scm/out-www
? scripts/lilypond-book-36.py
? scripts/lilypond-book.py.new
? scripts/out
? scripts/out-www
? scripts/stat
? stepmake/out
? stepmake/out-www
? stepmake/bin/out
? stepmake/bin/out-www
? stepmake/bin/packagepython.pyc
? stepmake/stepmake/out
? stepmake/stepmake/out-www
? tex/out
? tex/out-www
? ttftool/out
? ttftool/out-scons
? ttftool/include/.sconsign
? ttftool/include/out
? vim/out
? vim/out-www
Index: lily/input-smob.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/input-smob.cc,v
retrieving revision 1.42
diff -u -r1.42 input-smob.cc
--- lily/input-smob.cc	1 Sep 2006 10:02:46 -0000	1.42
+++ lily/input-smob.cc	10 Oct 2006 15:14:03 -0000
@@ -17,8 +17,8 @@
 
 static long input_tag;
 
-static
-SCM mark_smob (SCM s)
+static SCM
+mark_smob (SCM s)
 {
   Input *sc = (Input *) SCM_CELL_WORD_1 (s);
 
@@ -43,6 +43,19 @@
   return 0;
 }
 
+static SCM
+equal_smob (SCM sa, SCM sb)
+{
+  Input *a = (Input *) SCM_CELL_WORD_1 (sa);
+  Input *b = (Input *) SCM_CELL_WORD_1 (sb);
+  if (a->get_source_file () == b->get_source_file () &&
+      a->start () == b->start () &&
+      a->end () == b->end ())
+    return SCM_BOOL_T;
+  else
+    return SCM_BOOL_F;
+}
+
 static void
 start_input_smobs ()
 {
@@ -50,7 +63,7 @@
   scm_set_smob_mark (input_tag, mark_smob);
   scm_set_smob_free (input_tag, free_smob);
   scm_set_smob_print (input_tag, print_smob);
-  scm_set_smob_equalp (input_tag, 0);
+  scm_set_smob_equalp (input_tag, equal_smob);
 }
 
 SCM
Index: lily/music-scheme.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/music-scheme.cc,v
retrieving revision 1.17
diff -u -r1.17 music-scheme.cc
--- lily/music-scheme.cc	24 Jan 2006 13:51:14 -0000	1.17
+++ lily/music-scheme.cc	10 Oct 2006 15:14:03 -0000
@@ -215,3 +215,24 @@
   return scm_reverse_x (newlist, SCM_EOL);
 }
 
+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);
+}
Index: lily/music.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/music.cc,v
retrieving revision 1.158
diff -u -r1.158 music.cc
--- lily/music.cc	22 Sep 2006 07:51:36 -0000	1.158
+++ lily/music.cc	10 Oct 2006 15:14:03 -0000
@@ -253,21 +253,7 @@
 Stream_event *
 Music::to_event () const
 {
-  /* UGH. Temp hack */
-  SCM orig_sym = get_property ("name");
-  char out[200];
-  string in = ly_symbol2string (orig_sym);
-  /* don't add '-' before first character */
-  out[0] = tolower (in[0]);
-  size_t outpos = 1;
-  for (size_t inpos = 1; inpos < in.size () && outpos < 190; inpos++)
-    {
-      if (isupper (in[inpos]))
-	out[outpos++] = '-';
-      out[outpos++] = tolower (in[inpos]);      
-    }
-  out[outpos] = 0;
-  SCM class_name = ly_symbol2scm (out);
+  SCM class_name = ly_music_name_to_event_class (get_property ("name"));
 
   // catch programming mistakes.
   if (!internal_is_music_type (class_name))
Index: lily/parser.yy
===================================================================
RCS file: /sources/lilypond/lilypond/lily/parser.yy,v
retrieving revision 1.532
diff -u -r1.532 parser.yy
--- lily/parser.yy	2 Oct 2006 06:02:45 -0000	1.532
+++ lily/parser.yy	10 Oct 2006 15:14:03 -0000
@@ -108,7 +108,7 @@
 
 %{
 
-#define MY_MAKE_MUSIC(x)  make_music_by_name (ly_symbol2scm (x))
+#define MY_MAKE_MUSIC(x, spot)  make_music_with_input (ly_symbol2scm (x), spot)
 
 /* ES TODO:
 - Don't use lily module, create a new module instead.
@@ -132,8 +132,8 @@
 #endif
 
 
-
-SCM make_music_relative (Pitch start, SCM music);
+static Music *make_music_with_input (SCM name, Input where);
+SCM make_music_relative (Pitch start, SCM music, Input loc);
 SCM run_music_function (Lily_parser *, SCM expr);
 SCM get_first_context_id (SCM type, Music *m);
 SCM make_chord_elements (SCM pitch, SCM dur, SCM modification_list);
@@ -825,7 +825,7 @@
 
 	}
 	| music_list error {
-		Music *m = MY_MAKE_MUSIC("Music");
+		Music *m = MY_MAKE_MUSIC("Music", @$);
 		// ugh. code dup 
 		m->set_property ("error-found", SCM_BOOL_T);
 		SCM s = $$;
@@ -1079,11 +1079,11 @@
 relative_music:
 	RELATIVE absolute_pitch music {
 		Pitch start = *unsmob_pitch ($2);
-		$$ = make_music_relative (start, $3);
+		$$ = make_music_relative (start, $3, @$);
 	}
 	| RELATIVE composite_music {
 		Pitch middle_c (0, 0, 0);
-		$$ = make_music_relative (middle_c, $2);
+		$$ = make_music_relative (middle_c, $2, @$);
 	}
 	;
 
@@ -1330,7 +1330,7 @@
 		SCM check = $4;
 		SCM post = $5;
 
-		Music *n = MY_MAKE_MUSIC ("NoteEvent");
+		Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
 		n->set_property ("pitch", $1);
 		n->set_spot (@$);
 		if (q % 2)
@@ -1351,7 +1351,7 @@
 		$$ = n->unprotect ();
 	}
 	| DRUM_PITCH post_events {
-		Music *n = MY_MAKE_MUSIC ("NoteEvent");
+		Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
 		n->set_property ("duration", $2);
 		n->set_property ("drum-type", $1);
 		n->set_spot (@$);
@@ -1408,13 +1408,13 @@
 		$$ = MAKE_SYNTAX ("skip-music", @$, $2);
 	}
 	| E_BRACKET_OPEN {
-		Music *m = MY_MAKE_MUSIC ("LigatureEvent");
+		Music *m = MY_MAKE_MUSIC ("LigatureEvent", @$);
 		m->set_property ("span-direction", scm_from_int (START));
 		m->set_spot (@$);
 		$$ = m->unprotect();
 	}
 	| E_BRACKET_CLOSE {
-		Music *m = MY_MAKE_MUSIC ("LigatureEvent");
+		Music *m = MY_MAKE_MUSIC ("LigatureEvent", @$);
 		m->set_property ("span-direction", scm_from_int (STOP));
 		m->set_spot (@$);
 		$$ = m->unprotect ();
@@ -1456,22 +1456,23 @@
 
 command_event:
 	E_TILDE {
-		$$ = MY_MAKE_MUSIC ("PesOrFlexaEvent")->unprotect ();
+		$$ = MY_MAKE_MUSIC ("PesOrFlexaEvent", @$)->unprotect ();
 	}
 	| MARK DEFAULT  {
-		Music *m = MY_MAKE_MUSIC ("MarkEvent");
+		Music *m = MY_MAKE_MUSIC ("MarkEvent", @$);
 		$$ = m->unprotect ();
+		scm_display($$, SCM_UNDEFINED);
 	}
 	| tempo_event {
 		$$ = $1;
 	}
 	| KEY DEFAULT {
-		Music *key = MY_MAKE_MUSIC ("KeyChangeEvent");
+		Music *key = MY_MAKE_MUSIC ("KeyChangeEvent", @$);
 		$$ = key->unprotect ();
 	}
 	| KEY NOTENAME_PITCH SCM_IDENTIFIER 	{
 
-		Music *key = MY_MAKE_MUSIC ("KeyChangeEvent");
+		Music *key = MY_MAKE_MUSIC ("KeyChangeEvent", @$);
 		if (scm_ilength ($3) > 0)
 		{		
 			key->set_property ("pitch-alist", $3);
@@ -1506,12 +1507,12 @@
 	| HYPHEN {
 		if (!PARSER->lexer_->is_lyric_state ())
 			PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
-		$$ = MY_MAKE_MUSIC ("HyphenEvent")->unprotect ();
+		$$ = MY_MAKE_MUSIC ("HyphenEvent", @$)->unprotect ();
 	}
 	| EXTENDER {
 		if (!PARSER->lexer_->is_lyric_state ())
 			PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
-		$$ = MY_MAKE_MUSIC ("ExtenderEvent")->unprotect ();
+		$$ = MY_MAKE_MUSIC ("ExtenderEvent", @$)->unprotect ();
 	}
 	| script_dir direction_reqd_event {
 		if ($1)
@@ -1534,7 +1535,7 @@
 
 string_number_event:
 	E_UNSIGNED {
-		Music *s = MY_MAKE_MUSIC ("StringNumberEvent");
+		Music *s = MY_MAKE_MUSIC ("StringNumberEvent", @$);
 		s->set_property ("string-number", scm_from_int ($1));
 		s->set_spot (@$);
 		$$ = s->unprotect ();
@@ -1584,7 +1585,7 @@
 		}
 		else
 		{
-			m = MY_MAKE_MUSIC ("Music");
+			m = MY_MAKE_MUSIC ("Music", @$);
 		}
 		m->set_spot (@$);
 		$$ = m->unprotect ();
@@ -1593,7 +1594,7 @@
 		$$ = $1;
 	}
 	| tremolo_type  {
-               Music *a = MY_MAKE_MUSIC ("TremoloEvent");
+               Music *a = MY_MAKE_MUSIC ("TremoloEvent", @$);
                a->set_spot (@$);
                a->set_property ("tremolo-type", scm_from_int ($1));
                $$ = a->unprotect ();
@@ -1606,7 +1607,7 @@
 	}
 	| script_abbreviation {
 		SCM s = PARSER->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
-		Music *a = MY_MAKE_MUSIC ("ArticulationEvent");
+		Music *a = MY_MAKE_MUSIC ("ArticulationEvent", @$);
 		if (scm_is_string (s))
 			a->set_property ("articulation-type", s);
 		else PARSER->parser_error (@1, _ ("expecting string as script definition"));
@@ -1689,20 +1690,20 @@
 
 gen_text_def:
 	full_markup {
-		Music *t = MY_MAKE_MUSIC ("TextScriptEvent");
+		Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
 		t->set_property ("text", $1);
 		t->set_spot (@$);
 		$$ = t->unprotect ();
 	}
 	| string {
-		Music *t = MY_MAKE_MUSIC ("TextScriptEvent");
+		Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
 		t->set_property ("text",
 			make_simple_markup ($1));
 		t->set_spot (@$);
 		$$ = t->unprotect ();
 	}
 	| DIGIT {
-		Music *t = MY_MAKE_MUSIC ("FingeringEvent");
+		Music *t = MY_MAKE_MUSIC ("FingeringEvent", @$);
 		t->set_property ("digit", scm_from_int ($1));
 		t->set_spot (@$);
 		$$ = t->unprotect ();
@@ -1841,13 +1842,13 @@
 
 bass_figure:
 	FIGURE_SPACE {
-		Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent");
+		Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
 		$$ = bfr->self_scm ();
 		bfr->unprotect ();
 		bfr->set_spot (@1);
 	}
 	| bass_number  {
-		Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent");
+		Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
 		$$ = bfr->self_scm ();
 
 		if (scm_is_number ($1))
@@ -1941,9 +1942,9 @@
 
 		Music *n = 0;
 		if ($6)
-			n = MY_MAKE_MUSIC ("RestEvent");
+			n = MY_MAKE_MUSIC ("RestEvent", @$);
 		else
-			n = MY_MAKE_MUSIC ("NoteEvent");
+			n = MY_MAKE_MUSIC ("NoteEvent", @$);
 		
 		n->set_property ("pitch", $1);
 		n->set_property ("duration", $5);
@@ -1963,7 +1964,7 @@
 		$$ = n->unprotect ();
 	}
 	| DRUM_PITCH optional_notemode_duration {
-		Music *n = MY_MAKE_MUSIC ("NoteEvent");
+		Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
 		n->set_property ("duration", $2);
 		n->set_property ("drum-type", $1);
 
@@ -1973,10 +1974,10 @@
 		Music *ev = 0;
  		if (ly_scm2string ($1) == "s") {
 			/* Space */
-			ev = MY_MAKE_MUSIC ("SkipEvent");
+			ev = MY_MAKE_MUSIC ("SkipEvent", @$);
 		  }
 		else {
-			ev = MY_MAKE_MUSIC ("RestEvent");
+			ev = MY_MAKE_MUSIC ("RestEvent", @$);
 		
 		    }
 		ev->set_property ("duration", $2);
@@ -1987,7 +1988,7 @@
 		if (!PARSER->lexer_->is_lyric_state ())
 			PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
 
-		Music *levent = MY_MAKE_MUSIC ("LyricEvent");
+		Music *levent = MY_MAKE_MUSIC ("LyricEvent", @$);
 		levent->set_property ("text", $1);
 		levent->set_property ("duration",$2);
 		levent->set_spot (@$);
@@ -2445,6 +2446,13 @@
   return v;
 }
 
+Music *
+make_music_with_input (SCM name, Input where)
+{
+       Music *m = make_music_by_name (name);
+       m->set_spot (where);
+       return m;
+}
 
 SCM
 get_first_context_id (SCM type, Music *m)
@@ -2509,9 +2517,9 @@
 }
 
 SCM
-make_music_relative (Pitch start, SCM music)
+make_music_relative (Pitch start, SCM music, Input loc)
 {
-	Music *relative = MY_MAKE_MUSIC ("RelativeOctaveMusic");
+	Music *relative = MY_MAKE_MUSIC ("RelativeOctaveMusic", loc);
  	relative->set_property ("element", music);
 	
 	Music *m = unsmob_music (music);
Index: lily/prob.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/prob.cc,v
retrieving revision 1.8
diff -u -r1.8 prob.cc
--- lily/prob.cc	3 Oct 2006 12:00:18 -0000	1.8
+++ lily/prob.cc	10 Oct 2006 15:14:03 -0000
@@ -14,7 +14,49 @@
 
 IMPLEMENT_SMOBS (Prob);
 IMPLEMENT_TYPE_P (Prob, "ly:prob?");
-IMPLEMENT_DEFAULT_EQUAL_P (Prob);
+
+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_;
+	}
+
+      for (; scm_is_pair (aprop) && scm_is_pair(bprop); aprop = scm_cdr (aprop), bprop = scm_cdr (bprop))
+	{
+	  if (scm_caar (aprop) != scm_caar (bprop) ||
+	      !to_boolean (scm_equal_p (scm_cdar (aprop), scm_cdar (bprop))))
+	    return SCM_BOOL_F;
+	}
+
+      /* is one list shorter? */
+      if (aprop != SCM_EOL || bprop != SCM_EOL)
+	return SCM_BOOL_F;
+    }
+
+  return SCM_BOOL_T;
+}
 
 Prob::Prob (SCM type, SCM immutable_init)
 {
Index: lily/translator.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/translator.cc,v
retrieving revision 1.109
diff -u -r1.109 translator.cc
--- lily/translator.cc	2 Oct 2006 06:02:45 -0000	1.109
+++ lily/translator.cc	10 Oct 2006 15:14:03 -0000
@@ -184,19 +184,38 @@
 }
 
 /*
-  Used by ADD_THIS_TRANSLATOR to extract a list of event-class names
-  for each translator.  This list is used by the internals
-  documentation.
+ Helps the individual static_translator_description methods of translators.
 */
 SCM
-Translator::get_listened_class_list (const translator_listener_record *listeners) const
-{
+Translator::static_translator_description (const char *grobs,
+					   const char *desc,
+					   translator_listener_record *listener_list,
+					   const char *read, 
+					   const char *write) const
+{
+  SCM static_properties = SCM_EOL;					
+
+  static_properties = scm_acons (ly_symbol2scm ("grobs-created"),	
+				 parse_symbol_list (grobs), static_properties);
+  
+  static_properties = scm_acons (ly_symbol2scm ("description"),	
+				 scm_makfrom0str (desc), static_properties); 
+  
   SCM list = SCM_EOL;
-  for (; listeners; listeners = listeners->next_)
-    list = scm_cons (listeners->event_class_, list);
-  return list;
+  for (; listener_list; listener_list = listener_list->next_)
+    list = scm_cons (listener_list->event_class_, list);
+  static_properties = scm_acons (ly_symbol2scm ("events-accepted"),
+				 list, static_properties);
+  
+  static_properties = scm_acons (ly_symbol2scm ("properties-read"),	
+				 parse_symbol_list (read), static_properties); 
+  
+  static_properties = scm_acons (ly_symbol2scm ("properties-written"), 
+				 parse_symbol_list (write), static_properties); 
+  
+  return static_properties;						
 }
-
+  
 /*
   SMOBS
 */
@@ -294,7 +313,9 @@
 bool
 internal_event_assignment (Stream_event **old_ev, Stream_event *new_ev, const char *function)
 {
-  if (*old_ev)
+  if (*old_ev &&
+      !to_boolean (scm_equal_p ((*old_ev)->self_scm (), 
+			       new_ev->self_scm ())))
     {
       /* extract event class from function name */
       const char *prefix = "listen_";
Index: lily/include/music.hh
===================================================================
RCS file: /sources/lilypond/lilypond/lily/include/music.hh,v
retrieving revision 1.81
diff -u -r1.81 music.hh
--- lily/include/music.hh	2 Aug 2006 21:41:16 -0000	1.81
+++ lily/include/music.hh	10 Oct 2006 15:14:03 -0000
@@ -62,6 +62,7 @@
 Music *unsmob_music (SCM);
 Music *make_music_by_name (SCM sym);
 SCM ly_music_deep_copy (SCM);
+SCM ly_music_name_to_event_class (SCM name_sym);
 extern SCM ly_music_p_proc;
 
 /* common transposition function for music and event */
Index: lily/include/translator.hh
===================================================================
RCS file: /sources/lilypond/lilypond/lily/include/translator.hh,v
retrieving revision 1.107
diff -u -r1.107 translator.hh
--- lily/include/translator.hh	2 Oct 2006 06:02:46 -0000	1.107
+++ lily/include/translator.hh	10 Oct 2006 15:14:03 -0000
@@ -131,7 +131,11 @@
   void protect_event (SCM ev);
   virtual void derived_mark () const;
   static void add_translator_listener (translator_listener_record **listener_list, translator_listener_record *r, Listener (*get_listener) (void *), const char *ev_class);
-  SCM get_listened_class_list (const translator_listener_record *listeners) const;
+  SCM static_translator_description (const char *grobs, 
+				     const char *desc,
+				     translator_listener_record *listener_list,
+				     const char *read, 
+				     const char *write) const;
 
   friend class Translator_group;
 };
Index: lily/include/translator.icc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/include/translator.icc,v
retrieving revision 1.16
diff -u -r1.16 translator.icc
--- lily/include/translator.icc	2 Oct 2006 06:02:46 -0000	1.16
+++ lily/include/translator.icc	10 Oct 2006 15:14:03 -0000
@@ -49,26 +49,7 @@
   SCM									\
   classname::static_translator_description () const			\
   {									\
-    SCM static_properties = SCM_EOL;					\
-    /*  static_properties = acons (name , gh_str02scm (Translator::name (self_scm ())),	\
-	static_properties_);						\
-    */									\
-    static_properties = scm_acons (ly_symbol2scm ("grobs-created"),	\
-				   parse_symbol_list (grobs), static_properties); \
-									\
-    static_properties = scm_acons (ly_symbol2scm ("description"),	\
-				   scm_makfrom0str (desc), static_properties); \
-									\
-    static_properties = scm_acons (ly_symbol2scm ("events-accepted"),	\
-				   get_listened_class_list (listener_list_), static_properties); \
-									\
-    static_properties = scm_acons (ly_symbol2scm ("properties-read"),	\
-				   parse_symbol_list (read), static_properties); \
-									\
-    static_properties = scm_acons (ly_symbol2scm ("properties-written"), \
-				   parse_symbol_list (write), static_properties); \
-									\
-    return static_properties;						\
+    return Translator::static_translator_description (grobs, desc, listener_list_, read, write); \
   }
 
 #define IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS(T)			\
Index: scm/define-event-classes.scm
===================================================================
RCS file: /sources/lilypond/lilypond/scm/define-event-classes.scm,v
retrieving revision 1.13
diff -u -r1.13 define-event-classes.scm
--- scm/define-event-classes.scm	22 Sep 2006 07:51:37 -0000	1.13
+++ scm/define-event-classes.scm	10 Oct 2006 15:14:03 -0000
@@ -38,8 +38,7 @@
 				   rest-event skip-event bass-figure-event))
     (melodic-event . (cluster-note-event note-event))
     (() . (Announcement))
-    (Announcement . (AnnounceNewContext))
-    ))
+    (Announcement . (AnnounceNewContext))))
 
 ;; Maps event-class to a list of ancestors (inclusive)
 (define ancestor-lookup (make-hash-table 11))
Index: scm/document-music.scm
===================================================================
RCS file: /sources/lilypond/lilypond/scm/document-music.scm,v
retrieving revision 1.10
diff -u -r1.10 document-music.scm
--- scm/document-music.scm	4 Oct 2006 10:51:57 -0000	1.10
+++ scm/document-music.scm	10 Oct 2006 15:14:03 -0000
@@ -18,14 +18,18 @@
       texi)))
 
 (define music-types->names (make-vector 61 '()))
-(map (lambda (entry)
-       (let* ((types (cdr (assoc 'types (cdr entry)))))
-	 (map (lambda (type)
-		(hashq-set! music-types->names type
-			    (cons (car entry)
-				  (hashq-ref music-types->names type '()))))
-	      types)))
-     music-descriptions)
+(filter-map (lambda (entry)
+	      (let* ((class (ly:music-name->event-class (car entry)))
+		     (classes (ly:make-event-class class)))
+		(if classes
+		    (map (lambda (cl)
+			   (hashq-set! music-types->names cl
+				       (cons (car entry)
+					     (hashq-ref music-types->names cl '()))))
+			 classes)
+		    #f)))
+	    
+	    music-descriptions)
 
 (define (strip-description x)
   (cons (symbol->string (car x))
@@ -64,19 +68,24 @@
 (define (music-doc-str obj)
   (let* ((namesym  (car obj))
 	 (props (cdr obj))
-	 (types (cdr (assoc  'types props))))
-    
+	 (class (ly:music-name->event-class namesym))
+	 (classes (ly:make-event-class class))
+	 (event-texi (if classes
+			 (string-append
+			  "\n\nEvent classes:\n"
+			  (human-listify (map ref-ify (map symbol->string classes)))
+			  "\n\n"
+			  "\n\nAccepted by: "
+			  (human-listify
+			   (map ref-ify
+				(map symbol->string (map ly:translator-name
+							 (filter
+							  (lambda (x) (engraver-accepts-music-types? classes x)) all-engravers-list))))))
+			 "")))
+
     (string-append
      (object-property namesym 'music-description)
-     "\n\nMusic types:\n"
-     (human-listify (map ref-ify (map symbol->string types)))
-     "\n\n"
-     "\n\nAccepted by: "
-     (human-listify
-      (map ref-ify
-	   (map symbol->string (map ly:translator-name
-				    (filter
-				     (lambda (x) (engraver-accepts-music-types? types x)) all-engravers-list)))))
+     event-texi
      "\n\nProperties: \n"
      (description-list->texi
       (map
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to