2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
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.
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.
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/>.
20 #include "std-string.hh"
25 LY_DEFINE (ly_input_warning, "ly:input-warning", 2, 0, 1, (SCM sip, SCM msg, SCM rest),
26 "Print @var{msg} as a GNU compliant warning message, pointing"
27 " to the location in @var{sip}. @var{msg} is interpreted"
28 " similar to @code{format}'s argument, using @var{rest}.")
30 Input *ip = unsmob<Input> (sip);
32 LY_ASSERT_SMOB (Input, sip, 1);
33 LY_ASSERT_TYPE (scm_is_string, msg, 2);
35 msg = scm_simple_format (SCM_BOOL_F, msg, rest);
37 string m = ly_scm2string (msg);
40 return SCM_UNSPECIFIED;
43 LY_DEFINE (ly_input_message, "ly:input-message", 2, 0, 1, (SCM sip, SCM msg, SCM rest),
44 "Print @var{msg} as a GNU compliant error message, pointing"
45 " to the location in @var{sip}. @var{msg} is interpreted"
46 " similar to @code{format}'s argument, using @var{rest}.")
48 Input *ip = unsmob<Input> (sip);
50 LY_ASSERT_SMOB (Input, sip, 1);
51 LY_ASSERT_TYPE (scm_is_string, msg, 2);
53 msg = scm_simple_format (SCM_BOOL_F, msg, rest);
55 string m = ly_scm2string (msg);
58 return SCM_UNSPECIFIED;
61 LY_DEFINE (ly_input_file_line_char_column,
62 "ly:input-file-line-char-column",
64 "Return input location in @var{sip} as"
65 " @code{(file-name line char column)}.")
67 LY_ASSERT_SMOB (Input, sip, 1);
68 Input *ip = unsmob<Input> (sip);
70 int l, ch, col, offset = 0;
71 ip->get_counts (&l, &ch, &col, &offset);
72 return scm_list_4 (ly_string2scm (ip->file_string ()),
78 LY_DEFINE (ly_input_both_locations,
79 "ly:input-both-locations",
81 "Return input location in @var{sip} as"
82 " @code{(file-name first-line first-column last-line last-column)}.")
85 LY_ASSERT_SMOB (Input, sip, 1);
86 Input *ip = unsmob<Input> (sip);
88 return scm_list_5 (ly_string2scm (ip->file_string ()),
89 scm_from_int (ip->line_number ()),
90 scm_from_int (ip->column_number ()),
91 scm_from_int (ip->end_line_number ()),
92 scm_from_int (ip->end_column_number ()));