]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/include/ly-smobs.icc
* lily/global-context.cc (run_iterator_on_me): fix grace note
[lilypond.git] / lily / include / ly-smobs.icc
index 9dbf3698c686446f7b7f49229a51260d2233ebe9..7e93c837f3638902448296c88229e3daddec0735 100644 (file)
@@ -3,8 +3,7 @@
   
   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
@@ -16,8 +15,9 @@
 #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)
 
@@ -31,7 +31,7 @@ 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)                                             \
@@ -51,14 +51,6 @@ CL::init_smobs ()                                            \
   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)                                                \
 {                                                              \
@@ -69,8 +61,22 @@ 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 ()                                                            \
 {                                                                              \