2 grob-callback.cc -- implement Callback smob.
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "cxx-function-smob.hh"
11 #include "ly-smobs.icc"
13 static scm_t_bits callback_tag;
22 print_smob (SCM, SCM port, scm_print_state *)
24 scm_puts ("#<encapsulated C++ function>", port);
34 LY_DEFINE(cxx_function_type_p, "c++-function?", 1, 0, 0, (SCM x),
35 "Is this an encapsulated C++ function ?")
37 return (SCM_CELL_TYPE (x)) == callback_tag ? SCM_BOOL_T : SCM_BOOL_F;
40 void init_cxx_function_smobs ()
42 callback_tag = scm_make_smob_type ("callback", 0);
43 scm_set_smob_mark (callback_tag, mark_smob);
44 scm_set_smob_free (callback_tag, free_smob);
45 scm_set_smob_print (callback_tag, print_smob);
46 scm_set_smob_equalp (callback_tag, 0);
50 smobify_cxx_function (Cxx_function cb)
53 SCM_NEWSMOB(z,callback_tag, cb) ;
59 unsmob_cxx_function (SCM x)
62 if (SCM_NIMP (x) && SCM_CELL_TYPE (x) == callback_tag)
63 return (Cxx_function) SCM_CELL_WORD_1 (x);