2 input-scheme.cc -- implement Input bindings.
4 source file of the GNU LilyPond music typesetter
6 (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
11 #include "input-smob.hh"
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,
17 "Return #t if @var{x} is an input location.")
19 return unsmob_input (x) ? SCM_BOOL_T : SCM_BOOL_F;
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")
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");
30 String m = ly_scm2string (msg);
33 return SCM_UNSPECIFIED;
36 LY_DEFINE (ly_input_file_line_column, "ly:input-file-line-column", 1, 0, 0, (SCM sip),
37 "Return input location in @var{sip} as (file-name line column).")
39 Input *ip = unsmob_input (sip);
40 SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location");
41 return scm_list_3 (scm_makfrom0str (ip->file_string ().to_str0 ()),
42 scm_int2num (ip->line_number ()),
43 scm_int2num (ip->column_number ()));
46 LY_DEFINE (ly_input_both_locations, "ly:input-both-locations", 1, 0, 0, (SCM sip),
47 "Return input location in @var{sip} as (file-name first-line first-column last-line last-column).")
49 Input *ip = unsmob_input (sip);
50 SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location");
51 return scm_list_5 (scm_makfrom0str (ip->file_string ().to_str0 ()),
52 scm_int2num (ip->line_number ()),
53 scm_int2num (ip->column_number ()),
54 scm_int2num (ip->end_line_number ()),
55 scm_int2num (ip->end_column_number ()));