]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/lily-guile.hh
release: 1.3.73
[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 #include "direction.hh"
15 #include "flower-proto.hh"
16
17 #ifndef SCM_PACK
18 #define SCM_PACK(x) ((SCM) x)
19
20 #endif
21 #ifndef SCM_UNPACK
22 #define SCM_UNPACK(x) ( x)
23 #endif
24
25 /*
26   conversion functions follow the GUILE naming convention, i.e.
27
28     A ly_B2A (B b);
29  */
30 SCM ly_str02scm (char const*c);
31 SCM ly_deep_copy (SCM);
32
33
34 SCM ly_symbol2scm (char const *);
35 String ly_scm2string (SCM s);
36 String ly_symbol2string (SCM);
37 SCM ly_offset2scm (Offset);
38 Offset ly_scm2offset (SCM);
39
40 Interval ly_scm2interval (SCM);
41 SCM ly_interval2scm (Interval);
42
43 SCM ly_parse_scm (char const* s, int* n);
44 SCM ly_quote_scm (SCM s);
45 SCM ly_type (SCM);
46
47 /*
48   display and print newline.
49  */
50 void ly_display_scm (SCM s);
51
52 #include "array.hh"
53
54 void read_lily_scm_file (String);
55 void init_lily_guile ();
56
57 bool isdir_b (SCM s);
58
59 /*
60   these conversion functions also do a typecheck on the argument, and
61   return a default value if S has the wrong type.
62 */
63
64 Direction to_dir (SCM s);
65 bool to_boolean (SCM s);
66
67 void init_ly_protection ();
68 unsigned int ly_scm_hash (SCM s);
69
70 SCM index_cell (SCM cellp, Direction d);
71 SCM index_set_cell (SCM cellp, Direction d, SCM val);
72
73
74 /*
75   snarfing.
76  */
77 void add_scm_init_func (void (*)());
78
79
80
81 #define MAKE_SCHEME_CALLBACK(TYPE, FUNC) \
82 static SCM TYPE ## _ ## FUNC ## _proc;\
83 void                                                            \
84 TYPE ## _ ## FUNC ## _init_functions ()                                 \
85 {                                                               \
86   TYPE ## _ ## FUNC ## _proc = gh_new_procedure1_0 (#TYPE "::" #FUNC, \
87   (SCM(*)(...))TYPE :: FUNC);                           \
88 }                                                               \
89                                                                 \
90 ADD_SCM_INIT_FUNC(TYPE ## _ ## FUNC ## _callback, TYPE ## _ ## FUNC ## _init_functions);        \
91
92
93 #define ADD_SCM_INIT_FUNC(name, func)\
94 class name ## _scm_initter {                    \
95 public:\
96   name ## _scm_initter ()                       \
97   {                                             \
98     add_scm_init_func (func);           \
99   }                                             \
100 } _ ## name ## _scm_initter;                    \
101 /* end define */
102
103 #endif // LILY_GUILE_HH