From: David Kastrup Date: Sat, 4 Feb 2017 21:08:25 +0000 (+0100) Subject: Issue 5057/1: Add Protected_scm::is_bound () function X-Git-Url: https://git.donarmstrong.com/lilypond.git?a=commitdiff_plain;h=1bbe496d7d194ce6da2e710d0cc9a125e51a77b9;p=lilypond.git Issue 5057/1: Add Protected_scm::is_bound () function Since SCM_UNBNDP has problems with arguments of type Protected_scm, an alternative member function seems like a viable alternative. --- diff --git a/lily/include/protected-scm.hh b/lily/include/protected-scm.hh index 0115cb9f9f..db8a151ff5 100644 --- a/lily/include/protected-scm.hh +++ b/lily/include/protected-scm.hh @@ -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 */ diff --git a/lily/protected-scm.cc b/lily/protected-scm.cc index a9fabdc4f2..3a16254187 100644 --- a/lily/protected-scm.cc +++ b/lily/protected-scm.cc @@ -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_); +}