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; \
60 scm_done_malloc ( - sizeof (CL));\
66 if (self_scm_ != SCM_EOL) \
70 This is local. We don't assign to self_scm_ directly, to assure \
71 that S isn't GC-ed from under us. \
73 SCM s = smobify (this); \
75 scm_protect_object (s); \
77 scm_done_malloc(sizeof(CL));\
82 CL::free_smob (SCM ses) \
84 CL * s = (CL*) SCM_CDR(ses); \
85 /* someone else did the deed already; this might be an automatic var.*/ \
86 if (s->self_scm_ != ses)\
89 /* no need to call scm_unprotect_object, since this call \
90 implies that the object is not protected. */ \
91 SCM_CAR(ses) = SCM_EOL;\
95 ADD_SCM_INIT_FUNC(CL, CL::init_smobs)\
98 #endif /* LY_SMOBS_ICC */