]> gitweb.factorcode.org Git - factor.git/commitdiff
cocoa.messages: Don't import if we don't know the type
authorDoug Coleman <doug.coleman@gmail.com>
Sun, 29 Jan 2023 03:33:57 +0000 (21:33 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 29 Jan 2023 03:52:59 +0000 (21:52 -0600)
cmi_simdInt2ValueForKey:defaultValue:found: supposedly returns type "4" which is not published

when bootstrapping, NSDictionary imports 193 methods. when reloading, it imports 460, some of which aren't googleable

just punt if we don't understand the types

! To see the bad type, do this:

"NSDictionary" objc-class
[ nip dup . [ method-name dup "cmi_simdInt2ValueForKey:defaultValue:found:" = [ B ] when . ] [ method-arg-types . ] [ method-return-type . ] tri nl ] each-method-in-class

Related to #2754

basis/cocoa/messages/messages.factor

index f41690ed244dd3fe613b452cd660ad8bc3e679db..77ee8bbd9ceceea5232fca66e7c29231dd77d737 100644 (file)
@@ -2,10 +2,10 @@
 ! See https://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types alien.data alien.strings
 arrays assocs classes.struct cocoa.runtime cocoa.types
-combinators core-graphics.types generalizations
-io.encodings.utf8 kernel layouts libc make math namespaces
-sequences sets specialized-arrays splitting stack-checker
-strings words ;
+combinators core-graphics.types generalizations io
+io.encodings.utf8 kernel layouts libc make math math.parser
+namespaces sequences sets specialized-arrays
+splitting stack-checker strings words ;
 QUALIFIED-WITH: alien.c-types c
 IN: cocoa.messages
 
@@ -219,8 +219,11 @@ ERROR: no-objc-type name ;
 
 : method-return-type ( method -- ctype )
     method_copyReturnType
-    [ utf8 alien>string parse-objc-type ] keep
-    (free) ;
+    [
+        utf8 alien>string dup string>number
+        [ "unknown obcj return type: " prepend print f ]
+        [ parse-objc-type ] if
+    ] keep (free) ;
 
 : method-signature ( method -- signature )
     [ method-return-type ] [ method-arg-types ] bi 2array ;
@@ -232,9 +235,11 @@ ERROR: no-objc-type name ;
     method method-signature :> signature
     method method-name :> name
     classname "." name 3append :> fullname
-    signature cache-stubs
-    signature name objc-methods get set-at
-    signature fullname objc-methods get set-at ;
+    signature first [
+        signature cache-stubs
+        signature name objc-methods get set-at
+        signature fullname objc-methods get set-at
+    ] when ;
 
 : method-collisions ( -- collisions )
     objc-methods get >alist