]> git.donarmstrong.com Git - lilypond.git/blob - lily/input-scheme.cc
Fix some bugs in the dynamic engraver and PostScript backend
[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--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "std-string.hh"
10 #include "input-smob.hh"
11
12 /* We don't use IMPLEMENT_TYPE_P, since the smobification part is
13    implemented separately from the class.  */
14 LY_DEFINE (ly_input, "ly:input-location?", 1, 0, 0,
15            (SCM x),
16            "Is @var{x} an @code{input-location}?")
17 {
18   return unsmob_input (x) ? SCM_BOOL_T : SCM_BOOL_F;
19 }
20
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")
24 {
25   Input *ip = unsmob_input (sip);
26   SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location");
27   SCM_ASSERT_TYPE (scm_is_string (msg), msg, SCM_ARG2, __FUNCTION__, "string");
28
29   msg = scm_simple_format (SCM_BOOL_F, msg, rest);
30
31   string m = ly_scm2string (msg);
32   ip->message (m);
33
34   return SCM_UNSPECIFIED;
35 }
36
37
38 LY_DEFINE (ly_input_file_line_column,
39            "ly:input-file-line-char-column",
40            1, 0, 0, (SCM sip),
41            "Return input location in @var{sip} as (file-name line char column).")
42 {
43   Input *ip = unsmob_input (sip);
44   SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location");
45
46   int l = 0;
47   int ch = 0;
48   int col = 0;
49   ip->get_counts (&l, &ch, &col);
50   return scm_list_4 (scm_makfrom0str (ip->file_string ().c_str ()),
51                      scm_from_int (l),
52                      scm_from_int (ch),
53                      scm_from_int (col));
54 }
55
56 LY_DEFINE (ly_input_both_locations,
57            "ly:input-both-locations",
58            1, 0, 0, (SCM sip),
59            "Return input location in @var{sip} as "
60            "(file-name first-line first-column last-line last-column).")
61 {
62   Input *ip = unsmob_input (sip);
63   SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location");
64   return scm_list_5 (scm_makfrom0str (ip->file_string ().c_str ()),
65                      scm_from_int (ip->line_number ()),
66                      scm_from_int (ip->column_number ()),
67                      scm_from_int (ip->end_line_number ()),
68                      scm_from_int (ip->end_column_number ()));
69 }