]> gitweb.factorcode.org Git - factor.git/commitdiff
cocoa.messages: add a word to get all objc class names
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 30 Jan 2023 00:49:52 +0000 (18:49 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 30 Jan 2023 00:53:39 +0000 (18:53 -0600)
basis/cocoa/messages/messages.factor

index 859126ed67db412baf5d2edc9722f7550c819369..3960701e36f7a380dbaf2dbea9ef977821700a36 100644 (file)
@@ -2,9 +2,9 @@
 ! 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 continuations core-graphics.types generalizations io
-io.encodings.utf8 kernel layouts libc make math math.parser
-namespaces sequences sets specialized-arrays
+combinators continuations core-graphics.types destructors
+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
@@ -290,3 +290,11 @@ ERROR: no-objc-type name ;
 
 : root-class ( class -- root )
     dup class_getSuperclass [ root-class ] [ ] ?if ;
+
+: objc-class-names ( -- seq )
+    [
+        f 0 objc_getClassList
+        [ Class heap-size * malloc &free ] keep
+        dupd objc_getClassList void* <c-direct-array>
+        [ class_getName ] { } map-as
+    ] with-destructors ;