2 stream-event.cc -- implement Stream_event
4 source file of the GNU LilyPond music typesetter
6 (c) 2005-2006 Erik Sandberg <mandolaerik@gmail.com>
9 #include "stream-event.hh"
11 #include "ly-smobs.icc"
16 /* TODO: Rename Stream_event -> Event */
18 Stream_event::Stream_event ()
19 : Prob (ly_symbol2scm ("Stream_event"), SCM_EOL
)
23 Stream_event::Stream_event (SCM event_class
, SCM mutable_props
)
24 : Prob (ly_symbol2scm ("Stream_event"),
25 scm_list_1 (scm_cons (ly_symbol2scm ("class"), event_class
)))
27 mutable_property_alist_
= mutable_props
;
30 Stream_event::Stream_event (SCM class_name
, Input
*origin
)
31 : Prob (ly_symbol2scm ("Stream_event"),
32 scm_list_1 (scm_cons (ly_symbol2scm ("class"), class_name
)))
39 Stream_event::copy_mutable_properties () const
41 return ly_event_deep_copy (mutable_property_alist_
);
45 Stream_event::origin () const
47 Input
*i
= unsmob_input (get_property ("origin"));
48 return i
? i
: &dummy_input_global
;
52 Stream_event::set_spot (Input
*i
)
54 set_property ("origin", make_input (*i
));
58 Stream_event::internal_in_event_class (SCM class_name
)
60 SCM cl
= get_property ("class");
61 cl
= scm_call_1 (ly_lily_module_constant ("ly:make-event-class"), cl
);
62 return scm_c_memq (class_name
, cl
) != SCM_BOOL_F
;
65 IMPLEMENT_TYPE_P (Stream_event
, "ly:stream-event?");
67 MAKE_SCHEME_CALLBACK (Stream_event
, undump
, 1);
68 MAKE_SCHEME_CALLBACK (Stream_event
, dump
, 1);
71 Stream_event::dump (SCM self
)
73 Stream_event
*ev
= unsmob_stream_event (self
);
74 // Reversed alists look prettier.
75 return scm_cons (scm_reverse (ev
->immutable_property_alist_
),
76 scm_reverse (ev
->mutable_property_alist_
));
80 Stream_event::undump (SCM data
)
82 Stream_event
*obj
= new Stream_event ();
83 obj
->immutable_property_alist_
= scm_reverse (scm_car (data
));
84 obj
->mutable_property_alist_
= scm_reverse (scm_cdr (data
));
85 return obj
->unprotect ();
89 unsmob_stream_event (SCM m
)
91 return dynamic_cast<Stream_event
*> (unsmob_prob (m
));