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