2 ly-smobs.icc -- implement smob glue.
4 source file of the GNU LilyPond music typesetter
6 (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
13 #define IMPLEMENT_UNSMOB(CL, name) \
15 unsmob_ ## name ( SCM s) \
17 if (SMOB_IS_TYPE_B(CL, s)) \
18 return SMOB_TO_TYPE(CL, s); \
27 SCM_SETCAR(s,CL::smob_tag_); \
35 #define IMPLEMENT_SMOBS(CL)\
37 static scm_smobfuns CL ## _funs = { \
38 CL::mark_smob, CL::free_smob, \
44 smob_tag_ = scm_newsmob (&CL ## _funs); \
49 CL::unsmobify_self () \
52 scm_unprotect_object (s); \
54 SCM_CAR(self_scm_) = SCM_EOL; \
55 SCM_CDR(self_scm_) = SCM_EOL; \
56 self_scm_ = SCM_EOL; \
62 if (self_scm_ != SCM_EOL) \
66 This is local. We don't assign to self_scm_ directly, to assure \
67 that S isn't GC-ed from under us. \
69 SCM s = smobify (this); \
71 scm_protect_object (s); \
73 /* no scm_done_malloc() ! */ \
78 CL::free_smob (SCM ses) \
80 CL * s = (CL*) SCM_CDR(ses); \
81 /* someone else did the deed already; this might be an automatic var.*/ \
82 if (s->self_scm_ != ses)\
84 SCM_CAR(ses) = SCM_EOL;\
88 ADD_SCM_INIT_FUNC(CL, CL::init_smobs)\
91 #endif /* LY_SMOBS_ICC */