Better error checking for Cocoa bridge, update for NSRect -> CGRect renaming
parent
a5737a51b5
commit
b856cc5491
|
@ -52,7 +52,7 @@ CLASS: {
|
|||
{ +name+ "Bar" }
|
||||
} {
|
||||
"bar"
|
||||
"CGRect"
|
||||
"NSRect"
|
||||
{ "id" "SEL" }
|
||||
[ 2drop test-foo "x" get ]
|
||||
} {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
! Copyright (C) 2006, 2008 Slava Pestov.
|
||||
! Copyright (C) 2006, 2009 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors alien alien.c-types alien.strings arrays assocs
|
||||
continuations combinators compiler compiler.alien kernel math
|
||||
|
@ -167,13 +167,19 @@ assoc-union alien>objc-types set-global
|
|||
drop "void*"
|
||||
] unless ;
|
||||
|
||||
ERROR: no-objc-type name ;
|
||||
|
||||
: decode-type ( ch -- ctype )
|
||||
1string dup objc>alien-types get at
|
||||
[ ] [ no-objc-type ] ?if ;
|
||||
|
||||
: (parse-objc-type) ( i string -- ctype )
|
||||
[ [ 1+ ] dip ] [ nth ] 2bi {
|
||||
{ [ dup "rnNoORV" member? ] [ drop (parse-objc-type) ] }
|
||||
{ [ dup CHAR: ^ = ] [ 3drop "void*" ] }
|
||||
{ [ dup CHAR: { = ] [ drop objc-struct-type ] }
|
||||
{ [ dup CHAR: [ = ] [ 3drop "void*" ] }
|
||||
[ 2nip 1string objc>alien-types get at ]
|
||||
[ 2nip decode-type ]
|
||||
} cond ;
|
||||
|
||||
: parse-objc-type ( string -- ctype ) 0 swap (parse-objc-type) ;
|
||||
|
|
|
@ -32,10 +32,11 @@ IN: cocoa.subclassing
|
|||
[ add-protocols ] [ add-methods ] [ objc_registerClassPair ]
|
||||
tri ;
|
||||
|
||||
: encode-type ( type -- encoded )
|
||||
dup alien>objc-types get at [ ] [ no-objc-type ] ?if ;
|
||||
|
||||
: encode-types ( return types -- encoding )
|
||||
swap prefix [
|
||||
alien>objc-types get at "0" append
|
||||
] map concat ;
|
||||
swap prefix [ encode-type "0" append ] map concat ;
|
||||
|
||||
: prepare-method ( ret types quot -- type imp )
|
||||
[ [ encode-types ] 2keep ] dip [
|
||||
|
|
Loading…
Reference in New Issue