]> git.donarmstrong.com Git - lilypond.git/blob - lily/input-smob.cc
f6a3b7a77372098e6093137a26e212a3ca13730c
[lilypond.git] / lily / input-smob.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2000--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
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 "input.hh"
21 #include "source-file.hh"
22 #include "std-string.hh"
23
24 ADD_SMOB_INIT (Input);
25
26
27 /* Dummy input location for use if real one is missing.  */
28 Input dummy_input_global;
29
30 const char Input::type_p_name_[] = "ly:input-location?";
31
32 SCM
33 Input::mark_smob ()
34 {
35   if (Source_file *sf = get_source_file ())
36     return sf->self_scm ();
37
38   return SCM_EOL;
39 }
40
41 int
42 Input::print_smob (SCM port, scm_print_state *)
43 {
44   string str = "#<location " + location_string () + ">";
45   scm_puts (str.c_str (), port);
46   return 1;
47 }
48
49 SCM
50 Input::equal_p (SCM sa, SCM sb)
51 {
52   Input *a = unsmob (sa);
53   Input *b = unsmob (sb);
54   if (a->get_source_file () == b->get_source_file ()
55       && a->start () == b->start ()
56       && a->end () == b->end ())
57     return SCM_BOOL_T;
58   else
59     return SCM_BOOL_F;
60 }