]> git.donarmstrong.com Git - lilypond.git/blob - lily/warn-scheme.cc
1587d7f5abf477d18b7aae76369e25ebf7c53c3f
[lilypond.git] / lily / warn-scheme.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1998--2011 Jan Nieuwenhuizen <janneke@gnu.org>
5   Han-Wen Nienhuys <hanwen@xs4all.nl>
6
7   LilyPond is free software: you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   LilyPond is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "config.hh"
22
23 #include "lily-guile.hh"
24 #include "program-option.hh"
25 #include "version.hh"
26 #include "warn.hh"
27
28 /*
29   Error / warning / progress / debug message output functions
30 */
31
32 LY_DEFINE (ly_error, "ly:error",
33            1, 0, 1, (SCM str, SCM rest),
34            "A Scheme callable function to issue the error @var{str}."
35            "  The error is formatted with @code{format} and @var{rest}.")
36 {
37   LY_ASSERT_TYPE (scm_is_string, str, 1);
38   str = scm_simple_format (SCM_BOOL_F, str, rest);
39   error (ly_scm2string (str));
40   return SCM_UNSPECIFIED;
41 }
42
43 LY_DEFINE (ly_programming_error, "ly:programming-error",
44            1, 0, 1, (SCM str, SCM rest),
45            "A Scheme callable function to issue the internal warning"
46            "  @var{str}.  The message is formatted with @code{format}"
47            " and @var{rest}.")
48 {
49   LY_ASSERT_TYPE (scm_is_string, str, 1);
50   str = scm_simple_format (SCM_BOOL_F, str, rest);
51
52   if (get_program_option ("warning-as-error"))
53     error (ly_scm2string (str));
54   else
55     programming_error (ly_scm2string (str));
56
57   return SCM_UNSPECIFIED;
58 }
59
60 LY_DEFINE (ly_warning, "ly:warning",
61            1, 0, 1, (SCM str, SCM rest),
62            "A Scheme callable function to issue the warning @var{str}."
63            "  The message is formatted with @code{format} and @var{rest}.")
64 {
65   LY_ASSERT_TYPE (scm_is_string, str, 1);
66   str = scm_simple_format (SCM_BOOL_F, str, rest);
67
68   if (get_program_option ("warning-as-error"))
69     error (ly_scm2string (str));
70   else
71     warning (ly_scm2string (str));
72
73   return SCM_UNSPECIFIED;
74 }
75
76 LY_DEFINE (ly_progress, "ly:progress",
77            1, 0, 1, (SCM str, SCM rest),
78            "A Scheme callable function to print progress @var{str}."
79            "  The message is formatted with @code{format} and @var{rest}.")
80 {
81   LY_ASSERT_TYPE (scm_is_string, str, 1);
82   str = scm_simple_format (SCM_BOOL_F, str, rest);
83   // Calls to ly:progress should in general not start a new line
84   progress_indication (ly_scm2string (str), false);
85   return SCM_UNSPECIFIED;
86 }
87
88 LY_DEFINE (ly_success, "ly:success",
89            1, 0, 1, (SCM str, SCM rest),
90            "A Scheme callable function to issue a success message @var{str}."
91            "  The message is formatted with @code{format} and @var{rest}.")
92 {
93   LY_ASSERT_TYPE (scm_is_string, str, 1);
94   str = scm_simple_format (SCM_BOOL_F, str, rest);
95   successful (ly_scm2string (str));
96   return SCM_UNSPECIFIED;
97 }
98
99 LY_DEFINE (ly_message, "ly:message",
100            1, 0, 1, (SCM str, SCM rest),
101            "A Scheme callable function to issue the message @var{str}."
102            "  The message is formatted with @code{format} and @var{rest}.")
103 {
104   LY_ASSERT_TYPE (scm_is_string, str, 1);
105   str = scm_simple_format (SCM_BOOL_F, str, rest);
106   message (ly_scm2string (str));
107   return SCM_UNSPECIFIED;
108 }
109
110 LY_DEFINE (ly_debug, "ly:debug",
111            1, 0, 1, (SCM str, SCM rest),
112            "A Scheme callable function to issue a debug message @var{str}."
113            "  The message is formatted with @code{format} and @var{rest}.")
114 {
115   // TODO: Add the newline flag!
116   LY_ASSERT_TYPE (scm_is_string, str, 1);
117   str = scm_simple_format (SCM_BOOL_F, str, rest);
118   debug_output (ly_scm2string (str));
119   return SCM_UNSPECIFIED;
120 }
121
122 LY_DEFINE (ly_warning_located, "ly:warning-located",
123            2, 0, 1, (SCM location, SCM str, SCM rest),
124            "A Scheme callable function to issue the warning @var{str} at"
125            " the specified location in an input file."
126            "  The message is formatted with @code{format} and @var{rest}.")
127 {
128   LY_ASSERT_TYPE (scm_is_string, location, 1);
129   LY_ASSERT_TYPE (scm_is_string, str, 2);
130   str = scm_simple_format (SCM_BOOL_F, str, rest);
131
132   if (get_program_option ("warning-as-error"))
133     error (ly_scm2string (str), ly_scm2string (location));
134   else
135     warning (ly_scm2string (str), ly_scm2string (location));
136
137   return SCM_UNSPECIFIED;
138 }