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