]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/include/ly-smobs.icc
patch::: 1.3.33.jcn3
[lilypond.git] / lily / include / ly-smobs.icc
index 3ee8d6db515e231b4d67a963257dbb18213909fe..9b54ddc24e5e23165a83c5a11cad3aa251ed40b3 100644 (file)
@@ -3,13 +3,35 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
 
 #ifndef LY_SMOBS_ICC
 #define LY_SMOBS_ICC
 
+#define IMPLEMENT_UNSMOB(CL, name)             \
+CL *                                           \
+unsmob_ ## name ( SCM s)                       \
+{                                              \
+  if (SMOB_IS_TYPE_B(CL, s))                   \
+    return SMOB_TO_TYPE(CL, s);                        \
+  else                                         \
+    return 0;                                  \
+}\
+SCM smobify (CL *cl)\
+{\
+  SCM s;                                                               \
+                                                                       \
+  SCM_NEWCELL(s);                                                      \
+  SCM_SETCAR(s,CL::smob_tag_);                                         \
+  void * me_p = cl;                                                    \
+  SCM_SETCDR(s,me_p);                                                  \
+return s;\
+}\
+
+
+
 #define IMPLEMENT_SMOBS(CL)\
 long CL::smob_tag_;\
 static scm_smobfuns CL ## _funs = {                                    \
@@ -44,14 +66,8 @@ CL::smobify_self ()                                                  \
     This is local. We don't assign to self_scm_ directly, to assure    \
     that S isn't GC-ed from under us.                                  \
    */                                                                  \
-  SCM s;                                                               \
-                                                                       \
-  SCM_NEWCELL(s);                                                      \
+  SCM s = smobify (this); \
   self_scm_ = s;                                                       \
-                                                                       \
-  SCM_SETCAR(s,smob_tag_);                                             \
-  void * me_p = this;                                                  \
-  SCM_SETCDR(s,me_p);                                                  \
   scm_protect_object (s);                                              \
                                                                        \
 /* no scm_done_malloc() !  */ \