]> git.donarmstrong.com Git - lilypond.git/blob - lily/listener.cc
unsmob_pitch -> Pitch::unsmob and related
[lilypond.git] / lily / listener.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2005 Erik Sandberg  <mandolaerik@gmail.com>
5
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
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
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/>.
18 */
19
20 #include "listener.hh"
21 #include "ly-smobs.icc"
22 #include "warn.hh"
23
24 Listener::Listener ()
25 {
26   target_ = 0;
27   type_ = 0;
28 }
29
30 Listener::Listener (const void *target, Listener_function_table *type)
31 {
32   target_ = (void *)target;
33   type_ = type;
34 }
35
36 Listener::Listener (Listener const &other)
37 {
38   target_ = other.target_;
39   type_ = other.type_;
40 }
41
42 void Listener::listen (SCM ev) const
43 {
44   (type_->listen_callback) (target_, ev);
45 }
46
47 SCM
48 Listener::mark_smob (SCM sm)
49 {
50   Listener *me = (Listener *) SCM_CELL_WORD_1 (sm);
51   if (me->type_)
52     (me->type_->mark_callback) (me->target_);
53   return SCM_EOL;
54 }
55
56 int
57 Listener::print_smob (SCM, SCM p, scm_print_state *)
58 {
59   scm_puts ("#<Listener>", p);
60   return 1;
61 }
62
63 SCM
64 Listener::equal_p (SCM a, SCM b)
65 {
66   Listener *l1 = Listener::unsmob (a);
67   Listener *l2 = Listener::unsmob (b);
68
69   return (*l1 == *l2) ? SCM_BOOL_T : SCM_BOOL_F;
70 }
71
72 IMPLEMENT_SIMPLE_SMOBS (Listener);
73 IMPLEMENT_TYPE_P (Listener, "ly:listener?");