2 ly-smobs.icc -- implement smob glue.
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2000 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 should include equal_p ?
37 #define IMPLEMENT_SMOBS(CL)\
39 static scm_smobfuns CL ## _funs = { \
40 CL::mark_smob, CL::free_smob, \
46 smob_tag_ = scm_newsmob (&CL ## _funs); \
51 CL::unsmobify_self () \
54 scm_unprotect_object (s); \
56 SCM_CAR(self_scm_) = SCM_EOL; \
57 SCM_CDR(self_scm_) = SCM_EOL; \
58 self_scm_ = SCM_EOL; \
64 if (self_scm_ != SCM_EOL) \
68 This is local. We don't assign to self_scm_ directly, to assure \
69 that S isn't GC-ed from under us. \
71 SCM s = smobify (this); \
73 scm_protect_object (s); \
75 /* no scm_done_malloc() ! */ \
80 CL::free_smob (SCM ses) \
82 CL * s = (CL*) SCM_CDR(ses); \
83 /* someone else did the deed already; this might be an automatic var.*/ \
84 if (s->self_scm_ != ses)\
86 SCM_CAR(ses) = SCM_EOL;\
90 ADD_SCM_INIT_FUNC(CL, CL::init_smobs)\
93 #endif /* LY_SMOBS_ICC */