Use scalar instead of embedded_scm for context mod overrides.
[lilypond/mpolesky.git] / lily / input-scheme.cc
blob996a4a59b2c9ab14976a65554b95544f3ec0d38e
1 /*
2 input-scheme.cc -- implement Input bindings.
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "std-string.hh"
10 #include "input.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,
15 (SCM x),
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"
23 " to the location in @var{sip}. @var{msg} is interpreted"
24 " similar to @code{format}'s argument, using @var{rest}.")
26 Input *ip = unsmob_input (sip);
28 LY_ASSERT_TYPE (unsmob_input, sip, 1);
29 LY_ASSERT_TYPE (scm_is_string, msg,2);
31 msg = scm_simple_format (SCM_BOOL_F, msg, rest);
33 string m = ly_scm2string (msg);
34 ip->message (m);
36 return SCM_UNSPECIFIED;
40 LY_DEFINE (ly_input_file_line_char_column,
41 "ly:input-file-line-char-column",
42 1, 0, 0, (SCM sip),
43 "Return input location in @var{sip} as"
44 " @code{(file-name line char column)}.")
46 LY_ASSERT_TYPE (unsmob_input, sip, 1);
47 Input *ip = unsmob_input (sip);
49 int l, ch, col, offset = 0;
50 ip->get_counts (&l, &ch, &col, &offset);
51 return scm_list_4 (ly_string2scm (ip->file_string ()),
52 scm_from_int (l),
53 scm_from_int (ch),
54 scm_from_int (col));
57 LY_DEFINE (ly_input_both_locations,
58 "ly:input-both-locations",
59 1, 0, 0, (SCM sip),
60 "Return input location in @var{sip} as"
61 " @code{(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 ()));