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"
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
);
36 return SCM_UNSPECIFIED
;
40 LY_DEFINE (ly_input_file_line_char_column
,
41 "ly:input-file-line-char-column",
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
);
52 ip
->get_counts (&l
, &ch
, &col
);
53 return scm_list_4 (ly_string2scm (ip
->file_string ()),
59 LY_DEFINE (ly_input_both_locations
,
60 "ly:input-both-locations",
62 "Return input location in @var{sip} as"
63 " @code{(file-name first-line first-column last-line last-column)}.")
66 LY_ASSERT_TYPE (unsmob_input
, sip
, 1);
67 Input
*ip
= unsmob_input (sip
);
69 return scm_list_5 (ly_string2scm (ip
->file_string ()),
70 scm_from_int (ip
->line_number ()),
71 scm_from_int (ip
->column_number ()),
72 scm_from_int (ip
->end_line_number ()),
73 scm_from_int (ip
->end_column_number ()));