2 input-smob.cc -- implement Input smob
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "input-smob.hh"
13 #include "ly-smobs.icc"
15 static long input_tag;
24 print_smob (SCM s, SCM port, scm_print_state *)
26 String str = "#<location " + unsmob_input (s)->location_str () + ">";
27 scm_puts (str.ch_C (), port);
34 delete unsmob_input (s);
39 We don't use IMPLEMENT_TYPE_P, since the smobification part is
40 implemented separately from the class.
42 LY_DEFINE(ly_input_p, "ly-input-location?", 1, 0, 0,
44 "Return whether @var{x} is an input location")
46 return unsmob_input (x) ? SCM_BOOL_T : SCM_BOOL_F ;
49 LY_DEFINE(ly_input_message, "ly-input-message", 2, 0, 0, (SCM sip, SCM msg),
50 "Print @var{msg} as a GNU compliant error message, pointing to the
51 location in @var{sip}.")
53 Input *ip = unsmob_input(sip);
55 SCM_ASSERT_TYPE(ip, sip, SCM_ARG1, __FUNCTION__, "input location");
56 SCM_ASSERT_TYPE(gh_string_p(msg), msg, SCM_ARG2, __FUNCTION__, "string");
58 String m = ly_scm2string (msg);
68 input_tag = scm_make_smob_type ("input", 0);
69 scm_set_smob_mark (input_tag, mark_smob);
70 scm_set_smob_free (input_tag, free_smob);
71 scm_set_smob_print (input_tag, print_smob);
72 scm_set_smob_equalp (input_tag, 0);
80 Input * nip = new Input (ip);
83 SCM_NEWSMOB (z, input_tag, nip);
92 if (SCM_CAR (s) == (SCM)input_tag) // ugh.
93 return (Input*) SCM_CDR (s);
99 ADD_SCM_INIT_FUNC (input, start_input_smobs);
102 Input dummy_input_global;