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>
15 #define IMPLEMENT_UNSMOB(CL, name) \
17 unsmob_ ## name ( SCM s) \
19 if (SMOB_IS_TYPE_B(CL, s)) \
20 return SMOB_TO_TYPE(CL, s); \
29 SCM_SETCAR(s,CL::smob_tag_); \
30 SCM me_s = SCM_PACK(cl); \
31 SCM_SETCDR (s, me_s); \
37 should include equal_p ?
39 #define IMPLEMENT_SMOBS(CL)\
44 smob_tag_ = scm_make_smob_type_mfpe ( \
45 #CL, 0, CL::mark_smob, CL::free_smob, CL::print_smob, 0);\
50 CL::unsmobify_self () \
53 scm_unprotect_object (s); \
55 SCM_SETCAR (self_scm_, SCM_EOL); \
56 SCM_SETCDR (self_scm_, SCM_EOL); \
57 self_scm_ = SCM_EOL; \
59 scm_done_malloc ( - sizeof (CL));\
65 if (self_scm_ != SCM_EOL) \
69 This is local. We don't assign to self_scm_ directly, to assure \
70 that S isn't GC-ed from under us. \
72 SCM s = smobify (this); \
74 scm_protect_object (s); \
76 scm_done_malloc(sizeof(CL));\
81 CL::free_smob (SCM ses) \
83 CL * s = (CL*) SCM_CDR(ses); \
84 /* someone else did the deed already; this might be an automatic var.*/ \
85 if (s->self_scm_ != ses)\
88 /* no need to call scm_unprotect_object, since this call \
89 implies that the object is not protected. */ \
90 SCM_SETCAR (ses, SCM_EOL); \
94 ADD_SCM_INIT_FUNC(CL, CL::init_smobs)\
97 #endif /* LY_SMOBS_ICC */