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>
16 #define IMPLEMENT_UNSMOB(CL, name) \
18 unsmob_ ## name ( SCM s) \
20 if (SMOB_IS_TYPE_B(CL, s)) \
21 return SMOB_TO_TYPE(CL, s); \
30 SCM_SETCAR(s,CL::smob_tag_); \
31 SCM me_s = SCM_PACK(cl); \
32 SCM_SETCDR (s, me_s); \
38 should include equal_p ?
40 #define IMPLEMENT_SMOBS(CL)\
45 smob_tag_ = scm_make_smob_type_mfpe ( \
46 #CL, 0, CL::mark_smob, CL::free_smob, CL::print_smob, 0);\
51 CL::unsmobify_self () \
54 scm_unprotect_object (s); \
56 SCM_SETCAR (self_scm_, SCM_EOL); \
57 SCM_SETCDR (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_SETCAR (ses, SCM_EOL); \
95 ADD_SCM_INIT_FUNC(CL, CL::init_smobs)\
98 #endif /* LY_SMOBS_ICC */