]> git.donarmstrong.com Git - lilypond.git/blob - lily/input-smob.cc
*** empty log message ***
[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--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include "input-smob.hh"
11
12 #include "string.hh"
13
14 #include "ly-smobs.icc"
15
16 /* Dummy input location for use if real one is missing.  */
17 Input dummy_input_global;
18
19 static long input_tag;
20
21 static
22 SCM mark_smob (SCM)
23 {
24   return SCM_EOL;
25 }
26
27 static int
28 print_smob (SCM s, SCM port, scm_print_state *)
29 {
30   String str = "#<location " +  unsmob_input (s)->location_string () + ">";
31   scm_puts (str.to_str0 (), port);
32   return 1;
33 }
34
35 static size_t
36 free_smob (SCM s)
37 {
38   delete unsmob_input (s);
39   return 0;
40 }
41
42
43 static void
44 start_input_smobs ()
45 {
46   input_tag = scm_make_smob_type ("input", 0);
47   scm_set_smob_mark (input_tag, mark_smob);
48   scm_set_smob_free (input_tag, free_smob);
49   scm_set_smob_print (input_tag, print_smob);
50   scm_set_smob_equalp (input_tag, 0);
51 }
52
53 SCM
54 make_input (Input ip)
55 {
56   Input *nip = new Input (ip);
57   SCM z;
58   
59   SCM_NEWSMOB (z, input_tag, nip);
60   return z;
61 }
62
63 Input *                                         
64 unsmob_input (SCM s)
65 {
66   if (SCM_IMP (s))
67     return 0;
68   if (SCM_CAR (s) == (SCM)input_tag) // ugh.
69     return (Input*) SCM_CDR (s);
70   else                                          
71     return 0;                                   
72 }
73
74
75 ADD_SCM_INIT_FUNC (input, start_input_smobs);
76