- }
- template <class T, void (T::*callback)(Stream_event *)>
- static void trampoline (SCM target, SCM event)
- {
- // The same, but for callbacks for translator listeners which get
- // the unpacked event which, in turn, gets protected previously
-
- T *t = unsmob<T> (target);
- LY_ASSERT_SMOB (T, target, 1);
- LY_ASSERT_SMOB (Stream_event, event, 2);
-
- t->protect_event (event);
- (t->*callback) (unsmob<Stream_event> (event));
- }
-
- Callback_wrapper (void (*trampoline) (SCM, SCM)) : trampoline_ (trampoline)
- { } // Private constructor, use only in make_smob
-public:
- static const char * const type_p_name_; // = 0
- LY_DECLARE_SMOB_PROC (&Callback_wrapper::call, 2, 0, 0)
- SCM call (SCM target, SCM ev)
- {
- trampoline_ (target, ev);
- return SCM_UNSPECIFIED;
- }
- // Callback wrappers are for an unchanging entity, so we do the Lisp
- // creation just once on the first call of make_smob. So we only
- // get a single Callback_wrapper instance for each differently
- // templated make_smob call.
- template <class T, class Arg, void (T::*callback)(Arg)>
- static SCM make_smob ()
- {
- static SCM res = scm_permanent_object
- (Callback_wrapper (trampoline<T, callback>).smobbed_copy ());
- return res;