]> git.donarmstrong.com Git - lilypond.git/blob - lily/input-scheme.cc
*** empty log message ***
[lilypond.git] / lily / input-scheme.cc
1 /*
2   input-scheme.cc --  implement Input bindings.
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8 */
9
10 #include "string.hh"
11 #include "input-smob.hh"
12
13 /* We don't use IMPLEMENT_TYPE_P, since the smobification part is
14    implemented separately from the class.  */
15 LY_DEFINE (ly_input, "ly:input-location?", 1, 0, 0,
16            (SCM x),
17            "Return #t if @var{x} is an input location.")
18 {
19   return unsmob_input (x) ? SCM_BOOL_T : SCM_BOOL_F;
20 }
21
22 LY_DEFINE (ly_input_message, "ly:input-message", 2, 0, 0, (SCM sip, SCM msg),
23           "Print @var{msg} as a GNU compliant error message, pointing to the"
24            "location in @var{sip}.\n")
25 {
26   Input *ip = unsmob_input (sip);
27   SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location");
28   SCM_ASSERT_TYPE (scm_is_string (msg), msg, SCM_ARG2, __FUNCTION__, "string");
29
30   String m = ly_scm2string (msg);
31   ip->message (m);
32
33   return SCM_UNSPECIFIED;
34 }
35
36 /*
37   TODO: rename this function. ly:input-location? vs ly:input-location
38  */
39 LY_DEFINE (ly_input_location, "ly:input-location", 1, 0, 0, (SCM sip),
40           "Return input location in @var{sip} as (file-name line column).")
41 {
42   Input *ip = unsmob_input (sip);
43   SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location");
44   return scm_list_3 (scm_makfrom0str (ip->file_string ().to_str0 ()),
45                      scm_int2num (ip->line_number ()),
46                      scm_int2num (ip->column_number ()));
47 }