2 input-smob.cc -- implement Input smob
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "source-file.hh"
11 #include "std-string.hh"
13 #include "ly-smobs.icc"
15 /* Dummy input location for use if real one is missing. */
16 Input dummy_input_global;
18 static long input_tag;
23 Input *sc = (Input *) SCM_CELL_WORD_1 (s);
25 if (Source_file *sf = sc->get_source_file ())
26 return sf->self_scm ();
32 print_smob (SCM s, SCM port, scm_print_state *)
34 string str = "#<location " + unsmob_input (s)->location_string () + ">";
35 scm_puts (str.c_str (), port);
42 delete unsmob_input (s);
47 equal_smob (SCM sa, SCM sb)
49 Input *a = (Input *) SCM_CELL_WORD_1 (sa);
50 Input *b = (Input *) SCM_CELL_WORD_1 (sb);
51 if (a->get_source_file () == b->get_source_file () &&
52 a->start () == b->start () &&
53 a->end () == b->end ())
62 input_tag = scm_make_smob_type ("input", 0);
63 scm_set_smob_mark (input_tag, mark_smob);
64 scm_set_smob_free (input_tag, free_smob);
65 scm_set_smob_print (input_tag, print_smob);
66 scm_set_smob_equalp (input_tag, equal_smob);
72 Input *nip = new Input (ip);
75 SCM_NEWSMOB (z, input_tag, nip);
84 if (SCM_CAR (s) == (SCM)input_tag) // ugh.
85 return (Input *) SCM_CDR (s);
90 ADD_SCM_INIT_FUNC (input, start_input_smobs);