]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lily-guile.cc
Issue 4376: Add LY_ASSERT_DERIVED_SMOB macro
[lilypond.git] / lily / lily-guile.cc
index 6f7bf37f709f072594426b884827e0e2cd9b2515..d8d8d10edba05276889af19161e3a25b205e837b 100644 (file)
@@ -449,6 +449,23 @@ type_check_assignment (SCM sym, SCM val, SCM type_symbol)
   return true;
 }
 
+void
+ly_wrong_smob_arg (bool pred (SCM), SCM var, int number, const char *fun)
+{
+  string type = predicate_to_typename ((void *) pred);
+  if (pred (var))
+    {
+      // Uh oh.  derived_unsmob <T> delivered 0, yet
+      // T::is_smob delivers true.  This means that T::is_smob is a
+      // matching check from a base class of T, but var is of an
+      // incompatible derived type.
+      type = string (_ ("Wrong kind of ")).append (type);
+    }
+  scm_wrong_type_arg_msg (mangle_cxx_identifier (fun).c_str (),
+                          number, var, type.c_str ());
+}
+
+
 /* some SCM abbrevs
 
 zijn deze nou handig?