]> git.donarmstrong.com Git - lilypond.git/blob - lily/listener.cc
Added data structures for music streams.
[lilypond.git] / lily / listener.cc
1 /*
2   listener.cc -- implement Listener and Listener_target
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2005 Erik Sandberg  <mandolaerik@gmail.com>
7 */
8
9 #include "listener.hh"
10 #include "ly-smobs.icc"
11 #include "warn.hh"
12
13 /*
14 Listener_target::~Listener_target ()
15 {
16 }
17 */
18
19 Listener::Listener (const void *target, Listener_function_table *type)
20 {
21   target_ = (void *)target;
22   type_ = type;
23 }
24
25 Listener::Listener (Listener const &other)
26 {
27   target_ = other.target_;
28   type_ = other.type_; 
29 }
30
31 void Listener::listen (SCM ev) const {
32   (type_->listen_callback) (target_, ev);
33 }
34
35 SCM
36 Listener::mark_smob (SCM sm)
37 {
38   Listener *me = (Listener *) SCM_CELL_WORD_1 (sm);
39   (me->type_->mark_callback) (me->target_);
40   return SCM_EOL;
41 }
42
43 int
44 Listener::print_smob (SCM s, SCM p, scm_print_state*)
45 {
46   scm_puts ("#<Listener>", p);
47   return 1;
48 }
49
50 SCM
51 Listener::equal_p (SCM a, SCM b)
52 {
53   Listener *l1 = unsmob_listener (a);
54   Listener *l2 = unsmob_listener (b);
55
56   return (*l1 == *l2) ? SCM_BOOL_T : SCM_BOOL_F;
57 }
58
59 IMPLEMENT_SIMPLE_SMOBS (Listener);
60 IMPLEMENT_TYPE_P (Listener, "listener");