]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/lily-guile.hh
release: 1.3.93
[lilypond.git] / lily / include / lily-guile.hh
1 /*
2   lily-guile.hh encapsulate guile
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #ifndef LILY_GUILE_HH
10 #define LILY_GUILE_HH
11
12 #include <guile/gh.h>
13 #include <libguile.h>
14
15 #define fix_guile_1_3_4_scm_puts(scm_data, port) scm_puts ((char*)scm_data, port)
16 #define scm_puts(scm_data, port) fix_guile_1_3_4_scm_puts (scm_data, port)
17
18 #include "direction.hh"
19 #include "flower-proto.hh"
20
21 #ifndef SCM_PACK
22 #define SCM_PACK(x) ((SCM) x)
23
24 #endif
25 #ifndef SCM_UNPACK
26 #define SCM_UNPACK(x) ( x)
27 #endif
28
29 /*
30   conversion functions follow the GUILE naming convention, i.e.
31
32     A ly_B2A (B b);
33  */
34 SCM ly_str02scm (char const*c);
35 SCM ly_deep_copy (SCM);
36 SCM ly_symbol2scm (char const *);
37 String ly_scm2string (SCM s);
38 String ly_symbol2string (SCM);
39 SCM ly_offset2scm (Offset);
40 Offset ly_scm2offset (SCM);
41
42 Interval ly_scm2interval (SCM);
43 SCM ly_interval2scm (Interval);
44
45 SCM ly_parse_scm (char const* s, int* n);
46 SCM ly_quote_scm (SCM s);
47 SCM ly_type (SCM);
48
49 /*
50   display and print newline.
51  */
52 extern "C" { 
53 void ly_display_scm (SCM s);
54 }
55
56 #include "array.hh"
57
58 void read_lily_scm_file (String);
59 void init_lily_guile ();
60
61 bool isdir_b (SCM s);
62
63 /*
64   these conversion functions also do a typecheck on the argument, and
65   return a default value if S has the wrong type.
66 */
67
68 Direction to_dir (SCM s);
69 bool to_boolean (SCM s);
70
71 void init_ly_protection ();
72 unsigned int ly_scm_hash (SCM s);
73
74 SCM index_cell (SCM cellp, Direction d);
75 SCM index_set_cell (SCM cellp, Direction d, SCM val);
76
77
78 /*
79   snarfing.
80  */
81 void add_scm_init_func (void (*)());
82
83
84 typedef SCM(*Scheme_function_unknown)();
85
86 #if __GNUC_MINOR__ >= 96
87 typedef SCM(*Scheme_function_1)(SCM);    
88 #else
89 typedef SCM(*Scheme_function_1)(...);
90 #endif
91
92 #define MAKE_SCHEME_CALLBACK(TYPE, FUNC) \
93 static SCM TYPE ## _ ## FUNC ## _proc;\
94 void                                                            \
95 TYPE ## _ ## FUNC ## _init_functions ()                                 \
96 {                                                               \
97   TYPE ## _ ## FUNC ## _proc = gh_new_procedure1_0 (#TYPE "::" #FUNC, \
98   ((Scheme_function_1)TYPE :: FUNC));                           \
99 }                                                               \
100                                                                 \
101 ADD_SCM_INIT_FUNC(TYPE ## _ ## FUNC ## _callback, TYPE ## _ ## FUNC ## _init_functions);        \
102
103
104 #define ADD_SCM_INIT_FUNC(name, func)\
105 class name ## _scm_initter {                    \
106 public:\
107   name ## _scm_initter ()                       \
108   {                                             \
109     add_scm_init_func (func);           \
110   }                                             \
111 } _ ## name ## _scm_initter;                    \
112 /* end define */
113
114 #endif // LILY_GUILE_HH