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