]> git.donarmstrong.com Git - lilypond.git/blob - lily/listener.cc
Fix some bugs in the dynamic engraver and PostScript backend
[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 Listener::Listener (const void *target, Listener_function_table *type)
14 {
15   target_ = (void *)target;
16   type_ = type;
17 }
18
19 Listener::Listener (Listener const &other)
20 {
21   target_ = other.target_;
22   type_ = other.type_; 
23 }
24
25 void Listener::listen (SCM ev) const {
26   (type_->listen_callback) (target_, ev);
27 }
28
29 SCM
30 Listener::mark_smob (SCM sm)
31 {
32   Listener *me = (Listener *) SCM_CELL_WORD_1 (sm);
33   (me->type_->mark_callback) (me->target_);
34   return SCM_EOL;
35 }
36
37 int
38 Listener::print_smob (SCM s, SCM p, scm_print_state*)
39 {
40   scm_puts ("#<Listener>", p);
41   return 1;
42 }
43
44 SCM
45 Listener::equal_p (SCM a, SCM b)
46 {
47   Listener *l1 = unsmob_listener (a);
48   Listener *l2 = unsmob_listener (b);
49
50   return (*l1 == *l2) ? SCM_BOOL_T : SCM_BOOL_F;
51 }
52
53 IMPLEMENT_SIMPLE_SMOBS (Listener);
54 IMPLEMENT_TYPE_P (Listener, "listener");