bring back method redefinition
parent
d0281c58d1
commit
fddcd3d475
|
@ -43,25 +43,25 @@ IN: cocoa.subclassing
|
|||
: types= ( a b -- ? )
|
||||
[ ascii alien>string ] bi@ = ;
|
||||
|
||||
! : (verify-method-type) ( class sel types -- )
|
||||
! [ class_getInstanceMethod method_getTypeEncoding ]
|
||||
! dip types=
|
||||
! [ "Objective-C method types cannot be changed once defined" throw ]
|
||||
! unless ;
|
||||
! : verify-method-type ( class sel imp types -- class sel imp types )
|
||||
! 4 ndup nip (verify-method-type) ;
|
||||
: (verify-method-type) ( class sel types -- )
|
||||
[ class_getInstanceMethod method_getTypeEncoding ]
|
||||
dip types=
|
||||
[ "Objective-C method types cannot be changed once defined" throw ]
|
||||
unless ;
|
||||
: verify-method-type ( class sel imp types -- class sel imp types )
|
||||
4 ndup nip (verify-method-type) ;
|
||||
|
||||
! : (redefine-objc-method) ( class method -- )
|
||||
! init-method ! verify-method-type
|
||||
! drop
|
||||
! [ class_getInstanceMethod ] dip method_setImplementation drop ;
|
||||
!
|
||||
! : redefine-objc-methods ( imeth name -- )
|
||||
! dup class-exists? [
|
||||
! objc_getClass swap [ (redefine-objc-method) ] with each
|
||||
! ] [
|
||||
! 2drop
|
||||
! ] if ;
|
||||
: (redefine-objc-method) ( class method -- )
|
||||
init-method ! verify-method-type
|
||||
drop
|
||||
[ class_getInstanceMethod ] dip method_setImplementation drop ;
|
||||
|
||||
: redefine-objc-methods ( imeth name -- )
|
||||
dup class-exists? [
|
||||
objc_getClass swap [ (redefine-objc-method) ] with each
|
||||
] [
|
||||
2drop
|
||||
] if ;
|
||||
|
||||
SYMBOL: +name+
|
||||
SYMBOL: +protocols+
|
||||
|
@ -71,7 +71,7 @@ SYMBOL: +superclass+
|
|||
clone [
|
||||
prepare-methods
|
||||
+name+ get "cocoa.classes" create drop
|
||||
+name+ get swap [
|
||||
+name+ get 2dup redefine-objc-methods swap [
|
||||
+protocols+ get , +superclass+ get , +name+ get , ,
|
||||
\ (define-objc-class) ,
|
||||
] [ ] make import-objc-class
|
||||
|
|
Loading…
Reference in New Issue