]> git.donarmstrong.com Git - lilypond.git/blob - lily/input-smob.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / input-smob.cc
1 /*
2   input-smob.cc -- implement Input smob
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2000--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "input-smob.hh"
10
11 #include "std-string.hh"
12
13 #include "ly-smobs.icc"
14
15 /* Dummy input location for use if real one is missing.  */
16 Input dummy_input_global;
17
18 static long input_tag;
19
20 static
21 SCM mark_smob (SCM)
22 {
23   return SCM_EOL;
24 }
25
26 static int
27 print_smob (SCM s, SCM port, scm_print_state *)
28 {
29   string str = "#<location " + unsmob_input (s)->location_string () + ">";
30   scm_puts (str.c_str (), port);
31   return 1;
32 }
33
34 static size_t
35 free_smob (SCM s)
36 {
37   delete unsmob_input (s);
38   return 0;
39 }
40
41 static void
42 start_input_smobs ()
43 {
44   input_tag = scm_make_smob_type ("input", 0);
45   scm_set_smob_mark (input_tag, mark_smob);
46   scm_set_smob_free (input_tag, free_smob);
47   scm_set_smob_print (input_tag, print_smob);
48   scm_set_smob_equalp (input_tag, 0);
49 }
50
51 SCM
52 make_input (Input ip)
53 {
54   Input *nip = new Input (ip);
55   SCM z;
56
57   SCM_NEWSMOB (z, input_tag, nip);
58   return z;
59 }
60
61 Input *
62 unsmob_input (SCM s)
63 {
64   if (SCM_IMP (s))
65     return 0;
66   if (SCM_CAR (s) == (SCM)input_tag) // ugh.
67     return (Input *) SCM_CDR (s);
68   else
69     return 0;
70 }
71
72 ADD_SCM_INIT_FUNC (input, start_input_smobs);
73