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)\
41 static scm_smobfuns CL ## _funs = { \
42 CL::mark_smob, CL::free_smob, \
48 smob_tag_ = scm_newsmob (&CL ## _funs); \
53 CL::unsmobify_self () \
56 scm_unprotect_object (s); \
58 SCM_SETCAR (self_scm_, SCM_EOL); \
59 SCM_SETCDR (self_scm_, SCM_EOL); \
60 self_scm_ = SCM_EOL; \
62 scm_done_malloc ( - sizeof (CL));\
68 if (self_scm_ != SCM_EOL) \
72 This is local. We don't assign to self_scm_ directly, to assure \
73 that S isn't GC-ed from under us. \
75 SCM s = smobify (this); \
77 scm_protect_object (s); \
79 scm_done_malloc(sizeof(CL));\
84 CL::free_smob (SCM ses) \
86 CL * s = (CL*) SCM_CDR(ses); \
87 /* someone else did the deed already; this might be an automatic var.*/ \
88 if (s->self_scm_ != ses)\
91 /* no need to call scm_unprotect_object, since this call \
92 implies that the object is not protected. */ \
93 SCM_SETCAR (ses, SCM_EOL); \
97 ADD_SCM_INIT_FUNC(CL, CL::init_smobs)\
100 #endif /* LY_SMOBS_ICC */