X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fstream-event.cc;h=f8c9f8fc8b619235eb78baa87cf314a5381ac163;hb=f4abbfff5f0d985a457e15586dbcc3ae473b0dee;hp=12219884b1071d40e9919e4cf13b771b515d2148;hpb=af770f3440264c18ce01525dce1aa76b86ace0d5;p=lilypond.git diff --git a/lily/stream-event.cc b/lily/stream-event.cc index 12219884b1..f8c9f8fc8b 100644 --- a/lily/stream-event.cc +++ b/lily/stream-event.cc @@ -1,9 +1,20 @@ /* - stream-event.cc -- implement Stream_event + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2005--2014 Erik Sandberg - (c) 2005-2006 Erik Sandberg + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "stream-event.hh" @@ -11,7 +22,8 @@ #include "ly-smobs.icc" #include "context.hh" #include "input.hh" -#include "input.hh" +#include "music.hh" +#include "pitch.hh" /* TODO: Rename Stream_event -> Event */ @@ -20,16 +32,15 @@ Stream_event::Stream_event () { } -Stream_event::Stream_event (SCM event_class, SCM mutable_props) +Stream_event::Stream_event (SCM event_class, SCM immutable_props) : Prob (ly_symbol2scm ("Stream_event"), - scm_list_1 (scm_cons (ly_symbol2scm ("class"), event_class))) + scm_acons (ly_symbol2scm ("class"), event_class, immutable_props)) { - mutable_property_alist_ = mutable_props; } Stream_event::Stream_event (SCM class_name, Input *origin) : Prob (ly_symbol2scm ("Stream_event"), - scm_list_1 (scm_cons (ly_symbol2scm ("class"), class_name))) + scm_list_1 (scm_cons (ly_symbol2scm ("class"), class_name))) { if (origin) set_spot (origin); @@ -44,7 +55,7 @@ Stream_event::copy_mutable_properties () const Input * Stream_event::origin () const { - Input *i = unsmob_input (get_property ("origin")); + Input *i = Input::unsmob (get_property ("origin")); return i ? i : &dummy_input_global; } @@ -58,22 +69,41 @@ bool Stream_event::internal_in_event_class (SCM class_name) { SCM cl = get_property ("class"); - cl = scm_call_1 (ly_lily_module_constant ("ly:make-event-class"), cl); return scm_c_memq (class_name, cl) != SCM_BOOL_F; } -IMPLEMENT_TYPE_P (Stream_event, "ly:stream-event?"); - MAKE_SCHEME_CALLBACK (Stream_event, undump, 1); MAKE_SCHEME_CALLBACK (Stream_event, dump, 1); +void +Stream_event::make_transposable () +{ + /* This is in preparation for transposing stuff + that may be defined in the immutable part */ + + for (SCM s = immutable_property_alist_; scm_is_pair (s); s = scm_cdr (s)) + { + SCM entry = scm_car (s); + SCM prop = scm_car (entry); + SCM val = scm_cdr (entry); + + if ((Pitch::unsmob (val) + || (prop == ly_symbol2scm ("element") && Music::unsmob (val)) + || (prop == ly_symbol2scm ("elements") && scm_is_pair (val)) + || (prop == ly_symbol2scm ("pitch-alist") && scm_is_pair (val))) + && scm_is_false (scm_assq (prop, mutable_property_alist_))) + mutable_property_alist_ + = scm_acons (prop, ly_music_deep_copy (val), mutable_property_alist_); + } +} + SCM Stream_event::dump (SCM self) { - Stream_event *ev = unsmob_stream_event (self); + Stream_event *ev = Stream_event::unsmob (self); // Reversed alists look prettier. return scm_cons (scm_reverse (ev->immutable_property_alist_), - scm_reverse (ev->mutable_property_alist_)); + scm_reverse (ev->mutable_property_alist_)); } SCM @@ -86,7 +116,7 @@ Stream_event::undump (SCM data) } Stream_event * -unsmob_stream_event (SCM m) +Stream_event::unsmob (SCM m) { - return dynamic_cast (unsmob_prob (m)); + return dynamic_cast (Prob::unsmob (m)); }