]> git.donarmstrong.com Git - lilypond.git/blob - lily/music-iterator-ctor.cc
release: 1.3.107
[lilypond.git] / lily / music-iterator-ctor.cc
1 /*   
2   score-element-callback.cc --  implement Callback 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 "music-iterator-ctor.hh"
11
12 static long callback_tag;
13
14 static
15 SCM mark_smob (SCM)
16 {
17   return SCM_EOL;
18 }
19
20 static int
21 print_smob (SCM, SCM port, scm_print_state *)
22 {
23   scm_puts ("#<encapsulated C++ function>", port);
24   return 1;
25 }
26
27 static
28 scm_sizet free_smob (SCM)
29 {
30   return 0;
31 }
32
33
34 void init_cxx_function_smobs()
35 {
36   callback_tag = scm_make_smob_type_mfpe ("callback", 0,
37                                           mark_smob, free_smob,
38                                           print_smob, 0);
39 }
40
41 SCM
42 smobify_cxx_function (Cxx_function cb )
43 {
44   SCM z;
45   
46   SCM_NEWCELL(z);
47   SCM_SETCDR (z, (SCM)cb);
48   SCM_SETCAR (z, (SCM)callback_tag);
49
50   return z;
51 }
52
53
54 Cxx_function
55 unsmob_cxx_function (SCM x)
56 {
57   if (SCM_CELL_TYPE(x) == callback_tag)
58     return (Cxx_function) SCM_CELL_WORD_1(x);
59   else
60     return 0;
61 }
62
63
64