]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/lily-guile.hh
release: 1.3.149
[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--2001 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
35 SCM ly_last (SCM list);
36 SCM ly_str02scm (char const*c);
37 SCM ly_write2scm (SCM s);
38 SCM ly_deep_copy (SCM);
39 SCM ly_symbol2scm (char const *);
40 String ly_scm2string (SCM s);
41 String ly_symbol2string (SCM);
42 SCM ly_offset2scm (Offset);
43 Offset ly_scm2offset (SCM);
44 SCM ly_assoc_chain (SCM key, SCM achain);
45 Interval ly_scm2interval (SCM);
46 SCM ly_interval2scm (Interval);
47
48 SCM ly_parse_scm (char const* s, int* n);
49 SCM ly_quote_scm (SCM s);
50 SCM ly_type (SCM);
51 bool type_check_assignment (SCM val, SCM sym,  SCM type_symbol) ;
52 SCM ly_number2string (SCM s);
53
54 /*
55   display and print newline.
56  */
57 extern "C" { 
58 void ly_display_scm (SCM s);
59 }
60
61 #include "array.hh"
62
63 void read_lily_scm_file (String);
64 void init_lily_guile ();
65
66 bool isdir_b (SCM s);
67 bool isaxis_b (SCM s);
68 bool ly_number_pair_p (SCM);
69 bool ly_axis_p (SCM);
70
71 /*
72   these conversion functions also do a typecheck on the argument, and
73   return a default value if S has the wrong type.
74 */
75
76 Direction to_dir (SCM s);
77 bool to_boolean (SCM s);
78
79 void init_ly_protection ();
80 unsigned int ly_scm_hash (SCM s);
81
82 SCM index_cell (SCM cellp, Direction d);
83 SCM index_set_cell (SCM cellp, Direction d, SCM val);
84
85
86 /*
87   snarfing.
88  */
89 void add_scm_init_func (void (*) ());
90
91
92 typedef SCM (*Scheme_function_unknown) ();
93
94 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 96
95 typedef SCM (*Scheme_function_0) ();
96 typedef SCM (*Scheme_function_1) (SCM);
97 typedef SCM (*Scheme_function_2) (SCM,SCM);      
98 #else
99 typedef SCM (*Scheme_function_0) (...);
100 typedef SCM (*Scheme_function_1) (...);
101 typedef SCM (*Scheme_function_2) (...);
102 #endif
103
104 #define DECLARE_SCHEME_CALLBACK(NAME,ARGS) \
105         static SCM NAME ARGS; \
106         static SCM NAME ## _proc
107
108 #define MAKE_SCHEME_CALLBACK(TYPE, FUNC, ARGCOUNT) \
109 SCM TYPE :: FUNC ## _proc;\
110 void                                                            \
111 TYPE ## _ ## FUNC ## _init_functions ()                                 \
112 {                                                               \
113   TYPE :: FUNC ## _proc = gh_new_procedure ## ARGCOUNT  ## _0 (#TYPE "::" #FUNC, \
114  ((Scheme_function_ ## ARGCOUNT)TYPE :: FUNC));                                 \
115 }                                                               \
116                                                                 \
117 ADD_SCM_INIT_FUNC (TYPE ## _ ## FUNC ## _callback, TYPE ## _ ## FUNC ## _init_functions);       \
118
119
120 #define ADD_SCM_INIT_FUNC(name, func)\
121 class name ## _scm_initter {                    \
122 public:\
123   name ## _scm_initter ()                       \
124   {                                             \
125     add_scm_init_func (func);           \
126   }                                             \
127 } _ ## name ## _scm_initter;                    \
128 /* end define */
129
130 #endif // LILY_GUILE_HH