OLD | NEW |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 2005--2015 Erik Sandberg <mandolaerik@gmail.com> | 4 Copyright (C) 2005--2015 Erik Sandberg <mandolaerik@gmail.com> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
11 LilyPond is distributed in the hope that it will be useful, | 11 LilyPond is distributed in the hope that it will be useful, |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 GNU General Public License for more details. | 14 GNU General Public License for more details. |
15 | 15 |
16 You should have received a copy of the GNU General Public License | 16 You should have received a copy of the GNU General Public License |
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>. | 17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>. |
18 */ | 18 */ |
19 | 19 |
20 #include "stream-event.hh" | 20 #include "stream-event.hh" |
21 | 21 |
22 #include "context.hh" | 22 #include "context.hh" |
23 #include "input.hh" | 23 #include "input.hh" |
| 24 #include "international.hh" |
24 #include "music.hh" | 25 #include "music.hh" |
25 #include "pitch.hh" | 26 #include "pitch.hh" |
| 27 #include <string> |
26 | 28 |
27 /* TODO: Rename Stream_event -> Event */ | 29 /* TODO: Rename Stream_event -> Event */ |
28 | 30 |
29 Stream_event::Stream_event () | 31 Stream_event::Stream_event () |
30 : Prob (ly_symbol2scm ("Stream_event"), SCM_EOL) | 32 : Prob (ly_symbol2scm ("Stream_event"), SCM_EOL) |
31 { | 33 { |
32 } | 34 } |
33 | 35 |
34 Stream_event::Stream_event (SCM event_class, SCM immutable_props) | 36 Stream_event::Stream_event (SCM event_class, SCM immutable_props) |
35 : Prob (ly_symbol2scm ("Stream_event"), | 37 : Prob (ly_symbol2scm ("Stream_event"), |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 108 } |
107 | 109 |
108 SCM | 110 SCM |
109 Stream_event::undump (SCM data) | 111 Stream_event::undump (SCM data) |
110 { | 112 { |
111 Stream_event *obj = new Stream_event (); | 113 Stream_event *obj = new Stream_event (); |
112 obj->immutable_property_alist_ = scm_reverse (scm_car (data)); | 114 obj->immutable_property_alist_ = scm_reverse (scm_car (data)); |
113 obj->mutable_property_alist_ = scm_reverse (scm_cdr (data)); | 115 obj->mutable_property_alist_ = scm_reverse (scm_cdr (data)); |
114 return obj->unprotect (); | 116 return obj->unprotect (); |
115 } | 117 } |
| 118 |
| 119 void |
| 120 warn_reassign_event_ptr (Stream_event &old_ev, Stream_event *new_ev) |
| 121 { |
| 122 if (!new_ev) // not expected |
| 123 return; |
| 124 |
| 125 if (to_boolean (scm_equal_p (old_ev.self_scm (), new_ev->self_scm ()))) |
| 126 return; // nothing of value was lost |
| 127 |
| 128 std::string nc = ly_symbol2string (scm_car (new_ev->get_property ("class"))); |
| 129 std::string oc = ly_symbol2string (scm_car (old_ev.get_property ("class"))); |
| 130 |
| 131 // remove the suffix "-event" if it is present |
| 132 const std::string suffix ("-event"); |
| 133 if (nc.size () > suffix.size ()) |
| 134 { |
| 135 if (0 == nc.compare (nc.size () - suffix.size (), suffix.size (), suffix)) |
| 136 nc.erase (nc.size () - suffix.size ()); |
| 137 } |
| 138 if (oc.size () > suffix.size ()) |
| 139 { |
| 140 if (0 == oc.compare (oc.size () - suffix.size (), suffix.size (), suffix)) |
| 141 oc.erase (oc.size () - suffix.size ()); |
| 142 } |
| 143 |
| 144 new_ev->origin ()->warning (_f ("Junking this %s event ...", nc.c_str ())); |
| 145 old_ev.origin ()->warning (_f ("... because it conflicts with this %s event", |
| 146 oc.c_str ())); |
| 147 } |
OLD | NEW |