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"
23 LY_DEFINE (ly_input_warning, "ly:input-warning", 2, 0, 1, (SCM sip, SCM msg, SCM rest),
24 "Print @var{msg} as a GNU compliant warning message, pointing"
25 " to the location in @var{sip}. @var{msg} is interpreted"
26 " similar to @code{format}'s argument, using @var{rest}.")
28 Input *ip = Input::unsmob (sip);
30 LY_ASSERT_SMOB (Input, sip, 1);
31 LY_ASSERT_TYPE (scm_is_string, msg, 2);
33 msg = scm_simple_format (SCM_BOOL_F, msg, rest);
35 string m = ly_scm2string (msg);
38 return SCM_UNSPECIFIED;
41 LY_DEFINE (ly_input_message, "ly:input-message", 2, 0, 1, (SCM sip, SCM msg, SCM rest),
42 "Print @var{msg} as a GNU compliant error message, pointing"
43 " to the location in @var{sip}. @var{msg} is interpreted"
44 " similar to @code{format}'s argument, using @var{rest}.")
46 Input *ip = Input::unsmob (sip);
48 LY_ASSERT_SMOB (Input, sip, 1);
49 LY_ASSERT_TYPE (scm_is_string, msg, 2);
51 msg = scm_simple_format (SCM_BOOL_F, msg, rest);
53 string m = ly_scm2string (msg);
56 return SCM_UNSPECIFIED;
59 LY_DEFINE (ly_input_file_line_char_column,
60 "ly:input-file-line-char-column",
62 "Return input location in @var{sip} as"
63 " @code{(file-name line char column)}.")
65 LY_ASSERT_SMOB (Input, sip, 1);
66 Input *ip = Input::unsmob (sip);
68 int l, ch, col, offset = 0;
69 ip->get_counts (&l, &ch, &col, &offset);
70 return scm_list_4 (ly_string2scm (ip->file_string ()),
76 LY_DEFINE (ly_input_both_locations,
77 "ly:input-both-locations",
79 "Return input location in @var{sip} as"
80 " @code{(file-name first-line first-column last-line last-column)}.")
83 LY_ASSERT_SMOB (Input, sip, 1);
84 Input *ip = Input::unsmob (sip);
86 return scm_list_5 (ly_string2scm (ip->file_string ()),
87 scm_from_int (ip->line_number ()),
88 scm_from_int (ip->column_number ()),
89 scm_from_int (ip->end_line_number ()),
90 scm_from_int (ip->end_column_number ()));