]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/cocoa/subclassing/subclassing.factor
Merge branch 'master' of git://repo.or.cz/factor/jcg
[factor.git] / basis / cocoa / subclassing / subclassing.factor
index 3f8e709df0e779dc0d88855aba3177feb0329b0a..fd18c7fa89d738e07c95d3831fd8b238e8e0f6a4 100644 (file)
@@ -12,12 +12,17 @@ IN: cocoa.subclassing
     [ sel_registerName ] [ execute ] [ ascii string>alien ]
     tri* ;
 
+: throw-if-false ( YES/NO -- )
+    zero? [ "Failed to add method or protocol to class" throw ]
+    when ;
+
 : add-methods ( methods class -- )
     swap
-    [ init-method class_addMethod drop ] with each ;
+    [ init-method class_addMethod throw-if-false ] with each ;
 
 : add-protocols ( protocols class -- )
-    swap [ objc-protocol class_addProtocol drop ] with each ;
+    swap [ objc-protocol class_addProtocol throw-if-false ]
+    with each ;
 
 : (define-objc-class) ( protocols superclass name imeth -- )
     -rot