]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 5057/1: Add Protected_scm::is_bound () function
authorDavid Kastrup <dak@gnu.org>
Sat, 4 Feb 2017 21:08:25 +0000 (22:08 +0100)
committerDavid Kastrup <dak@gnu.org>
Sat, 11 Feb 2017 07:49:55 +0000 (08:49 +0100)
Since SCM_UNBNDP has problems with arguments of type Protected_scm, an
alternative member function seems like a viable alternative.

lily/include/protected-scm.hh
lily/protected-scm.cc

index 0115cb9f9ff6e2d388dd2fc714ec5639cdcc180c..db8a151ff558854e31ad52e421a74bba7ccb228b 100644 (file)
@@ -54,6 +54,7 @@ public:
   Protected_scm &operator = (Protected_scm const &);
   operator const SCM & () const;
   operator SCM & ();
+  bool is_bound () const;  // SCM_UNBNDP balks at Protected_scm
 };
 
 #endif /* PROTECTED_SCM_HH */
index a9fabdc4f2e6fa69803b4c2aaa2c3583039d2154..3a16254187a05b0b7880a53ec9250c47071e8aee 100644 (file)
@@ -86,3 +86,11 @@ Protected_scm::operator SCM & ()
 
   return *SCM_CARLOC (object_);
 }
+
+bool
+Protected_scm::is_bound () const
+{
+  if (SCM_CONSP (object_))
+    return !SCM_UNBNDP (SCM_CAR (object_));
+  return !SCM_UNBNDP (object_);
+}