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>
14 #define SCM_PACK(x) ((SCM) x)
17 #define IMPLEMENT_UNSMOB(CL, name) \
19 unsmob_ ## name ( SCM s) \
21 if (SMOB_IS_TYPE_B(CL, s)) \
22 return SMOB_TO_TYPE(CL, s); \
31 SCM_SETCAR(s,CL::smob_tag_); \
32 SCM me_s = SCM_PACK (cl); \
33 SCM_SETCDR (s, me_s); \
39 should include equal_p ?
41 #define IMPLEMENT_SMOBS(CL)\
43 static scm_smobfuns CL ## _funs = { \
44 CL::mark_smob, CL::free_smob, \
50 smob_tag_ = scm_newsmob (&CL ## _funs); \
55 CL::unsmobify_self () \
58 scm_unprotect_object (s); \
60 SCM_SETCAR (self_scm_, SCM_EOL); \
61 SCM_SETCDR (self_scm_, SCM_EOL); \
62 self_scm_ = SCM_EOL; \
64 scm_done_malloc ( - sizeof (CL));\
70 if (self_scm_ != SCM_EOL) \
74 This is local. We don't assign to self_scm_ directly, to assure \
75 that S isn't GC-ed from under us. \
77 SCM s = smobify (this); \
79 scm_protect_object (s); \
81 scm_done_malloc(sizeof(CL));\
86 CL::free_smob (SCM ses) \
88 CL * s = (CL*) SCM_CDR(ses); \
89 /* someone else did the deed already; this might be an automatic var.*/ \
90 if (s->self_scm_ != ses)\
93 /* no need to call scm_unprotect_object, since this call \
94 implies that the object is not protected. */ \
95 SCM_SETCAR (ses, SCM_EOL); \
99 ADD_SCM_INIT_FUNC(CL, CL::init_smobs)\
102 #endif /* LY_SMOBS_ICC */