]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/include/smobs.hh
2003 -> 2004
[lilypond.git] / lily / include / smobs.hh
index 45be2c08ae65cdb4fbbd377ea74ee2f03de654a7..c0155ee1fd771f3aef54c179dda33dcbd4437d37 100644 (file)
@@ -3,7 +3,7 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
 
@@ -75,7 +75,7 @@
 
    class Bla {
    Csmob *ptr;
-   ~Bla () {  scm_unprotect_object (ptr->self_scm_); }
+   ~Bla () {  scm_gc_unprotect_object (ptr->self_scm_); }
    
    };
 
@@ -104,13 +104,18 @@ protected: \
        friend class Non_existant_class ; \
        SCM smobbed_self () const; \
 private:\
-       static long smob_tag_;                                  \
+       static scm_t_bits smob_tag_;                            \
        static SCM mark_smob (SCM);                             \
-       static scm_sizet free_smob (SCM s);                     \
+       static size_t free_smob (SCM s);                        \
        static int print_smob (SCM s, SCM p, scm_print_state*); \
 public: \
        static SCM equal_p (SCM a, SCM b);\
-       static CL * unsmob (SCM);\
+       static CL * unsmob (SCM s){\
+  if (SCM_NIMP (s) && SCM_CELL_TYPE (s) == smob_tag_)          \
+    return (CL*) SCM_CELL_WORD_1 (s);                          \
+  else                                                         \
+    return 0;                                                  \
+}                                                              \
        static SCM smob_p (SCM);\
        static void init_smobs ();                              \
 private:
@@ -128,6 +133,14 @@ public: \
        SCM self_scm () const { return self_scm_; } \
 private:
 
+#define DECLARE_UNSMOB(CL,name) \
+inline CL *                                            \
+unsmob_ ## name (SCM s)                        \
+{                                              \
+return  CL::unsmob (s);                                \
+}
+
+
 
 #endif /* SMOBS_HH */