source file of the GNU LilyPond music typesetter
- (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
+ (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#ifndef LY_SMOBS_ICC
#define IMPLEMENT_TYPE_P(CL, FUNCNAME)\
void init_type_ ## CL ()\
{\
- scm_c_define_gsubr (FUNCNAME, 1, 0, 0, (Scheme_function_unknown) CL::smob_p);\
- ly_add_function_documentation (FUNCNAME, "(SCM x)", "Check if @var{x} is a " #CL " object");\
+ SCM subr = scm_c_define_gsubr (FUNCNAME, 1, 0, 0, (Scheme_function_unknown) CL::smob_p);\
+ ly_add_function_documentation (subr, FUNCNAME, "(SCM x)", "Is @var{x} a @code{" #CL "} object?");\
+ scm_c_export (FUNCNAME, NULL);\
}\
ADD_SCM_INIT_FUNC (init_type_ ## CL, init_type_ ## CL)
-#define IMPLEMENT_SIMPLE_SMOBS(CL) \
+#define IMPLEMENT_BASE_SMOBS(CL) \
scm_t_bits CL::smob_tag_; \
SCM \
CL::smob_p (SCM s) \
scm_set_smob_print (smob_tag_, CL::print_smob); \
scm_set_smob_equalp (smob_tag_, CL::equal_p); \
} \
-SCM CL::smobbed_self () const \
-{ \
- SCM s; \
- s = gh_cons (SCM_PACK (CL::smob_tag_), SCM_PACK (this)); \
- scm_gc_register_collectable_memory ((CL*)this, sizeof (CL), #CL " smob"); \
- \
- return s; \
-} \
size_t \
CL::free_smob (SCM ses) \
{ \
}\
ADD_SCM_INIT_FUNC (CL, CL::init_smobs)
+
+#define IMPLEMENT_SIMPLE_SMOBS(CL) \
+IMPLEMENT_BASE_SMOBS(CL);\
+SCM CL::smobbed_copy () const \
+{ \
+ CL * ptr = new CL (*this);\
+ SCM s; \
+ s = gh_cons (SCM_PACK (CL::smob_tag_), SCM_PACK (ptr)); \
+ scm_gc_register_collectable_memory ((CL*)this, sizeof (CL), #CL " smob"); \
+ \
+ return s; \
+} \
+
+
#define IMPLEMENT_SMOBS(CL) \
-IMPLEMENT_SIMPLE_SMOBS (CL) \
+IMPLEMENT_BASE_SMOBS (CL) \
SCM \
CL::smobify_self () \
{ \