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