]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/include/smobs.tcc
Run grand replace for 2015.
[lilypond.git] / lily / include / smobs.tcc
index eaec076de349442b1b4726e07f71c1160e097b76..c0a62535f5e4f830200c8b4a249ae955032d414f 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- C++ -*-
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2005--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 2005--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -35,6 +35,13 @@ Smob_base<Super>::mark_trampoline (SCM arg)
   return (Super::unsmob (arg))->mark_smob ();
 }
 
+template <class Super>
+int
+Smob_base<Super>::print_trampoline (SCM arg, SCM port, scm_print_state *p)
+{
+  return (Super::unsmob (arg))->print_smob (port, p);
+}
+
 template <class Super>
 SCM
 Smob_base<Super>::register_ptr (Super *p)
@@ -49,7 +56,7 @@ Smob_base<Super>::register_ptr (Super *p)
   return s;
 }
 
-// Default, should not actually get called
+// Defaults, should not actually get called
 template <class Super>
 SCM
 Smob_base<Super>::mark_smob ()
@@ -57,9 +64,25 @@ Smob_base<Super>::mark_smob ()
   return SCM_UNSPECIFIED;
 }
 
+template <class Super>
+size_t
+Smob_base<Super>::free_smob (SCM)
+{
+  return 0;
+}
+
+template <class Super>
+SCM
+Smob_base<Super>::equal_p (SCM, SCM)
+{
+  return SCM_BOOL_F;
+}
+
+// Default, will often get called
+
 template <class Super>
 int
-Smob_base<Super>::print_smob (SCM, SCM p, scm_print_state *)
+Smob_base<Super>::print_smob (SCM p, scm_print_state *)
 {
   scm_puts ("#<", p);
   scm_puts (smob_name_.c_str (), p);
@@ -103,13 +126,18 @@ void Smob_base<Super>::init ()
   // While that's not a consideration for type_p_name_, it's easier
   // doing it like the rest.
 
-  if (Super::free_smob != 0)
+  if (&Super::free_smob != &Smob_base<Super>::free_smob)
     scm_set_smob_free (smob_tag_, Super::free_smob);
-  if (&Super::mark_smob != &Smob_base<Super>::mark_smob)
+  // Old GCC versions get their type lattice for pointers-to-members
+  // tangled up to a degree where we need to typecast _both_ covariant
+  // types in order to be able to compare them.  The other comparisons
+  // are for static member functions and thus are ordinary function
+  // pointers which work without those contortions.
+  if (static_cast<SCM (Super::*)()>(&Super::mark_smob) !=
+      static_cast<SCM (Super::*)()>(&Smob_base<Super>::mark_smob))
     scm_set_smob_mark (smob_tag_, Super::mark_trampoline);
-  if (Super::print_smob != 0)
-    scm_set_smob_print (smob_tag_, Super::print_smob);
-  if (Super::equal_p != 0)
+  scm_set_smob_print (smob_tag_, Super::print_trampoline);
+  if (&Super::equal_p != &Smob_base<Super>::equal_p)
     scm_set_smob_equalp (smob_tag_, Super::equal_p);
   if (Super::type_p_name_ != 0)
     {
@@ -122,7 +150,7 @@ void Smob_base<Super>::init ()
       scm_c_export (Super::type_p_name_, NULL);
     }
   ly_add_type_predicate ((void *) is_smob, smob_name_.c_str ());
-  if (Super::smob_proc != 0)
+  if (Super::smob_proc_signature_ >= 0)
     scm_set_smob_apply (smob_tag_,
                         (scm_t_subr)Super::smob_proc,
                         Super::smob_proc_signature_ >> 8,