glib: Add guarantee-color.
authorMatt Birkholz <matt@birchwood-abbey.net>
Mon, 12 Mar 2018 16:12:48 +0000 (09:12 -0700)
committerMatt Birkholz <matt@birchwood-abbey.net>
Mon, 12 Mar 2018 16:12:48 +0000 (09:12 -0700)
src/glib/glib.scm

index 252fa05800eb280b52fd560299bad25aa0043a69..1fbdd0b9f767a44874ac4b5fd8a34846d2d51d79 100644 (file)
@@ -114,6 +114,11 @@ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
     (set-color-blue! color blue)
     (set-color-alpha! color alpha)
     color))
+
+(define (guarantee-color object operator)
+  (if (color? object)
+      object
+      (error:wrong-type-argument object "a color" operator)))
 \f
 ;;; GLib Mutex