2 input-scheme.cc -- implement Input bindings.
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "std-string.hh"
12 /* We don't use IMPLEMENT_TYPE_P, since the smobification part is
13 implemented separately from the class. */
14 LY_DEFINE (ly_input_location_p, "ly:input-location?", 1, 0, 0,
16 "Is @var{x} an @code{input-location}?")
18 return unsmob_input (x) ? SCM_BOOL_T : SCM_BOOL_F;
21 LY_DEFINE (ly_input_message, "ly:input-message", 2, 0, 1, (SCM sip, SCM msg, SCM rest),
22 "Print @var{msg} as a GNU compliant error message, pointing to the "
23 "location in @var{sip}. @var{msg} is interpreted similar to @code{format}'s argument\n")
25 Input *ip = unsmob_input (sip);
27 LY_ASSERT_TYPE (unsmob_input, sip, 1);
28 LY_ASSERT_TYPE (scm_is_string, msg,2);
30 msg = scm_simple_format (SCM_BOOL_F, msg, rest);
32 string m = ly_scm2string (msg);
35 return SCM_UNSPECIFIED;
39 LY_DEFINE (ly_input_file_line_char_column,
40 "ly:input-file-line-char-column",
42 "Return input location in @var{sip} as (file-name line char column).")
44 LY_ASSERT_TYPE (unsmob_input, sip, 1);
45 Input *ip = unsmob_input (sip);
50 ip->get_counts (&l, &ch, &col);
51 return scm_list_4 (ly_string2scm (ip->file_string ()),
57 LY_DEFINE (ly_input_both_locations,
58 "ly:input-both-locations",
60 "Return input location in @var{sip} as "
61 "(file-name first-line first-column last-line last-column).")
64 LY_ASSERT_TYPE (unsmob_input, sip, 1);
65 Input *ip = unsmob_input (sip);
67 return scm_list_5 (ly_string2scm (ip->file_string ()),
68 scm_from_int (ip->line_number ()),
69 scm_from_int (ip->column_number ()),
70 scm_from_int (ip->end_line_number ()),
71 scm_from_int (ip->end_column_number ()));