From 0da6f780888e85ab01b706ade6b98dc9e8093735 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 21 Feb 2010 22:27:32 +1300 Subject: [PATCH] cocoa.messages: if a class cannot be found, IMPORT: no longer fails at parse time. Instead, there will be a runtime error when the class word is executed --- basis/cocoa/messages/messages.factor | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/basis/cocoa/messages/messages.factor b/basis/cocoa/messages/messages.factor index 02e6335c54..eab301add7 100644 --- a/basis/cocoa/messages/messages.factor +++ b/basis/cocoa/messages/messages.factor @@ -76,13 +76,13 @@ MACRO: (send) ( selector super? -- quot ) : super-send ( receiver args... selector -- return... ) t (send) ; inline ! Runtime introspection -SYMBOL: class-startup-hooks +SYMBOL: class-init-hooks -class-startup-hooks [ H{ } clone ] initialize +class-init-hooks [ H{ } clone ] initialize : (objc-class) ( name word -- class ) 2dup execute dup [ 2nip ] [ - drop over class-startup-hooks get at [ call( -- ) ] when* + drop over class-init-hooks get at [ call( -- ) ] when* 2dup execute dup [ 2nip ] [ 2drop "No such class: " prepend throw ] if @@ -229,7 +229,7 @@ ERROR: no-objc-type name ; : class-exists? ( string -- class ) objc_getClass >boolean ; : define-objc-class-word ( quot name -- ) - [ class-startup-hooks get set-at ] + [ class-init-hooks get set-at ] [ [ "cocoa.classes" create ] [ '[ _ objc-class ] ] bi (( -- class )) define-declared @@ -237,8 +237,10 @@ ERROR: no-objc-type name ; : import-objc-class ( name quot -- ) over define-objc-class-word - [ objc-class register-objc-methods ] - [ objc-meta-class register-objc-methods ] bi ; + dup objc_getClass [ + [ objc-class register-objc-methods ] + [ objc-meta-class register-objc-methods ] bi + ] [ drop ] if ; : root-class ( class -- root ) dup class_getSuperclass [ root-class ] [ ] ?if ;